未验证 提交 d8e8df8d 编写于 作者: M Manish Vasani 提交者: GitHub

Merge pull request #43178 from mavasani/PortNewAnalyzer

Port CSharpUseLocalFunction analyzer/tests to shared layer
......@@ -80,6 +80,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseInferredMemberName\CSharpUseInferredMemberNameDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseIsNullCheck\CSharpUseIsNullCheckForReferenceEqualsDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\CSharpUseNullPropagationDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\CSharpUseObjectInitializerDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs" />
......
......@@ -256,6 +256,9 @@
<data name="Indexing_can_be_simplified" xml:space="preserve">
<value>Indexing can be simplified</value>
</data>
<data name="Use_local_function" xml:space="preserve">
<value>Use local function</value>
</data>
<data name="Use_index_operator" xml:space="preserve">
<value>Use index operator</value>
</data>
......
......@@ -45,7 +45,7 @@ public CSharpUseLocalFunctionDiagnosticAnalyzer()
CSharpCodeStyleOptions.PreferLocalOverAnonymousFunction,
LanguageNames.CSharp,
new LocalizableResourceString(
nameof(FeaturesResources.Use_local_function), FeaturesResources.ResourceManager, typeof(FeaturesResources)))
nameof(CSharpAnalyzersResources.Use_local_function), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)))
{
}
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -172,6 +172,11 @@
<target state="new">Use 'is null' check</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="new">Use local function</target>
<note />
</trans-unit>
<trans-unit id="Use_pattern_matching">
<source>Use pattern matching</source>
<target state="new">Use pattern matching</target>
......
......@@ -75,6 +75,7 @@
<Compile Include="$(MSBuildThisFileDirectory)UseIsNullCheck\UseIsNullCheckForCastAndEqualityOperatorTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseIsNullCheck\UseIsNullCheckForReferenceEqualsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseExplicitTupleName\UseExplicitTupleNameTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseLocalFunction\UseLocalFunctionTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseNullPropagation\UseNullPropagationTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UseObjectInitializer\UseObjectInitializerTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UsePatternMatching\CSharpAsAndNullCheckTests.cs" />
......
......@@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.UseLocalFunction
public partial class UseLocalFunctionTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (new CSharpUseLocalFunctionDiagnosticAnalyzer(), new CSharpUseLocalFunctionCodeFixProvider());
=> (new CSharpUseLocalFunctionDiagnosticAnalyzer(), GetCSharpUseLocalFunctionCodeFixProvider());
private static readonly ParseOptions CSharp72ParseOptions = CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7_2);
......
......@@ -11,6 +11,7 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic;
using Microsoft.CodeAnalysis.CSharp.UseAutoProperty;
using Microsoft.CodeAnalysis.CSharp.UseLocalFunction;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
......@@ -240,6 +241,9 @@ private void AssertNoAnalyzerExceptionDiagnostics(IEnumerable<Diagnostic> diagno
// https://github.com/dotnet/roslyn/issues/43056 blocks porting the fixer to CodeStyle layer.
protected static CodeFixProvider GetMakeLocalFunctionStaticCodeFixProvider() => new MakeLocalFunctionStaticCodeFixProvider();
// https://github.com/dotnet/roslyn/issues/43056 blocks porting the fixer to CodeStyle layer.
protected static CodeFixProvider GetCSharpUseLocalFunctionCodeFixProvider() => new CSharpUseLocalFunctionCodeFixProvider();
// https://github.com/dotnet/roslyn/issues/43091 blocks porting the fixer to CodeStyle layer.
protected static CodeFixProvider GetCSharpUseAutoPropertyCodeFixProvider() => new CSharpUseAutoPropertyCodeFixProvider();
......
......@@ -312,10 +312,10 @@ private static int TryDetermineParameterIndex(NameColonSyntax argumentNameColon,
private static EqualsValueClauseSyntax GetDefaultValue(IParameterSymbol parameter)
=> SyntaxFactory.EqualsValueClause(ExpressionGenerator.GenerateExpression(parameter.Type, parameter.ExplicitDefaultValue, canUseFieldReference: true));
private class MyCodeAction : CodeAction.DocumentChangeAction
private class MyCodeAction : CustomCodeActions.DocumentChangeAction
{
public MyCodeAction(Func<CancellationToken, Task<Document>> createChangedDocument)
: base(FeaturesResources.Use_local_function, createChangedDocument, FeaturesResources.Use_local_function)
: base(CSharpAnalyzersResources.Use_local_function, createChangedDocument, CSharpAnalyzersResources.Use_local_function)
{
}
}
......
......@@ -1126,9 +1126,6 @@ This version used in: {2}</value>
<data name="Add_accessibility_modifiers" xml:space="preserve">
<value>Add accessibility modifiers</value>
</data>
<data name="Use_local_function" xml:space="preserve">
<value>Use local function</value>
</data>
<data name="Move_declaration_near_reference" xml:space="preserve">
<value>Move declaration near reference</value>
</data>
......
......@@ -2810,11 +2810,6 @@ Tato verze se používá zde: {2}.</target>
<target state="translated">Přidat Modifikátory dostupnosti</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Použít lokální funkci</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Přesunout deklaraci do blízkosti odkazu</target>
......
......@@ -2810,11 +2810,6 @@ Diese Version wird verwendet in: {2}</target>
<target state="translated">Zugriffsmodifizierer hinzufügen</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Lokale Funktion verwenden</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Deklaration nahe Referenz verschieben</target>
......
......@@ -2810,11 +2810,6 @@ Esta versión se utiliza en: {2}</target>
<target state="translated">Agregar modificadores de accesibilidad</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Usar función local</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Mover la declaración cerca de la referencia</target>
......
......@@ -2810,11 +2810,6 @@ Version utilisée dans : {2}</target>
<target state="translated">Ajouter des modificateurs d'accessibilité</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Utiliser une fonction locale</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Déplacer la déclaration près de la référence</target>
......
......@@ -2810,11 +2810,6 @@ Questa versione è usata {2}</target>
<target state="translated">Aggiungi i modificatori di accessibilità</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Usa la funzione locale</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Sposta la dichiarazione accanto al riferimento</target>
......
......@@ -2810,11 +2810,6 @@ This version used in: {2}</source>
<target state="translated">アクセシビリティ修飾子を追加します</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">ローカル関数を使用します</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">宣言を参照の近くに移動します</target>
......
......@@ -2810,11 +2810,6 @@ This version used in: {2}</source>
<target state="translated">접근성 한정자 추가</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">로컬 함수 사용</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">참조 근처로 선언 이동</target>
......
......@@ -2810,11 +2810,6 @@ Ta wersja jest używana wersja: {2}</target>
<target state="translated">Dodaj modyfikatory dostępności</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Użyj funkcji lokalnej</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Przenieś deklarację blisko odwołania</target>
......
......@@ -2810,11 +2810,6 @@ Essa versão é usada no: {2}</target>
<target state="translated">Adicionar modificadores de acessibilidade</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Usar função local</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Mover declaração para próximo da referência</target>
......
......@@ -2810,11 +2810,6 @@ This version used in: {2}</source>
<target state="translated">Добавьте модификаторы доступности</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Использовать локальную функцию</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Переместить объявление рядом со ссылкой</target>
......
......@@ -2810,11 +2810,6 @@ Bu sürüm şurada kullanılır: {2}</target>
<target state="translated">Erişilebilirlik değiştiricileri Ekle</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">Yerel işlev kullan</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">Bildirimi başvurunun yanına taşı</target>
......
......@@ -2810,11 +2810,6 @@ This version used in: {2}</source>
<target state="translated">添加可访问性修饰符</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">使用本地函数</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">将声明移动至引用附近</target>
......
......@@ -2810,11 +2810,6 @@ This version used in: {2}</source>
<target state="translated">新增協助工具修飾元</target>
<note />
</trans-unit>
<trans-unit id="Use_local_function">
<source>Use local function</source>
<target state="translated">使用區域函式</target>
<note />
</trans-unit>
<trans-unit id="Move_declaration_near_reference">
<source>Move declaration near reference</source>
<target state="translated">將宣告移近參考</target>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册