Skip to content

Commit 5bdb97d

Browse files
author
msftbot[bot]
authored
Merge pull request #43195 from dotnet/merges/release/dev16.5-to-release/dev16.5-vs-deps
Merge release/dev16.5 to release/dev16.5-vs-deps
2 parents 20b9af9 + 973d5a4 commit 5bdb97d

File tree

8 files changed

+23
-10
lines changed

8 files changed

+23
-10
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ dotnet_naming_symbols.all_members.applicable_kinds = *
136136

137137
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
138138

139+
# error RS2008: Enable analyzer release tracking for the analyzer project containing rule '{0}'
140+
dotnet_diagnostic.RS2008.severity = none
141+
139142
# CSharp code style settings:
140143
[*.cs]
141144
# Newline settings

eng/Versions.props

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@
5454
<MicrosoftBuildLocatorVersion>1.2.2</MicrosoftBuildLocatorVersion>
5555
<MicrosoftBuildRuntimeVersion>15.1.548</MicrosoftBuildRuntimeVersion>
5656
<MicrosoftBuildTasksCoreVersion>15.1.548</MicrosoftBuildTasksCoreVersion>
57-
<MicrosoftCodeAnalysisAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</MicrosoftCodeAnalysisAnalyzersVersion>
57+
<!--
58+
Since the Microsoft.CodeAnalysis.Analyzers package is a public dependency of our NuGet
59+
packages we will keep it untied to the RoslynDiagnosticsNugetPackageVersion we use for
60+
other analyzers to ensure it stays on a release version.
61+
-->
62+
<MicrosoftCodeAnalysisAnalyzersVersion>3.0.0</MicrosoftCodeAnalysisAnalyzersVersion>
5863
<MicrosoftCodeAnalysisBuildTasksVersion>2.0.0-rc2-61102-09</MicrosoftCodeAnalysisBuildTasksVersion>
5964
<MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion>
6065
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>$(CodeStyleAnalyzerVersion)</MicrosoftCodeAnalysisCSharpCodeStyleVersion>

src/Features/CSharp/Portable/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,13 @@ protected override void RegisterIneligibleFieldsAction(
6666
List<AnalysisResult> analysisResults, HashSet<IFieldSymbol> ineligibleFields,
6767
Compilation compilation, CancellationToken cancellationToken)
6868
{
69-
var groups = analysisResults.Select(r => (TypeDeclarationSyntax)r.PropertyDeclaration.Parent)
69+
var groups = analysisResults.Select(r => (typeDeclaration: (TypeDeclarationSyntax)r.PropertyDeclaration.Parent, r.SemanticModel))
7070
.Distinct()
71-
.GroupBy(n => n.SyntaxTree);
71+
.GroupBy(n => n.typeDeclaration.SyntaxTree);
7272

7373
foreach (var (tree, typeDeclarations) in groups)
7474
{
75-
var semanticModel = compilation.GetSemanticModel(tree);
76-
77-
foreach (var typeDeclaration in typeDeclarations)
75+
foreach (var (typeDeclaration, semanticModel) in typeDeclarations)
7876
{
7977
foreach (var argument in typeDeclaration.DescendantNodesAndSelf().OfType<ArgumentSyntax>())
8078
{

src/Features/CSharp/Portable/UsePatternMatching/CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ public SemanticModel ReplaceMatches(
223223

224224
var updatedCompilation = semanticModel.Compilation.ReplaceSyntaxTree(
225225
semanticModel.SyntaxTree, updatedSyntaxTree);
226+
#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
226227
return updatedCompilation.GetSemanticModel(updatedSyntaxTree);
228+
#pragma warning restore RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
227229
}
228230

229231
private SyntaxNode GetContainer(BinaryExpressionSyntax isExpression)

src/Features/Core/Portable/UseAutoProperty/AbstractUseAutoPropertyAnalyzer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Collections.Immutable;
77
using System.Threading;
8+
using Microsoft.CodeAnalysis;
89
using Microsoft.CodeAnalysis.CodeStyle;
910
using Microsoft.CodeAnalysis.Diagnostics;
1011
using Microsoft.CodeAnalysis.Shared.Extensions;
@@ -230,7 +231,7 @@ protected void AnalyzeProperty(
230231

231232
// Looks like a viable property/field to convert into an auto property.
232233
analysisResults.Add(new AnalysisResult(property, getterField, propertyDeclaration,
233-
fieldDeclaration, variableDeclarator, property.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)));
234+
fieldDeclaration, variableDeclarator, semanticModel, property.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)));
234235
}
235236

236237
protected virtual bool CanConvert(IPropertySymbol property)
@@ -358,6 +359,7 @@ internal class AnalysisResult
358359
public readonly TPropertyDeclaration PropertyDeclaration;
359360
public readonly TFieldDeclaration FieldDeclaration;
360361
public readonly TVariableDeclarator VariableDeclarator;
362+
public readonly SemanticModel SemanticModel;
361363
public readonly string SymbolEquivalenceKey;
362364

363365
public AnalysisResult(
@@ -366,13 +368,15 @@ public AnalysisResult(
366368
TPropertyDeclaration propertyDeclaration,
367369
TFieldDeclaration fieldDeclaration,
368370
TVariableDeclarator variableDeclarator,
371+
SemanticModel semanticModel,
369372
string symbolEquivalenceKey)
370373
{
371374
Property = property;
372375
Field = field;
373376
PropertyDeclaration = propertyDeclaration;
374377
FieldDeclaration = fieldDeclaration;
375378
VariableDeclarator = variableDeclarator;
379+
SemanticModel = semanticModel;
376380
SymbolEquivalenceKey = symbolEquivalenceKey;
377381
}
378382
}

src/Features/Core/Portable/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ private void AnalyzeOperation(OperationAnalysisContext context, INamedTypeSymbol
7474
var throwOperation = (IThrowOperation)context.Operation;
7575
var throwStatementSyntax = throwOperation.Syntax;
7676

77-
var compilation = context.Compilation;
78-
var semanticModel = compilation.GetSemanticModel(throwStatementSyntax.SyntaxTree);
77+
var semanticModel = context.Operation.SemanticModel;
7978

8079
var ifOperation = GetContainingIfOperation(
8180
semanticModel, throwOperation, cancellationToken);

src/Features/VisualBasic/Portable/UseAutoProperty/VisualBasicUseAutoPropertyAnalyzer.vb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseAutoProperty
172172
For Each ref In containingType.DeclaringSyntaxReferences
173173
Dim containingNode = ref.GetSyntax(cancellationToken)?.Parent
174174
If containingNode IsNot Nothing Then
175+
#Disable Warning RS1030 ' Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
175176
Dim semanticModel = compilation.GetSemanticModel(containingNode.SyntaxTree)
177+
#Enable Warning RS1030 ' Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
176178
If IsWrittenOutsideOfConstructorOrProperty(field, propertyDeclaration, containingNode, semanticModel, cancellationToken) Then
177179
Return False
178180
End If

src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public sealed override void Initialize(AnalysisContext context)
6565
ITypeSymbol type = increment.Type;
6666
Optional<object> constantValue = new Optional<object>(1);
6767
bool isImplicit = increment.IsImplicit;
68-
var value = new LiteralOperation(operationContext.Compilation.GetSemanticModel(syntax.SyntaxTree), syntax, type, constantValue, isImplicit);
68+
var value = new LiteralOperation(increment.SemanticModel, syntax, type, constantValue, isImplicit);
6969

7070
AssignTo(increment.Target, localsSourceTypes, fieldsSourceTypes, value);
7171
}

0 commit comments

Comments
 (0)