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

NullReferenceException in analyzer #31

Open
WalkerCodeRanger opened this issue Oct 6, 2019 · 4 comments
Open

NullReferenceException in analyzer #31

WalkerCodeRanger opened this issue Oct 6, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@WalkerCodeRanger
Copy link
Owner

System.NullReferenceException: Object reference not set to an instance of an object.
    at ExhaustiveMatching.Analyzer.TypeSymbolExtensions.GetFullName(ISymbol symbol)
    at ExhaustiveMatching.Analyzer.SwitchStatementAnalyzer.GetTypeSymbolMatched(SyntaxNodeAnalysisContext context, ITypeSymbol type, CasePatternSwitchLabelSyntax casePattern, HashSet`1 allCases, Boolean isClosed)
    at ExhaustiveMatching.Analyzer.SwitchStatementAnalyzer.<>c__DisplayClass3_0.<AnalyzeSwitchOnClosed>b__1(CasePatternSwitchLabelSyntax casePattern)
    at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
    at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
    at System.Collections.Immutable.DisposableEnumeratorAdapter`2.MoveNext()
    at System.Collections.Immutable.ImmutableHashSet`1.Union(IEnumerable`1 other, MutationInput origin)
    at System.Collections.Immutable.ImmutableHashSet`1.Union(IEnumerable`1 items, Boolean avoidWithComparer)
    at System.Collections.Immutable.ImmutableHashSet`1.Union(IEnumerable`1 other)
    at System.Collections.Immutable.ImmutableHashSet.ToImmutableHashSet[TSource](IEnumerable`1 source, IEqualityComparer`1 equalityComparer)
    at ExhaustiveMatching.Analyzer.SwitchStatementAnalyzer.AnalyzeSwitchOnClosed(SyntaxNodeAnalysisContext context, SwitchStatementSyntax switchStatement, ITypeSymbol type)
    at ExhaustiveMatching.Analyzer.SwitchStatementAnalyzer.Analyze(SyntaxNodeAnalysisContext context, SwitchStatementSyntax switchStatement)
    at ExhaustiveMatching.Analyzer.ExhaustiveMatchAnalyzer.AnalyzeSwitchStatement(SyntaxNodeAnalysisContext context)
@WalkerCodeRanger
Copy link
Owner Author

System.NullReferenceException: Object reference not set to an instance of an object.
    at ExhaustiveMatching.Analyzer.TypeSymbolExtensions.GetFullName(ISymbol symbol)
    at ExhaustiveMatching.Analyzer.SwitchStatementAnalyzer.GetTypeSymbolMatched(SyntaxNodeAnalysisContext context, ITypeSymbol type, CasePatternSwitchLabelSyntax casePattern, HashSet`1 allCases, Boolean isClosed)
    at ExhaustiveMatching.Analyzer.SwitchStatementAnalyzer.<>c__DisplayClass3_0.<AnalyzeSwitchOnClosed>b__1(CasePatternSwitchLabelSyntax casePattern)
    at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
    at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
    at System.Collections.Immutable.DisposableEnumeratorAdapter`2.MoveNext()
    at System.Collections.Immutable.ImmutableHashSet`1.Union(IEnumerable`1 other, MutationInput origin)
    at System.Collections.Immutable.ImmutableHashSet`1.Union(IEnumerable`1 items, Boolean avoidWithComparer)
    at System.Collections.Immutable.ImmutableHashSet`1.Union(IEnumerable`1 other)
    at System.Collections.Immutable.ImmutableHashSet.ToImmutableHashSet[TSource](IEnumerable`1 source, IEqualityComparer`1 equalityComparer)
    at ExhaustiveMatching.Analyzer.SwitchStatementAnalyzer.AnalyzeSwitchOnClosed(SyntaxNodeAnalysisContext context, SwitchStatementSyntax switchStatement, ITypeSymbol type)
    at ExhaustiveMatching.Analyzer.SwitchStatementAnalyzer.Analyze(SyntaxNodeAnalysisContext context, SwitchStatementSyntax switchStatement)
    at ExhaustiveMatching.Analyzer.ExhaustiveMatchAnalyzer.AnalyzeSwitchStatement(SyntaxNodeAnalysisContext context)

@WalkerCodeRanger WalkerCodeRanger added the bug Something isn't working label Dec 28, 2019
@WalkerCodeRanger
Copy link
Owner Author

WalkerCodeRanger commented May 25, 2020

Note: this GetFullName has moved to SymbolExtensions.GetFullName() and GetTypeSymbolMatched has moved to PatternAnalyzer.GetMatchedTypeSymbol()

@APIWT
Copy link

APIWT commented Aug 4, 2020

Do you have some code to reproduce this? I might have some time soon to attempt to look at it.

@WalkerCodeRanger
Copy link
Owner Author

Thanks for the offer to help!

No, unfortunately, I don't have code to reproduce this. That is a big part of why it isn't already fixed. I also haven't seen the error myself in a while. I believe it is caused by C# code that has other compile errors in it. I captured these stack traces from the Visual Studio error panel. I'd be editing code and then find that at some point one of these occurred. But then I'd close and reopen Visual Studio and it would go away. The code that caused it having been already edited out of existence by fixing other bugs. So, I think when the code is invalid, some invariant I'm thinking would always hold no longer holds, and thus something is null. But I don't know what and why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants