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/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; 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 + { + } } }