Skip to content
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

NRE from VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer when working in Roslyn.sln #77134

Open
tmat opened this issue Feb 10, 2025 · 0 comments
Labels
Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@tmat
Copy link
Member

tmat commented Feb 10, 2025

Analyzer 'Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryCast.VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
Exception occurred with following context:
Compilation: Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests
SyntaxTree: C:\R1\src\Compilers\VisualBasic\Test\Emit\ExpressionTrees\Sources\QueryHelper.vb
SyntaxNode: DirectCast(Nothing, QueryHelper ... [DirectCastExpressionSyntax]@[1442..1480) (29,67)-(29,105)

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.VisualBasic.Extensions.CastAnalyzer.CastPassedToParamArrayDefinitelyCantBeRemoved(ITypeSymbol castType)
   at Microsoft.CodeAnalysis.VisualBasic.Extensions.CastAnalyzer.IsUnnecessary()
   at Microsoft.CodeAnalysis.VisualBasic.RemoveUnnecessaryCast.VisualBasicRemoveUnnecessaryCastDiagnosticAnalyzer.IsUnnecessaryCast(SemanticModel model, ExpressionSyntax node, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.RemoveUnnecessaryCast.AbstractRemoveUnnecessaryCastDiagnosticAnalyzer`2.TryRemoveCastExpression(SemanticModel model, TCastExpression node, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.RemoveUnnecessaryCast.AbstractRemoveUnnecessaryCastDiagnosticAnalyzer`2.AnalyzeSyntax(SyntaxNodeAnalysisContext context)
   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info, CancellationToken cancellationToken)
-----

Suppress the following diagnostics to disable this analyzer: IDE0004
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant