diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems index 8e86bff70631f..11626e4ceb326 100644 --- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems +++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems @@ -51,6 +51,8 @@ + + diff --git a/src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceCodeFixProvider.cs similarity index 100% rename from src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceCodeFixProvider.cs rename to src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceCodeFixProvider.cs diff --git a/src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs b/src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceService.cs similarity index 81% rename from src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs rename to src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceService.cs index c1d9811c90da9..8605be36ee10c 100644 --- a/src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs +++ b/src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceService.cs @@ -5,14 +5,16 @@ #nullable disable using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; using System.Threading; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.CodeGeneration; using Microsoft.CodeAnalysis.CSharp.Extensions; +using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Editing; +using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.ImplementInterface; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -20,13 +22,15 @@ namespace Microsoft.CodeAnalysis.CSharp.ImplementInterface; [ExportLanguageService(typeof(IImplementInterfaceService), LanguageNames.CSharp), Shared] -internal class CSharpImplementInterfaceService : AbstractImplementInterfaceService +[method: ImportingConstructor] +[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] +internal sealed class CSharpImplementInterfaceService() : AbstractImplementInterfaceService { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public CSharpImplementInterfaceService() - { - } + protected override ISyntaxFormatting SyntaxFormatting + => CSharpSyntaxFormatting.Instance; + + protected override SyntaxGeneratorInternal SyntaxGeneratorInternal + => CSharpSyntaxGeneratorInternal.Instance; protected override string ToDisplayString(IMethodSymbol disposeImplMethod, SymbolDisplayFormat format) => SymbolDisplay.ToDisplayString(disposeImplMethod, format); @@ -90,16 +94,16 @@ protected override SyntaxNode CreateFinalizer( { // ' Do not change this code... // Dispose(false) - var disposeStatement = (StatementSyntax)AddComment(g, - string.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString), + var disposeStatement = (StatementSyntax)AddComment( + string.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString), g.ExpressionStatement(g.InvocationExpression( g.IdentifierName(nameof(IDisposable.Dispose)), g.Argument(DisposingName, RefKind.None, g.FalseLiteralExpression())))); var methodDecl = SyntaxFactory.DestructorDeclaration(classType.Name).AddBodyStatements(disposeStatement); - return AddComment(g, - string.Format(FeaturesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, disposeMethodDisplayString), + return AddComment( + string.Format(CodeFixesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, disposeMethodDisplayString), methodDecl); } } diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems index f9144edf99aed..16526869a0819 100644 --- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems +++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems @@ -38,6 +38,8 @@ + + diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests.cs b/src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests.cs similarity index 93% rename from src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests.cs rename to src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests.cs index cf28711a00bfa..1fcfb16183639 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests.cs +++ b/src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests.cs @@ -377,7 +377,7 @@ class Class : IInterface } } """, -codeAction: ("True;False;False:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, CompilerTrait(CompilerFeature.Tuples)] @@ -560,7 +560,7 @@ public void M(string? s1, string s2) """, }, }, - CodeActionEquivalenceKey = "False;False;True:global::IInterface;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }; @@ -1017,7 +1017,7 @@ public void Method1() } } """, -codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1)); +codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1)); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69177")] @@ -1048,7 +1048,7 @@ public void Method1() } } """, -codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1)); +codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1)); } [Fact] @@ -1097,7 +1097,7 @@ public void Method1() } } """, -codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1)); +codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1)); } [Fact] @@ -1146,7 +1146,7 @@ public void Method1() } } """, -codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1)); +codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1)); } [Fact] @@ -1199,7 +1199,7 @@ class D : {|CS0535:I|} MarkupHandling = MarkupMode.Allow, }, CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne, - CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", + CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", CodeActionIndex = 1, }; @@ -1246,7 +1246,7 @@ public int this[int x] } } """, -codeAction: ("False;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;f", 1)); +codeAction: ("False;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;f", 1)); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/472")] @@ -1274,7 +1274,7 @@ public int Compare(object x, object y) } } """, -codeAction: ("False;False;False:global::System.Collections.IComparer;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;x", 1)); +codeAction: ("False;False;False:global::System.Collections.IComparer;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;x", 1)); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/472")] @@ -1302,7 +1302,7 @@ public int Compare(object x, object y) } } """, -codeAction: ("False;False;False:global::System.Collections.IComparer;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", 1)); +codeAction: ("False;False;False:global::System.Collections.IComparer;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", 1)); } [Fact] @@ -1330,7 +1330,7 @@ abstract class C : I public abstract void Method1(); } """, -codeAction: ("False;True;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("False;True;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact] @@ -1371,7 +1371,7 @@ interface I int Method2(); } """, -codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;goo", 1)); +codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;goo", 1)); } [Fact] @@ -2180,7 +2180,7 @@ int i1.p } } """, -codeAction: ("True;False;False:global::i1;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::i1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541981")] @@ -2220,7 +2220,7 @@ public void Method1() """, Options = { AllOptionsOff }, CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length), - CodeActionEquivalenceKey = "False;False;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); @@ -2245,7 +2245,7 @@ public void Method1() """, Options = { AllOptionsOff }, CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length), - CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", + CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", CodeActionIndex = 1, }.RunAsync(); @@ -2270,7 +2270,7 @@ void I.Method1() """, Options = { AllOptionsOff }, CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length), - CodeActionEquivalenceKey = "True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 2, }.RunAsync(); } @@ -2322,7 +2322,7 @@ IEnumerator IEnumerable.GetEnumerator() } } """, -codeAction: ("False;False;False:global::System.Collections.Generic.IReadOnlyList;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;field", 1)); +codeAction: ("False;False;False:global::System.Collections.Generic.IReadOnlyList;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;field", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768799")] @@ -2372,7 +2372,7 @@ IEnumerator IEnumerable.GetEnumerator() } } """, -codeAction: ("False;False;False:global::System.Collections.Generic.IReadOnlyList;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;field", 1)); +codeAction: ("False;False;False:global::System.Collections.Generic.IReadOnlyList;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;field", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768799")] @@ -2422,7 +2422,7 @@ public int M() } } """, -codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", 1)); +codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768799")] @@ -2504,7 +2504,7 @@ public int M() CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length), DiagnosticSelector = diagnostics => diagnostics[0], CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne, - CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", + CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", CodeActionIndex = 1, }.RunAsync(); @@ -2584,7 +2584,7 @@ public int M2() CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length), DiagnosticSelector = diagnostics => diagnostics[1], CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne, - CodeActionEquivalenceKey = "False;False;False:global::I2;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", + CodeActionEquivalenceKey = "False;False;False:global::I2;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", CodeActionIndex = 1, }.RunAsync(); } @@ -2648,7 +2648,7 @@ public int M() }, Options = { AllOptionsOff }, CodeActionsVerifier = codeActions => Assert.Equal(4, codeActions.Length), - CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", + CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", CodeActionIndex = 1, }.RunAsync(); @@ -2708,7 +2708,7 @@ public int M() }, Options = { AllOptionsOff }, CodeActionsVerifier = codeActions => Assert.Equal(4, codeActions.Length), - CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;aa", + CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;aa", CodeActionIndex = 2, }.RunAsync(); } @@ -2800,7 +2800,7 @@ public int M() CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length), DiagnosticSelector = diagnostics => diagnostics[0], CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne, - CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", + CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", CodeActionIndex = 1, }.RunAsync(); @@ -2888,7 +2888,7 @@ public int M2() CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length), DiagnosticSelector = diagnostics => diagnostics[1], CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne, - CodeActionEquivalenceKey = "False;False;False:global::I2;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;b", + CodeActionEquivalenceKey = "False;False;False:global::I2;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;b", CodeActionIndex = 1, }.RunAsync(); } @@ -2933,7 +2933,7 @@ public int M() """, Options = { AllOptionsOff }, CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length), - CodeActionEquivalenceKey = "False;False;False:global::IB;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;IA.B", + CodeActionEquivalenceKey = "False;False;False:global::IB;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;IA.B", CodeActionIndex = 1, }.RunAsync(); } @@ -3113,7 +3113,7 @@ public event EventHandler E } } } - """, codeAction: ("False;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;canGoo", 1)); + """, codeAction: ("False;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;canGoo", 1)); } [Fact] @@ -3140,7 +3140,7 @@ public event EventHandler E } } """, -codeAction: ("False;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;canGoo", 1)); +codeAction: ("False;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;canGoo", 1)); } [Fact] @@ -3170,7 +3170,7 @@ abstract class Goo : IGoo public event EventHandler E; } """, -codeAction: ("False;False;True:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); +codeAction: ("False;False;True:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); } [Fact] @@ -3200,7 +3200,7 @@ abstract class Goo : IGoo public abstract event EventHandler E; } """, -codeAction: ("False;True;True:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("False;True;True:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact] @@ -3241,7 +3241,7 @@ event EventHandler IGoo.E } } """, -codeAction: ("True;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2)); +codeAction: ("True;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2)); } [Fact] @@ -3427,7 +3427,7 @@ int ISomeInterface.this[int index] } } """, -codeAction: ("True;False;False:global::ISomeInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::ISomeInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact] @@ -3521,7 +3521,7 @@ void I.Goo() } } """, -codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542357")] @@ -3660,7 +3660,7 @@ void I.Goo() } } """, -codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542587")] @@ -3751,7 +3751,7 @@ void I.Goo() } } """, -codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542587")] @@ -4220,7 +4220,7 @@ void I.Goo(S x, IList list) } } """, -codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542505")] @@ -4303,7 +4303,7 @@ void I.Goo(A x, B y, IList list1, IList list2) } } """, -codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542506")] @@ -4467,7 +4467,7 @@ abstract class Goo : IGoo public abstract int Gibberish { get; set; } } """, -codeAction: ("False;True;True:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("False;True;True:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544210")] @@ -4546,7 +4546,7 @@ int IOptional.Goo(int g) } } """, -codeAction: ("True;False;False:global::IOptional;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::IOptional;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact] @@ -4737,7 +4737,7 @@ void IGoo.Goo(DateTime x) } } """, -codeAction: ("True;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545477")] @@ -4824,7 +4824,7 @@ void IGoo.Goo2(object x) } } """, -codeAction: ("True;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545464")] @@ -4947,7 +4947,7 @@ void d.m(b? x, b? y) throw new System.NotImplementedException(); } } - """, codeAction: ("True;False;False:global::d;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;False:global::d;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/916114")] @@ -6074,7 +6074,7 @@ public void Dispose() } } - """, codeAction: ("False;False;True:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); + """, codeAction: ("False;False;True:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/958699")] @@ -6093,7 +6093,7 @@ class C : IDisposable {DisposePattern("protected virtual ", "C", "public void ")} }} -", codeAction: ("False;False;True:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); +", codeAction: ("False;False;True:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/958699")] @@ -6115,7 +6115,7 @@ void IDisposable.Dispose() } } - """, codeAction: ("True;False;False:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2)); + """, codeAction: ("True;False;False:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/941469")] @@ -6142,7 +6142,7 @@ class IDisposable }} {DisposePattern("protected virtual ", "C", "void System.IDisposable.")} -}}", codeAction: ("True;False;False:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); +}}", codeAction: ("True;False;False:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/958699")] @@ -6161,7 +6161,7 @@ abstract class C : IDisposable public abstract void Dispose(); } - """, codeAction: ("False;True;True:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2)); + """, codeAction: ("False;True;True:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/958699")] @@ -6187,7 +6187,7 @@ public void Dispose() goo.Dispose(); } } - """, codeAction: ("False;False;False:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;goo", 2)); + """, codeAction: ("False;False;False:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;goo", 2)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/941469")] @@ -6203,7 +6203,7 @@ public async Task TestImplementIDisposableExplicitly_NoNamespaceImportForSystem( {DisposePattern("protected virtual ", "C", "void System.IDisposable.", gcPrefix: "System.")} }} ", - CodeActionEquivalenceKey = "True;False;False:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", CodeActionIndex = 3, // 🐛 generated QualifiedName where SimpleMemberAccessExpression was expected @@ -6243,7 +6243,7 @@ public void F() throw new NotImplementedException(); } } - """, codeAction: ("False;False;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); + """, codeAction: ("False;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/951968")] @@ -6275,7 +6275,7 @@ public void F() }} {DisposePattern("protected virtual ", "C", "public void ")} -}}", codeAction: ("False;False;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); +}}", codeAction: ("False;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/951968")] @@ -6307,7 +6307,7 @@ void I.F() }} {DisposePattern("protected virtual ", "C", "void IDisposable.")} -}}", codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); +}}", codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/941469")] @@ -6341,7 +6341,7 @@ void IDisposable.Dispose() } } } - """, codeAction: ("True;False;False:global::System.IDisposable;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;False:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact] @@ -6383,7 +6383,7 @@ void IDisposable.Dispose() } } - """, codeAction: ("True;False;False:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;False:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545924")] @@ -6732,7 +6732,7 @@ bool I.Goo(bool x) } } """, -codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); +codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546443")] @@ -6879,7 +6879,7 @@ void I.M() throw new System.NotImplementedException(); } } - """, codeAction: ("True;False;False:global::N.I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;False:global::N.I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/847464")] @@ -6917,7 +6917,7 @@ void I.Goo() throw new System.NotImplementedException(); } } - """, codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/847464")] @@ -6955,7 +6955,7 @@ void I.Goo() partial class C { } - """, codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/847464")] @@ -7014,7 +7014,7 @@ partial class C : {|CS0535:I2|} }, Options = { AllOptionsOff }, CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne, - CodeActionEquivalenceKey = "True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -7073,7 +7073,7 @@ void IGoo.set_IndexProp(int p1, string Value) """, }, }, - CodeActionEquivalenceKey = "True;False;False:global::IGoo;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }; @@ -7136,7 +7136,7 @@ public void set_P(int x, object Value) """, }, }, - CodeActionEquivalenceKey = "False;False;True:global::I;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -7205,7 +7205,7 @@ public string this[int i] """, }, }, - CodeActionEquivalenceKey = "False;False;True:global::I;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }; @@ -7245,7 +7245,7 @@ class Program : IDisposable private bool disposedValue; {DisposePattern("protected virtual ", "Program", "public void ")} -}}", codeAction: ("False;False;True:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); +}}", codeAction: ("False;False;True:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); } [Fact] @@ -7268,7 +7268,7 @@ class Program : IDisposable private bool disposedValue; {DisposePattern("protected virtual ", "Program", "void IDisposable.")} -}}", codeAction: ("True;False;False:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); +}}", codeAction: ("True;False;False:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); } [Fact] @@ -7295,7 +7295,7 @@ public void Dispose() throw new NotImplementedException(); } } - """, codeAction: ("False;False;True:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); + """, codeAction: ("False;False;True:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); } [Fact] @@ -7326,7 +7326,7 @@ public void Dispose() throw new NotImplementedException(); } } - """, codeAction: ("False;False;True:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); + """, codeAction: ("False;False;True:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0)); } [Fact] @@ -7347,7 +7347,7 @@ sealed class Program : IDisposable private bool disposedValue; {DisposePattern("private ", "Program", "void IDisposable.")} -}}", codeAction: ("True;False;False:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); +}}", codeAction: ("True;False;False:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/9760")] @@ -7370,7 +7370,7 @@ class Program : IDisposable private bool disposedValue1; {DisposePattern("protected virtual ", "Program", "public void ", disposeField: "disposedValue1")} -}}", codeAction: ("False;False;True:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); +}}", codeAction: ("False;False;True:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/9760")] @@ -7397,7 +7397,7 @@ class Program : IDisposable { _options.FieldNamesAreCamelCaseWithUnderscorePrefix, }, - CodeActionEquivalenceKey = "False;False;True:global::System.IDisposable;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::System.IDisposable;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -7544,7 +7544,30 @@ public void M1() [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/994328")] public async Task TestDisposePatternWhenAdditionalUsingsAreIntroduced1() { - //CSharpFeaturesResources.DisposePattern +#if NET9_0_OR_GREATER + var extraUsing = """ + + using System.Diagnostics.CodeAnalysis; + """; + + var equalsMethod = """ + public bool Equals([AllowNull] int other) + { + throw new NotImplementedException(); + } + """; +#else + var extraUsing = ""; + + var equalsMethod = """ + public bool Equals(int other) + { + throw new NotImplementedException(); + } + """; +#endif + + //CSharpCodeFixesResources.DisposePattern await TestWithAllCodeStyleOptionsOffAsync( """ interface I : System.IDisposable, System.IEquatable where U : T @@ -7561,40 +7584,39 @@ partial class C : {|CS0535:{|CS0535:{|CS0535:I : System.IDisposable, System.IEquatable where U : T -{{ - System.Collections.Generic.List M(System.Collections.Generic.Dictionary> a, T b, U c); - System.Collections.Generic.List M(System.Collections.Generic.Dictionary> a, TT b, UU c) where UU : TT; -}} + $$""" + using System; + using System.Collections.Generic;{{extraUsing}} -partial class C -{{ -}} + interface I : System.IDisposable, System.IEquatable where U : T + { + System.Collections.Generic.List M(System.Collections.Generic.Dictionary> a, T b, U c); + System.Collections.Generic.List M(System.Collections.Generic.Dictionary> a, TT b, UU c) where UU : TT; + } -partial class C : I, System.IDisposable -{{ - private bool disposedValue; + partial class C + { + } - public bool Equals(int other) - {{ - throw new NotImplementedException(); - }} + partial class C : I, System.IDisposable + { + private bool disposedValue; + + {{equalsMethod}} - public List M(Dictionary> a, Exception b, AggregateException c) - {{ - throw new NotImplementedException(); - }} + public List M(Dictionary> a, Exception b, AggregateException c) + { + throw new NotImplementedException(); + } - public List M(Dictionary> a, TT b, UU c) where UU : TT - {{ - throw new NotImplementedException(); - }} + public List M(Dictionary> a, TT b, UU c) where UU : TT + { + throw new NotImplementedException(); + } -{DisposePattern("protected virtual ", "C", "public void ")} -}}", codeAction: ("False;False;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); + {{DisposePattern("protected virtual ", "C", "public void ")}} + } + """, codeAction: ("False;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 1)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/994328")] @@ -7616,40 +7638,42 @@ partial class C { } """, -$@"using System; -using System.Collections.Generic; + $$""" + using System; + using System.Collections.Generic; -interface I : System.IDisposable, System.IEquatable where U : T -{{ - System.Collections.Generic.List M(System.Collections.Generic.Dictionary> a, T b, U c); - System.Collections.Generic.List M(System.Collections.Generic.Dictionary> a, TT b, UU c) where UU : TT; -}} + interface I : System.IDisposable, System.IEquatable where U : T + { + System.Collections.Generic.List M(System.Collections.Generic.Dictionary> a, T b, U c); + System.Collections.Generic.List M(System.Collections.Generic.Dictionary> a, TT b, UU c) where UU : TT; + } -partial class C : I, System.IDisposable -{{ - private bool disposedValue; + partial class C : I, System.IDisposable + { + private bool disposedValue; - bool IEquatable.Equals(int other) - {{ - throw new NotImplementedException(); - }} + bool IEquatable.Equals(int other) + { + throw new NotImplementedException(); + } - List I.M(Dictionary> a, Exception b, AggregateException c) - {{ - throw new NotImplementedException(); - }} + List I.M(Dictionary> a, Exception b, AggregateException c) + { + throw new NotImplementedException(); + } - List I.M(Dictionary> a, TT b, UU c) - {{ - throw new NotImplementedException(); - }} + List I.M(Dictionary> a, TT b, UU c) + { + throw new NotImplementedException(); + } -{DisposePattern("protected virtual ", "C", "void IDisposable.")} -}} + {{DisposePattern("protected virtual ", "C", "void IDisposable.")}} + } -partial class C -{{ -}}", codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); + partial class C + { + } + """, codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceWithDisposePatternCodeAction;", 3)); } private static string DisposePattern( @@ -7659,34 +7683,36 @@ private static string DisposePattern( string disposeField = "disposedValue", string gcPrefix = "") { - return $@" {disposeVisibility}void Dispose(bool disposing) - {{ - if (!{disposeField}) - {{ - if (disposing) - {{ - // {FeaturesResources.TODO_colon_dispose_managed_state_managed_objects} - }} - - // {FeaturesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer} - // {FeaturesResources.TODO_colon_set_large_fields_to_null} - {disposeField} = true; - }} - }} + return $$""" + {{disposeVisibility}}void Dispose(bool disposing) + { + if (!{{disposeField}}) + { + if (disposing) + { + // {{CodeFixesResources.TODO_colon_dispose_managed_state_managed_objects}} + } - // // {string.Format(FeaturesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, "Dispose(bool disposing)")} - // ~{className}() - // {{ - // // {string.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(bool disposing)")} - // Dispose(disposing: false); - // }} + // {{CodeFixesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer}} + // {{CodeFixesResources.TODO_colon_set_large_fields_to_null}} + {{disposeField}} = true; + } + } - {implementationVisibility}Dispose() - {{ - // {string.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(bool disposing)")} - Dispose(disposing: true); - {gcPrefix}GC.SuppressFinalize(this); - }}"; + // // {{string.Format(CodeFixesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, "Dispose(bool disposing)")}} + // ~{{className}}() + // { + // // {{string.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(bool disposing)")}} + // Dispose(disposing: false); + // } + + {{implementationVisibility}}Dispose() + { + // {{string.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(bool disposing)")}} + Dispose(disposing: true); + {{gcPrefix}}GC.SuppressFinalize(this); + } + """; } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1132014")] @@ -7843,7 +7869,7 @@ IEnumerator IEnumerable.GetEnumerator() } } """, -codeAction: ("False;False;False:global::System.Collections.Generic.IList;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;innerList", 1)); +codeAction: ("False;False;False:global::System.Collections.Generic.IList;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;innerList", 1)); } [Fact, CompilerTrait(CompilerFeature.Tuples)] @@ -8476,7 +8502,7 @@ void IInterface.Method1() } """, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "True;False;False:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -8515,7 +8541,7 @@ abstract class Class : IInterface } """, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "False;True;True:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;True;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -8564,7 +8590,7 @@ public void Method1() MarkupHandling = MarkupMode.Allow, }, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "False;False;True:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", }.RunAsync(); } @@ -8618,7 +8644,7 @@ void IInterface.M1() Options = { AllOptionsOff }, DiagnosticSelector = diagnostics => diagnostics[1], CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne, - CodeActionEquivalenceKey = "True;False;False:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -8664,7 +8690,7 @@ abstract class Class : {|CS0535:{|CS0535:IInterface|}|} MarkupHandling = MarkupMode.Allow, }, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "False;True;True:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;True;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", }.RunAsync(); } @@ -8712,7 +8738,7 @@ public void Method1() MarkupHandling = MarkupMode.Allow, }, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "False;False;True:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", }.RunAsync(); } @@ -8777,7 +8803,7 @@ int IInterface.P2 MarkupHandling = MarkupMode.Allow, }, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "True;False;False:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -8823,7 +8849,7 @@ abstract class Class : {|CS0535:{|CS0535:IInterface|}|} MarkupHandling = MarkupMode.Allow, }, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "False;True;True:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;True;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", }.RunAsync(); } @@ -8904,7 +8930,7 @@ void IInterface.Method1() } """, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "True;False;False:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -8943,7 +8969,7 @@ abstract class Class : IInterface } """, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "False;True;True:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;True;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -9002,7 +9028,7 @@ public void Method1() Options = { AllOptionsOff }, // Specify the code action by equivalence key only to avoid trying to implement the interface explicitly with a second code fix pass. - CodeActionEquivalenceKey = "False;False;True:global::IInterface;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", }.RunAsync(); } @@ -9058,7 +9084,7 @@ void IInterface.Method1() MarkupHandling = MarkupMode.Allow, }, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "True;False;False:global::IInterface;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -9114,7 +9140,7 @@ abstract class Class : {|CS0535:{|CS0535:IInterface|}|} Options = { AllOptionsOff }, // Specify the code action by equivalence key only to avoid trying to execute a second code fix pass with a different action - CodeActionEquivalenceKey = "False;True;True:global::IInterface;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;True;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", }.RunAsync(); } @@ -9614,7 +9640,7 @@ public void Method1() Options = { AllOptionsOff }, // Specify the code action by equivalence key only to avoid trying to implement the interface explicitly with a second code fix pass. - CodeActionEquivalenceKey = "False;False;True:global::IInterface;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;False;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", }.RunAsync(); } @@ -9670,7 +9696,7 @@ void IInterface.Method1() MarkupHandling = MarkupMode.Allow, }, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "True;False;False:global::IInterface;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -9726,7 +9752,7 @@ abstract class Class : {|CS0535:{|CS0535:IInterface|}|} Options = { AllOptionsOff }, // Specify the code action by equivalence key only to avoid trying to execute a second code fix pass with a different action - CodeActionEquivalenceKey = "False;True;True:global::IInterface;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;True;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", }.RunAsync(); } @@ -9807,7 +9833,7 @@ void IInterface.Method1() } """, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "True;False;False:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -9846,7 +9872,7 @@ abstract class Class : IInterface } """, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "False;True;True:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;True;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -9936,7 +9962,7 @@ void IInterface.Method1() } """, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "True;False;False:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -9979,7 +10005,7 @@ abstract class Class : IInterface } """, Options = { AllOptionsOff }, - CodeActionEquivalenceKey = "False;True;True:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionEquivalenceKey = "False;True;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -10017,7 +10043,7 @@ public async Task TestWithNullableProperty() { await TestInRegularAndScriptAsync( """ - #nullable enable + #nullable enable public interface ITest { @@ -10028,7 +10054,7 @@ public class Test : {|CS0535:ITest|} } """, """ - #nullable enable + #nullable enable public interface ITest { @@ -10046,7 +10072,7 @@ public async Task TestWithNullablePropertyAlreadyImplemented() { var code = """ - #nullable enable + #nullable enable public interface ITest { @@ -10065,7 +10091,7 @@ public async Task TestWithNullableMethod() { await TestInRegularAndScriptAsync( """ - #nullable enable + #nullable enable public interface ITest { @@ -10076,7 +10102,7 @@ public class Test : {|CS0535:ITest|} } """, """ - #nullable enable + #nullable enable public interface ITest { @@ -10099,7 +10125,7 @@ public async Task TestWithNullableEvent() // see https://github.com/dotnet/roslyn/issues/36673 await TestInRegularAndScriptAsync( """ - #nullable enable + #nullable enable using System; @@ -10112,7 +10138,7 @@ public class Test : {|CS0535:ITest|} } """, """ - #nullable enable + #nullable enable using System; @@ -10132,7 +10158,7 @@ public async Task TestWithNullableDisabled() { await TestInRegularAndScriptAsync( """ - #nullable enable + #nullable enable public interface ITest { @@ -10146,7 +10172,7 @@ public class Test : {|CS0535:ITest|} } """, """ - #nullable enable + #nullable enable public interface ITest { @@ -10169,7 +10195,7 @@ public async Task GenericInterfaceNotNull1() { ReferenceAssemblies = ReferenceAssemblies.Net.Net50, TestCode = """ - #nullable enable + #nullable enable using System.Diagnostics.CodeAnalysis; @@ -10187,7 +10213,7 @@ class A : {|CS0535:{|CS0535:IFoo|}|} } """, FixedCode = """ - #nullable enable + #nullable enable using System.Diagnostics.CodeAnalysis; @@ -10289,7 +10315,7 @@ void I.M2() throw new System.NotImplementedException(); } } - """, codeAction: ("True;False;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2)); + """, codeAction: ("True;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2)); } [Fact] @@ -10415,7 +10441,7 @@ void I.M2() throw new System.NotImplementedException(); } } - """, codeAction: ("True;False;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/48295")] @@ -10859,7 +10885,7 @@ void I.M(T1? a, T2 b, T1? c, T3? d) throw new System.NotImplementedException(); } } - """, codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/53012")] @@ -10895,7 +10921,7 @@ void I.M(T1? a, T2 b, T1? c, T3? d) throw new System.NotImplementedException(); } } - """, codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); + """, codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1)); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/51779")] @@ -10975,8 +11001,8 @@ public static void M1() } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface, codeAction.Title), - CodeActionEquivalenceKey = "False;False;True:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface, codeAction.Title), + CodeActionEquivalenceKey = "False;False;True:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -11012,8 +11038,8 @@ static void ITest.M1() } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_all_members_explicitly, codeAction.Title), - CodeActionEquivalenceKey = "True;False;False:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_all_members_explicitly, codeAction.Title), + CodeActionEquivalenceKey = "True;False;False:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -11049,8 +11075,8 @@ public static void M1() } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface_abstractly, codeAction.Title), - CodeActionEquivalenceKey = "False;True;True:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface_abstractly, codeAction.Title), + CodeActionEquivalenceKey = "False;True;True:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -11084,8 +11110,8 @@ class C : ITest } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_all_members_explicitly, codeAction.Title), - CodeActionEquivalenceKey = "True;False;False:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_all_members_explicitly, codeAction.Title), + CodeActionEquivalenceKey = "True;False;False:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -11119,8 +11145,8 @@ class C : ITest } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_all_members_explicitly, codeAction.Title), - CodeActionEquivalenceKey = "True;False;False:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_all_members_explicitly, codeAction.Title), + CodeActionEquivalenceKey = "True;False;False:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -11161,8 +11187,8 @@ class C : ITest } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface, codeAction.Title), - CodeActionEquivalenceKey = "False;False;True:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface, codeAction.Title), + CodeActionEquivalenceKey = "False;False;True:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -11196,8 +11222,8 @@ class C : ITest } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface, codeAction.Title), - CodeActionEquivalenceKey = "False;False;True:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface, codeAction.Title), + CodeActionEquivalenceKey = "False;False;True:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -11231,8 +11257,8 @@ class C : ITest } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_all_members_explicitly, codeAction.Title), - CodeActionEquivalenceKey = "True;False;False:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_all_members_explicitly, codeAction.Title), + CodeActionEquivalenceKey = "True;False;False:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -11266,8 +11292,8 @@ abstract class C : ITest } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface_abstractly, codeAction.Title), - CodeActionEquivalenceKey = "False;True;True:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface_abstractly, codeAction.Title), + CodeActionEquivalenceKey = "False;True;True:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); @@ -11302,8 +11328,8 @@ static int ITest.M(ITest x) } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_all_members_explicitly, codeAction.Title), - CodeActionEquivalenceKey = "True;False;False:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_all_members_explicitly, codeAction.Title), + CodeActionEquivalenceKey = "True;False;False:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); @@ -11338,8 +11364,8 @@ public static int M(ITest x) } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface, codeAction.Title), - CodeActionEquivalenceKey = "False;False;True:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface, codeAction.Title), + CodeActionEquivalenceKey = "False;False;True:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); @@ -11374,8 +11400,8 @@ public static int M(C x) } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface, codeAction.Title), - CodeActionEquivalenceKey = "False;False;True:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface, codeAction.Title), + CodeActionEquivalenceKey = "False;False;True:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); @@ -11410,8 +11436,8 @@ static int ITest.M(C x) } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_all_members_explicitly, codeAction.Title), - CodeActionEquivalenceKey = "True;False;False:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_all_members_explicitly, codeAction.Title), + CodeActionEquivalenceKey = "True;False;False:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); @@ -11446,8 +11472,8 @@ public static int M(C x) } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface_abstractly, codeAction.Title), - CodeActionEquivalenceKey = "False;True;True:global::ITest;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface_abstractly, codeAction.Title), + CodeActionEquivalenceKey = "False;True;True:global::ITest;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); @@ -11523,8 +11549,8 @@ public static explicit operator string(C3 x) } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_all_members_explicitly, codeAction.Title), - CodeActionEquivalenceKey = "True;False;False:global::I1;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_all_members_explicitly, codeAction.Title), + CodeActionEquivalenceKey = "True;False;False:global::I1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -11599,8 +11625,8 @@ public static explicit operator string(C3 x) } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface, codeAction.Title), - CodeActionEquivalenceKey = "False;False;True:global::I1;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface, codeAction.Title), + CodeActionEquivalenceKey = "False;False;True:global::I1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 0, }.RunAsync(); } @@ -11675,8 +11701,8 @@ public static explicit operator string(C3 x) } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_interface_abstractly, codeAction.Title), - CodeActionEquivalenceKey = "False;True;True:global::I1;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_interface_abstractly, codeAction.Title), + CodeActionEquivalenceKey = "False;True;True:global::I1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", CodeActionIndex = 1, }.RunAsync(); } @@ -11817,7 +11843,7 @@ static void I.M() } } """, - CodeActionVerifier = (codeAction, verifier) => verifier.Equal(FeaturesResources.Implement_all_members_explicitly, codeAction.Title), + CodeActionVerifier = (codeAction, verifier) => verifier.Equal(CodeFixesResources.Implement_all_members_explicitly, codeAction.Title), }.RunAsync(); } diff --git a/src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests_FixAllTests.cs new file mode 100644 index 0000000000000..ede09df35995f --- /dev/null +++ b/src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests_FixAllTests.cs @@ -0,0 +1,696 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CSharp.ImplementInterface; +using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; +using Microsoft.CodeAnalysis.Test.Utilities; +using Microsoft.CodeAnalysis.Testing; +using Xunit; + +namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ImplementInterface; + +using VerifyCS = CSharpCodeFixVerifier< + EmptyDiagnosticAnalyzer, + CSharpImplementInterfaceCodeFixProvider>; + +public class ImplementInterfaceTests_FixAllTests +{ + #region "Fix all occurrences tests" + + [Fact] + [Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)] + [Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)] + public async Task TestFixAllInDocument() + { + await new VerifyCS.Test + { + TestState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C1 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + AdditionalProjects = + { + ["Assembly1"] = + { + Sources = + { + """ + class B3 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C3 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + AdditionalProjectReferences = { "TestProject" }, + }, + }, + }, + FixedState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : I1, I2 + { + public void F1() + { + throw new System.NotImplementedException(); + } + + class C1 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + MarkupHandling = MarkupMode.Allow, + }, + BatchFixedState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : I1, I2 + { + public void F1() + { + throw new System.NotImplementedException(); + } + + class C1 : I1, I2 + { + public void F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + MarkupHandling = MarkupMode.Allow, + }, + CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne | CodeFixTestBehaviors.SkipFixAllInProjectCheck | CodeFixTestBehaviors.SkipFixAllInSolutionCheck, + CodeActionEquivalenceKey = "False;False;True:global::I1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionIndex = 0, + }.RunAsync(); + } + + [Fact] + [Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)] + [Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)] + public async Task TestFixAllInProject() + { + await new VerifyCS.Test + { + TestState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C1 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + AdditionalProjects = + { + ["Assembly1"] = + { + Sources = + { + """ + class B3 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C3 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + AdditionalProjectReferences = { "TestProject" }, + }, + }, + }, + FixedState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : I1, I2 + { + public void F1() + { + throw new System.NotImplementedException(); + } + + class C1 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + MarkupHandling = MarkupMode.Allow, + }, + BatchFixedState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : I1, I2 + { + public void F1() + { + throw new System.NotImplementedException(); + } + + class C1 : I1, I2 + { + public void F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + """ + class B2 : I1, I2 + { + public void F1() + { + throw new System.NotImplementedException(); + } + + class C2 : I1, I2 + { + public void F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + }, + MarkupHandling = MarkupMode.Allow, + }, + CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne | CodeFixTestBehaviors.SkipFixAllInDocumentCheck | CodeFixTestBehaviors.SkipFixAllInSolutionCheck, + CodeActionEquivalenceKey = "False;False;True:global::I1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionIndex = 0, + }.RunAsync(); + } + + [Fact] + [Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)] + [Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)] + public async Task TestFixAllInSolution() + { + await new VerifyCS.Test + { + TestState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C1 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + AdditionalProjects = + { + ["Assembly1"] = + { + Sources = + { + """ + class B3 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C3 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + AdditionalProjectReferences = { "TestProject" }, + }, + }, + }, + FixedState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + + class C1 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + MarkupHandling = MarkupMode.Allow, + }, + BatchFixedState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + + class C1 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + """ + class B2 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + + class C2 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + }, + AdditionalProjects = + { + ["Assembly1"] = + { + Sources = + { + """ + class B3 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + + class C3 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + }, + AdditionalProjectReferences = { "TestProject" }, + }, + }, + MarkupHandling = MarkupMode.Allow, + }, + CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne | CodeFixTestBehaviors.SkipFixAllInDocumentCheck | CodeFixTestBehaviors.SkipFixAllInProjectCheck, + DiagnosticSelector = diagnostics => diagnostics[1], + CodeActionEquivalenceKey = "True;False;False:global::I2;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionIndex = 1, + }.RunAsync(); + } + + [Fact] + [Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)] + [Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)] + public async Task TestFixAllInSolution_DifferentAssemblyWithSameTypeName() + { + await new VerifyCS.Test + { + TestState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C1 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + AdditionalProjects = + { + ["Assembly1"] = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B3 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C3 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + }, + }, + }, + FixedState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + + class C1 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + """ + class B2 : {|CS0535:I1|}, {|CS0535:I2|} + { + class C2 : {|CS0535:I1|}, {|CS0535:I2|} + { + } + } + """, + }, + MarkupHandling = MarkupMode.Allow, + }, + BatchFixedState = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B1 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + + class C1 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + """ + class B2 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + + class C2 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + }, + MarkupHandling = MarkupMode.Allow, + AdditionalProjects = + { + ["Assembly1"] = + { + Sources = + { + """ + public interface I1 + { + void F1(); + } + + public interface I2 + { + void F1(); + } + + class B3 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + + class C3 : {|CS0535:I1|}, I2 + { + void I2.F1() + { + throw new System.NotImplementedException(); + } + } + } + """, + }, + }, + }, + }, + CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne | CodeFixTestBehaviors.SkipFixAllInDocumentCheck | CodeFixTestBehaviors.SkipFixAllInProjectCheck, + DiagnosticSelector = diagnostics => diagnostics[1], + CodeActionEquivalenceKey = "True;False;False:global::I2;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", + CodeActionIndex = 1, + }.RunAsync(); + } + + #endregion +} diff --git a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems index 109666fd2b682..82719fc7b956a 100644 --- a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems +++ b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems @@ -10,7 +10,9 @@ - + + Designer + @@ -46,8 +48,17 @@ + + + + + + + + + @@ -61,6 +72,8 @@ + + diff --git a/src/Analyzers/Core/CodeFixes/CodeFixesResources.resx b/src/Analyzers/Core/CodeFixes/CodeFixesResources.resx index 3ab3d032de3b5..0583ac1ce8eaa 100644 --- a/src/Analyzers/Core/CodeFixes/CodeFixesResources.resx +++ b/src/Analyzers/Core/CodeFixes/CodeFixesResources.resx @@ -231,4 +231,40 @@ Generate field assigning constructor '{0}({1})' + + Implement interface abstractly + + + Implement interface through '{0}' + + + Implement interface with Dispose pattern + + + Implement interface explicitly with Dispose pattern + + + Implement remaining members explicitly + + + Implement interface + + + Implement all members explicitly + + + TODO: dispose managed state (managed objects) + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + TODO: set large fields to null + + + Do not change this code. Put cleanup code in '{0}' method + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + \ No newline at end of file diff --git a/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceCodeFixProvider.cs similarity index 92% rename from src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceCodeFixProvider.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceCodeFixProvider.cs index 8a0f328e31f6f..b78a2f7910461 100644 --- a/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceCodeFixProvider.cs +++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceCodeFixProvider.cs @@ -75,26 +75,26 @@ private static string GetTitle(ImplementInterfaceConfiguration options) if (options.ImplementDisposePattern) { return options.Explicitly - ? FeaturesResources.Implement_interface_explicitly_with_Dispose_pattern - : FeaturesResources.Implement_interface_with_Dispose_pattern; + ? CodeFixesResources.Implement_interface_explicitly_with_Dispose_pattern + : CodeFixesResources.Implement_interface_with_Dispose_pattern; } else if (options.Explicitly) { return options.OnlyRemaining - ? FeaturesResources.Implement_remaining_members_explicitly - : FeaturesResources.Implement_all_members_explicitly; + ? CodeFixesResources.Implement_remaining_members_explicitly + : CodeFixesResources.Implement_all_members_explicitly; } else if (options.Abstractly) { - return FeaturesResources.Implement_interface_abstractly; + return CodeFixesResources.Implement_interface_abstractly; } else if (options.ThroughMember != null) { - return string.Format(FeaturesResources.Implement_interface_through_0, options.ThroughMember.Name); + return string.Format(CodeFixesResources.Implement_interface_through_0, options.ThroughMember.Name); } else { - return FeaturesResources.Implement_interface; + return CodeFixesResources.Implement_interface; } } @@ -104,7 +104,6 @@ private static string GetEquivalenceKey( { var interfaceType = state.InterfaceTypes.First(); var typeName = interfaceType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - var assemblyName = interfaceType.ContainingAssembly.Name; // Legacy part of the equivalence key. Kept the same to avoid test churn. var codeActionTypeName = options.ImplementDisposePattern @@ -118,7 +117,6 @@ private static string GetEquivalenceKey( options.Abstractly.ToString() + ";" + options.OnlyRemaining.ToString() + ":" + typeName + ";" + - assemblyName + ";" + codeActionTypeName + ";" + options.ThroughMember?.Name; } diff --git a/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.State.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceService.State.cs similarity index 95% rename from src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.State.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceService.State.cs index feb8d03fedd17..d718a23ebd75d 100644 --- a/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.State.cs +++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceService.State.cs @@ -47,7 +47,8 @@ internal sealed class State( return null; } - if (!CodeGenerator.CanAdd(document.Project.Solution, classOrStructType, cancellationToken)) + var generator = document.GetRequiredLanguageService(); + if (!generator.CanAddTo(classOrStructType, document.Project.Solution, cancellationToken)) { return null; } diff --git a/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceService.cs similarity index 81% rename from src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceService.cs index f207a6b07155d..36a3cf68a3aec 100644 --- a/src/Features/Core/Portable/ImplementInterface/AbstractImplementInterfaceService.cs +++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/AbstractImplementInterfaceService.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editing; +using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.ImplementType; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.PooledObjects; @@ -19,6 +20,9 @@ internal abstract partial class AbstractImplementInterfaceService() : IImplement { protected const string DisposingName = "disposing"; + protected abstract ISyntaxFormatting SyntaxFormatting { get; } + protected abstract SyntaxGeneratorInternal SyntaxGeneratorInternal { get; } + protected abstract string ToDisplayString(IMethodSymbol disposeImplMethod, SymbolDisplayFormat format); protected abstract bool CanImplementImplicitly { get; } @@ -56,23 +60,24 @@ public async Task ImplementInterfaceAsync( return State.Generate(this, document, model, interfaceType, cancellationToken); } - protected static TNode AddComment(SyntaxGenerator g, string comment, TNode node) where TNode : SyntaxNode - => AddComments(g, [comment], node); + protected TNode AddComment(string comment, TNode node) where TNode : SyntaxNode + => AddComments([comment], node); - protected static TNode AddComments(SyntaxGenerator g, string comment1, string comment2, TNode node) where TNode : SyntaxNode - => AddComments(g, [comment1, comment2], node); + protected TNode AddComments(string comment1, string comment2, TNode node) where TNode : SyntaxNode + => AddComments([comment1, comment2], node); - protected static TNode AddComments(SyntaxGenerator g, string[] comments, TNode node) where TNode : SyntaxNode - => node.WithPrependedLeadingTrivia(CreateCommentTrivia(g, comments)); + protected TNode AddComments(string[] comments, TNode node) where TNode : SyntaxNode + => node.WithPrependedLeadingTrivia(CreateCommentTrivia(comments)); - protected static SyntaxTriviaList CreateCommentTrivia(SyntaxGenerator generator, params string[] comments) + protected SyntaxTriviaList CreateCommentTrivia( + params string[] comments) { using var _ = ArrayBuilder.GetInstance(out var trivia); foreach (var comment in comments) { - trivia.Add(generator.SingleLineComment(" " + comment)); - trivia.Add(generator.ElasticCarriageReturnLineFeed); + trivia.Add(this.SyntaxGeneratorInternal.SingleLineComment(" " + comment)); + trivia.Add(this.SyntaxGeneratorInternal.ElasticCarriageReturnLineFeed); } return new SyntaxTriviaList(trivia); diff --git a/src/Features/Core/Portable/ImplementInterface/IImplementInterfaceService.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/IImplementInterfaceService.cs similarity index 100% rename from src/Features/Core/Portable/ImplementInterface/IImplementInterfaceService.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/IImplementInterfaceService.cs diff --git a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator.cs similarity index 98% rename from src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator.cs index cba9623a8a64d..6176d02f16af8 100644 --- a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator.cs +++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator.cs @@ -18,6 +18,12 @@ using Microsoft.CodeAnalysis.Shared.Utilities; using Roslyn.Utilities; +#if CODE_STYLE +using DeclarationModifiers = Microsoft.CodeAnalysis.Internal.Editing.DeclarationModifiers; +#else +using DeclarationModifiers = Microsoft.CodeAnalysis.Editing.DeclarationModifiers; +#endif + namespace Microsoft.CodeAnalysis.ImplementInterface; using static ImplementHelpers; @@ -85,7 +91,8 @@ private async Task ImplementInterfaceAsync( var groupMembers = !isComImport && Options.InsertionBehavior == ImplementTypeInsertionBehavior.WithOtherMembersOfTheSameKind; - return await CodeGenerator.AddMemberDeclarationsAsync( + var generator = this.Document.GetRequiredLanguageService(); + return await generator.AddMembersAsync( new CodeGenerationSolutionContext( this.Document.Project.Solution, new CodeGenerationContext( diff --git a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Conflicts.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Conflicts.cs similarity index 94% rename from src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Conflicts.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Conflicts.cs index e64a3ec8df477..157a8ff24dacc 100644 --- a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Conflicts.cs +++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Conflicts.cs @@ -9,6 +9,12 @@ using Microsoft.CodeAnalysis.Shared.Utilities; using Roslyn.Utilities; +#if CODE_STYLE +using DeclarationModifiers = Microsoft.CodeAnalysis.Internal.Editing.DeclarationModifiers; +#else +using DeclarationModifiers = Microsoft.CodeAnalysis.Editing.DeclarationModifiers; +#endif + namespace Microsoft.CodeAnalysis.ImplementInterface; internal abstract partial class AbstractImplementInterfaceService diff --git a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_DisposePattern.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_DisposePattern.cs similarity index 86% rename from src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_DisposePattern.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_DisposePattern.cs index b8158f89e8f2e..7d5f3c86763dd 100644 --- a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_DisposePattern.cs +++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_DisposePattern.cs @@ -18,6 +18,12 @@ using Microsoft.CodeAnalysis.Shared.Utilities; using Roslyn.Utilities; +#if CODE_STYLE +using DeclarationModifiers = Microsoft.CodeAnalysis.Internal.Editing.DeclarationModifiers; +#else +using DeclarationModifiers = Microsoft.CodeAnalysis.Editing.DeclarationModifiers; +#endif + namespace Microsoft.CodeAnalysis.ImplementInterface; using static ImplementHelpers; @@ -44,7 +50,7 @@ private async Task ImplementDisposePatternAsync( var compilation = await document.Project.GetRequiredCompilationAsync(cancellationToken).ConfigureAwait(false); var disposedValueField = await CreateDisposedValueFieldAsync( - document, State.ClassOrStructType, cancellationToken).ConfigureAwait(false); + document, this.Service.SyntaxFormatting, State.ClassOrStructType, cancellationToken).ConfigureAwait(false); var disposeMethod = TryGetIDisposableDispose(compilation)!; var (disposableMethods, finalizer) = CreateDisposableMethods(compilation, disposeMethod, disposedValueField); @@ -85,7 +91,7 @@ private async Task ImplementDisposePatternAsync( return await AddFinalizerCommentAsync(docWithAllMembers, finalizer, cancellationToken).ConfigureAwait(false); } - private static async Task AddFinalizerCommentAsync( + private async Task AddFinalizerCommentAsync( Document document, SyntaxNode finalizer, CancellationToken cancellationToken) { var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); @@ -98,11 +104,11 @@ private static async Task AddFinalizerCommentAsync( var finalizerLines = finalizer.ToFullString().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); var generator = document.GetRequiredLanguageService(); - var finalizerComments = CreateCommentTrivia(generator, finalizerLines); + var finalizerComments = this.Service.CreateCommentTrivia(finalizerLines); var lastMemberWithComments = lastGeneratedMember.WithPrependedLeadingTrivia( - finalizerComments.Insert(0, generator.CarriageReturnLineFeed) - .Add(generator.CarriageReturnLineFeed)); + finalizerComments.Insert(0, this.Service.SyntaxGeneratorInternal.CarriageReturnLineFeed) + .Add(this.Service.SyntaxGeneratorInternal.CarriageReturnLineFeed)); var finalRoot = root.ReplaceNode(lastGeneratedMember, lastMemberWithComments); return document.WithSyntaxRoot(finalRoot); @@ -140,6 +146,7 @@ private IMethodSymbol CreateDisposeImplementationMethod( : DeclarationModifiers.Virtual; var g = this.Document.GetRequiredLanguageService(); + var gi = this.Service.SyntaxGeneratorInternal; // if (disposing) // { @@ -148,15 +155,15 @@ private IMethodSymbol CreateDisposeImplementationMethod( var ifDisposingStatement = g.IfStatement(g.IdentifierName(DisposingName), []); ifDisposingStatement = Service.AddCommentInsideIfStatement( ifDisposingStatement, - CreateCommentTrivia(g, FeaturesResources.TODO_colon_dispose_managed_state_managed_objects)) - .WithoutTrivia().WithTrailingTrivia(g.CarriageReturnLineFeed, g.CarriageReturnLineFeed); + this.Service.CreateCommentTrivia(CodeFixesResources.TODO_colon_dispose_managed_state_managed_objects)) + .WithoutTrivia().WithTrailingTrivia(gi.CarriageReturnLineFeed, gi.CarriageReturnLineFeed); // TODO: free unmanaged ... // TODO: set large fields... // disposedValue = true - var disposedValueEqualsTrueStatement = AddComments(g, - FeaturesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer, - FeaturesResources.TODO_colon_set_large_fields_to_null, + var disposedValueEqualsTrueStatement = this.Service.AddComments( + CodeFixesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer, + CodeFixesResources.TODO_colon_set_large_fields_to_null, g.AssignmentStatement( g.IdentifierName(disposedValueField.Name), g.TrueLiteralExpression())); @@ -170,10 +177,9 @@ private IMethodSymbol CreateDisposeImplementationMethod( accessibility: accessibility, modifiers: modifiers, name: disposeMethod.Name, - parameters: ImmutableArray.Create( - CodeGenerationSymbolFactory.CreateParameterSymbol( - compilation.GetSpecialType(SpecialType.System_Boolean), - DisposingName)), + parameters: [CodeGenerationSymbolFactory.CreateParameterSymbol( + compilation.GetSpecialType(SpecialType.System_Boolean), + DisposingName)], statements: [ifStatement]); } @@ -189,8 +195,8 @@ private IMethodSymbol CreateDisposeInterfaceMethod( // // Do not change... // Dispose(true); - statements.Add(AddComment(g, - string.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString), + statements.Add(this.Service.AddComment( + string.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString), g.ExpressionStatement( g.InvocationExpression( g.IdentifierName(nameof(IDisposable.Dispose)), @@ -226,13 +232,14 @@ private IMethodSymbol CreateDisposeInterfaceMethod( private static async Task CreateDisposedValueFieldAsync( Document document, + ISyntaxFormatting syntaxFormatting, INamedTypeSymbol containingType, CancellationToken cancellationToken) { var rule = await document.GetApplicableNamingRuleAsync( SymbolKind.Field, Accessibility.Private, cancellationToken).ConfigureAwait(false); - var options = await document.GetSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false); + var options = await document.GetSyntaxFormattingOptionsAsync(syntaxFormatting, cancellationToken).ConfigureAwait(false); var compilation = await document.Project.GetRequiredCompilationAsync(cancellationToken).ConfigureAwait(false); var boolType = compilation.GetSpecialType(SpecialType.System_Boolean); var accessibilityLevel = options.AccessibilityModifiersRequired is AccessibilityModifiersRequired.Never or AccessibilityModifiersRequired.OmitIfDefault diff --git a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Method.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Method.cs similarity index 91% rename from src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Method.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Method.cs index 7cca6268057b1..6c41d141632f7 100644 --- a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Method.cs +++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Method.cs @@ -7,6 +7,12 @@ using Microsoft.CodeAnalysis.LanguageService; using Microsoft.CodeAnalysis.Shared.Extensions; +#if CODE_STYLE +using DeclarationModifiers = Microsoft.CodeAnalysis.Internal.Editing.DeclarationModifiers; +#else +using DeclarationModifiers = Microsoft.CodeAnalysis.Editing.DeclarationModifiers; +#endif + namespace Microsoft.CodeAnalysis.ImplementInterface; internal abstract partial class AbstractImplementInterfaceService diff --git a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Property.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Property.cs similarity index 96% rename from src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Property.cs rename to src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Property.cs index 48e915de06709..eb20761ff1eda 100644 --- a/src/Features/Core/Portable/ImplementInterface/ImplementInterfaceGenerator_Property.cs +++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Property.cs @@ -13,6 +13,12 @@ using Microsoft.CodeAnalysis.Shared.Utilities; using Roslyn.Utilities; +#if CODE_STYLE +using DeclarationModifiers = Microsoft.CodeAnalysis.Internal.Editing.DeclarationModifiers; +#else +using DeclarationModifiers = Microsoft.CodeAnalysis.Editing.DeclarationModifiers; +#endif + namespace Microsoft.CodeAnalysis.ImplementInterface; internal abstract partial class AbstractImplementInterfaceService @@ -164,7 +170,7 @@ private ImmutableArray GetGetAccessorStatements( if (generateAbstractly) return default; - var generator = Document.Project.Services.GetRequiredService(); + var generator = Document.GetRequiredLanguageService(); return generator.GetGetAccessorStatements(compilation, property, ThroughMember, propertyGenerationBehavior == ImplementTypePropertyGenerationBehavior.PreferAutoProperties); } diff --git a/src/Features/Core/Portable/Shared/Naming/FallbackNamingRules.cs b/src/Analyzers/Core/CodeFixes/Naming/FallbackNamingRules.cs similarity index 100% rename from src/Features/Core/Portable/Shared/Naming/FallbackNamingRules.cs rename to src/Analyzers/Core/CodeFixes/Naming/FallbackNamingRules.cs diff --git a/src/Analyzers/Core/CodeFixes/Naming/NamingExtensions.cs b/src/Analyzers/Core/CodeFixes/Naming/NamingExtensions.cs new file mode 100644 index 0000000000000..27105cf108b7c --- /dev/null +++ b/src/Analyzers/Core/CodeFixes/Naming/NamingExtensions.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Immutable; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CodeStyle; +using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles; +using Microsoft.CodeAnalysis.Shared.Naming; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis.Shared.Extensions; + +internal static class NamingExtensions +{ + public static async Task GetApplicableNamingRuleAsync( + this Document document, SymbolKind symbolKind, Accessibility accessibility, CancellationToken cancellationToken) + { + var rules = await document.GetNamingRulesAsync(cancellationToken).ConfigureAwait(false); + foreach (var rule in rules) + { + if (rule.SymbolSpecification.AppliesTo(symbolKind, accessibility)) + return rule; + } + + throw ExceptionUtilities.Unreachable(); + } + + /// + /// Gets the set of naming rules the user has set for this document. Will include a set of default naming rules + /// that match if the user hasn't specified any for a particular symbol type. The are added at the end so they + /// will only be used if the user hasn't specified a preference. + /// + public static async Task> GetNamingRulesAsync( + this Document document, CancellationToken cancellationToken) + { + var options = await document.GetNamingStylePreferencesAsync(cancellationToken).ConfigureAwait(false); + return options.CreateRules().NamingRules.AddRange(FallbackNamingRules.Default); + } +} diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.cs.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.cs.xlf index 95a04884af47a..244bb7c3abf45 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.cs.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.cs.xlf @@ -19,7 +19,7 @@ Add explicit cast - Přidat explicitní přetypování + Přidat explicitní přetypování @@ -62,6 +62,11 @@ Převést typ na {0} + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Opravit všechny výskyty v @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Nastavit třídu jako abstract @@ -152,6 +192,26 @@ Potlačit nebo konfigurovat problémy + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' Vzít {0} diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.de.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.de.xlf index f0b33f987336b..9c4bdbc60cf79 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.de.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.de.xlf @@ -19,7 +19,7 @@ Add explicit cast - Explizite Umwandlung hinzufügen + Explizite Umwandlung hinzufügen @@ -62,6 +62,11 @@ Typ in "{0}" konvertieren + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Alle Vorkommen korrigieren in @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Klasse als "abstract" festlegen @@ -152,6 +192,26 @@ Issues unterdrücken oder konfigurieren + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' "{0}" übernehmen diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.es.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.es.xlf index ec92e56b1c942..91536cdff9df8 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.es.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.es.xlf @@ -19,7 +19,7 @@ Add explicit cast - Agregar conversión explícita + Agregar conversión explícita @@ -62,6 +62,11 @@ Convertir tipo en "{0}" + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Corregir todas las repeticiones de @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Convertir la clase en "abstract" @@ -152,6 +192,26 @@ Suprimir o configurar incidencias + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' Tomar "{0}" diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.fr.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.fr.xlf index b5d577106ba74..0eaa688716400 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.fr.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.fr.xlf @@ -19,7 +19,7 @@ Add explicit cast - Ajouter un cast explicite + Ajouter un cast explicite @@ -62,6 +62,11 @@ Convertir le type en '{0}' + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Corriger toutes les occurrences dans @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Rendre la classe 'abstract' @@ -152,6 +192,26 @@ Supprimer ou configurer des problèmes + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' Prendre '{0}' diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.it.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.it.xlf index f0aa3f33e7c6f..62b2de323d303 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.it.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.it.xlf @@ -19,7 +19,7 @@ Add explicit cast - Aggiungi cast esplicito + Aggiungi cast esplicito @@ -62,6 +62,11 @@ Converti il tipo in '{0}' + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Correggi tutte le occorrenze in @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Rendi la classe 'abstract' @@ -152,6 +192,26 @@ Elimina o configura i problemi + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' Accetta '{0}' diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ja.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ja.xlf index 0e1a4b2c92881..bd09e0417ed4e 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ja.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ja.xlf @@ -19,7 +19,7 @@ Add explicit cast - 明示的なキャストの追加 + 明示的なキャストの追加 @@ -62,6 +62,11 @@ 型を '{0}' に変換 + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in 次の場所のすべての出現箇所を修正します @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' クラスを 'abstract' にしてください @@ -152,6 +192,26 @@ 問題の抑制または構成 + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' '{0}' を取る diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ko.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ko.xlf index bb050c3d64c9a..ce339eb4bb48b 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ko.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ko.xlf @@ -19,7 +19,7 @@ Add explicit cast - 명시적 캐스트 추가 + 명시적 캐스트 추가 @@ -62,6 +62,11 @@ 형식을 '{0}'(으)로 변환 + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in 다음 위치에서 모든 발생 수정 @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' 'abstract' 클래스 만들기 @@ -152,6 +192,26 @@ 문제 표시 안 함 또는 구성 + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' '{0}' 사용 diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pl.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pl.xlf index 84dc4d85d3cc9..8cabbbcd04e1c 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pl.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pl.xlf @@ -19,7 +19,7 @@ Add explicit cast - Dodaj rzutowanie jawne + Dodaj rzutowanie jawne @@ -62,6 +62,11 @@ Konwertuj typ na „{0}” + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Popraw wszystkie wystąpienia w @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Ustaw specyfikator „abstract” dla klasy @@ -152,6 +192,26 @@ Problemy z pomijaniem lub konfigurowaniem + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' Przyjmij „{0}” diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pt-BR.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pt-BR.xlf index 73e83053bbb0a..1ba6afe712798 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pt-BR.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.pt-BR.xlf @@ -19,7 +19,7 @@ Add explicit cast - Adicionar conversão explícita + Adicionar conversão explícita @@ -62,6 +62,11 @@ Converter o tipo em '{0}' + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Corrigir todas as ocorrências em @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Tornar a classe 'abstract' @@ -152,6 +192,26 @@ Suprimir ou configurar problemas + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' Obter '{0}' diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ru.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ru.xlf index ebde1902155b5..e79843df0f768 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ru.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.ru.xlf @@ -19,7 +19,7 @@ Add explicit cast - Добавить явное приведение + Добавить явное приведение @@ -62,6 +62,11 @@ Преобразовать тип в "{0}" + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Исправить все случаи в @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Сделать класс абстрактным @@ -152,6 +192,26 @@ Подавление проблем или настройка уровня их серьезности + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' Принимать "{0}" diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.tr.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.tr.xlf index 1f8d9b5325710..b5384be02a46e 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.tr.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.tr.xlf @@ -19,7 +19,7 @@ Add explicit cast - Açık tür dönüştürme ekle + Açık tür dönüştürme ekle @@ -62,6 +62,11 @@ Türü '{0}' olarak dönüştür + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in Tüm oluşumları şurada düzelt: @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' Sınıfı 'abstract' yap @@ -152,6 +192,26 @@ Sorunları gizle veya yapılandır + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' '{0}' al diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hans.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hans.xlf index ae3ca5661cabc..263a2f9788fde 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hans.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hans.xlf @@ -19,7 +19,7 @@ Add explicit cast - 添加显式转换 + 添加显式转换 @@ -62,6 +62,11 @@ 将类型转换为“{0}” + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in 修复以下对象中的所有实例: @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' 将类设置为 "abstract" @@ -152,6 +192,26 @@ 抑制或配置方面的问题 + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' 采用“{0}” diff --git a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hant.xlf b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hant.xlf index c6e046ccc0369..3f452fc1faae9 100644 --- a/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hant.xlf +++ b/src/Analyzers/Core/CodeFixes/xlf/CodeFixesResources.zh-Hant.xlf @@ -19,7 +19,7 @@ Add explicit cast - 新增明確轉換 + 新增明確轉換 @@ -62,6 +62,11 @@ 將類型轉換為 '{0}' + + Do not change this code. Put cleanup code in '{0}' method + Do not change this code. Put cleanup code in '{0}' method + + Fix all occurrences in 修正所有出現之處於 @@ -102,6 +107,41 @@ Generate field assigning constructor '{0}({1})' + + Implement all members explicitly + Implement all members explicitly + + + + Implement interface + Implement interface + + + + Implement interface abstractly + Implement interface abstractly + + + + Implement interface explicitly with Dispose pattern + Implement interface explicitly with Dispose pattern + + + + Implement interface through '{0}' + Implement interface through '{0}' + + + + Implement interface with Dispose pattern + Implement interface with Dispose pattern + + + + Implement remaining members explicitly + Implement remaining members explicitly + + Make class 'abstract' 將類別設為 'abstract' @@ -152,6 +192,26 @@ 抑制或設定問題 + + TODO: dispose managed state (managed objects) + TODO: dispose managed state (managed objects) + + + + TODO: free unmanaged resources (unmanaged objects) and override finalizer + TODO: free unmanaged resources (unmanaged objects) and override finalizer + + + + TODO: override finalizer only if '{0}' has code to free unmanaged resources + TODO: override finalizer only if '{0}' has code to free unmanaged resources + + + + TODO: set large fields to null + TODO: set large fields to null + + Take '{0}' 接受 '{0}' diff --git a/src/Features/VisualBasic/Portable/ImplementInterface/VisualBasicImplementInterfaceCodeFixProvider.vb b/src/Analyzers/VisualBasic/CodeFixes/ImplementInterface/VisualBasicImplementInterfaceCodeFixProvider.vb similarity index 100% rename from src/Features/VisualBasic/Portable/ImplementInterface/VisualBasicImplementInterfaceCodeFixProvider.vb rename to src/Analyzers/VisualBasic/CodeFixes/ImplementInterface/VisualBasicImplementInterfaceCodeFixProvider.vb diff --git a/src/Features/VisualBasic/Portable/ImplementInterface/VisualBasicImplementInterfaceService.vb b/src/Analyzers/VisualBasic/CodeFixes/ImplementInterface/VisualBasicImplementInterfaceService.vb similarity index 88% rename from src/Features/VisualBasic/Portable/ImplementInterface/VisualBasicImplementInterfaceService.vb rename to src/Analyzers/VisualBasic/CodeFixes/ImplementInterface/VisualBasicImplementInterfaceService.vb index ebbf799aca6a0..161a9857bd4db 100644 --- a/src/Features/VisualBasic/Portable/ImplementInterface/VisualBasicImplementInterfaceService.vb +++ b/src/Analyzers/VisualBasic/CodeFixes/ImplementInterface/VisualBasicImplementInterfaceService.vb @@ -7,8 +7,11 @@ Imports System.Composition Imports System.Threading Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Editing +Imports Microsoft.CodeAnalysis.Formatting Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.ImplementInterface +Imports Microsoft.CodeAnalysis.VisualBasic.CodeGeneration +Imports Microsoft.CodeAnalysis.VisualBasic.Formatting Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.ImplementInterface @@ -21,6 +24,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ImplementInterface Public Sub New() End Sub + Protected Overrides ReadOnly Property SyntaxFormatting As ISyntaxFormatting = VisualBasicSyntaxFormatting.Instance + + Protected Overrides ReadOnly Property SyntaxGeneratorInternal As SyntaxGeneratorInternal = VisualBasicSyntaxGeneratorInternal.Instance + Protected Overrides Function ToDisplayString(disposeImplMethod As IMethodSymbol, format As SymbolDisplayFormat) As String Return SymbolDisplay.ToDisplayString(disposeImplMethod, format) End Function @@ -104,8 +111,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ImplementInterface ' ' Do not change this code... ' Dispose(False) - Dim disposeStatement = AddComment(g, - String.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString), + Dim disposeStatement = AddComment( + String.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString), g.ExpressionStatement(g.InvocationExpression( g.IdentifierName(NameOf(IDisposable.Dispose)), g.Argument(DisposingName, RefKind.None, g.FalseLiteralExpression())))) @@ -121,8 +128,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ImplementInterface modifiers:=DeclarationModifiers.Override, statements:={disposeStatement, finalizeStatement}) - Return AddComment(g, - String.Format(FeaturesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, disposeMethodDisplayString), + Return AddComment( + String.Format(CodeFixesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, disposeMethodDisplayString), methodDecl) End Function End Class diff --git a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems index ffeb48ad4d6cf..d5673680f3e38 100644 --- a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems +++ b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems @@ -31,6 +31,8 @@ + + diff --git a/src/Features/VisualBasicTest/ImplementInterface/ImplementInterfaceTests.vb b/src/Analyzers/VisualBasic/Tests/ImplementInterface/ImplementInterfaceTests.vb similarity index 98% rename from src/Features/VisualBasicTest/ImplementInterface/ImplementInterfaceTests.vb rename to src/Analyzers/VisualBasic/Tests/ImplementInterface/ImplementInterfaceTests.vb index 423354c18c0ca..8658148219004 100644 --- a/src/Features/VisualBasicTest/ImplementInterface/ImplementInterfaceTests.vb +++ b/src/Analyzers/VisualBasic/Tests/ImplementInterface/ImplementInterfaceTests.vb @@ -4183,24 +4183,24 @@ Class _ Protected Overridable Sub Dispose(disposing As Boolean) If Not disposedValue Then If disposing Then - ' { FeaturesResources.TODO_colon_dispose_managed_state_managed_objects } + ' { CodeFixesResources.TODO_colon_dispose_managed_state_managed_objects } End If - ' { FeaturesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer} - ' { FeaturesResources.TODO_colon_set_large_fields_to_null } + ' { CodeFixesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer} + ' { CodeFixesResources.TODO_colon_set_large_fields_to_null } disposedValue = True End If End Sub - ' ' { String.Format(FeaturesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, "Dispose(disposing As Boolean)") } + ' ' { String.Format(CodeFixesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, "Dispose(disposing As Boolean)") } ' Protected Overrides Sub Finalize() - ' ' { String.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)") } + ' ' { String.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)") } ' Dispose(disposing:=False) ' MyBase.Finalize() ' End Sub Public Sub Dispose() Implements IDisposable.Dispose - ' { String.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)") } + ' { String.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)") } Dispose(disposing:=True) GC.SuppressFinalize(Me) End Sub @@ -4254,24 +4254,24 @@ Partial Class C Protected Overridable Sub Dispose(disposing As Boolean) If Not disposedValue Then If disposing Then - ' { FeaturesResources.TODO_colon_dispose_managed_state_managed_objects } + ' { CodeFixesResources.TODO_colon_dispose_managed_state_managed_objects } End If - ' { FeaturesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer } - ' { FeaturesResources.TODO_colon_set_large_fields_to_null } + ' { CodeFixesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer } + ' { CodeFixesResources.TODO_colon_set_large_fields_to_null } disposedValue = True End If End Sub - ' ' { String.Format(FeaturesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, "Dispose(disposing As Boolean)") } + ' ' { String.Format(CodeFixesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, "Dispose(disposing As Boolean)") } ' Protected Overrides Sub Finalize() - ' ' { String.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)")} + ' ' { String.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)")} ' Dispose(disposing:=False) ' MyBase.Finalize() ' End Sub Public Sub Dispose() Implements IDisposable.Dispose - ' { String.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)") } + ' { String.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)") } Dispose(disposing:=True) GC.SuppressFinalize(Me) End Sub @@ -4294,24 +4294,24 @@ End Interface", {disposeMethodAccessibility} {disposeMethodModifiers}Sub Dispose(disposing As Boolean) If Not {disposeField} Then If disposing Then - ' {FeaturesResources.TODO_colon_dispose_managed_state_managed_objects} + ' {CodeFixesResources.TODO_colon_dispose_managed_state_managed_objects} End If - ' {FeaturesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer} - ' {FeaturesResources.TODO_colon_set_large_fields_to_null} + ' {CodeFixesResources.TODO_colon_free_unmanaged_resources_unmanaged_objects_and_override_finalizer} + ' {CodeFixesResources.TODO_colon_set_large_fields_to_null} {disposeField} = True End If End Sub - ' ' {String.Format(FeaturesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, "Dispose(disposing As Boolean)")} + ' ' {String.Format(CodeFixesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, "Dispose(disposing As Boolean)")} ' Protected Overrides Sub Finalize() - ' ' {String.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)")} + ' ' {String.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)")} ' Dispose(disposing:=False) ' MyBase.Finalize() ' End Sub Public Sub Dispose() Implements System.IDisposable.Dispose - ' {String.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)")} + ' {String.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, "Dispose(disposing As Boolean)")} Dispose(disposing:=True) {gcPrefix}GC.SuppressFinalize(Me) End Sub" diff --git a/src/Features/VisualBasicTest/ImplementInterface/ImplementInterfaceTests_FixAllTests.vb b/src/Analyzers/VisualBasic/Tests/ImplementInterface/ImplementInterfaceTests_FixAllTests.vb similarity index 98% rename from src/Features/VisualBasicTest/ImplementInterface/ImplementInterfaceTests_FixAllTests.vb rename to src/Analyzers/VisualBasic/Tests/ImplementInterface/ImplementInterfaceTests_FixAllTests.vb index 2074f1be2e429..46138758ecf48 100644 --- a/src/Features/VisualBasicTest/ImplementInterface/ImplementInterfaceTests_FixAllTests.vb +++ b/src/Analyzers/VisualBasic/Tests/ImplementInterface/ImplementInterfaceTests_FixAllTests.vb @@ -491,9 +491,17 @@ Class B3 Implements I1 Implements I2 + Public Sub F1() Implements I1.F1 + Throw New NotImplementedException() + End Sub + Private Class C3 Implements I1 Implements I2 + + Public Sub F1() Implements I1.F1 + Throw New NotImplementedException() + End Sub End Class End Class]]> diff --git a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems index 22251d02f58d5..686b3b663fe2a 100644 --- a/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems +++ b/src/Analyzers/VisualBasic/Tests/VisualBasicAnalyzers.UnitTests.projitems @@ -26,6 +26,8 @@ + + diff --git a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj index 0b68a2d055d75..48f34cef5364a 100644 --- a/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj +++ b/src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj @@ -14,7 +14,9 @@ + + diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests_FixAllTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests_FixAllTests.cs deleted file mode 100644 index 77ec85506e8e0..0000000000000 --- a/src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests_FixAllTests.cs +++ /dev/null @@ -1,599 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.CodeAnalysis.Testing; -using Xunit; -using VerifyCS = Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions.CSharpCodeFixVerifier< - Microsoft.CodeAnalysis.Testing.EmptyDiagnosticAnalyzer, - Microsoft.CodeAnalysis.CSharp.ImplementInterface.CSharpImplementInterfaceCodeFixProvider>; - -namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ImplementInterface; - -public class ImplementInterfaceTests_FixAllTests -{ - #region "Fix all occurrences tests" - - [Fact] - [Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)] - [Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)] - public async Task TestFixAllInDocument() - { - await new VerifyCS.Test - { - TestState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C1 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - AdditionalProjects = - { - ["Assembly1"] = - { - Sources = - { - @"class B3 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C3 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - AdditionalProjectReferences = { "TestProject" }, - }, - }, - }, - FixedState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : I1, I2 -{ - public void F1() - { - throw new System.NotImplementedException(); - } - - class C1 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - MarkupHandling = MarkupMode.Allow, - }, - BatchFixedState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : I1, I2 -{ - public void F1() - { - throw new System.NotImplementedException(); - } - - class C1 : I1, I2 - { - public void F1() - { - throw new System.NotImplementedException(); - } - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - MarkupHandling = MarkupMode.Allow, - }, - CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne | CodeFixTestBehaviors.SkipFixAllInProjectCheck | CodeFixTestBehaviors.SkipFixAllInSolutionCheck, - CodeActionEquivalenceKey = "False;False;True:global::I1;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", - CodeActionIndex = 0, - }.RunAsync(); - } - - [Fact] - [Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)] - [Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)] - public async Task TestFixAllInProject() - { - await new VerifyCS.Test - { - TestState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C1 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - AdditionalProjects = - { - ["Assembly1"] = - { - Sources = - { - @"class B3 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C3 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - AdditionalProjectReferences = { "TestProject" }, - }, - }, - }, - FixedState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : I1, I2 -{ - public void F1() - { - throw new System.NotImplementedException(); - } - - class C1 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - MarkupHandling = MarkupMode.Allow, - }, - BatchFixedState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : I1, I2 -{ - public void F1() - { - throw new System.NotImplementedException(); - } - - class C1 : I1, I2 - { - public void F1() - { - throw new System.NotImplementedException(); - } - } -}", - @"class B2 : I1, I2 -{ - public void F1() - { - throw new System.NotImplementedException(); - } - - class C2 : I1, I2 - { - public void F1() - { - throw new System.NotImplementedException(); - } - } -}", - }, - MarkupHandling = MarkupMode.Allow, - }, - CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne | CodeFixTestBehaviors.SkipFixAllInDocumentCheck | CodeFixTestBehaviors.SkipFixAllInSolutionCheck, - CodeActionEquivalenceKey = "False;False;True:global::I1;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", - CodeActionIndex = 0, - }.RunAsync(); - } - - [Fact] - [Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)] - [Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)] - public async Task TestFixAllInSolution() - { - await new VerifyCS.Test - { - TestState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C1 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - AdditionalProjects = - { - ["Assembly1"] = - { - Sources = - { - @"class B3 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C3 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - AdditionalProjectReferences = { "TestProject" }, - }, - }, - }, - FixedState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : {|CS0535:I1|}, I2 -{ - void I2.F1() - { - throw new System.NotImplementedException(); - } - - class C1 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - MarkupHandling = MarkupMode.Allow, - }, - BatchFixedState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : {|CS0535:I1|}, I2 -{ - void I2.F1() - { - throw new System.NotImplementedException(); - } - - class C1 : {|CS0535:I1|}, I2 - { - void I2.F1() - { - throw new System.NotImplementedException(); - } - } -}", - @"class B2 : {|CS0535:I1|}, I2 -{ - void I2.F1() - { - throw new System.NotImplementedException(); - } - - class C2 : {|CS0535:I1|}, I2 - { - void I2.F1() - { - throw new System.NotImplementedException(); - } - } -}", - }, - AdditionalProjects = - { - ["Assembly1"] = - { - Sources = - { - @"class B3 : {|CS0535:I1|}, I2 -{ - void I2.F1() - { - throw new System.NotImplementedException(); - } - - class C3 : {|CS0535:I1|}, I2 - { - void I2.F1() - { - throw new System.NotImplementedException(); - } - } -}", - }, - AdditionalProjectReferences = { "TestProject" }, - }, - }, - MarkupHandling = MarkupMode.Allow, - }, - CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne | CodeFixTestBehaviors.SkipFixAllInDocumentCheck | CodeFixTestBehaviors.SkipFixAllInProjectCheck, - DiagnosticSelector = diagnostics => diagnostics[1], - CodeActionEquivalenceKey = "True;False;False:global::I2;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", - CodeActionIndex = 1, - }.RunAsync(); - } - - [Fact] - [Trait(Traits.Feature, Traits.Features.CodeActionsImplementAbstractClass)] - [Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)] - public async Task TestFixAllInSolution_DifferentAssemblyWithSameTypeName() - { - await new VerifyCS.Test - { - TestState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C1 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - AdditionalProjects = - { - ["Assembly1"] = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B3 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C3 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - }, - }, - }, - FixedState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : {|CS0535:I1|}, I2 -{ - void I2.F1() - { - throw new System.NotImplementedException(); - } - - class C1 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - @"class B2 : {|CS0535:I1|}, {|CS0535:I2|} -{ - class C2 : {|CS0535:I1|}, {|CS0535:I2|} - { - } -}", - }, - MarkupHandling = MarkupMode.Allow, - }, - BatchFixedState = - { - Sources = - { - @"public interface I1 -{ - void F1(); -} - -public interface I2 -{ - void F1(); -} - -class B1 : {|CS0535:I1|}, I2 -{ - void I2.F1() - { - throw new System.NotImplementedException(); - } - - class C1 : {|CS0535:I1|}, I2 - { - void I2.F1() - { - throw new System.NotImplementedException(); - } - } -}", - @"class B2 : {|CS0535:I1|}, I2 -{ - void I2.F1() - { - throw new System.NotImplementedException(); - } - - class C2 : {|CS0535:I1|}, I2 - { - void I2.F1() - { - throw new System.NotImplementedException(); - } - } -}", - }, - MarkupHandling = MarkupMode.Allow, - }, - CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne | CodeFixTestBehaviors.SkipFixAllInDocumentCheck | CodeFixTestBehaviors.SkipFixAllInProjectCheck, - DiagnosticSelector = diagnostics => diagnostics[1], - CodeActionEquivalenceKey = "True;False;False:global::I2;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", - CodeActionIndex = 1, - }.RunAsync(); - } - - #endregion -} diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 4aa22886737eb..af2217d84115d 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -237,18 +237,6 @@ Generate nested {0} '{1}' - - Implement all members explicitly - - - Implement interface abstractly - - - Implement interface through '{0}' - - - Implement interface - Introduce field for '{0}' @@ -646,12 +634,6 @@ Do you want to continue? Note: Tab twice to insert the '{0}' snippet. - - Implement interface explicitly with Dispose pattern - - - Implement interface with Dispose pattern - Suppress {0} @@ -676,12 +658,6 @@ Do you want to continue? Containing Type - - TODO: dispose managed state (managed objects) - - - TODO: set large fields to null - Modifying {0} which contains a static variable requires restarting the application. @@ -1317,15 +1293,6 @@ This version used in: {2} Add 'DebuggerDisplay' attribute {Locked="DebuggerDisplay"} "DebuggerDisplay" is a BCL class and should not be localized. - - Do not change this code. Put cleanup code in '{0}' method - - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - AM/PM (abbreviated) @@ -1783,9 +1750,6 @@ If the "H" format specifier is used without other custom format specifiers, it's The "HH" custom format specifier (plus any number of additional "H" specifiers) represents the hour as a number from 00 through 23; that is, the hour is represented by a zero-based 24-hour clock that counts the hours since midnight. A single-digit hour is formatted with a leading zero. - - Implement remaining members explicitly - Generate for '{0}' diff --git a/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs b/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs index cfcc7666beea3..e1dbba9c7589e 100644 --- a/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs +++ b/src/Features/Core/Portable/Shared/Extensions/DocumentExtensions.cs @@ -93,18 +93,6 @@ public static async Task IsValidContextForDocumentOrLinkedDocumentsAsync( return false; } - /// - /// Gets the set of naming rules the user has set for this document. Will include a set of default naming rules - /// that match if the user hasn't specified any for a particular symbol type. The are added at the end so they - /// will only be used if the user hasn't specified a preference. - /// - public static async Task> GetNamingRulesAsync( - this Document document, CancellationToken cancellationToken) - { - var options = await document.GetNamingStylePreferencesAsync(cancellationToken).ConfigureAwait(false); - return options.CreateRules().NamingRules.AddRange(FallbackNamingRules.Default); - } - public static async Task GetApplicableNamingRuleAsync(this Document document, ISymbol symbol, CancellationToken cancellationToken) { var rules = await document.GetNamingRulesAsync(cancellationToken).ConfigureAwait(false); @@ -117,19 +105,6 @@ public static async Task GetApplicableNamingRuleAsync(this Document throw ExceptionUtilities.Unreachable(); } - public static async Task GetApplicableNamingRuleAsync( - this Document document, SymbolKind symbolKind, Accessibility accessibility, CancellationToken cancellationToken) - { - var rules = await document.GetNamingRulesAsync(cancellationToken).ConfigureAwait(false); - foreach (var rule in rules) - { - if (rule.SymbolSpecification.AppliesTo(symbolKind, accessibility)) - return rule; - } - - throw ExceptionUtilities.Unreachable(); - } - public static async Task GetApplicableNamingRuleAsync( this Document document, SymbolKindOrTypeKind kind, DeclarationModifiers modifiers, Accessibility? accessibility, CancellationToken cancellationToken) { diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index e421ac29a115f..1c384ab1dea55 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -660,11 +660,6 @@ Ujistěte se, že specifikátor tt použijete pro jazyky, pro které je nezbytn Zavřít - - Do not change this code. Put cleanup code in '{0}' method - Neměňte tento kód. Kód pro vyčištění vložte do metody {0}. - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. Aktuální obsah zdrojového souboru {0} se neshoduje se sestaveným zdrojem. Případné změny provedené v tomto souboru během ladění se nepoužijí, dokud se jeho obsah nebude shodovat se sestaveným zdrojem. @@ -930,11 +925,6 @@ Ujistěte se, že specifikátor tt použijete pro jazyky, pro které je nezbytn Implementovat všechna rozhraní implicitně - - Implement all members explicitly - Implementovat všechny členy explicitně - - Implement explicitly Implementovat explicitně @@ -945,11 +935,6 @@ Ujistěte se, že specifikátor tt použijete pro jazyky, pro které je nezbytn Implementovat implicitně - - Implement remaining members explicitly - Implementovat zbývající členy explicitně - - Incomplete \p{X} character escape Neúplné uvození znaků \p{X} @@ -2715,16 +2700,6 @@ Pozitivní kontrolní výrazy zpětného vyhledávání s nulovou délkou se obv Chyba syntaxe - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: Uvolněte nespravované prostředky (nespravované objekty) a přepište finalizační metodu. - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: Finalizační metodu přepište, jen pokud metoda {0} obsahuje kód pro uvolnění nespravovaných prostředků. - - Target type matches Shody cílového typu @@ -3925,21 +3900,6 @@ Pokud se specifikátor formátu M použije bez dalších specifikátorů vlastn Generovat vnořené {0} {1} - - Implement interface abstractly - Implementovat rozhraní abstraktně - - - - Implement interface through '{0}' - Implementovat rozhraní přes {0} - - - - Implement interface - Implementujte rozhraní. - - Introduce field for '{0}' Zavést pole pro {0} @@ -4220,16 +4180,6 @@ Chcete pokračovat? Poznámka: Pro vložení fragmentu {0} stiskněte dvakrát tabulátor. - - Implement interface explicitly with Dispose pattern - Implementovat rozhraní explicitně se vzorem Dispose - - - - Implement interface with Dispose pattern - Implementovat rozhraní se vzorem Dispose - - Computing fix all occurrences code fix... Vypočítává se oprava kódu pro opravu všech výskytů... @@ -4255,16 +4205,6 @@ Chcete pokračovat? Řešení - - TODO: dispose managed state (managed objects) - TODO: Uvolněte spravovaný stav (spravované objekty). - - - - TODO: set large fields to null - TODO: Nastavte velká pole na hodnotu null. - - Compiler Kompilátor diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 9d775ccc93bba..e53dd58413dff 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -660,11 +660,6 @@ Stellen Sie sicher, dass Sie den Bezeichner "tt" für Sprachen verwenden, für d Schließen - - Do not change this code. Put cleanup code in '{0}' method - Ändern Sie diesen Code nicht. Fügen Sie Bereinigungscode in der Methode "{0}" ein. - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. Der aktuelle Inhalt der Quelldatei "{0}" stimmt nicht mit dem kompilierten Quellcode überein. Alle Änderungen, die während des Debuggens an dieser Datei vorgenommen wurden, werden erst angewendet, wenn der Inhalt dem kompilierten Quellcode entspricht. @@ -930,11 +925,6 @@ Stellen Sie sicher, dass Sie den Bezeichner "tt" für Sprachen verwenden, für d Alle Schnittstellen implizit implementieren - - Implement all members explicitly - Alle Member explizit implementieren - - Implement explicitly Explizit implementieren @@ -945,11 +935,6 @@ Stellen Sie sicher, dass Sie den Bezeichner "tt" für Sprachen verwenden, für d Implizit implementieren - - Implement remaining members explicitly - Verbleibende Member explizit implementieren - - Incomplete \p{X} character escape Unvollständiges \p{X}-Escapezeichen. @@ -2715,16 +2700,6 @@ Positive Lookbehindassertionen mit Nullbreite werden normalerweise am Anfang reg Syntaxfehler - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: Nicht verwaltete Ressourcen (nicht verwaltete Objekte) freigeben und Finalizer überschreiben - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: Finalizer nur überschreiben, wenn "{0}" Code für die Freigabe nicht verwalteter Ressourcen enthält - - Target type matches Übereinstimmungen mit Zieltyp @@ -3925,21 +3900,6 @@ Bei Verwendung des Formatbezeichners "M" ohne weitere benutzerdefinierte Formatb Geschachteltes {0}-Objekt "{1}" generieren - - Implement interface abstractly - Schnittstelle abstrakt implementieren - - - - Implement interface through '{0}' - Schnittstelle über "{0}" implementieren - - - - Implement interface - Schnittstelle implementieren - - Introduce field for '{0}' Feld für "{0}" bereitstellen @@ -4220,16 +4180,6 @@ Möchten Sie fortfahren? Hinweis: Drücken Sie zweimal die TAB-TASTE, um den Schnipsel "{0}" einzufügen. - - Implement interface explicitly with Dispose pattern - Schnittstelle explizit mit Dispose-Muster implementieren - - - - Implement interface with Dispose pattern - Schnittstelle mit Dispose-Muster implementieren - - Computing fix all occurrences code fix... Berechnen der Codefehlerbehebung für alle Vorkommen... @@ -4255,16 +4205,6 @@ Möchten Sie fortfahren? Projektmappe - - TODO: dispose managed state (managed objects) - TODO: Verwalteten Zustand (verwaltete Objekte) bereinigen - - - - TODO: set large fields to null - TODO: Große Felder auf NULL setzen - - Compiler Compiler diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index df5c8c52650ee..8d854dbb4a00e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -660,11 +660,6 @@ Asegúrese de usar el especificador "tt" para los idiomas para los que es necesa Descartar - - Do not change this code. Put cleanup code in '{0}' method - No cambie este código. Coloque el código de limpieza en el método "{0}". - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. El contenido actual del archivo de código fuente "{0}" no coincide con el del código fuente compilado, así que los cambios realizados en este archivo durante la depuración no se aplicarán hasta que coincida. @@ -930,11 +925,6 @@ Asegúrese de usar el especificador "tt" para los idiomas para los que es necesa Implementar todas las interfaces de forma implícita - - Implement all members explicitly - Implementar todos los miembros de forma explícita - - Implement explicitly Implementar de forma explícita @@ -945,11 +935,6 @@ Asegúrese de usar el especificador "tt" para los idiomas para los que es necesa Implementar de forma implícita - - Implement remaining members explicitly - Implementar los miembros restantes de forma explícita - - Incomplete \p{X} character escape Escape de carácter incompleto \p{X} @@ -2715,16 +2700,6 @@ Las aserciones de búsqueda retrasada (lookbehind) positivas de ancho cero se us Error de sintaxis - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: liberar los recursos no administrados (objetos no administrados) y reemplazar el finalizador - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: reemplazar el finalizador solo si "{0}" tiene código para liberar los recursos no administrados - - Target type matches El tipo de destino coincide con @@ -3925,21 +3900,6 @@ Si el especificador de formato "M" se usa sin otros especificadores de formato p Generar {0} anidado '{1}' - - Implement interface abstractly - Implementar interfaz de forma abstracta - - - - Implement interface through '{0}' - Implementar interfaz a través de '{0}' - - - - Implement interface - Implementar interfaz - - Introduce field for '{0}' Introducir el campo de '{0}' @@ -4220,16 +4180,6 @@ Do you want to continue? Nota: Presione dos veces la tecla Tab para insertar el fragmento de código '{0}'. - - Implement interface explicitly with Dispose pattern - Implementar la interfaz de forma explícita con el patrón de Dispose - - - - Implement interface with Dispose pattern - Implementar la interfaz con el patrón de Dispose - - Computing fix all occurrences code fix... Calculando corrección de todas las repeticiones de corrección de código... @@ -4255,16 +4205,6 @@ Do you want to continue? Solución - - TODO: dispose managed state (managed objects) - TODO: eliminar el estado administrado (objetos administrados) - - - - TODO: set large fields to null - TODO: establecer los campos grandes como NULL - - Compiler Compilador diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 93137d9190f24..51e9b1ee8111e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -660,11 +660,6 @@ Veillez à utiliser le spécificateur "tt" pour les langues où il est nécessai Ignorer - - Do not change this code. Put cleanup code in '{0}' method - Ne changez pas ce code. Placez le code de nettoyage dans la méthode '{0}' - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. Le contenu actuel du fichier source '{0}' ne correspond pas à la source générée. Les changements apportés à ce fichier durant le débogage ne seront pas appliqués tant que son contenu ne correspondra pas à la source générée. @@ -930,11 +925,6 @@ Veillez à utiliser le spécificateur "tt" pour les langues où il est nécessai Implémenter toutes les interfaces implicitement - - Implement all members explicitly - Implémenter tous les membres explicitement - - Implement explicitly Implémenter explicitement @@ -945,11 +935,6 @@ Veillez à utiliser le spécificateur "tt" pour les langues où il est nécessai Implémenter implicitement - - Implement remaining members explicitly - Implémenter les membres restants explicitement - - Incomplete \p{X} character escape Caractère d'échappement \p{X} incomplet @@ -2715,16 +2700,6 @@ Les assertions arrière positives de largeur nulle sont généralement utilisée Erreur de syntaxe - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: libérer les ressources non managées (objets non managés) et substituer le finaliseur - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: substituer le finaliseur uniquement si '{0}' a du code pour libérer les ressources non managées - - Target type matches Cibler les correspondances de types @@ -3925,21 +3900,6 @@ Si le spécificateur de format "M" est utilisé sans autres spécificateurs de f Générer un {0} '{1}' imbriqué - - Implement interface abstractly - Implémenter l'interface abstraitement - - - - Implement interface through '{0}' - Implémenter l'interface via '{0}' - - - - Implement interface - Implémenter l'interface - - Introduce field for '{0}' Introduire un champ pour '{0}' @@ -4220,16 +4180,6 @@ Voulez-vous continuer ? Remarque : appuyez deux fois sur la touche Tab pour insérer l'extrait de code '{0}'. - - Implement interface explicitly with Dispose pattern - Implémenter l'interface explicitement avec le modèle Dispose - - - - Implement interface with Dispose pattern - Implémenter l'interface avec le modèle Dispose - - Computing fix all occurrences code fix... Calcul de la correction de toutes les occurrences (correction du code)... @@ -4255,16 +4205,6 @@ Voulez-vous continuer ? Solution - - TODO: dispose managed state (managed objects) - TODO: supprimer l'état managé (objets managés) - - - - TODO: set large fields to null - TODO: affecter aux grands champs une valeur null - - Compiler Compilateur diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index 83ed6c2856827..a302aa093cf04 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -660,11 +660,6 @@ Assicurarsi di usare l'identificatore "tt" per le lingue per le quali è necessa Chiudi - - Do not change this code. Put cleanup code in '{0}' method - Non modificare questo codice. Inserire il codice di pulizia nel metodo '{0}' - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. Il contenuto corrente del file di origine '{0}' non corrisponde al codice sorgente compilato. Tutte le modifiche apportate a questo file durante il debug non verranno applicate finché il relativo contenuto non corrisponde al codice sorgente compilato. @@ -930,11 +925,6 @@ Assicurarsi di usare l'identificatore "tt" per le lingue per le quali è necessa Implementa tutte le interfacce in modo implicito - - Implement all members explicitly - Implementare tutti i membri in modo esplicito - - Implement explicitly Implementa in modo esplicito @@ -945,11 +935,6 @@ Assicurarsi di usare l'identificatore "tt" per le lingue per le quali è necessa Implementa in modo implicito - - Implement remaining members explicitly - Implementare i membri rimanenti in modo esplicito - - Incomplete \p{X} character escape Sequenza di caratteri di escape \p{X} incompleta @@ -2715,16 +2700,6 @@ Le asserzioni lookbehind positive di larghezza zero vengono usate in genere all' Errore di sintassi - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: liberare risorse non gestite (oggetti non gestiti) ed eseguire l'override del finalizzatore - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: eseguire l'override del finalizzatore solo se '{0}' contiene codice per liberare risorse non gestite - - Target type matches Imposta destinazione per corrispondenze di tipo @@ -3925,21 +3900,6 @@ Se l'identificatore di formato "M" viene usato senza altri identificatori di for Genera l'elemento {0} '{1}' annidato - - Implement interface abstractly - Implementa l'interfaccia in modo astratto - - - - Implement interface through '{0}' - Implementa l'interfaccia tramite '{0}' - - - - Implement interface - Implementa l'interfaccia - - Introduce field for '{0}' Introduce il campo per '{0}' @@ -4220,16 +4180,6 @@ Continuare? Nota: premere due volte TAB per inserire il frammento di codice '{0}'. - - Implement interface explicitly with Dispose pattern - Implementa l'interfaccia in modo esplicito con il criterio Dispose - - - - Implement interface with Dispose pattern - Implementa l'interfaccia con il criterio Dispose - - Computing fix all occurrences code fix... Calcolo di tutte le occorrenze da correggere nel codice... @@ -4255,16 +4205,6 @@ Continuare? Soluzione - - TODO: dispose managed state (managed objects) - TODO: eliminare lo stato gestito (oggetti gestiti) - - - - TODO: set large fields to null - TODO: impostare campi di grandi dimensioni su Null - - Compiler Compilatore diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index db9f17e023aa5..e7b72b287eb59 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -660,11 +660,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 無視 - - Do not change this code. Put cleanup code in '{0}' method - このコードを変更しないでください。クリーンアップ コードを '{0}' メソッドに記述します - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. ソース ファイル '{0}' の現在のコンテンツが、ビルドされたソースと一致しません。デバッグ中にこのファイルに加えられた変更は、そのコンテンツがビルドされたソースと一致するまで適用されません。 @@ -930,11 +925,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma すべてのインターフェイスを暗黙的に実装する - - Implement all members explicitly - すべてのメンバーを明示的に実装する - - Implement explicitly 明示的に実装する @@ -945,11 +935,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 暗黙的に実装する - - Implement remaining members explicitly - 残りのメンバーを明示的に実装する - - Incomplete \p{X} character escape 不完全な \p{X} 文字エスケープです @@ -2715,16 +2700,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 構文エラー - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: アンマネージド リソース (アンマネージド オブジェクト) を解放し、ファイナライザーをオーバーライドします - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: '{0}' にアンマネージド リソースを解放するコードが含まれる場合にのみ、ファイナライザーをオーバーライドします - - Target type matches ターゲットの種類が一致します @@ -3925,21 +3900,6 @@ If the "M" format specifier is used without other custom format specifiers, it's 入れ子 {0} '{1}' を生成する - - Implement interface abstractly - インタ フェースを抽象的に実装します - - - - Implement interface through '{0}' - '{0}' を通じてインターフェイスを実装します - - - - Implement interface - インターフェイスを実装します - - Introduce field for '{0}' '{0}' に対してフィールドを導入します @@ -4220,16 +4180,6 @@ Do you want to continue? メモ: '{0}' スニペットを挿入するには、Tab キーを 2 回押してください。 - - Implement interface explicitly with Dispose pattern - 破棄パターンを使って明示的にインターフェイスを実装します - - - - Implement interface with Dispose pattern - 破棄パターンを使ってインターフェイスを実装します - - Computing fix all occurrences code fix... 出現箇所をすべて修正するコード修正プログラムを計算しています... @@ -4255,16 +4205,6 @@ Do you want to continue? ソリューション - - TODO: dispose managed state (managed objects) - TODO: マネージド状態を破棄します (マネージド オブジェクト) - - - - TODO: set large fields to null - TODO: 大きなフィールドを null に設定します - - Compiler コンパイラ diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 6dfe95efb7858..e123b3e9a10e4 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -660,11 +660,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 해제 - - Do not change this code. Put cleanup code in '{0}' method - 이 코드를 변경하지 마세요. '{0}' 메서드에 정리 코드를 입력합니다. - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. 소스 파일 '{0}'의 현재 콘텐츠가 빌드된 소스와 일치하지 않습니다. 디버그하는 동안 이 파일의 변경된 모든 내용은 해당 콘텐츠가 빌드된 소스와 일치할 때까지 적용되지 않습니다. @@ -930,11 +925,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 모든 인터페이스를 암시적으로 구현 - - Implement all members explicitly - 모든 멤버를 명시적으로 구현 - - Implement explicitly 명시적으로 구현 @@ -945,11 +935,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 암시적으로 구현 - - Implement remaining members explicitly - 나머지 멤버를 명시적으로 구현 - - Incomplete \p{X} character escape 불완전한 \p{X} 문자 이스케이프 @@ -2715,16 +2700,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 구문 오류 - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: 비관리형 리소스(비관리형 개체)를 해제하고 종료자를 재정의합니다. - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: 비관리형 리소스를 해제하는 코드가 '{0}'에 포함된 경우에만 종료자를 재정의합니다. - - Target type matches 대상 유형 일치 @@ -3925,21 +3900,6 @@ If the "M" format specifier is used without other custom format specifiers, it's 중첩된 {0} '{1}' 생성 - - Implement interface abstractly - 추상적으로 인터페이스 구현 - - - - Implement interface through '{0}' - '{0}'을(를) 통해 인터페이스 구현 - - - - Implement interface - 인터페이스 구현 - - Introduce field for '{0}' '{0}'에 대한 필드 지정 @@ -4220,16 +4180,6 @@ Do you want to continue? 참고: '{0}' 코드 조각을 삽입하려면 두 번 탭하세요. - - Implement interface explicitly with Dispose pattern - 인터페이스를 Dispose 패턴으로 명시적으로 구현 - - - - Implement interface with Dispose pattern - 인터페이스를 Dispose 패턴으로 구현 - - Computing fix all occurrences code fix... 모든 항목 코드 수정 사항을 계산하는 중... @@ -4255,16 +4205,6 @@ Do you want to continue? 솔루션 - - TODO: dispose managed state (managed objects) - TODO: 관리형 상태(관리형 개체)를 삭제합니다. - - - - TODO: set large fields to null - TODO: 큰 필드를 null로 설정합니다. - - Compiler 컴파일러 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 27eaa0a3212a3..b0b5db3130350 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -660,11 +660,6 @@ Pamiętaj, aby nie używać specyfikatora „tt” dla wszystkich języków, w k Odrzuć - - Do not change this code. Put cleanup code in '{0}' method - Nie zmieniaj tego kodu. Umieść kod czyszczący w metodzie „{0}”. - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. Bieżąca zawartość pliku źródłowego „{0}” nie pasuje do skompilowanego źródła. Wszystkie zmiany wprowadzone w tym pliku podczas debugowania nie zostaną zastosowane do czasu, aż jego zawartość będzie zgodna ze skompilowanym źródłem. @@ -930,11 +925,6 @@ Pamiętaj, aby nie używać specyfikatora „tt” dla wszystkich języków, w k Niejawnie zaimplementuj wszystkie interfejsy - - Implement all members explicitly - Jawnie zaimplementuj wszystkie składowe - - Implement explicitly Zaimplementuj jawnie @@ -945,11 +935,6 @@ Pamiętaj, aby nie używać specyfikatora „tt” dla wszystkich języków, w k Zaimplementuj niejawnie - - Implement remaining members explicitly - Jawnie zaimplementuj pozostałe składowe - - Incomplete \p{X} character escape Niekompletna sekwencja ucieczki znaku \p{X} @@ -2715,16 +2700,6 @@ Pozytywne asercje wsteczne o zerowej szerokości są zwykle używane na początk Błąd składniowy - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: Zwolnić niezarządzane zasoby (niezarządzane obiekty) i przesłonić finalizator - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: Przesłonić finalizator tylko w sytuacji, gdy powyższa metoda „{0}” zawiera kod służący do zwalniania niezarządzanych zasobów - - Target type matches Dopasowania typu docelowego @@ -3925,21 +3900,6 @@ Jeśli specyfikator formatu „M” jest używany bez innych niestandardowych sp Generuj zagnieżdżony element {0} „{1}” - - Implement interface abstractly - Implementuj interfejs abstrakcyjnie - - - - Implement interface through '{0}' - Implementuj interfejs za pomocą elementu „{0}” - - - - Implement interface - Zaimplementuj interfejs - - Introduce field for '{0}' Wprowadź pole dla elementu „{0}” @@ -4220,16 +4180,6 @@ Czy chcesz kontynuować? Uwaga: naciśnij dwa razy klawisz Tab, aby wstawić fragment kodu „{0}”. - - Implement interface explicitly with Dispose pattern - Jawnie implementuj interfejs za pomocą wzorca likwidacji - - - - Implement interface with Dispose pattern - Implementuj interfejs za pomocą wzorca likwidacji - - Computing fix all occurrences code fix... Trwa obliczanie poprawki kodu naprawiającej wszystkie obliczenia... @@ -4255,16 +4205,6 @@ Czy chcesz kontynuować? Rozwiązanie - - TODO: dispose managed state (managed objects) - TODO: Wyczyścić stan zarządzany (obiekty zarządzane) - - - - TODO: set large fields to null - TODO: Ustawić wartość null dla dużych pól - - Compiler Kompilator diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index a07ffbfadd2cf..672f0e5312e09 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -660,11 +660,6 @@ Verifique se o especificador "tt" foi usado para idiomas para os quais é necess Ignorar - - Do not change this code. Put cleanup code in '{0}' method - Não altere este código. Coloque o código de limpeza no método '{0}' - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. O conteúdo atual do arquivo de origem '{0}' não corresponde à origem criada. Todas as alterações feitas neste arquivo durante a depuração não serão aplicadas até que o conteúdo corresponda à origem criada. @@ -930,11 +925,6 @@ Verifique se o especificador "tt" foi usado para idiomas para os quais é necess Implementar todas as interfaces implicitamente - - Implement all members explicitly - Implementar todos os membros explicitamente - - Implement explicitly Implementar explicitamente @@ -945,11 +935,6 @@ Verifique se o especificador "tt" foi usado para idiomas para os quais é necess Implementar implicitamente - - Implement remaining members explicitly - Implementar os membros restantes explicitamente - - Incomplete \p{X} character escape Escape de caractere incompleto \p{X} @@ -2715,16 +2700,6 @@ As declarações de lookbehind positivas de largura zero normalmente são usadas Erro de sintaxe - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: liberar recursos não gerenciados (objetos não gerenciados) e substituir o finalizador - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: substituir o finalizador somente se '{0}' tiver o código para liberar recursos não gerenciados - - Target type matches Correspondências de tipos de destino @@ -3925,21 +3900,6 @@ Se o especificador de formato "M" for usado sem outros especificadores de format Gerar {0} '{1}' aninhado - - Implement interface abstractly - Implementar interface de forma abstrata - - - - Implement interface through '{0}' - Implementar interface por meio de "{0}" - - - - Implement interface - Implementar a interface - - Introduce field for '{0}' Encapsular campo para "{0}" @@ -4220,16 +4180,6 @@ Deseja continuar? Observação: pressione Tab duas vezes para inserir o snippet '{0}'. - - Implement interface explicitly with Dispose pattern - Implementar interface explicitamente com Padrão de descarte - - - - Implement interface with Dispose pattern - Implementar interface com Padrão de descarte - - Computing fix all occurrences code fix... Computando a correção de todas as correções de código de ocorrências… @@ -4255,16 +4205,6 @@ Deseja continuar? Solução - - TODO: dispose managed state (managed objects) - TODO: descartar o estado gerenciado (objetos gerenciados) - - - - TODO: set large fields to null - TODO: definir campos grandes como nulos - - Compiler Compilador diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index b525ee650add3..c29eba611742a 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -660,11 +660,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma Отклонить - - Do not change this code. Put cleanup code in '{0}' method - Не изменяйте этот код. Разместите код очистки в методе "{0}". - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. Текущее содержимое исходного файла "{0}" не соответствует созданному источнику. Все изменения, внесенные в этот файл во время отладки, не будут применены, пока содержимое файла не будет соответствовать созданному источнику. @@ -930,11 +925,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma Реализовать все интерфейсы неявно - - Implement all members explicitly - Реализовать все элементы явно - - Implement explicitly Реализовать явно @@ -945,11 +935,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma Реализовать неявно - - Implement remaining members explicitly - Реализовать оставшиеся элементы явно - - Incomplete \p{X} character escape Незавершенная escape-последовательность \p{X} @@ -2715,16 +2700,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Синтаксическая ошибка - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: освободить неуправляемые ресурсы (неуправляемые объекты) и переопределить метод завершения - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: переопределить метод завершения, только если "{0}" содержит код для освобождения неуправляемых ресурсов - - Target type matches Соответствия целевого типа @@ -3925,21 +3900,6 @@ If the "M" format specifier is used without other custom format specifiers, it's Создать вложенный {0} "{1}" - - Implement interface abstractly - Реализовать интерфейс абстрактно - - - - Implement interface through '{0}' - Реализовать интерфейс через "{0}" - - - - Implement interface - Реализовать интерфейс - - Introduce field for '{0}' Введите поле для "{0}" @@ -4220,16 +4180,6 @@ Do you want to continue? Примечание. Два раза нажмите клавишу TAB, чтобы вставить фрагмент кода "{0}". - - Implement interface explicitly with Dispose pattern - Явно внедрите интерфейс с шаблоном освобождения - - - - Implement interface with Dispose pattern - Внедрите интерфейс с шаблоном освобождения - - Computing fix all occurrences code fix... Вычисление изменения кода для исправления всех вхождений... @@ -4255,16 +4205,6 @@ Do you want to continue? Решение - - TODO: dispose managed state (managed objects) - TODO: освободить управляемое состояние (управляемые объекты) - - - - TODO: set large fields to null - TODO: установить значение NULL для больших полей - - Compiler Компилятор diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index d96ecb8f69bfa..77fc6ac3412b7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -660,11 +660,6 @@ AM ve PM arasındaki farkın korunmasının gerekli olduğu diller için "tt" be Kapat - - Do not change this code. Put cleanup code in '{0}' method - Bu kodu değiştirmeyin. Temizleme kodunu '{0}' metodunun içine yerleştirin. - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. '{0}' kaynak dosyasının geçerli içeriği, derlenen kaynakla eşleşmiyor. Hata ayıklama işlemi sırasında bu dosyada yapılan değişiklikler, dosyanın içeriği derlenen kaynakla eşleşene kadar uygulanmaz. @@ -930,11 +925,6 @@ AM ve PM arasındaki farkın korunmasının gerekli olduğu diller için "tt" be Tüm arabirimleri örtük olarak uygula - - Implement all members explicitly - Tüm üyeleri açıkça uygula - - Implement explicitly Açıkça uygula @@ -945,11 +935,6 @@ AM ve PM arasındaki farkın korunmasının gerekli olduğu diller için "tt" be Örtük olarak uygula - - Implement remaining members explicitly - Kalan üyeleri açıkça uygula - - Incomplete \p{X} character escape Tamamlanmamış \p{X} karakter kaçış @@ -2715,16 +2700,6 @@ Sıfır genişlikli pozitif geri yönlü onaylamalar genellikle normal ifadeleri Söz dizimi hatası - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: yönetilmeyen kaynakları (yönetilmeyen nesneleri) serbest bırakın ve sonlandırıcıyı geçersiz kılın - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: sonlandırıcıyı yalnızca '{0}' içinde yönetilmeyen kaynakları serbest bırakacak kod varsa geçersiz kılın - - Target type matches Hedef tür eşleşmeleri @@ -3925,21 +3900,6 @@ If the "M" format specifier is used without other custom format specifiers, it's İç içe {0} '{1}' oluştur - - Implement interface abstractly - Arabirimi soyut olarak uygula - - - - Implement interface through '{0}' - Arabirimi '{0}' aracılığıyla uygula - - - - Implement interface - Arabirimi uygula - - Introduce field for '{0}' '{0}' için alanı ortaya çıkar @@ -4220,16 +4180,6 @@ Devam etmek istiyor musunuz? Not: '{0}' kod parçacığını eklemek için iki kez sekme yapın. - - Implement interface explicitly with Dispose pattern - Ara birimi açık olarak Dispose düzeniyle uygula - - - - Implement interface with Dispose pattern - Ara birimi Dispose düzeniyle uygula - - Computing fix all occurrences code fix... Geçtiği her yerde düzeltme kod düzeltmesi hesaplanıyor... @@ -4255,16 +4205,6 @@ Devam etmek istiyor musunuz? Çözüm - - TODO: dispose managed state (managed objects) - TODO: yönetilen durumu (yönetilen nesneleri) atın - - - - TODO: set large fields to null - TODO: büyük alanları null olarak ayarlayın - - Compiler Derleyici diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 4c3b9775d805c..458372994851b 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -660,11 +660,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 消除 - - Do not change this code. Put cleanup code in '{0}' method - 不要更改此代码。请将清理代码放入“{0}”方法中 - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. 源文件 "{0}" 的当前内容与生成的源不匹配。在调试期间对此文件所做的任何更改都不会应用,直到其内容与生成的源匹配为止。 @@ -930,11 +925,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 隐式实现所有接口 - - Implement all members explicitly - 显式实现所有成员 - - Implement explicitly 显式实现 @@ -945,11 +935,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 隐式实现 - - Implement remaining members explicitly - 显式实现剩余成员 - - Incomplete \p{X} character escape \p{X} 字符转义不完整 @@ -2715,16 +2700,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 语法错误 - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: 释放未托管的资源(未托管的对象)并重写终结器 - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: 仅当“{0}”拥有用于释放未托管资源的代码时才替代终结器 - - Target type matches 目标类型匹配 @@ -3925,21 +3900,6 @@ If the "M" format specifier is used without other custom format specifiers, it's 生成嵌套的 {0}“{1}” - - Implement interface abstractly - 以抽象方式实现接口 - - - - Implement interface through '{0}' - 通过“{0}”实现接口 - - - - Implement interface - 实现接口 - - Introduce field for '{0}' 为“{0}”引入字段 @@ -4220,16 +4180,6 @@ Do you want to continue? 注意: 两次 Tab 插入“{0}”片段。 - - Implement interface explicitly with Dispose pattern - 通过释放模式显式实现接口 - - - - Implement interface with Dispose pattern - 通过释放模式实现接口 - - Computing fix all occurrences code fix... 正在计算“修复所有出现的地方”代码修复... @@ -4255,16 +4205,6 @@ Do you want to continue? 解决方案 - - TODO: dispose managed state (managed objects) - TODO: 释放托管状态(托管对象) - - - - TODO: set large fields to null - TODO: 将大型字段设置为 null - - Compiler 编译器 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index a0a33e6daf7a6..be8ca9aa88290 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -660,11 +660,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 關閉 - - Do not change this code. Put cleanup code in '{0}' method - 請勿變更此程式碼。請將清除程式碼放入 '{0}' 方法 - - The current content of source file '{0}' does not match the built source. Any changes made to this file while debugging won't be applied until its content matches the built source. 來源檔案 '{0}' 目前的內容與已建置的來源不一致。等到此檔案的內容與已建置的來源一致後,才會套用於偵錯期間對此檔案所做的所有變更。 @@ -930,11 +925,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 隱含實作所有介面 - - Implement all members explicitly - 明確實作所有成員 - - Implement explicitly 明確實作 @@ -945,11 +935,6 @@ Make sure to use the "tt" specifier for languages for which it's necessary to ma 隱含實作 - - Implement remaining members explicitly - 明確實作剩餘的成員 - - Incomplete \p{X} character escape 不完整的 \p{X} 字元逸出 @@ -2715,16 +2700,6 @@ Zero-width positive lookbehind assertions are typically used at the beginning of 語法錯誤 - - TODO: free unmanaged resources (unmanaged objects) and override finalizer - TODO: 釋出非受控資源 (非受控物件) 並覆寫完成項 - - - - TODO: override finalizer only if '{0}' has code to free unmanaged resources - TODO: 僅有當 '{0}' 具有會釋出非受控資源的程式碼時,才覆寫完成項 - - Target type matches 目標類型相符項目 @@ -3925,21 +3900,6 @@ If the "M" format specifier is used without other custom format specifiers, it's 產生巢狀 {0} '{1}' - - Implement interface abstractly - 以抽象方式實作介面 - - - - Implement interface through '{0}' - 透過 '{0}' 實作介面 - - - - Implement interface - 實作介面 - - Introduce field for '{0}' 為 '{0}' 引進欄位 @@ -4220,16 +4180,6 @@ Do you want to continue? 注意: 按兩次 Tab 鍵即可插入 '{0}' 程式碼片段。 - - Implement interface explicitly with Dispose pattern - 使用 Dispose 模式明確地實作介面 - - - - Implement interface with Dispose pattern - 使用 Dispose 模式實作介面 - - Computing fix all occurrences code fix... 正在計算修正所有出現程式碼修正之處... @@ -4255,16 +4205,6 @@ Do you want to continue? 解決方案 - - TODO: dispose managed state (managed objects) - TODO: 處置受控狀態 (受控物件) - - - - TODO: set large fields to null - TODO: 將大型欄位設為 Null - - Compiler 編譯器 diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs index 7512194ba3485..1a5a3fe8f5d77 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs @@ -39,8 +39,6 @@ public CSharpSyntaxGenerator() { } - internal override SyntaxTrivia ElasticCarriageReturnLineFeed => SyntaxFactory.ElasticCarriageReturnLineFeed; - internal override SyntaxTrivia CarriageReturnLineFeed => SyntaxFactory.CarriageReturnLineFeed; internal override SyntaxTrivia ElasticMarker => SyntaxFactory.ElasticMarker; internal override bool RequiresExplicitImplementationForInterfaceMembers => false; @@ -50,9 +48,6 @@ public CSharpSyntaxGenerator() internal override SyntaxTrivia Whitespace(string text) => SyntaxFactory.Whitespace(text); - internal override SyntaxTrivia SingleLineComment(string text) - => SyntaxFactory.Comment("//" + text); - internal override SeparatedSyntaxList SeparatedList(SyntaxNodeOrTokenList list) => SyntaxFactory.SeparatedList(list); diff --git a/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs b/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs index da35c94ba2347..6e36eaae9ba34 100644 --- a/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs +++ b/src/Workspaces/Core/Portable/Editing/SyntaxGenerator.cs @@ -33,8 +33,8 @@ public abstract class SyntaxGenerator : ILanguageService { public static readonly SyntaxRemoveOptions DefaultRemoveOptions = SyntaxRemoveOptions.KeepUnbalancedDirectives | SyntaxRemoveOptions.AddElasticMarker; - internal abstract SyntaxTrivia CarriageReturnLineFeed { get; } - internal abstract SyntaxTrivia ElasticCarriageReturnLineFeed { get; } + internal SyntaxTrivia CarriageReturnLineFeed => this.SyntaxGeneratorInternal.CarriageReturnLineFeed; + internal SyntaxTrivia ElasticCarriageReturnLineFeed => this.SyntaxGeneratorInternal.ElasticCarriageReturnLineFeed; internal abstract SyntaxTrivia ElasticMarker { get; } internal abstract bool RequiresExplicitImplementationForInterfaceMembers { get; } @@ -42,7 +42,9 @@ public abstract class SyntaxGenerator : ILanguageService internal abstract SyntaxGeneratorInternal SyntaxGeneratorInternal { get; } internal abstract SyntaxTrivia Whitespace(string text); - internal abstract SyntaxTrivia SingleLineComment(string text); + + internal SyntaxTrivia SingleLineComment(string text) + => this.SyntaxGeneratorInternal.SingleLineComment(text); internal abstract SyntaxToken CreateInterpolatedStringStartToken(bool isVerbatim); internal abstract SyntaxToken CreateInterpolatedStringEndToken(); diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs index b23036ed0d967..a27788c516f15 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/IMethodSymbolExtensions.cs @@ -54,42 +54,6 @@ public static bool CompatibleSignatureToDelegate(this IMethodSymbol method, INam return true; } - public static IMethodSymbol RemoveInaccessibleAttributesAndAttributesOfTypes( - this IMethodSymbol method, ISymbol accessibleWithin, - params INamedTypeSymbol[] removeAttributeTypes) - { - // Many static predicates use the same state argument in this method - var arg = (removeAttributeTypes, accessibleWithin); - - var methodHasAttribute = method.GetAttributes().Any(shouldRemoveAttribute, arg); - - var someParameterHasAttribute = method.Parameters - .Any(static (m, arg) => m.GetAttributes().Any(shouldRemoveAttribute, arg), arg); - - var returnTypeHasAttribute = method.GetReturnTypeAttributes().Any(shouldRemoveAttribute, arg); - - if (!methodHasAttribute && !someParameterHasAttribute && !returnTypeHasAttribute) - { - return method; - } - - return CodeGenerationSymbolFactory.CreateMethodSymbol( - method, - containingType: method.ContainingType, - explicitInterfaceImplementations: method.ExplicitInterfaceImplementations, - attributes: method.GetAttributes().WhereAsArray(static (a, arg) => !shouldRemoveAttribute(a, arg), arg), - parameters: method.Parameters.SelectAsArray(static (p, arg) => - CodeGenerationSymbolFactory.CreateParameterSymbol( - p.GetAttributes().WhereAsArray(static (a, arg) => !shouldRemoveAttribute(a, arg), arg), - p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional, - p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null), arg), - returnTypeAttributes: method.GetReturnTypeAttributes().WhereAsArray(static (a, arg) => !shouldRemoveAttribute(a, arg), arg)); - - static bool shouldRemoveAttribute(AttributeData a, (INamedTypeSymbol[] removeAttributeTypes, ISymbol accessibleWithin) arg) - => arg.removeAttributeTypes.Any(attr => attr.Equals(a.AttributeClass)) || - a.AttributeClass?.IsAccessibleWithin(arg.accessibleWithin) == false; - } - public static bool? IsMoreSpecificThan(this IMethodSymbol method1, IMethodSymbol method2) { var p1 = method1.Parameters; diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/IPropertySymbolExtensions.cs b/src/Workspaces/Core/Portable/Shared/Extensions/IPropertySymbolExtensions.cs index 2b2a1a8d5c1f3..1f423e23f8998 100644 --- a/src/Workspaces/Core/Portable/Shared/Extensions/IPropertySymbolExtensions.cs +++ b/src/Workspaces/Core/Portable/Shared/Extensions/IPropertySymbolExtensions.cs @@ -12,65 +12,6 @@ namespace Microsoft.CodeAnalysis.Shared.Extensions; internal static partial class IPropertySymbolExtensions { - public static IPropertySymbol RenameParameters(this IPropertySymbol property, ImmutableArray parameterNames) - { - var parameterList = property.Parameters; - if (parameterList.Select(p => p.Name).SequenceEqual(parameterNames)) - { - return property; - } - - var parameters = parameterList.RenameParameters(parameterNames); - - return CodeGenerationSymbolFactory.CreatePropertySymbol( - property.ContainingType, - property.GetAttributes(), - property.DeclaredAccessibility, - property.GetSymbolModifiers(), - property.Type, - property.RefKind, - property.ExplicitInterfaceImplementations, - property.Name, - parameters, - property.GetMethod, - property.SetMethod, - property.IsIndexer); - } - - public static IPropertySymbol RemoveInaccessibleAttributesAndAttributesOfTypes( - this IPropertySymbol property, ISymbol accessibleWithin, params INamedTypeSymbol[] attributesToRemove) - { - // Many static predicates use the same state argument in this method - var arg = (attributesToRemove, accessibleWithin); - - var someParameterHasAttribute = property.Parameters - .Any(static (p, arg) => p.GetAttributes().Any(ShouldRemoveAttribute, arg), arg); - if (!someParameterHasAttribute) - return property; - - return CodeGenerationSymbolFactory.CreatePropertySymbol( - property.ContainingType, - property.GetAttributes(), - property.DeclaredAccessibility, - property.GetSymbolModifiers(), - property.Type, - property.RefKind, - property.ExplicitInterfaceImplementations, - property.Name, - property.Parameters.SelectAsArray(static (p, arg) => - CodeGenerationSymbolFactory.CreateParameterSymbol( - p.GetAttributes().WhereAsArray(static (a, arg) => !ShouldRemoveAttribute(a, arg), arg), - p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional, - p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null), arg), - property.GetMethod, - property.SetMethod, - property.IsIndexer); - - static bool ShouldRemoveAttribute(AttributeData a, (INamedTypeSymbol[] attributesToRemove, ISymbol accessibleWithin) arg) - => arg.attributesToRemove.Any(attr => attr.Equals(a.AttributeClass)) || - a.AttributeClass?.IsAccessibleWithin(arg.accessibleWithin) == false; - } - public static bool IsWritableInConstructor(this IPropertySymbol property) => property.SetMethod != null || ContainsBackingField(property); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index c00a31249fe65..1969c93209650 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -484,6 +484,7 @@ + @@ -508,6 +509,7 @@ + @@ -551,6 +553,8 @@ + + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/NamingStyleOptions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/NamingStyleOptions.cs index a317ecb0a3637..fbeeeceb2af82 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/NamingStyleOptions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/NamingStyles/NamingStyleOptions.cs @@ -33,14 +33,3 @@ internal interface NamingStylePreferencesProvider #endif { } - -#if !CODE_STYLE -internal static class NamingStylePreferencesProviders -{ - public static async ValueTask GetNamingStylePreferencesAsync(this Document document, CancellationToken cancellationToken) - { - var configOptions = await document.GetAnalyzerConfigOptionsAsync(cancellationToken).ConfigureAwait(false); - return configOptions.GetEditorConfigOption(NamingStyleOptions.NamingPreferences, NamingStylePreferences.Default); - } -} -#endif diff --git a/src/Workspaces/Core/Portable/Shared/Extensions/IAsyncEnumerableExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IAsyncEnumerableExtensions.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Extensions/IAsyncEnumerableExtensions.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IAsyncEnumerableExtensions.cs diff --git a/src/Workspaces/Core/Portable/Shared/Utilities/ProducerConsumer.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ProducerConsumer.cs similarity index 100% rename from src/Workspaces/Core/Portable/Shared/Utilities/ProducerConsumer.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ProducerConsumer.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/RoslynParallel.NetFramework.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.NetFramework.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/RoslynParallel.NetFramework.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.NetFramework.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/RoslynParallel.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.cs similarity index 100% rename from src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/RoslynParallel.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.cs diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems index 485fed5b88906..9c4e4383030e3 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CSharpWorkspaceExtensions.projitems @@ -33,6 +33,7 @@ + diff --git a/src/Workspaces/CSharp/Portable/Editing/CSharpImportAdder.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Editing/CSharpImportAdder.cs similarity index 98% rename from src/Workspaces/CSharp/Portable/Editing/CSharpImportAdder.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Editing/CSharpImportAdder.cs index 88e35a0adefb7..d27ef36a0f7b3 100644 --- a/src/Workspaces/CSharp/Portable/Editing/CSharpImportAdder.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Editing/CSharpImportAdder.cs @@ -21,14 +21,10 @@ namespace Microsoft.CodeAnalysis.CSharp.Editing; [ExportLanguageService(typeof(ImportAdderService), LanguageNames.CSharp), Shared] -internal class CSharpImportAdder : ImportAdderService +[method: ImportingConstructor] +[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] +internal sealed class CSharpImportAdder() : ImportAdderService { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public CSharpImportAdder() - { - } - protected override INamespaceSymbol? GetExplicitNamespaceSymbol(SyntaxNode node, SemanticModel model) { switch (node) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs index e92cff2ad9f08..1ae9968af3955 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSyntaxGeneratorInternal.cs @@ -30,11 +30,21 @@ public CSharpSyntaxGeneratorInternal() public static readonly SyntaxGeneratorInternal Instance = new CSharpSyntaxGeneratorInternal(); - public override ISyntaxFacts SyntaxFacts => CSharpSyntaxFacts.Instance; + public override ISyntaxFacts SyntaxFacts + => CSharpSyntaxFacts.Instance; + + public override SyntaxTrivia CarriageReturnLineFeed + => SyntaxFactory.CarriageReturnLineFeed; + + public override SyntaxTrivia ElasticCarriageReturnLineFeed + => SyntaxFactory.ElasticCarriageReturnLineFeed; public override SyntaxTrivia EndOfLine(string text) => SyntaxFactory.EndOfLine(text); + public override SyntaxTrivia SingleLineComment(string text) + => SyntaxFactory.Comment("//" + text); + public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken name, SyntaxNode? initializer, bool isConst) { return SyntaxFactory.LocalDeclarationStatement( diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/AbstractCodeGenerationService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/AbstractCodeGenerationService.cs index d77822a2bfb03..b3bed594d27ac 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/AbstractCodeGenerationService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/CodeGeneration/AbstractCodeGenerationService.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Reflection.Metadata; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -251,13 +252,17 @@ private async Task GetEditAsync( var newDocument = oldDocument.WithSyntaxRoot(currentRoot); -#if !CODE_STYLE if (context.Context.AddImports) { var addImportsOptions = await newDocument.GetAddImportPlacementOptionsAsync(cancellationToken).ConfigureAwait(false); - newDocument = await ImportAdder.AddImportsFromSymbolAnnotationAsync(newDocument, addImportsOptions, cancellationToken).ConfigureAwait(false); + var service = newDocument.GetRequiredLanguageService(); + newDocument = await service.AddImportsAsync( + newDocument, + [currentRoot.FullSpan], + ImportAdderService.Strategy.AddImportsFromSymbolAnnotations, + addImportsOptions, + cancellationToken).ConfigureAwait(false); } -#endif return newDocument; } diff --git a/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Editing/ImportAdderService.cs similarity index 98% rename from src/Workspaces/Core/Portable/Editing/ImportAdderService.cs rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Editing/ImportAdderService.cs index 5b13036e05388..b836a2d0d8f01 100644 --- a/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Editing/ImportAdderService.cs @@ -174,7 +174,12 @@ private async Task AddImportDirectivesFromSymbolAnnotationsAsync( using var _ = PooledDictionary.GetInstance(out var importToSyntax); var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + +#if CODE_STYLE + var model = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false); +#else var model = await document.GetRequiredNullableDisabledSemanticModelAsync(cancellationToken).ConfigureAwait(false); +#endif SyntaxNode? first = null, last = null; var annotatedNodes = syntaxNodes.Where(x => x.HasAnnotations(SymbolAnnotation.Kind)); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs index 33e5d7ffda476..5373096393005 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/DocumentExtensions.cs @@ -16,6 +16,8 @@ using Roslyn.Utilities; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles; +using Microsoft.CodeAnalysis.CodeStyle; #if DEBUG using System.Collections.Immutable; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/IMethodSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/IMethodSymbolExtensions.cs index c13c6c3e09ccd..4032634ac146a 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/IMethodSymbolExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/IMethodSymbolExtensions.cs @@ -139,4 +139,40 @@ private static ImmutableArray RenameTypeParameters( return newTypeParameters.Cast().ToImmutableArray(); } + + public static IMethodSymbol RemoveInaccessibleAttributesAndAttributesOfTypes( + this IMethodSymbol method, ISymbol accessibleWithin, + params INamedTypeSymbol[] removeAttributeTypes) + { + // Many static predicates use the same state argument in this method + var arg = (removeAttributeTypes, accessibleWithin); + + var methodHasAttribute = method.GetAttributes().Any(shouldRemoveAttribute, arg); + + var someParameterHasAttribute = method.Parameters + .Any(static (m, arg) => m.GetAttributes().Any(shouldRemoveAttribute, arg), arg); + + var returnTypeHasAttribute = method.GetReturnTypeAttributes().Any(shouldRemoveAttribute, arg); + + if (!methodHasAttribute && !someParameterHasAttribute && !returnTypeHasAttribute) + { + return method; + } + + return CodeGenerationSymbolFactory.CreateMethodSymbol( + method, + containingType: method.ContainingType, + explicitInterfaceImplementations: method.ExplicitInterfaceImplementations, + attributes: method.GetAttributes().WhereAsArray(static (a, arg) => !shouldRemoveAttribute(a, arg), arg), + parameters: method.Parameters.SelectAsArray(static (p, arg) => + CodeGenerationSymbolFactory.CreateParameterSymbol( + p.GetAttributes().WhereAsArray(static (a, arg) => !shouldRemoveAttribute(a, arg), arg), + p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional, + p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null), arg), + returnTypeAttributes: method.GetReturnTypeAttributes().WhereAsArray(static (a, arg) => !shouldRemoveAttribute(a, arg), arg)); + + static bool shouldRemoveAttribute(AttributeData a, (INamedTypeSymbol[] removeAttributeTypes, ISymbol accessibleWithin) arg) + => arg.removeAttributeTypes.Any(attr => attr.Equals(a.AttributeClass)) || + a.AttributeClass?.IsAccessibleWithin(arg.accessibleWithin) == false; + } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/IPropertySymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/IPropertySymbolExtensions.cs new file mode 100644 index 0000000000000..581b1de1dd6c6 --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/IPropertySymbolExtensions.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Immutable; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CodeGeneration; + +namespace Microsoft.CodeAnalysis.Shared.Extensions; + +internal static partial class IPropertySymbolExtensions +{ + public static IPropertySymbol RenameParameters(this IPropertySymbol property, ImmutableArray parameterNames) + { + var parameterList = property.Parameters; + if (parameterList.Select(p => p.Name).SequenceEqual(parameterNames)) + { + return property; + } + + var parameters = parameterList.RenameParameters(parameterNames); + + return CodeGenerationSymbolFactory.CreatePropertySymbol( + property.ContainingType, + property.GetAttributes(), + property.DeclaredAccessibility, + property.GetSymbolModifiers(), + property.Type, + property.RefKind, + property.ExplicitInterfaceImplementations, + property.Name, + parameters, + property.GetMethod, + property.SetMethod, + property.IsIndexer); + } + + public static IPropertySymbol RemoveInaccessibleAttributesAndAttributesOfTypes( + this IPropertySymbol property, ISymbol accessibleWithin, params INamedTypeSymbol[] attributesToRemove) + { + // Many static predicates use the same state argument in this method + var arg = (attributesToRemove, accessibleWithin); + + var someParameterHasAttribute = property.Parameters + .Any(static (p, arg) => p.GetAttributes().Any(ShouldRemoveAttribute, arg), arg); + if (!someParameterHasAttribute) + return property; + + return CodeGenerationSymbolFactory.CreatePropertySymbol( + property.ContainingType, + property.GetAttributes(), + property.DeclaredAccessibility, + property.GetSymbolModifiers(), + property.Type, + property.RefKind, + property.ExplicitInterfaceImplementations, + property.Name, + property.Parameters.SelectAsArray(static (p, arg) => + CodeGenerationSymbolFactory.CreateParameterSymbol( + p.GetAttributes().WhereAsArray(static (a, arg) => !ShouldRemoveAttribute(a, arg), arg), + p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional, + p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null), arg), + property.GetMethod, + property.SetMethod, + property.IsIndexer); + + static bool ShouldRemoveAttribute(AttributeData a, (INamedTypeSymbol[] attributesToRemove, ISymbol accessibleWithin) arg) + => arg.attributesToRemove.Any(attr => attr.Equals(a.AttributeClass)) || + a.AttributeClass?.IsAccessibleWithin(arg.accessibleWithin) == false; + } +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs index 99e1123316d71..5e629108ccba9 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SyntaxGeneratorInternalExtensions/SyntaxGeneratorInternal.cs @@ -20,7 +20,11 @@ internal abstract class SyntaxGeneratorInternal : ILanguageService { public abstract ISyntaxFacts SyntaxFacts { get; } + public abstract SyntaxTrivia CarriageReturnLineFeed { get; } + public abstract SyntaxTrivia ElasticCarriageReturnLineFeed { get; } + public abstract SyntaxTrivia EndOfLine(string text); + public abstract SyntaxTrivia SingleLineComment(string text); /// /// Creates a statement that declares a single local variable with an optional initializer. diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/NamingStyles/NamingStylePreferencesProviders.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/NamingStyles/NamingStylePreferencesProviders.cs new file mode 100644 index 0000000000000..852f353f856fb --- /dev/null +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/NamingStyles/NamingStylePreferencesProviders.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles; +using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Shared.Extensions; + +namespace Microsoft.CodeAnalysis.CodeStyle; + +internal static class NamingStylePreferencesProviders +{ + public static async ValueTask GetNamingStylePreferencesAsync(this Document document, CancellationToken cancellationToken) + { + var configOptions = await document.GetAnalyzerConfigOptionsAsync(cancellationToken).ConfigureAwait(false); + return configOptions.GetOption(NamingStyleOptions.NamingPreferences, document.Project.Language); + } +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems index bb37b3337ca82..b522e8be46a20 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/WorkspaceExtensions.projitems @@ -14,11 +14,14 @@ + + + @@ -138,8 +141,6 @@ - - diff --git a/src/Workspaces/VisualBasic/Portable/Editing/VisualBasicImportAdder.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Editing/VisualBasicImportAdder.vb similarity index 99% rename from src/Workspaces/VisualBasic/Portable/Editing/VisualBasicImportAdder.vb rename to src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Editing/VisualBasicImportAdder.vb index 7d3efc3941eda..48df567891d0a 100644 --- a/src/Workspaces/VisualBasic/Portable/Editing/VisualBasicImportAdder.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Editing/VisualBasicImportAdder.vb @@ -14,7 +14,7 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.Editing - Partial Friend Class VisualBasicImportAdder + Partial Friend NotInheritable Class VisualBasicImportAdder Inherits ImportAdderService diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb index 7baacaddcb1a8..ea088045ecfea 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/LanguageServices/VisualBasicSyntaxGeneratorInternal.vb @@ -36,10 +36,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration Public Overrides ReadOnly Property SyntaxFacts As ISyntaxFacts = VisualBasicSyntaxFacts.Instance + Public Overrides ReadOnly Property CarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.CarriageReturnLineFeed + + Public Overrides ReadOnly Property ElasticCarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.ElasticCarriageReturnLineFeed + Public Overrides Function EndOfLine(text As String) As SyntaxTrivia Return SyntaxFactory.EndOfLine(text) End Function + Public Overrides Function SingleLineComment(text As String) As SyntaxTrivia + Return SyntaxFactory.CommentTrivia("'" + text) + End Function + Public Overloads Overrides Function LocalDeclarationStatement(type As SyntaxNode, identifier As SyntaxToken, Optional initializer As SyntaxNode = Nothing, Optional isConst As Boolean = False) As SyntaxNode Return SyntaxFactory.LocalDeclarationStatement( SyntaxFactory.TokenList(SyntaxFactory.Token(If(isConst, SyntaxKind.ConstKeyword, SyntaxKind.DimKeyword))), diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems index 3d5b5730771b3..91d7087582872 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/VisualBasicWorkspaceExtensions.projitems @@ -34,6 +34,7 @@ + diff --git a/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb b/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb index 6bb6fff41a5af..47ca86f1e7a52 100644 --- a/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb +++ b/src/Workspaces/VisualBasic/Portable/CodeGeneration/VisualBasicSyntaxGenerator.vb @@ -25,8 +25,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration Public Sub New() End Sub - Friend Overrides ReadOnly Property ElasticCarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.ElasticCarriageReturnLineFeed - Friend Overrides ReadOnly Property CarriageReturnLineFeed As SyntaxTrivia = SyntaxFactory.CarriageReturnLineFeed Friend Overrides ReadOnly Property ElasticMarker As SyntaxTrivia = SyntaxFactory.ElasticMarker Friend Overrides ReadOnly Property RequiresExplicitImplementationForInterfaceMembers As Boolean = True @@ -37,10 +35,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration Return SyntaxFactory.Whitespace(text) End Function - Friend Overrides Function SingleLineComment(text As String) As SyntaxTrivia - Return SyntaxFactory.CommentTrivia("'" + text) - End Function - Friend Overrides Function SeparatedList(Of TElement As SyntaxNode)(list As SyntaxNodeOrTokenList) As SeparatedSyntaxList(Of TElement) Return SyntaxFactory.SeparatedList(Of TElement)(list) End Function