Skip to content

Commit

Permalink
Merge pull request #43068 from mavasani/PortUseSimpleUsingStatement
Browse files Browse the repository at this point in the history
Port UseSimpleUsingStatement analyzer/fixer/test to shared layer
  • Loading branch information
msftbot[bot] authored Apr 4, 2020
2 parents 02b346f + dadb2c1 commit abe7a8a
Show file tree
Hide file tree
Showing 34 changed files with 143 additions and 140 deletions.
1 change: 1 addition & 0 deletions src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseThrowExpression\CSharpUseThrowExpressionDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ValidateFormatString\CSharpValidateFormatStringDiagnosticAnalyzer.cs" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@
<data name="Use_is_null_check" xml:space="preserve">
<value>Use 'is null' check</value>
</data>
<data name="Use_simple_using_statement" xml:space="preserve">
<value>Use simple 'using' statement</value>
</data>
<data name="using_statement_can_be_simplified" xml:space="preserve">
<value>'using' statement can be simplified</value>
</data>
<data name="if_statement_can_be_simplified" xml:space="preserve">
<value>'if' statement can be simplified</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public UseSimpleUsingStatementDiagnosticAnalyzer()
: base(IDEDiagnosticIds.UseSimpleUsingStatementDiagnosticId,
CSharpCodeStyleOptions.PreferSimpleUsingStatement,
LanguageNames.CSharp,
new LocalizableResourceString(nameof(FeaturesResources.Use_simple_using_statement), FeaturesResources.ResourceManager, typeof(FeaturesResources)),
new LocalizableResourceString(nameof(FeaturesResources.using_statement_can_be_simplified), FeaturesResources.ResourceManager, typeof(FeaturesResources)))
new LocalizableResourceString(nameof(CSharpAnalyzersResources.Use_simple_using_statement), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)),
new LocalizableResourceString(nameof(CSharpAnalyzersResources.using_statement_can_be_simplified), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)))
{
}

Expand Down
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
<target state="new">Use range operator</target>
<note />
</trans-unit>
<trans-unit id="Use_simple_using_statement">
<source>Use simple 'using' statement</source>
<target state="new">Use simple 'using' statement</target>
<note />
</trans-unit>
<trans-unit id="Use_switch_expression">
<source>Use 'switch' expression</source>
<target state="new">Use 'switch' expression</target>
Expand Down Expand Up @@ -222,6 +227,11 @@
<target state="new">Using directive is unnecessary.</target>
<note />
</trans-unit>
<trans-unit id="using_statement_can_be_simplified">
<source>'using' statement can be simplified</source>
<target state="new">'using' statement can be simplified</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
1 change: 1 addition & 0 deletions src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\UseInitializerHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseSimpleUsingStatement\UseSimpleUsingStatementCodeFixProvider.cs" />
</ItemGroup>
<ItemGroup Condition="'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'">
<ExpectedCompile Include="$(MSBuildThisFileDirectory)**\*$(DefaultLanguageSourceExtension)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ private static LocalDeclarationStatementSyntax Convert(UsingStatementSyntax usin
Token(SyntaxKind.SemicolonToken)).WithTrailingTrivia(ElasticCarriageReturnLineFeed);
}

private class MyCodeAction : CodeAction.DocumentChangeAction
private class MyCodeAction : CustomCodeActions.DocumentChangeAction
{
public MyCodeAction(Func<CancellationToken, Task<Document>> createChangedDocument)
: base(FeaturesResources.Use_simple_using_statement, createChangedDocument, FeaturesResources.Use_simple_using_statement)
: base(CSharpAnalyzersResources.Use_simple_using_statement, createChangedDocument, CSharpAnalyzersResources.Use_simple_using_statement)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckTests_FixAllTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzerTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzerTests_FixAllTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseSimpleUsingStatement\UseSimpleUsingStatementTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseSystemHashCode\UseSystemHashCodeTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseThrowExpression\UseThrowExpressionTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseThrowExpression\UseThrowExpressionTests_FixAllTests.cs" />
Expand Down
6 changes: 0 additions & 6 deletions src/Features/Core/Portable/FeaturesResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1366,12 +1366,6 @@ This version used in: {2}</value>
<data name="Wrap_and_align_expression" xml:space="preserve">
<value>Wrap and align expression</value>
</data>
<data name="Use_simple_using_statement" xml:space="preserve">
<value>Use simple 'using' statement</value>
</data>
<data name="using_statement_can_be_simplified" xml:space="preserve">
<value>'using' statement can be simplified</value>
</data>
<data name="Move_contents_to_namespace" xml:space="preserve">
<value>Move contents to namespace...</value>
</data>
Expand Down
Loading

0 comments on commit abe7a8a

Please sign in to comment.