Skip to content

Commit 9f255d1

Browse files
Copilotjoperezr
andauthored
Add UrlFormat to ObsoleteAttribute for ASPDEPR diagnostics (#63909)
* Initial plan * Add UrlFormat to all ASPDEPR obsoletions Co-authored-by: joperezr <[email protected]> * Use Obsoletions.AspNetCoreSharedUrlFormat constant for all ASPDEPR UrlFormat references Co-authored-by: joperezr <[email protected]> * Fix UrlFormat to use numeric diagnostic IDs instead of full ASPDEPR IDs Co-authored-by: joperezr <[email protected]> * Remove unnecessary reference to Obsoletions.cs in the project file --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: joperezr <[email protected]> Co-authored-by: Jose Perez Rodriguez <[email protected]>
1 parent f9037b3 commit 9f255d1

30 files changed

+81
-25
lines changed

src/DefaultBuilder/src/Microsoft.AspNetCore.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
<Reference Include="Microsoft.Extensions.Logging.EventSource" />
3636
</ItemGroup>
3737

38+
<ItemGroup>
39+
<Compile Include="$(SharedSourceRoot)Obsoletions.cs" LinkBase="Shared" />
40+
</ItemGroup>
41+
3842
<ItemGroup>
3943
<InternalsVisibleTo Include="Microsoft.AspNetCore.Authentication.Test" />
4044
<InternalsVisibleTo Include="Microsoft.AspNetCore.Authorization.Test" />

src/DefaultBuilder/src/WebHost.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.AspNetCore.Http;
1111
using Microsoft.AspNetCore.Routing;
1212
using Microsoft.AspNetCore.Server.Kestrel.Core;
13+
using Microsoft.AspNetCore.Shared;
1314
using Microsoft.Extensions.Configuration;
1415
using Microsoft.Extensions.DependencyInjection;
1516
using Microsoft.Extensions.Hosting;
@@ -21,7 +22,7 @@ namespace Microsoft.AspNetCore;
2122
/// <summary>
2223
/// Provides convenience methods for creating instances of <see cref="IWebHost"/> and <see cref="IWebHostBuilder"/> with pre-configured defaults.
2324
/// </summary>
24-
[Obsolete("WebHost is obsolete. Use HostBuilder or WebApplicationBuilder instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008")]
25+
[Obsolete("WebHost is obsolete. Use HostBuilder or WebApplicationBuilder instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008", UrlFormat = Obsoletions.AspNetCoreDeprecate008Url)]
2526
public static class WebHost
2627
{
2728
/// <summary>

src/Hosting/Abstractions/src/IWebHost.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Microsoft.AspNetCore.Http.Features;
5+
using Microsoft.AspNetCore.Shared;
56

67
namespace Microsoft.AspNetCore.Hosting;
78

89
/// <summary>
910
/// Represents a configured web host.
1011
/// </summary>
11-
[Obsolete("IWebHost is obsolete. Use IHost instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008")]
12+
[Obsolete("IWebHost is obsolete. Use IHost instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008", UrlFormat = Obsoletions.AspNetCoreDeprecate008Url)]
1213
public interface IWebHost : IDisposable
1314
{
1415
/// <summary>

src/Hosting/Abstractions/src/IWebHostBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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+
using Microsoft.AspNetCore.Shared;
45
using Microsoft.Extensions.Configuration;
56
using Microsoft.Extensions.DependencyInjection;
67
using Microsoft.Extensions.Logging;
@@ -15,7 +16,7 @@ public interface IWebHostBuilder
1516
/// <summary>
1617
/// Builds an <see cref="IWebHost"/> which hosts a web application.
1718
/// </summary>
18-
[Obsolete("IWebHost is obsolete. Use IHost instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008")]
19+
[Obsolete("IWebHost is obsolete. Use IHost instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008", UrlFormat = Obsoletions.AspNetCoreDeprecate008Url)]
1920
IWebHost Build();
2021

2122
/// <summary>

src/Hosting/Abstractions/src/Microsoft.AspNetCore.Hosting.Abstractions.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@
1717
<Reference Include="Microsoft.Extensions.Hosting.Abstractions" />
1818
</ItemGroup>
1919

20+
<ItemGroup>
21+
<Compile Include="$(SharedSourceRoot)Obsoletions.cs" LinkBase="Shared" />
22+
</ItemGroup>
23+
2024
</Project>

src/Hosting/Hosting/src/Microsoft.AspNetCore.Hosting.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<Compile Include="$(SharedSourceRoot)Metrics\MetricsConstants.cs" />
2121
<Compile Include="$(SharedSourceRoot)Diagnostics\ActivityCreator.cs" />
2222
<Compile Include="$(SharedSourceRoot)Diagnostics\RouteDiagnosticsHelpers.cs" />
23+
<Compile Include="$(SharedSourceRoot)Obsoletions.cs" LinkBase="Shared" />
2324
</ItemGroup>
2425

2526
<ItemGroup>

src/Hosting/Hosting/src/WebHostBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Runtime.ExceptionServices;
1010
using Microsoft.AspNetCore.Hosting.Builder;
1111
using Microsoft.AspNetCore.Http;
12+
using Microsoft.AspNetCore.Shared;
1213
using Microsoft.Extensions.Configuration;
1314
using Microsoft.Extensions.DependencyInjection;
1415
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -20,7 +21,7 @@ namespace Microsoft.AspNetCore.Hosting;
2021
/// <summary>
2122
/// A builder for <see cref="IWebHost"/>
2223
/// </summary>
23-
[Obsolete("WebHostBuilder is deprecated in favor of HostBuilder and WebApplicationBuilder. For more information, visit https://aka.ms/aspnet/deprecate/004.", DiagnosticId = "ASPDEPR004")]
24+
[Obsolete("WebHostBuilder is deprecated in favor of HostBuilder and WebApplicationBuilder. For more information, visit https://aka.ms/aspnet/deprecate/004.", DiagnosticId = "ASPDEPR004", UrlFormat = Obsoletions.AspNetCoreDeprecate004Url)]
2425
public class WebHostBuilder : IWebHostBuilder
2526
{
2627
private readonly HostingEnvironment _hostingEnvironment;

src/Hosting/Hosting/src/WebHostExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#nullable enable
55

66
using Microsoft.AspNetCore.Hosting.Server.Features;
7+
using Microsoft.AspNetCore.Shared;
78
using Microsoft.Extensions.DependencyInjection;
89
using Microsoft.Extensions.Hosting;
910

@@ -12,7 +13,7 @@ namespace Microsoft.AspNetCore.Hosting;
1213
/// <summary>
1314
/// Contains extensions for managing the lifecycle of an <see cref="IWebHost"/>.
1415
/// </summary>
15-
[Obsolete("WebHostExtensions is obsolete. Use Host.CreateDefaultBuilder or WebApplication.CreateBuilder instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008")]
16+
[Obsolete("WebHostExtensions is obsolete. Use Host.CreateDefaultBuilder or WebApplication.CreateBuilder instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008", UrlFormat = Obsoletions.AspNetCoreDeprecate008Url)]
1617
public static class WebHostExtensions
1718
{
1819
/// <summary>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" />
1414
</ItemGroup>
1515

16+
<ItemGroup>
17+
<Compile Include="$(SharedSourceRoot)Obsoletions.cs" LinkBase="Shared" />
18+
</ItemGroup>
19+
1620
<ItemGroup>
1721
<InternalsVisibleTo Include="Microsoft.AspNetCore.TestHost.Tests" />
1822
</ItemGroup>

src/Hosting/TestHost/src/TestServer.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.AspNetCore.Hosting.Server.Features;
88
using Microsoft.AspNetCore.Http;
99
using Microsoft.AspNetCore.Http.Features;
10+
using Microsoft.AspNetCore.Shared;
1011
using Microsoft.Extensions.Options;
1112

1213
namespace Microsoft.AspNetCore.TestHost;
@@ -80,7 +81,7 @@ public TestServer(IServiceProvider services, IFeatureCollection featureCollectio
8081
/// For use with IWebHostBuilder.
8182
/// </summary>
8283
/// <param name="builder"></param>
83-
[Obsolete("IWebHost, which this method uses, is obsolete. Use one of the ctors that takes an IServiceProvider instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008")]
84+
[Obsolete("IWebHost, which this method uses, is obsolete. Use one of the ctors that takes an IServiceProvider instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008", UrlFormat = Obsoletions.AspNetCoreDeprecate008Url)]
8485
public TestServer(IWebHostBuilder builder)
8586
: this(builder, CreateTestFeatureCollection())
8687
{
@@ -91,7 +92,7 @@ public TestServer(IWebHostBuilder builder)
9192
/// </summary>
9293
/// <param name="builder"></param>
9394
/// <param name="featureCollection"></param>
94-
[Obsolete("IWebHost, which this method uses, is obsolete. Use one of the ctors that takes an IServiceProvider instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008")]
95+
[Obsolete("IWebHost, which this method uses, is obsolete. Use one of the ctors that takes an IServiceProvider instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008", UrlFormat = Obsoletions.AspNetCoreDeprecate008Url)]
9596
public TestServer(IWebHostBuilder builder, IFeatureCollection featureCollection)
9697
{
9798
ArgumentNullException.ThrowIfNull(builder);
@@ -113,7 +114,7 @@ public TestServer(IWebHostBuilder builder, IFeatureCollection featureCollection)
113114
/// <summary>
114115
/// Gets the <see cref="IWebHost" /> instance associated with the test server.
115116
/// </summary>
116-
[Obsolete("IWebHost is obsolete. Use IHost instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008")]
117+
[Obsolete("IWebHost is obsolete. Use IHost instead. For more information, visit https://aka.ms/aspnet/deprecate/008.", DiagnosticId = "ASPDEPR008", UrlFormat = Obsoletions.AspNetCoreDeprecate008Url)]
117118
public IWebHost Host
118119
{
119120
get

0 commit comments

Comments
 (0)