Skip to content

Commit 0a9cda3

Browse files
author
msftbot[bot]
authored
Merge pull request #43125 from dotnet/merges/release/dev16.6-to-release/dev16.6-vs-deps
Merge release/dev16.6 to release/dev16.6-vs-deps
2 parents 1b62921 + e768297 commit 0a9cda3

File tree

199 files changed

+2370
-1722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+2370
-1722
lines changed

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<!-- Versions used by several individual references below -->
3030
<RoslynDiagnosticsNugetPackageVersion>3.0.0-beta2.20169.3</RoslynDiagnosticsNugetPackageVersion>
3131
<CodeStyleLayerCodeAnalysisVersion>3.3.1</CodeStyleLayerCodeAnalysisVersion>
32-
<MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.20126.2</MicrosoftCodeAnalysisTestingVersion>
32+
<MicrosoftCodeAnalysisTestingVersion>1.0.1-beta1.20206.1</MicrosoftCodeAnalysisTestingVersion>
3333
<CodeStyleAnalyzerVersion>3.6.0-2.20157.5</CodeStyleAnalyzerVersion>
3434
<VisualStudioEditorPackagesVersion>16.4.248</VisualStudioEditorPackagesVersion>
3535
<ILToolsPackageVersion>5.0.0-alpha1.19409.1</ILToolsPackageVersion>
@@ -199,7 +199,7 @@
199199
<SystemThreadingTasksExtensionsVersion>4.5.3</SystemThreadingTasksExtensionsVersion>
200200
<SQLitePCLRawbundle_greenVersion>1.1.2</SQLitePCLRawbundle_greenVersion>
201201
<UIAComWrapperVersion>1.1.0.14</UIAComWrapperVersion>
202-
<MicrosoftVSSDKBuildToolsVersion>16.3.2099</MicrosoftVSSDKBuildToolsVersion>
202+
<MicrosoftVSSDKBuildToolsVersion>16.5.2044</MicrosoftVSSDKBuildToolsVersion>
203203
<MicrosoftVSSDKVSDConfigToolVersion>16.0.2032702</MicrosoftVSSDKVSDConfigToolVersion>
204204
<VSLangProjVersion>7.0.3301</VSLangProjVersion>
205205
<VSLangProj140Version>14.0.25030</VSLangProj140Version>

src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,23 @@
2424
<Compile Include="$(MSBuildThisFileDirectory)ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs" />
2525
<Compile Include="$(MSBuildThisFileDirectory)FileHeaders\CSharpFileHeaderDiagnosticAnalyzer.cs" />
2626
<Compile Include="$(MSBuildThisFileDirectory)FileHeaders\CSharpFileHeaderHelper.cs" />
27+
<Compile Include="$(MSBuildThisFileDirectory)MakeLocalFunctionStatic\MakeLocalFunctionStaticDiagnosticAnalyzer.cs" />
28+
<Compile Include="$(MSBuildThisFileDirectory)MakeLocalFunctionStatic\MakeLocalFunctionStaticHelper.cs" />
29+
<Compile Include="$(MSBuildThisFileDirectory)MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs" />
30+
<Compile Include="$(MSBuildThisFileDirectory)MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs" />
2731
<Compile Include="$(MSBuildThisFileDirectory)NamingStyle\CSharpNamingStyleDiagnosticAnalyzer.cs" />
2832
<Compile Include="$(MSBuildThisFileDirectory)OrderModifiers\CSharpOrderModifiersDiagnosticAnalyzer.cs" />
2933
<Compile Include="$(MSBuildThisFileDirectory)OrderModifiers\CSharpOrderModifiersHelper.cs" />
3034
<Compile Include="$(MSBuildThisFileDirectory)PopulateSwitch\CSharpPopulateSwitchExpressionDiagnosticAnalyzer.cs" />
3135
<Compile Include="$(MSBuildThisFileDirectory)PopulateSwitch\CSharpPopulateSwitchStatementDiagnosticAnalyzer.cs" />
3236
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs" />
3337
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs" />
38+
<Compile Include="$(MSBuildThisFileDirectory)UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs" />
3439
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\CSharpUseCoalesceExpressionDiagnosticAnalyzer.cs" />
3540
<Compile Include="$(MSBuildThisFileDirectory)UseCoalesceExpression\CSharpUseCoalesceExpressionForNullableDiagnosticAnalyzer.cs" />
41+
<Compile Include="$(MSBuildThisFileDirectory)UseCompoundAssignment\CSharpUseCompoundAssignmentDiagnosticAnalyzer.cs" />
42+
<Compile Include="$(MSBuildThisFileDirectory)UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs" />
43+
<Compile Include="$(MSBuildThisFileDirectory)UseCompoundAssignment\Utilities.cs" />
3644
<Compile Include="$(MSBuildThisFileDirectory)UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentDiagnosticAnalyzer.cs" />
3745
<Compile Include="$(MSBuildThisFileDirectory)UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs" />
3846
<Compile Include="$(MSBuildThisFileDirectory)UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs" />
@@ -72,6 +80,7 @@
7280
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs" />
7381
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs" />
7482
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs" />
83+
<Compile Include="$(MSBuildThisFileDirectory)UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs" />
7584
<Compile Include="$(MSBuildThisFileDirectory)UseThrowExpression\CSharpUseThrowExpressionDiagnosticAnalyzer.cs" />
7685
<Compile Include="$(MSBuildThisFileDirectory)ValidateFormatString\CSharpValidateFormatStringDiagnosticAnalyzer.cs" />
7786
</ItemGroup>

src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@
144144
<data name="Add_braces_to_0_statement" xml:space="preserve">
145145
<value>Add braces to '{0}' statement.</value>
146146
</data>
147+
<data name="Misplaced_using_directive" xml:space="preserve">
148+
<value>Misplaced using directive</value>
149+
<comment>{Locked="using"} "using" is a C# keyword and should not be localized.</comment>
150+
</data>
151+
<data name="Move_misplaced_using_directives" xml:space="preserve">
152+
<value>Move misplaced using directives</value>
153+
<comment>{Locked="using"} "using" is a C# keyword and should not be localized.</comment>
154+
</data>
155+
<data name="Using_directives_must_be_placed_inside_of_a_namespace_declaration" xml:space="preserve">
156+
<value>Using directives must be placed inside of a namespace declaration</value>
157+
<comment>{Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized.</comment>
158+
</data>
159+
<data name="Using_directives_must_be_placed_outside_of_a_namespace_declaration" xml:space="preserve">
160+
<value>Using directives must be placed outside of a namespace declaration</value>
161+
<comment>{Locked="using"} "using" is a C# keyword and should not be localized. {Locked="namespace"} "namespace" is a C# keyword and should not be localized.</comment>
162+
</data>
163+
<data name="Warning_colon_Moving_using_directives_may_change_code_meaning" xml:space="preserve">
164+
<value>Warning: Moving using directives may change code meaning.</value>
165+
<comment>{Locked="using"} "using" is a C# keyword and should not be localized.</comment>
166+
</data>
147167
<data name="Use_expression_body_for_methods" xml:space="preserve">
148168
<value>Use expression body for methods</value>
149169
</data>
@@ -195,6 +215,12 @@
195215
<data name="Use_is_null_check" xml:space="preserve">
196216
<value>Use 'is null' check</value>
197217
</data>
218+
<data name="Use_simple_using_statement" xml:space="preserve">
219+
<value>Use simple 'using' statement</value>
220+
</data>
221+
<data name="using_statement_can_be_simplified" xml:space="preserve">
222+
<value>'using' statement can be simplified</value>
223+
</data>
198224
<data name="if_statement_can_be_simplified" xml:space="preserve">
199225
<value>'if' statement can be simplified</value>
200226
</data>
@@ -204,12 +230,26 @@
204230
<data name="default_expression_can_be_simplified" xml:space="preserve">
205231
<value>'default' expression can be simplified</value>
206232
</data>
233+
<data name="Make_readonly_fields_writable" xml:space="preserve">
234+
<value>Make readonly fields writable</value>
235+
<comment>{Locked="readonly"} "readonly" is C# keyword and should not be localized.</comment>
236+
</data>
237+
<data name="Struct_contains_assignment_to_this_outside_of_constructor_Make_readonly_fields_writable" xml:space="preserve">
238+
<value>Struct contains assignment to 'this' outside of constructor. Make readonly fields writable</value>
239+
<comment>{Locked="Struct"}{Locked="this"} these are C#/VB keywords and should not be localized.</comment>
240+
</data>
207241
<data name="Deconstruct_variable_declaration" xml:space="preserve">
208242
<value>Deconstruct variable declaration</value>
209243
</data>
210244
<data name="Variable_declaration_can_be_deconstructed" xml:space="preserve">
211245
<value>Variable declaration can be deconstructed</value>
212246
</data>
247+
<data name="Local_function_can_be_made_static" xml:space="preserve">
248+
<value>Local function can be made static</value>
249+
</data>
250+
<data name="Make_local_function_static" xml:space="preserve">
251+
<value>Make local function 'static'</value>
252+
</data>
213253
<data name="_0_can_be_simplified" xml:space="preserve">
214254
<value>{0} can be simplified</value>
215255
</data>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public MakeLocalFunctionStaticDiagnosticAnalyzer()
1717
: base(IDEDiagnosticIds.MakeLocalFunctionStaticDiagnosticId,
1818
CSharpCodeStyleOptions.PreferStaticLocalFunction,
1919
LanguageNames.CSharp,
20-
new LocalizableResourceString(nameof(FeaturesResources.Make_local_function_static), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
21-
new LocalizableResourceString(nameof(FeaturesResources.Local_function_can_be_made_static), FeaturesResources.ResourceManager, typeof(FeaturesResources)))
20+
new LocalizableResourceString(nameof(CSharpAnalyzersResources.Make_local_function_static), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)),
21+
new LocalizableResourceString(nameof(CSharpAnalyzersResources.Local_function_can_be_made_static), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)))
2222
{
2323
}
2424

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
#nullable enable
6+
7+
using System.Collections.Immutable;
8+
using System.Linq;
9+
using Microsoft.CodeAnalysis.CSharp.Extensions;
10+
using Microsoft.CodeAnalysis.CSharp.Syntax;
11+
using Microsoft.CodeAnalysis.Shared.Extensions;
12+
13+
namespace Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic
14+
{
15+
internal static class MakeLocalFunctionStaticHelper
16+
{
17+
public static bool IsStaticLocalFunctionSupported(SyntaxTree tree)
18+
=> tree.Options is CSharpParseOptions csharpOption && csharpOption.LanguageVersion >= LanguageVersion.CSharp8;
19+
20+
public static bool TryGetCaputuredSymbols(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray<ISymbol> captures)
21+
{
22+
var dataFlow = semanticModel.AnalyzeDataFlow(localFunction);
23+
if (dataFlow is null)
24+
{
25+
captures = default;
26+
return false;
27+
}
28+
29+
captures = dataFlow.CapturedInside;
30+
return dataFlow.Succeeded;
31+
}
32+
33+
public static bool TryGetCaputuredSymbolsAndCheckApplicability(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray<ISymbol> captures)
34+
=> TryGetCaputuredSymbols(localFunction, semanticModel, out captures) && CanMakeLocalFunctionStatic(captures);
35+
36+
private static bool CanMakeLocalFunctionStatic(ImmutableArray<ISymbol> captures)
37+
=> captures.Length > 0 && !captures.Any(s => s.IsThisParameter());
38+
}
39+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ internal sealed class CSharpMakeStructFieldsWritableDiagnosticAnalyzer : Abstrac
1515
{
1616
private static readonly DiagnosticDescriptor s_diagnosticDescriptor = CreateDescriptor(
1717
IDEDiagnosticIds.MakeStructFieldsWritable,
18-
new LocalizableResourceString(nameof(FeaturesResources.Make_readonly_fields_writable), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
19-
new LocalizableResourceString(nameof(FeaturesResources.Struct_contains_assignment_to_this_outside_of_constructor_Make_readonly_fields_writable), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
18+
new LocalizableResourceString(nameof(CSharpAnalyzersResources.Make_readonly_fields_writable), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)),
19+
new LocalizableResourceString(nameof(CSharpAnalyzersResources.Struct_contains_assignment_to_this_outside_of_constructor_Make_readonly_fields_writable), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)),
2020
isUnnecessary: false);
2121

2222
public CSharpMakeStructFieldsWritableDiagnosticAnalyzer()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ namespace Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives
1919
internal sealed class MisplacedUsingDirectivesDiagnosticAnalyzer : AbstractBuiltInCodeStyleDiagnosticAnalyzer
2020
{
2121
private static readonly LocalizableResourceString s_localizableTitle = new LocalizableResourceString(
22-
nameof(CSharpFeaturesResources.Misplaced_using_directive), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources));
22+
nameof(CSharpAnalyzersResources.Misplaced_using_directive), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources));
2323

2424
private static readonly LocalizableResourceString s_localizableOutsideMessage = new LocalizableResourceString(
25-
nameof(CSharpFeaturesResources.Using_directives_must_be_placed_outside_of_a_namespace_declaration), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources));
25+
nameof(CSharpAnalyzersResources.Using_directives_must_be_placed_outside_of_a_namespace_declaration), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources));
2626

2727
private static readonly DiagnosticDescriptor s_outsideDiagnosticDescriptor = CreateDescriptorWithId(
2828
IDEDiagnosticIds.MoveMisplacedUsingDirectivesDiagnosticId, s_localizableTitle, s_localizableOutsideMessage);
2929

3030
private static readonly LocalizableResourceString s_localizableInsideMessage = new LocalizableResourceString(
31-
nameof(CSharpFeaturesResources.Using_directives_must_be_placed_inside_of_a_namespace_declaration), CSharpFeaturesResources.ResourceManager, typeof(CSharpFeaturesResources));
31+
nameof(CSharpAnalyzersResources.Using_directives_must_be_placed_inside_of_a_namespace_declaration), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources));
3232

3333
private static readonly DiagnosticDescriptor s_insideDiagnosticDescriptor = CreateDescriptorWithId(
3434
IDEDiagnosticIds.MoveMisplacedUsingDirectivesDiagnosticId, s_localizableTitle, s_localizableInsideMessage);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer
2222
public CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer()
2323
: base(IDEDiagnosticIds.UseCoalesceCompoundAssignmentDiagnosticId,
2424
CodeStyleOptions2.PreferCompoundAssignment,
25-
new LocalizableResourceString(nameof(FeaturesResources.Use_compound_assignment), FeaturesResources.ResourceManager, typeof(FeaturesResources)))
25+
new LocalizableResourceString(nameof(AnalyzersResources.Use_compound_assignment), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)))
2626
{
2727
}
2828

0 commit comments

Comments
 (0)