-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
[8.0] RouteHandlerAnalyzer throws InvalidOperationException #50836
Comments
Thanks for reporting this issue, @adamsitnik! We've gotten a few similar reports over the past few days including in #50868 and #50881. I'll close those in favor of using this one as the investigation. #50868 highlights the framework reference being included as possibly related but I think that there might be a red herring considering the nature of the other bug reports. I'll dig in and see what I can find...I suspect upgrading runtime versions ithe more likely dilemma here... |
OK, it turns out that this is related to the fact that the HealthChecks UI package uses the same type name in their sources as we do in ours: Since we use |
This is also affecting HotChocolate. |
package AspNetCore.HealthChecks.UI (7.0.2) is also causing this issue to appear |
Is there any workaround for this? We're using HotChocolate and hitting this blocking issue on upgrading to DotNet8 today 😢 Did #51276 not make it into the final release? |
<PropertyGroup>
<NoWarn>$(NoWarn);AD0001</NoWarn>
</PropertyGroup> |
Thanks! This set me on the correct path, but in my case I had to do
This list showed up in one of the errors: |
I get 3 similar warnings in 3 different analyzers... (I'm using HotChocolate also) warning AD0001: Analyzer 'Microsoft.AspNetCore.Analyzers.WebApplicationBuilder.WebApplicationBuilderAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Failed to resolve well-known type 'Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions' warning AD0001: Analyzer 'Microsoft.AspNetCore.Analyzers.RouteHandlers.RouteHandlerAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Failed to resolve well-known type 'Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions'.' warning AD0001: Analyzer 'Microsoft.AspNetCore.Analyzers.RouteEmbeddedLanguage.RoutePatternAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'Failed to resolve well-known type 'Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions' |
I cannot believe this wasn't resolved before 8 went live to the world... the fix was supposedly merged a month ago: #51276 |
Thanks for the feedback here folks! The actual fix to this issue is in #50969. I'm bumped CI and request for reviews on this PR so that we can get it in the next servicing cycle. In the meantime, the workarounds identified in this comment should be sufficient for projects running into this with the dependencies at hand. For context, this issue will manifest if any library references in your application are also declaring methods in the The fix here was to modify the behavior of our lookup to use alternative APIs that only checked for types based on name and assembly. |
1>CSC : warning AD0001: 分析器“Microsoft.AspNetCore.Analyzers.RouteHandlers.RouteHandlerAnalyzer”引发类型为“System.InvalidOperationException”的异常,并显示消息“Failed to resolve well-known type 'Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions'.”。 The compilation result is not affected, but the error message is annoying |
I am facing the same issues when I use AspNetCore.HealthChecks.UI (version 7.0.2) |
The current version of .NET 8.0 contains a bug [1] in `RouteHandlerAnalyzer` that causes it to throw `InvalidOperationException` with message 'Failed to resolve well-known type 'Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions' when the application references any libraries that declare methods in the `Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions` static class. A fix [2] is expected [3] to be included in an upcoming .NET 8 patch release. [1] dotnet/aspnetcore#50836 [2] dotnet/aspnetcore#50969 [3] dotnet/aspnetcore#50836 (comment)
To follow-up on this, the fix for this has been merged and is expected to be released in the next servicing release of .NET 8. In the meantime, recommend using the workarounds mentioned above. |
Anyone else seeing this?
Using HotChocolate, but adding a simple route near the bottom of my file causes this error app.MapGet("/graphql/getdocument", () => Results.Ok("hi")); Error goes away if that line is commented out |
@onionhammer I haven't seen that one before. My hunch tells me that Does using the workarounds mentioned above resolve the issue with the C# extension? |
No, I already had that NoWarn set up ages ago. This issue started happening more recently |
@onionhammer OK, in that case. I'd recommend trying to see if updating to the upcoming .NET 8 release will resolve the issue. If not, I'd recommend filing an issue against the C# extension repo, especially if you are not seeing these exceptions in VS or when building from the commandline. |
I only started seeing it after .net 8 |
Hi everyone -- the bug fix has been released as part of today's (January 9th) monthly release. You can download it at https://dotnet.microsoft.com/en-us/download/dotnet/8.0. Let me know if there are any other issues! |
Great 👍🏻 thanks |
I've hit the following error while working on Xabaril/AspNetCore.Diagnostics.HealthChecks#2044.
PS D:\projects\forks\healthChecks> dotnet --info .NET SDK: Version: 8.0.100-rc.2.23429.6 Commit: 4bafa2271a Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.100-rc.2.23429.6\
Repro:
git clone https://github.com/adamsitnik/AspNetCore.Diagnostics.HealthChecks.git --branch reproBug reproBug cd reproBug dotnet build .\test\HealthChecks.UI.Tests\HealthChecks.UI.Tests.csproj
The text was updated successfully, but these errors were encountered: