Fix nullref in ComponentsAnalyzer (#18608)

This commit is contained in:
Brennan 2020-01-27 18:10:19 -08:00 committed by GitHub
parent 2481862682
commit 547350002a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -30,6 +30,9 @@
-->
<IsStableBuild>false</IsStableBuild>
<IsStableBuild Condition=" '$(DotNetFinalVersionKind)' == 'release' ">true</IsStableBuild>
<!-- Workaround issue with ComponentsAnalyzer throwing for interfaces -->
<DisableImplicitComponentsAnalyzers>true</DisableImplicitComponentsAnalyzers>
</PropertyGroup>
<Import Project="eng\FlakyTests.BeforeArcade.props" />

View File

@ -126,7 +126,7 @@ namespace Microsoft.Extensions.Internal
// Similar logic here to VisitDeclarationSymbol, keep these in sync.
private void VisitOperationSymbol(OperationAnalysisContext context, ISymbol symbol)
{
if (symbol.ContainingAssembly == context.Compilation.Assembly)
if (symbol == null || symbol.ContainingAssembly == context.Compilation.Assembly)
{
// The type is being referenced within the same assembly. This is valid use of an "internal" type
return;
@ -155,7 +155,7 @@ namespace Microsoft.Extensions.Internal
// Similar logic here to VisitOperationSymbol, keep these in sync.
private void VisitDeclarationSymbol(SymbolAnalysisContext context, ISymbol symbol, ISymbol symbolForDiagnostic)
{
if (symbol.ContainingAssembly == context.Compilation.Assembly)
if (symbol == null || symbol.ContainingAssembly == context.Compilation.Assembly)
{
// This is part of the compilation, avoid this analyzer when building from source.
return;

View File

@ -22,11 +22,15 @@ namespace Microsoft.AspNetCore.Components.Analyzers.Tests.TestFiles.ComponentInt
throw new NotImplementedException();
}
/*MMParameter*/protected override Task UpdateDisplayAsync(in RenderBatch renderBatch)
/*MMParameter*/protected override Task UpdateDisplayAsync(in RenderBatch renderBatch)
{
throw new NotImplementedException();
}
/*MMReturnType*/private Renderer GetRenderer() => _field;
public interface ITestInterface
{
}
}
}