Skip to content

TopLevelParameterNameAnalyzer threw an exception of type 'System.NullReferenceException' #8686

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
fuocor opened this issue Mar 20, 2019 · 21 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed

Comments

@fuocor
Copy link

fuocor commented Mar 20, 2019

Describe the bug

dotnet build throws using 3.0.100-preview4-010911 of the sdk
Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer threw an exception of type 'System.NullReferenceException'

To Reproduce

on my builds

Expected behavior

should build

Additional context

I attached the diagnostic build logs and dotnet --info

build.zip
ditnet.info.txt

@pranavkm
Copy link
Contributor

Thanks for the report. We addressed this as part of #8403. If you get the most recent SDK (3.0.100-preview4-010913), the issue should be resolved.

@pranavkm pranavkm added ✔️ Resolution: Duplicate Resolved as a duplicate of another issue area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Mar 20, 2019
@spydacarnage
Copy link

@pranavkm

I've just download SDK (3.0.100-preview4-011223) and I am now also getting this NRE - has something reverted?

@pranavkm
Copy link
Contributor

@spydacarnage not that I know of. I'll reopen this issue for investigation.

@pranavkm pranavkm reopened this Apr 24, 2019
@pranavkm pranavkm removed the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Apr 24, 2019
@spydacarnage
Copy link

Thanks

@Enngage
Copy link

Enngage commented May 17, 2019

I'm getting the same on Preview 5, but as warning and it does not prevent me from building the app:

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.'.

@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. PRI: 1 - Required labels May 20, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.0.0-preview6 milestone May 20, 2019
@pranavkm pranavkm added the Done This issue has been fixed label May 21, 2019
@pranavkm
Copy link
Contributor

Thanks @Enngage. I think I sorted out of the last null refs from this analyzer.

@hellfirehd
Copy link

I'm still getting this with v3.0.100-preview6-012264:

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.'.

This is no global.json in use.

D:\Source> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview6-012264
 Commit:    be3f0c1a03

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-preview6-012264\

Host (useful for support):
  Version: 3.0.0-preview6-27804-01
  Commit:  fdf81c6faf

.NET Core SDKs installed:
  2.1.700 [C:\Program Files\dotnet\sdk]
  2.1.800-preview-009677 [C:\Program Files\dotnet\sdk]
  2.1.800-preview-009696 [C:\Program Files\dotnet\sdk]
  2.2.300 [C:\Program Files\dotnet\sdk]
  3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

What else can I provide to help troubleshoot this?

@pranavkm pranavkm reopened this Jun 25, 2019
@pranavkm
Copy link
Contributor

pranavkm commented Jun 25, 2019

@hellfirehd do you happen to have the stack trace for this? Also, does this reproduce with a specific app? If so could you share it?

@hellfirehd
Copy link

I don't know how to get a Stack Trace from inside Visual Studio 2019 Community but it only happens during build, but on several different projects.

https://gist.github.com/hellfirehd/9720846be7aa1880f794861921f3c03a

I'm willing to share the Source Code/Project Files for Project1.txt

@pranavkm
Copy link
Contributor

I'm willing to share the Source Code/Project Files for Project1.txt

That would be great!

@hellfirehd
Copy link

hellfirehd commented Jun 25, 2019

@pranavkm How do I get it to you? It's a .zip

@pranavkm
Copy link
Contributor

Could you publish it as a GitHub repo? I think GitHub might also allow you to attach zip files to comments.

@hellfirehd
Copy link

Invite sent.

@pranavkm
Copy link
Contributor

Your netcoreapp3.0 application is referencing 2.2 versions of packages which is unsupported. Have a look at https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-2.2&tabs=visual-studio for migrating to 3.0.

@sunildixit
Copy link

sunildixit commented Aug 6, 2019

I am still seeing this issue.

Here's the stack trace

Severity Code Description Project File Line Suppression State Detail Description
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.<InitializeWorker>b__0(SymbolAnalysisContext symbolAnalysisContext) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSymbolActionsCore>b__43_1(ValueTuple2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action1 analyze, TArg argument, Nullable1 info)

@spydacarnage
Copy link

spydacarnage commented Aug 6, 2019 via email

@pranavkm
Copy link
Contributor

pranavkm commented Aug 6, 2019

Hi, it looks like you are posting on a closed issue/PR/commit!

We're very likely to lose track of your bug/feedback/question unless you:

  1. Open a new issue
  2. Explain very clearly what you need help with
  3. If you think you have found a bug, include detailed repro steps so that we can investigate the problem

Thanks!

@deathcat05
Copy link

I am having an issue as well.
I have several cs projects that target netstandard2.0. But, I have a asp.net app targeting the netcoreapp3.0 which has a dependency on these 2.0 projects.

My netstandard projects reference these packages:

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />

I don't have any need for these packages in the .csproj for my netcoreapp3.0.

@SimonCropp
Copy link
Contributor

@pranavkm

Your netcoreapp3.0 application is referencing 2.2 versions of packages which is unsupported.

would it be worthwhile having some better interactive feedback as to this scenario? I assume most people will just change to <TargetFramework>netcoreapp3.0</TargetFramework> (as i did) and then cant build to a null reference in the TopLevelParameterNameAnalyzer

@DonaldAirey
Copy link

I had a working solution with no warnings or errors. Just downloaded the production release of Visual Studio 2019 16.3.0. Now I'm getting:

5>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.'.
5>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.'.
5>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.'.
5>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.'.
5>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.'.


@pranavkm
Copy link
Contributor

@SimonCropp our migration guide is fairly elaborate, so hopefully this should be covered.

@gammafour \ @deathcat05 please file a separate issue, possibly with a minimal repro. I'm locking this issue since we've resolved the original issue and it's just incredibly noisy at this point.

@dotnet dotnet locked as resolved and limited conversation to collaborators Sep 24, 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 bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed
Projects
None yet
Development

No branches or pull requests

10 participants