Skip to content

Commit 4c94381

Browse files
Apply [Obsolete] attribute to correct WebHost class with appropriate warning suppressions
Co-authored-by: BrennanConroy <[email protected]>
1 parent 2711b5c commit 4c94381

File tree

14 files changed

+24
-4
lines changed

14 files changed

+24
-4
lines changed

src/DefaultBuilder/samples/SampleApp/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
46
using Microsoft.AspNetCore;
57

68
namespace SampleApp;

src/DefaultBuilder/src/GenericHostBuilderExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public static IHostBuilder ConfigureWebHostDefaults(this IHostBuilder builder, A
6161

6262
return builder.ConfigureWebHost(webHostBuilder =>
6363
{
64+
#pragma warning disable CS0618 // Type or member is obsolete
6465
WebHost.ConfigureWebDefaults(webHostBuilder);
66+
#pragma warning restore CS0618 // Type or member is obsolete
6567

6668
configure(webHostBuilder);
6769
}, configureOptions);

src/DefaultBuilder/src/WebApplicationBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ internal WebApplicationBuilder(WebApplicationOptions options, bool slim, Action<
127127
bootstrapHostBuilder.ConfigureSlimWebHost(
128128
webHostBuilder =>
129129
{
130+
#pragma warning disable CS0618 // Type or member is obsolete
130131
AspNetCore.WebHost.ConfigureWebDefaultsSlim(webHostBuilder);
132+
#pragma warning restore CS0618 // Type or member is obsolete
131133

132134
// Runs inline.
133135
webHostBuilder.Configure(ConfigureApplication);

src/DefaultBuilder/src/WebHost.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Microsoft.AspNetCore;
2121
/// <summary>
2222
/// Provides convenience methods for creating instances of <see cref="IWebHost"/> and <see cref="IWebHostBuilder"/> with pre-configured defaults.
2323
/// </summary>
24+
[Obsolete("WebHost is obsolete. Use HostBuilder or WebApplicationBuilder instead.")]
2425
public static class WebHost
2526
{
2627
/// <summary>

src/DefaultBuilder/test/Microsoft.AspNetCore.FunctionalTests/WebHostFunctionalTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
46
using System.Net.Http;
57
using Microsoft.AspNetCore.Http;
68
using Microsoft.AspNetCore.Server.IntegrationTesting;

src/DefaultBuilder/test/Microsoft.AspNetCore.Tests/WebHostTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
46
using System.Collections.Concurrent;
57
using System.Diagnostics.Tracing;
68
using Microsoft.AspNetCore.Builder;

src/DefaultBuilder/testassets/CreateDefaultBuilderApp/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
46
using System;
57
using Microsoft.AspNetCore;
68
using Microsoft.AspNetCore.Builder;

src/DefaultBuilder/testassets/CreateDefaultBuilderOfTApp/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
46
using System;
57
using Microsoft.AspNetCore;
68
using Microsoft.AspNetCore.Builder;

src/DefaultBuilder/testassets/DependencyInjectionApp/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// 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+
46
using System;
57
using Microsoft.AspNetCore;
68
using Microsoft.AspNetCore.Builder;

src/DefaultBuilder/testassets/StartRequestDelegateUrlApp/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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+
46
using System;
57
using System.Threading;
68
using Microsoft.AspNetCore;

0 commit comments

Comments
 (0)