diff --git a/src/Features/CSharp/Portable/UsePatternMatching/CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/UsePatternMatching/CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs index 8299b2bc75547de0757c4f68bb7361c06ee87a0b..184e60f00f1a7aa9630b3c9533bd4c96bf8b69a9 100644 --- a/src/Features/CSharp/Portable/UsePatternMatching/CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/UsePatternMatching/CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs @@ -215,7 +215,9 @@ private void SyntaxNodeAction(SyntaxNodeAnalysisContext context) var updatedCompilation = semanticModel.Compilation.ReplaceSyntaxTree( semanticModel.SyntaxTree, updatedSyntaxTree); +#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer return updatedCompilation.GetSemanticModel(updatedSyntaxTree); +#pragma warning restore RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer } private SyntaxNode GetContainer(BinaryExpressionSyntax isExpression) diff --git a/src/Features/VisualBasic/Portable/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb b/src/Features/VisualBasic/Portable/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb index 6506a6250c2f8e4da94549ad884a7baec7df2511..535f785836f9bc8f6a1ec7bbe7f8a062aa78ddb2 100644 --- a/src/Features/VisualBasic/Portable/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb +++ b/src/Features/VisualBasic/Portable/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb @@ -172,7 +172,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseAutoProperty For Each ref In containingType.DeclaringSyntaxReferences Dim containingNode = ref.GetSyntax(cancellationToken)?.Parent If containingNode IsNot Nothing Then +#Disable Warning RS1030 ' Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer Dim semanticModel = compilation.GetSemanticModel(containingNode.SyntaxTree) +#Enable Warning RS1030 ' Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer If IsWrittenOutsideOfConstructorOrProperty(field, propertyDeclaration, containingNode, semanticModel, cancellationToken) Then Return False End If