Skip to content

Commit 2711b5c

Browse files
Add [Obsolete] attribute to WebHost class with suppression pragmas
Co-authored-by: BrennanConroy <[email protected]>
1 parent 2955f0e commit 2711b5c

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

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

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

2020
namespace Microsoft.AspNetCore.Hosting;
2121

22+
[Obsolete("WebHost is obsolete. Use HostBuilder or WebApplicationBuilder instead.")]
2223
internal sealed partial class WebHost : IWebHost, IAsyncDisposable
2324
{
2425
private const string DeprecatedServerUrlsKey = "server.urls";

src/Hosting/Hosting/src/WebHostBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@ public IWebHost Build()
160160

161161
AddApplicationServices(applicationServices, hostingServiceProvider);
162162

163+
#pragma warning disable CS0618 // Type or member is obsolete
163164
var host = new WebHost(
164165
applicationServices,
165166
hostingServiceProvider,
166167
_options,
167168
_config,
168169
hostingStartupErrors);
170+
#pragma warning restore CS0618 // Type or member is obsolete
169171
try
170172
{
171173
host.Initialize();

0 commit comments

Comments
 (0)