Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MakeTypeAbstract to preserve existing modifiers #54905

Merged
merged 2 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -143,7 +144,8 @@ public abstract class Goo
}");
}

[Fact(Skip = "https://github.com/dotnet/roslyn/issues/41654"), Trait(Traits.Feature, Traits.Features.CodeActionsMakeTypeAbstract)]
[WorkItem(54218, "https://github.com/dotnet/roslyn/issues/54218")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeTypeAbstract)]
public async Task TestPartialClass()
{
await TestInRegularAndScript1Async(
Expand All @@ -157,7 +159,7 @@ public partial class Goo
{
}",
@"
public partial abstract class Goo
public abstract partial class Goo
{
public abstract void M();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,24 @@ Namespace NS
End Class
End Namespace")
End Function

<WorkItem(54218, "https://github.com/dotnet/roslyn/issues/54218")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMakeTypeAbstract)>
Public Async Function TestMethod_PartialClass() As Task
Await TestInRegularAndScriptAsync("
Partial Public Class [|Foo|]
Public MustOverride Sub M()
End Class

Partial Public Class Foo
End Class",
"
Partial Public MustInherit Class Foo
Public MustOverride Sub M()
End Class

Partial Public Class Foo
End Class")
End Function
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected sealed override Task FixAllAsync(Document document, ImmutableArray<Dia
if (IsValidRefactoringContext(diagnostics[i].Location?.FindNode(cancellationToken), out var typeDeclaration))
{
editor.ReplaceNode(typeDeclaration,
(currentTypeDeclaration, generator) => generator.WithModifiers(currentTypeDeclaration, DeclarationModifiers.Abstract));
(currentTypeDeclaration, generator) => generator.WithModifiers(currentTypeDeclaration, generator.GetModifiers(currentTypeDeclaration).WithIsAbstract(true)));
}
}

Expand Down