aspnetcore: TopLevelParameterNameAnalyzer threw an exception of type System.NullReferenceException.
Describe the bug
The warning below is emitted when building my project.
CSC : warning AD0001: Analyzer 'Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
To Reproduce
- Install .NET Core SDK 3.0.100.
git clone git@github.com:twitchax/AspNetCore.Proxy.gitdotnet test
Expected behavior
No warnings.
Screenshots
N/A.
Additional context
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100\
Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33
.NET Core SDKs installed:
1.0.4 [C:\Program Files\dotnet\sdk]
1.1.0-preview1-005051 [C:\Program Files\dotnet\sdk]
1.1.0-preview1-005077 [C:\Program Files\dotnet\sdk]
1.1.0-preview1-005098 [C:\Program Files\dotnet\sdk]
1.1.0 [C:\Program Files\dotnet\sdk]
2.0.0-preview1-005977 [C:\Program Files\dotnet\sdk]
2.0.0-preview2-006497 [C:\Program Files\dotnet\sdk]
2.0.0 [C:\Program Files\dotnet\sdk]
2.0.2-vspre-006949 [C:\Program Files\dotnet\sdk]
2.0.2 [C:\Program Files\dotnet\sdk]
2.1.1-preview-007094 [C:\Program Files\dotnet\sdk]
2.1.1-preview-007165 [C:\Program Files\dotnet\sdk]
2.1.1 [C:\Program Files\dotnet\sdk]
2.1.2 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.100-preview-007326 [C:\Program Files\dotnet\sdk]
2.1.100-preview-007363 [C:\Program Files\dotnet\sdk]
2.1.100 [C:\Program Files\dotnet\sdk]
2.1.200-preview-007474 [C:\Program Files\dotnet\sdk]
2.1.200-preview-007597 [C:\Program Files\dotnet\sdk]
2.1.200 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.301 [C:\Program Files\dotnet\sdk]
2.1.400-preview-009171 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.600-preview-009426 [C:\Program Files\dotnet\sdk]
2.1.600-preview-009472 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.2.102 [C:\Program Files\dotnet\sdk]
2.2.401 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0-preview1-002111-00 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0-preview2-25407-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 17 (5 by maintainers)
I have the same problem after migration to core 3, visual studio is 16.3.7
Without disabling the Code Analysis (Project Settings > Code Analysis > Run On Build) this error prevents my project from building in Visual Studio.
VS version: 16.3.9 .NET Core SDK: 3.0.100
As you can see my project after upgrading from .net core 2.2 to 3.0 has references to two different versions of Microsoft.AspNetCore.Mvc.Analyzers
@twitchax the test app is using a 3.0.0 of
Microsoft.AspNetCore.TestHostwhich is effectively lifting the tests to compile the app against 3.0.0 versions of ASP.NET Core. Your app is still targeting .NET Core 2.2. Given there were many breaking changes in 3.0, I don’t think you want to mix the two versions when testing.Consider changing the test app to target
2.2.xversion of TestHost or migrating your application to .NET Core 3.0. Alternatively, you should be able to suppress the analyzer in the test project.More details: The null refs is a result of one of the breaking changes in 3.0 - some types that were formerly pub-internal were moved to a public interface while also changing their namespace. The app’s package reference to
Microsoft.AspNetCore.Mvcto 2.2.0 gets lifted to the 3.0.0 framework reference in the test app, but the analyzer package remains 2.2.0. You effectively get this:This might fall in to the category of the SDK lifting the 2.2 analyzer package reference to a 3.0 version if it sees a
FrameworkReferencetoMicrosoft.AspNetCore.App, but I’m not sure how trivial that is.Closing this as there are no follow-up items left here. If you hit this issue, read @pranavkm 's comment above: https://github.com/dotnet/aspnetcore/issues/14723#issuecomment-588389938
@OwenPattison Yes, I have noted that the issue is that code analysis by default does generate the issue by the way it is configured. 2 options: The first
remove the checkboxes, the default is checked and what it installs does not work
The 2nd Install FxCop package
and then
update to the new version, no clue why it isn’t installing a updated version to start with
I am also seeing the same issue after upgrading to dotnet core 3.1.101.
@PeterPann23 were you able to resolve your issue, I’m also interested in how you established it was introduced via an entity framework dll? so that I could potentially track down where my issue lies.
@yuchen-w You probably have nuget package which have 2.2.0 as dependency, like: