Skip to content

Commit 650081c

Browse files
Update diagnostic IDs to ASPDEPR008/ASPDEPR004, remove unnecessary pragma disables, and add suppression to test projects
Co-authored-by: BrennanConroy <[email protected]>
1 parent fc1770f commit 650081c

File tree

14 files changed

+25
-31
lines changed

14 files changed

+25
-31
lines changed

src/Hosting/Hosting/src/WebHostExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Hosting;
1212
/// <summary>
1313
/// Contains extensions for managing the lifecycle of an <see cref="IWebHost"/>.
1414
/// </summary>
15-
[Obsolete("WebHostExtensions is obsolete. Use Host.CreateDefaultBuilder or WebApplication.CreateBuilder instead.")]
15+
[Obsolete("WebHostExtensions is obsolete. Use Host.CreateDefaultBuilder or WebApplication.CreateBuilder instead.", DiagnosticId = "ASPDEPR008")]
1616
public static class WebHostExtensions
1717
{
1818
/// <summary>

src/Hosting/Hosting/test/WebHostTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,9 +1087,7 @@ public void ConfigureServices(IServiceCollection services, int gunk) { }
10871087
public void Configure(IApplicationBuilder app) { }
10881088
}
10891089

1090-
#pragma warning disable CS0618 // Type or member is obsolete
10911090
private IWebHost CreateHost(RequestDelegate requestDelegate)
1092-
#pragma warning restore CS0618 // Type or member is obsolete
10931091
{
10941092
var builder = CreateBuilder()
10951093
.UseFakeServer()

src/Hosting/TestHost/src/TestServer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public TestServer(IServiceProvider services, IFeatureCollection featureCollectio
8080
/// For use with IWebHostBuilder.
8181
/// </summary>
8282
/// <param name="builder"></param>
83-
[Obsolete("IWebHost, which this method uses, is obsolete. Use one of the ctors that takes an IServiceProvider instead.")]
83+
[Obsolete("IWebHost, which this method uses, is obsolete. Use one of the ctors that takes an IServiceProvider instead.", DiagnosticId = "ASPDEPR008")]
8484
public TestServer(IWebHostBuilder builder)
8585
: this(builder, CreateTestFeatureCollection())
8686
{
@@ -91,7 +91,7 @@ public TestServer(IWebHostBuilder builder)
9191
/// </summary>
9292
/// <param name="builder"></param>
9393
/// <param name="featureCollection"></param>
94-
[Obsolete("IWebHost, which this method uses, is obsolete. Use one of the ctors that takes an IServiceProvider instead.")]
94+
[Obsolete("IWebHost, which this method uses, is obsolete. Use one of the ctors that takes an IServiceProvider instead.", DiagnosticId = "ASPDEPR008")]
9595
public TestServer(IWebHostBuilder builder, IFeatureCollection featureCollection)
9696
{
9797
ArgumentNullException.ThrowIfNull(builder);
@@ -113,7 +113,7 @@ public TestServer(IWebHostBuilder builder, IFeatureCollection featureCollection)
113113
/// <summary>
114114
/// Gets the <see cref="IWebHost" /> instance associated with the test server.
115115
/// </summary>
116-
[Obsolete("IWebHost is obsolete. Use IHost instead.")]
116+
[Obsolete("IWebHost is obsolete. Use IHost instead.", DiagnosticId = "ASPDEPR008")]
117117
public IWebHost Host
118118
{
119119
get

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static IWebHostBuilder UseTestServer(this IWebHostBuilder builder, Action
5151
/// </summary>
5252
/// <param name="host"></param>
5353
/// <returns></returns>
54-
[Obsolete("IWebHost is obsolete. Use IHost instead.")]
54+
[Obsolete("IWebHost is obsolete. Use IHost instead.", DiagnosticId = "ASPDEPR008")]
5555
public static TestServer GetTestServer(this IWebHost host)
5656
{
5757
return (TestServer)host.Services.GetRequiredService<IServer>();
@@ -62,7 +62,7 @@ public static TestServer GetTestServer(this IWebHost host)
6262
/// </summary>
6363
/// <param name="host"></param>
6464
/// <returns></returns>
65-
[Obsolete("IWebHost is obsolete. Use IHost instead.")]
65+
[Obsolete("IWebHost is obsolete. Use IHost instead.", DiagnosticId = "ASPDEPR008")]
6666
public static HttpClient GetTestClient(this IWebHost host)
6767
{
6868
return host.GetTestServer().CreateClient();

src/Hosting/TestHost/test/ClientHandlerTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#pragma warning disable CS0618 // Type or member is obsolete
5-
64
using System.Net;
75
using System.Net.Http;
86
using System.Text;

src/Hosting/TestHost/test/HttpContextBuilderTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#pragma warning disable CS0618 // Type or member is obsolete
5-
64
using System.Text;
75
using Microsoft.AspNetCore.Builder;
86
using Microsoft.AspNetCore.Hosting;

src/Hosting/TestHost/test/Microsoft.AspNetCore.TestHost.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
5+
<NoWarn>$(NoWarn);ASPDEPR008</NoWarn>
56
</PropertyGroup>
67

78
<ItemGroup>

src/Hosting/TestHost/test/TestClientTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#pragma warning disable CS0618 // Type or member is obsolete
5-
64
using System.Net;
75
using System.Net.Http;
86
using System.Net.WebSockets;

src/Hosting/WindowsServices/src/WebHostService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Hosting.WindowsServices;
1212
/// Provides an implementation of a Windows service that hosts ASP.NET Core.
1313
/// </summary>
1414
[DesignerCategory("Code")]
15-
[Obsolete("Use UseWindowsService and AddHostedService instead.")]
15+
[Obsolete("Use UseWindowsService and AddHostedService instead.", DiagnosticId = "ASPDEPR004")]
1616
public class WebHostService : ServiceBase
1717
{
1818
private readonly IWebHost _host;

src/Hosting/WindowsServices/src/WebHostWindowsServiceExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Hosting.WindowsServices;
88
/// <summary>
99
/// Extensions to <see cref="IWebHost"/> for hosting inside a Windows service.
1010
/// </summary>
11-
[Obsolete("Use UseWindowsService and AddHostedService instead.")]
11+
[Obsolete("Use UseWindowsService and AddHostedService instead.", DiagnosticId = "ASPDEPR004")]
1212
public static class WebHostWindowsServiceExtensions
1313
{
1414
/// <summary>

0 commit comments

Comments
 (0)