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

Fix NRE in DiagnosticAnalyzerApiUsageAnalyzer when processi… #1843

Merged
merged 1 commit into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private ImmutableHashSet<INamedTypeSymbol> GetUsedNamedTypes(INamedTypeSymbol na
var syntax = decl.GetSyntax(cancellationToken);

// GetSyntax for VB returns the StatementSyntax instead of BlockSyntax node.
syntax = syntax.FirstAncestorOrSelf<SyntaxNode>(node => IsNamedTypeDeclarationBlock(node), ascendOutOfTrivia: false);
syntax = syntax.FirstAncestorOrSelf<SyntaxNode>(node => IsNamedTypeDeclarationBlock(node), ascendOutOfTrivia: false) ?? syntax;

var semanticModel = compilation.GetSemanticModel(syntax.SyntaxTree);
var nodesToProcess = new Queue<(SyntaxNode node, bool inExecutableCode)>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ public void NoDiagnosticCases()

interface I<T> { }

internal delegate void MyDelegateGlobal();

class MyAnalyzer : DiagnosticAnalyzer
{
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics=> throw new NotImplementedException();

internal delegate void MyDelegateInType();

public override void Initialize(AnalysisContext context)
{
var x = typeof(I<>);
Expand Down Expand Up @@ -66,8 +70,11 @@ Imports Microsoft.CodeAnalysis.VisualBasic
Interface I(Of T)
End Interface

Friend Delegate Sub MyDelegateGlobal()

Class MyAnalyzer
Inherits DiagnosticAnalyzer
Friend Delegate Sub MyDelegateInType()

Public Overrides ReadOnly Property SupportedDiagnostics() As ImmutableArray(Of DiagnosticDescriptor)
Get
Expand Down