Skip to content

Commit 3eea5ec

Browse files
Merge pull request #74547 from CyrusNajmabadi/moveImplInterfaceDown
2 parents 47e718f + aec47e7 commit 3eea5ec

File tree

80 files changed

+2149
-1881
lines changed

Some content is hidden

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

80 files changed

+2149
-1881
lines changed

src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
<Compile Include="$(MSBuildThisFileDirectory)HideBase\HideBaseCodeFixProvider.AddNewKeywordAction.cs" />
5252
<Compile Include="$(MSBuildThisFileDirectory)HideBase\HideBaseCodeFixProvider.cs" />
5353
<Compile Include="$(MSBuildThisFileDirectory)ImplementAbstractClass\CSharpImplementAbstractClassCodeFixProvider.cs" />
54+
<Compile Include="$(MSBuildThisFileDirectory)ImplementInterface\CSharpImplementInterfaceCodeFixProvider.cs" />
55+
<Compile Include="$(MSBuildThisFileDirectory)ImplementInterface\CSharpImplementInterfaceService.cs" />
5456
<Compile Include="$(MSBuildThisFileDirectory)Iterator\CSharpAddYieldCodeFixProvider.cs" />
5557
<Compile Include="$(MSBuildThisFileDirectory)Iterator\CSharpChangeToIEnumerableCodeFixProvider.cs" />
5658
<Compile Include="$(MSBuildThisFileDirectory)MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs" />

src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs renamed to src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceService.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,32 @@
55
#nullable disable
66

77
using System;
8-
using System.Collections.Generic;
98
using System.Collections.Immutable;
109
using System.Composition;
1110
using System.Threading;
1211
using Microsoft.CodeAnalysis;
12+
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
1313
using Microsoft.CodeAnalysis.CSharp.Extensions;
14+
using Microsoft.CodeAnalysis.CSharp.Formatting;
1415
using Microsoft.CodeAnalysis.CSharp.Syntax;
1516
using Microsoft.CodeAnalysis.Editing;
17+
using Microsoft.CodeAnalysis.Formatting;
1618
using Microsoft.CodeAnalysis.Host.Mef;
1719
using Microsoft.CodeAnalysis.ImplementInterface;
1820
using Microsoft.CodeAnalysis.Shared.Extensions;
1921

2022
namespace Microsoft.CodeAnalysis.CSharp.ImplementInterface;
2123

2224
[ExportLanguageService(typeof(IImplementInterfaceService), LanguageNames.CSharp), Shared]
23-
internal class CSharpImplementInterfaceService : AbstractImplementInterfaceService
25+
[method: ImportingConstructor]
26+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
27+
internal sealed class CSharpImplementInterfaceService() : AbstractImplementInterfaceService
2428
{
25-
[ImportingConstructor]
26-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
27-
public CSharpImplementInterfaceService()
28-
{
29-
}
29+
protected override ISyntaxFormatting SyntaxFormatting
30+
=> CSharpSyntaxFormatting.Instance;
31+
32+
protected override SyntaxGeneratorInternal SyntaxGeneratorInternal
33+
=> CSharpSyntaxGeneratorInternal.Instance;
3034

3135
protected override string ToDisplayString(IMethodSymbol disposeImplMethod, SymbolDisplayFormat format)
3236
=> SymbolDisplay.ToDisplayString(disposeImplMethod, format);
@@ -90,16 +94,16 @@ protected override SyntaxNode CreateFinalizer(
9094
{
9195
// ' Do not change this code...
9296
// Dispose(false)
93-
var disposeStatement = (StatementSyntax)AddComment(g,
94-
string.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString),
97+
var disposeStatement = (StatementSyntax)AddComment(
98+
string.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString),
9599
g.ExpressionStatement(g.InvocationExpression(
96100
g.IdentifierName(nameof(IDisposable.Dispose)),
97101
g.Argument(DisposingName, RefKind.None, g.FalseLiteralExpression()))));
98102

99103
var methodDecl = SyntaxFactory.DestructorDeclaration(classType.Name).AddBodyStatements(disposeStatement);
100104

101-
return AddComment(g,
102-
string.Format(FeaturesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, disposeMethodDisplayString),
105+
return AddComment(
106+
string.Format(CodeFixesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, disposeMethodDisplayString),
103107
methodDecl);
104108
}
105109
}

src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
<Compile Include="$(MSBuildThisFileDirectory)ImplementAbstractClass\ImplementAbstractClassTests.cs" />
3939
<Compile Include="$(MSBuildThisFileDirectory)ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.cs" />
4040
<Compile Include="$(MSBuildThisFileDirectory)ImplementAbstractClass\ImplementAbstractClassTests_ThroughMember.cs" />
41+
<Compile Include="$(MSBuildThisFileDirectory)ImplementInterface\ImplementInterfaceTests.cs" />
42+
<Compile Include="$(MSBuildThisFileDirectory)ImplementInterface\ImplementInterfaceTests_FixAllTests.cs" />
4143
<Compile Include="$(MSBuildThisFileDirectory)Iterator\AddYieldTests.cs" />
4244
<Compile Include="$(MSBuildThisFileDirectory)Iterator\ChangeToIEnumerableTests.cs" />
4345
<Compile Include="$(MSBuildThisFileDirectory)MakeAnonymousFunctionStatic\MakeAnonymousFunctionStaticTests.cs" />

0 commit comments

Comments
 (0)