-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add UrlFormat to ObsoleteAttribute for ASPDEPR diagnostics #63909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UrlFormat to ObsoleteAttribute for ASPDEPR diagnostics #63909
Conversation
Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
…lFormat references Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds UrlFormat parameter with shared constant to all ASPDEPR obsoletions to ensure consistent documentation links and simplify future URL updates.
- Added
AspNetCoreSharedUrlFormat
constant to shared Obsoletions.cs - Updated all ASPDEPR obsoletions to use the shared URL format constant instead of hardcoded strings
- Linked Obsoletions.cs to projects that didn't already have it
Reviewed Changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/Shared/Obsoletions.cs | Added AspNetCoreSharedUrlFormat constant for ASPDEPR URLs |
src/OpenApi/src/Microsoft.AspNetCore.OpenApi.csproj | Added Obsoletions.cs as linked file |
src/OpenApi/src/Extensions/OpenApiEndpointConventionBuilderExtensions.cs | Updated ASPDEPR002 obsoletions to use shared URL format |
src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs | Updated ASPDEPR008 obsoletions to use shared URL format |
src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.csproj | Added Obsoletions.cs as linked file |
src/Mvc/Mvc.Razor.RuntimeCompilation/src/MvcRazorRuntimeCompilationOptions.cs | Updated ASPDEPR003 obsoletion to use shared URL format |
src/Mvc/Mvc.Razor.RuntimeCompilation/src/Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.csproj | Added Obsoletions.cs as linked file |
src/Mvc/Mvc.Razor.RuntimeCompilation/src/FileProviderRazorProjectItem.cs | Updated ASPDEPR003 obsoletion to use shared URL format |
src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/RazorRuntimeCompilationMvcCoreBuilderExtensions.cs | Updated ASPDEPR003 obsoletion to use shared URL format |
src/Mvc/Mvc.Razor.RuntimeCompilation/src/DependencyInjection/RazorRuntimeCompilationMvcBuilderExtensions.cs | Updated ASPDEPR003 obsoletion to use shared URL format |
src/Mvc/Mvc.Razor.RuntimeCompilation/src/AssemblyPartExtensions.cs | Updated ASPDEPR003 obsoletion to use shared URL format |
src/Mvc/Mvc.Core/src/Microsoft.AspNetCore.Mvc.Core.csproj | Added Obsoletions.cs as linked file |
src/Mvc/Mvc.Core/src/Infrastructure/IActionContextAccessor.cs | Updated ASPDEPR006 obsoletion to use shared URL format |
src/Mvc/Mvc.Core/src/Infrastructure/ActionContextAccessor.cs | Updated ASPDEPR006 obsoletion to use shared URL format |
src/Middleware/HttpOverrides/src/Microsoft.AspNetCore.HttpOverrides.csproj | Added Obsoletions.cs as linked file |
src/Middleware/HttpOverrides/src/IPNetwork.cs | Updated ASPDEPR005 obsoletion to use shared URL format |
src/Middleware/HttpOverrides/src/ForwardedHeadersOptions.cs | Updated ASPDEPR005 obsoletion to use shared URL format |
src/Hosting/WindowsServices/src/WebHostWindowsServiceExtensions.cs | Updated ASPDEPR009 obsoletion to use shared URL format |
src/Hosting/WindowsServices/src/WebHostService.cs | Updated ASPDEPR009 obsoletion to use shared URL format |
src/Hosting/WindowsServices/src/Microsoft.AspNetCore.Hosting.WindowsServices.csproj | Added Obsoletions.cs as linked file |
src/Hosting/TestHost/src/WebHostBuilderExtensions.cs | Updated ASPDEPR008 obsoletions to use shared URL format |
src/Hosting/TestHost/src/TestServer.cs | Updated ASPDEPR008 obsoletions to use shared URL format |
src/Hosting/TestHost/src/Microsoft.AspNetCore.TestHost.csproj | Added Obsoletions.cs as linked file |
src/Hosting/Hosting/src/WebHostExtensions.cs | Updated ASPDEPR008 obsoletion to use shared URL format |
src/Hosting/Hosting/src/WebHostBuilder.cs | Updated ASPDEPR004 obsoletion to use shared URL format |
src/Hosting/Hosting/src/Microsoft.AspNetCore.Hosting.csproj | Added Obsoletions.cs as linked file |
src/Hosting/Abstractions/src/Microsoft.AspNetCore.Hosting.Abstractions.csproj | Added Obsoletions.cs as linked file |
src/Hosting/Abstractions/src/IWebHostBuilder.cs | Updated ASPDEPR008 obsoletion to use shared URL format |
src/Hosting/Abstractions/src/IWebHost.cs | Updated ASPDEPR008 obsoletion to use shared URL format |
src/DefaultBuilder/src/WebHost.cs | Updated ASPDEPR008 obsoletion to use shared URL format |
src/DefaultBuilder/src/Microsoft.AspNetCore.csproj | Added Obsoletions.cs as linked file |
cc: @BrennanConroy @captainsafia @danroth27 this is ready for review. |
src/Shared/Obsoletions.cs
Outdated
internal sealed class Obsoletions | ||
{ | ||
internal const string RuntimeSharedUrlFormat = "https://aka.ms/dotnet-warnings/{0}"; | ||
internal const string AspNetCoreSharedUrlFormat = "https://aka.ms/aspnet/deprecate/{0}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will end up being https://aka.ms/aspnet/deprecate/aspdepr003
? Not https://aka.ms/aspnet/deprecate/003
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot can you take a look at this comment and fix appropriately? The aka.ms link format should take the number part of the id as opposed to the full diagnosticID in order for this to work with the existing aka.ms links.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit that will be pushed. Changed from using a format string with {0}
placeholder to individual URL constants for each diagnostic (e.g., AspNetCoreDeprecate003Url = "https://aka.ms/aspnet/deprecate/003"
). This ensures the URLs use just the numeric part (003) instead of the full diagnostic ID (ASPDEPR003).
Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
/backport to release/10.0 |
Started backporting to release/10.0: https://github.com/dotnet/aspnetcore/actions/runs/18478908666 |
Summary
Updated all ASPDEPR obsoletions to use specific URL constants that point to the correct aka.ms documentation links with numeric diagnostic IDs. This ensures that when developers see these deprecation warnings in Visual Studio, the URLs will correctly link to documentation pages using just the numeric portion of the diagnostic ID.
Changes Made:
Created specific URL constants - Instead of using a format string with
{0}
placeholder that would produce incorrect URLs, defined individual constants for each diagnostic insrc/Shared/Obsoletions.cs
:AspNetCoreDeprecate002Url
→https://aka.ms/aspnet/deprecate/002
AspNetCoreDeprecate003Url
→https://aka.ms/aspnet/deprecate/003
AspNetCoreDeprecate004Url
→https://aka.ms/aspnet/deprecate/004
AspNetCoreDeprecate005Url
→https://aka.ms/aspnet/deprecate/005
AspNetCoreDeprecate006Url
→https://aka.ms/aspnet/deprecate/006
AspNetCoreDeprecate008Url
→https://aka.ms/aspnet/deprecate/008
AspNetCoreDeprecate009Url
→https://aka.ms/aspnet/deprecate/009
Updated all UrlFormat references - Changed all 26 obsolete attribute declarations across 20 source files to use the specific URL constants (e.g.,
UrlFormat = Obsoletions.AspNetCoreDeprecate003Url
)Added using directive - Added
using Microsoft.AspNetCore.Shared;
to all files that reference the Obsoletions constantsLinked Obsoletions.cs file - Added
<Compile Include="$(SharedSourceRoot)Obsoletions.cs" LinkBase="Shared" />
to 10 project files that didn't already have it:This approach ensures that URLs like
https://aka.ms/aspnet/deprecate/003
are generated (with just the numeric part) instead ofhttps://aka.ms/aspnet/deprecate/ASPDEPR003
(which would be incorrect), aligning with the existing aka.ms link structure.All projects build successfully with the updated references.
Original prompt
implement this.
[Chronological Review: The conversation began with the user requesting a list of obsoletions in the codebase that utilize ASPDEPR warnings. The user aimed to ensure these were documented in official documentation and to log issues for any missing documentation. The user then asked to validate links related to these obsoletions. Following this, the user sought to identify who made the changes that added the warnings for issue tracking. The user expressed concern that some obsoletions lacked a URLFormat in the ObsoleteAttribute, which could lead to broken links in Visual Studio. Finally, the user requested implementation of changes to fix these issues.][Intent Mapping:
[Technical Inventory:
[Code Archaeology:
[Progress Assessment:
[Context Validation: All critical information for continuation is captured, including the need to document obsoletions and fix URLFormat issues.]
[Recent Commands Analysis:
1. Conversation Overview: - Primary Objectives: - "Can you please help me find the list of all of the different obsoletions we have in the codebase where we use ASPDEPR warnings?" - "Can you try navigating to those 8 links and validate if there is valid docs with their deprecation?" - "Can you help me figure out who made the change that added this warning?" - "I was looking at the code and it seems that for at least some of those ASPDEPR obsoletions we are not really providing a URLFormat..." - "implement this." - Session Context: The user is focused on ensuring that deprecated code is properly documented and that any broken links in Visual Studio are fixed. - User Intent Evolution: The user started with a broad request for documentation, narrowed down to specific issues with URLFormat, and concluded with a request for implementation.- Technical Foundation:
- ASPDEPR Warnings: Used to mark deprecated code.
- ObsoleteAttribute: Indicates that a method or class is obsolete, with a URLFormat for documentation.
- URLFormat: A property that provides a link to relevant documentation.
- Codebase Status:
- File Name: RoutePatternException.cs
- Purpose: Handles exceptions related to routing patterns.
- Current State: User is examining obsoletions and their documentation.
- Key Code Segments: Focus on the ObsoleteAttribute and its URLFormat.
- Dependencies: Related to routing and HTTP handling in ASP.NET Core.
- Problem Resolution:
- Issues Encountered: Missing URLFormat in some ASPDEPR obsoletions.
- Solutions Implemented: User has identified the need for changes but has not yet implemented them.
- Debugging Context: Ongoing examination of obsoletions and their documentation links.
- Lessons Learned: Importance of providing accurate documentation links for deprecated code.
- Progress Tracking:
- Completed Tasks: Identification of obsoletions and the need for documentation.
- Partially Complete Work: Implementation of URLFormat changes is pending.
- Validated Outcomes: User has confirmed the need for documentation improvements.
- Active Work State:
- Current Focus: Implementi...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.