From 6b4151d3c36de39f47e8fff1e541f0fc8158f503 Mon Sep 17 00:00:00 2001 From: Brennan Conroy Date: Mon, 27 Jan 2020 15:13:22 -0800 Subject: [PATCH 1/2] Fix nullref in ComponentsAnalyzer --- src/Components/Analyzers/src/InternalUsageAnalyzer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/Analyzers/src/InternalUsageAnalyzer.cs b/src/Components/Analyzers/src/InternalUsageAnalyzer.cs index 495e4c90fa61..af77a42eccec 100644 --- a/src/Components/Analyzers/src/InternalUsageAnalyzer.cs +++ b/src/Components/Analyzers/src/InternalUsageAnalyzer.cs @@ -126,7 +126,7 @@ private void AnalyzeSymbol(SymbolAnalysisContext context) // 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 @@ private void VisitOperationSymbol(OperationAnalysisContext context, ISymbol symb // 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; From 5b75e84aa48244493cb91d9b8118c780a2000ae0 Mon Sep 17 00:00:00 2001 From: Brennan Conroy Date: Mon, 27 Jan 2020 15:48:18 -0800 Subject: [PATCH 2/2] test --- Directory.Build.props | 3 +++ .../UsesRendererTypesInDeclarations.cs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6cbe46561b1e..b68fd8cb6691 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -30,6 +30,9 @@ --> false true + + + true diff --git a/src/Components/Analyzers/test/TestFiles/ComponentInternalUsageDiagnosticsAnalyzerTest/UsesRendererTypesInDeclarations.cs b/src/Components/Analyzers/test/TestFiles/ComponentInternalUsageDiagnosticsAnalyzerTest/UsesRendererTypesInDeclarations.cs index e2877b0df52f..0a0bd11b7bee 100644 --- a/src/Components/Analyzers/test/TestFiles/ComponentInternalUsageDiagnosticsAnalyzerTest/UsesRendererTypesInDeclarations.cs +++ b/src/Components/Analyzers/test/TestFiles/ComponentInternalUsageDiagnosticsAnalyzerTest/UsesRendererTypesInDeclarations.cs @@ -22,11 +22,15 @@ protected override void HandleException(Exception exception) 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 + { + } } }