Skip to content

Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer threw NullReferenceException #12932

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

Closed
sunildixit opened this issue Aug 6, 2019 · 8 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates question

Comments

@sunildixit
Copy link

I am using VS 2019 Preview 16.3.0 Preview 1.0

I have two webapps in the solution and for both of them I am always getting the warning described below

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.'. ConnectorApp.Web 1 Active Analyzer 'Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer' threw the following exception:

Exception occurred with following context:
Compilation: ConnectorApp.Web
ISymbol: Create (Method)
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.CodeAnalysis.CodeAnalysisExtensions.IsAssignableFrom(ITypeSymbol source, ITypeSymbol target)
at Microsoft.CodeAnalysis.CodeAnalysisExtensions.d__2.MoveNext()
at Microsoft.CodeAnalysis.CodeAnalysisExtensions.d__4.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source) at Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer.<>c__DisplayClass3_0.b__0(SymbolAnalysisContext symbolAnalysisContext) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.b__43_1(ValueTuple2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action1 analyze, TArg argument, Nullable1 info)

@pranavkm
Copy link
Contributor

pranavkm commented Aug 7, 2019

@sunildixit could you include the obj\project.assets.json? The last time somebody ran in to this was because they had a mix of 3.0 and 2.2 packages in their application

@pranavkm pranavkm added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Aug 7, 2019
@mkArtakMSFT mkArtakMSFT added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Aug 8, 2019
@sunildixit
Copy link
Author

Here's the file.
project.assets.txt

@pranavkm
Copy link
Contributor

pranavkm commented Aug 9, 2019

Thanks. Could you also link your project file? The assets file suggests some fairly odd dependencies - it's a bit difficult to tell how you got there just inspecting it.

@sunildixit
Copy link
Author

Here you go.
ConnectorApp.Web.txt

@pranavkm pranavkm removed the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Aug 13, 2019
@pranavkm
Copy link
Contributor

Thanks @sunildixit. It's clearly not the same issue as #8686 so this does need further investigation since it's not entirely obvious where the null ref is. If you happen to have a simple app to repro the problem, that'd be great.

@JunTaoLuo looking at the project.assets.json, would you know why the app's picking up references to Kestrel 1.0, Hosting 1.0 etc? Shouldn't the shared runtime override the values here?

@sunildixit
Copy link
Author

I think I found one issue. The MVC analyzer was not installed on the MVCApp. I am not sure how to explain how this error cropped up then. But after I explicitly installed the analyzer on the web projects, then the error went away.

@mynkow
Copy link

mynkow commented Nov 8, 2019

This happens to me as well. The scenario is that I have a project on core 2.2 and a branch updating to 3.0. When I switch branches this happens.

@pranavkm
Copy link
Contributor

pranavkm commented Nov 8, 2019

@mynkow could you please file a new issue with a minimal repro? Thanks.

@dotnet dotnet locked as resolved and limited conversation to collaborators Nov 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates question
Projects
None yet
Development

No branches or pull requests

4 participants