Skip to content

Commit 8b4c6a9

Browse files
Scope pragma warning disables to specific locations and mark classes as obsolete as requested
Co-authored-by: BrennanConroy <[email protected]>
1 parent 2d43301 commit 8b4c6a9

File tree

12 files changed

+20
-24
lines changed

12 files changed

+20
-24
lines changed

src/DefaultBuilder/src/ConfigureWebHostBuilder.cs

Lines changed: 2 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.Diagnostics.CodeAnalysis;
75
using Microsoft.AspNetCore.Hosting;
86
using Microsoft.AspNetCore.Hosting.Infrastructure;
@@ -15,6 +13,7 @@ namespace Microsoft.AspNetCore.Builder;
1513
/// A non-buildable <see cref="IWebHostBuilder"/> for <see cref="WebApplicationBuilder"/>.
1614
/// Use <see cref="WebApplicationBuilder.Build"/> to build the <see cref="WebApplicationBuilder"/>.
1715
/// </summary>
16+
#pragma warning disable CS0618 // Type or member is obsolete
1817
public sealed class ConfigureWebHostBuilder : IWebHostBuilder, ISupportsStartup
1918
{
2019
private readonly IWebHostEnvironment _environment;
@@ -185,3 +184,4 @@ IWebHostBuilder ISupportsStartup.UseStartup([DynamicallyAccessedMembers(StartupL
185184
throw new NotSupportedException("UseStartup() is not supported by WebApplicationBuilder.WebHost. Use the WebApplication returned by WebApplicationBuilder.Build() instead.");
186185
}
187186
}
187+
#pragma warning restore CS0618 // Type or member is obsolete

src/Hosting/Abstractions/src/HostingAbstractionsWebHostBuilderExtensions.cs

Lines changed: 2 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.Diagnostics.CodeAnalysis;
75
using System.Globalization;
86
using System.Linq;
@@ -15,6 +13,7 @@ namespace Microsoft.AspNetCore.Hosting;
1513
/// <summary>
1614
/// Contains extension methods for configuring the <see cref="IWebHostBuilder" />.
1715
/// </summary>
16+
#pragma warning disable CS0618 // Type or member is obsolete
1817
public static class HostingAbstractionsWebHostBuilderExtensions
1918
{
2019
/// <summary>
@@ -178,3 +177,4 @@ public static IWebHost Start(this IWebHostBuilder hostBuilder, [StringSyntax(Str
178177
return host;
179178
}
180179
}
180+
#pragma warning restore CS0618 // Type or member is obsolete

src/Hosting/Abstractions/src/IWebHostBuilder.cs

Lines changed: 2 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 Microsoft.Extensions.Configuration;
75
using Microsoft.Extensions.DependencyInjection;
86
using Microsoft.Extensions.Logging;
@@ -12,6 +10,7 @@ namespace Microsoft.AspNetCore.Hosting;
1210
/// <summary>
1311
/// A builder for <see cref="IWebHost"/>.
1412
/// </summary>
13+
#pragma warning disable CS0618 // Type or member is obsolete
1514
public interface IWebHostBuilder
1615
{
1716
/// <summary>
@@ -61,3 +60,4 @@ public interface IWebHostBuilder
6160
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
6261
IWebHostBuilder UseSetting(string key, string? value);
6362
}
63+
#pragma warning restore CS0618 // Type or member is obsolete

src/Hosting/Hosting/src/GenericHost/HostingStartupWebHostBuilder.cs

Lines changed: 2 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.Diagnostics.CodeAnalysis;
75
using Microsoft.AspNetCore.Builder;
86
using Microsoft.AspNetCore.Hosting.Infrastructure;
@@ -14,6 +12,7 @@ namespace Microsoft.AspNetCore.Hosting;
1412

1513
// We use this type to capture calls to the IWebHostBuilder so the we can properly order calls to
1614
// to GenericHostWebHostBuilder.
15+
#pragma warning disable CS0618 // Type or member is obsolete
1716
internal sealed class HostingStartupWebHostBuilder : IWebHostBuilder, ISupportsStartup, ISupportsUseDefaultServiceProvider
1817
{
1918
private readonly GenericWebHostBuilder _builder;
@@ -92,3 +91,4 @@ public IWebHostBuilder UseStartup([DynamicallyAccessedMembers(StartupLinkerOptio
9291
return _builder.UseStartup(startupFactory);
9392
}
9493
}
94+
#pragma warning restore CS0618 // Type or member is obsolete

src/Hosting/Hosting/src/GenericHost/WebHostBuilderBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
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 Microsoft.Extensions.Configuration;
75
using Microsoft.Extensions.DependencyInjection;
86
using Microsoft.Extensions.Hosting;
97

108
namespace Microsoft.AspNetCore.Hosting;
119

10+
#pragma warning disable CS0618 // Type or member is obsolete
1211
internal abstract class WebHostBuilderBase : IWebHostBuilder, ISupportsUseDefaultServiceProvider
1312
{
1413
private protected readonly IHostBuilder _builder;
@@ -107,3 +106,4 @@ public IWebHostBuilder UseSetting(string key, string? value)
107106
return this;
108107
}
109108
}
109+
#pragma warning restore CS0618 // Type or member is obsolete

src/Hosting/Hosting/src/Internal/WebHost.cs

Lines changed: 1 addition & 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.Diagnostics;
75
using System.Diagnostics.CodeAnalysis;
86
using System.Linq;
@@ -21,6 +19,7 @@
2119

2220
namespace Microsoft.AspNetCore.Hosting;
2321

22+
[Obsolete("WebHost is obsolete. Use Host.CreateDefaultBuilder or WebApplication.CreateBuilder instead.")]
2423
internal sealed partial class WebHost : IWebHost, IAsyncDisposable
2524
{
2625
private const string DeprecatedServerUrlsKey = "server.urls";

src/Hosting/Hosting/src/WebHostExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#nullable enable
55

6-
#pragma warning disable CS0618 // Type or member is obsolete
7-
86
using Microsoft.AspNetCore.Hosting.Server.Features;
97
using Microsoft.Extensions.DependencyInjection;
108
using Microsoft.Extensions.Hosting;
@@ -14,6 +12,7 @@ namespace Microsoft.AspNetCore.Hosting;
1412
/// <summary>
1513
/// Contains extensions for managing the lifecycle of an <see cref="IWebHost"/>.
1614
/// </summary>
15+
[Obsolete("WebHostExtensions is obsolete. Use Host.CreateDefaultBuilder or WebApplication.CreateBuilder instead.")]
1716
public static class WebHostExtensions
1817
{
1918
/// <summary>

src/Hosting/TestHost/src/TestServer.cs

Lines changed: 2 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.Http;
75
using Microsoft.AspNetCore.Hosting;
86
using Microsoft.AspNetCore.Hosting.Server;
@@ -18,6 +16,7 @@ namespace Microsoft.AspNetCore.TestHost;
1816
/// </summary>
1917
public class TestServer : IServer
2018
{
19+
#pragma warning disable CS0618 // Type or member is obsolete
2120
private readonly IWebHost? _hostInstance;
2221
private bool _disposed;
2322
private ApplicationWrapper? _application;
@@ -119,6 +118,7 @@ public IWebHost Host
119118
?? throw new InvalidOperationException("The TestServer constructor was not called with a IWebHostBuilder so IWebHost is not available.");
120119
}
121120
}
121+
#pragma warning restore CS0618 // Type or member is obsolete
122122

123123
/// <summary>
124124
/// Gets the service provider associated with the test server.

src/Hosting/TestHost/src/WebHostBuilderExtensions.cs

Lines changed: 2 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.Diagnostics.CodeAnalysis;
75
using System.Linq;
86
using System.Net.Http;
@@ -16,6 +14,7 @@ namespace Microsoft.AspNetCore.TestHost;
1614
/// <summary>
1715
/// Contains extensions for configuring the <see cref="IWebHostBuilder" /> instance.
1816
/// </summary>
17+
#pragma warning disable CS0618 // Type or member is obsolete
1918
public static class WebHostBuilderExtensions
2019
{
2120
/// <summary>
@@ -210,3 +209,4 @@ public Action<TContainer> ConfigureContainer(Action<TContainer> next) =>
210209
};
211210
}
212211
}
212+
#pragma warning restore CS0618 // Type or member is obsolete

src/Hosting/WindowsServices/src/WebHostService.cs

Lines changed: 1 addition & 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.ComponentModel;
75
using System.ServiceProcess;
86
using Microsoft.Extensions.DependencyInjection;
@@ -14,6 +12,7 @@ namespace Microsoft.AspNetCore.Hosting.WindowsServices;
1412
/// Provides an implementation of a Windows service that hosts ASP.NET Core.
1513
/// </summary>
1614
[DesignerCategory("Code")]
15+
[Obsolete("Use UseWindowsService and AddHostedService instead.")]
1716
public class WebHostService : ServiceBase
1817
{
1918
private readonly IWebHost _host;

0 commit comments

Comments
 (0)