-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add refactoring 'Remove directive (including content)' (#1224)
- Loading branch information
1 parent
cfae950
commit 6fd43e1
Showing
5 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/CSharp.Workspaces/CSharp/PreprocessorDirectiveRemoveOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
|
||
namespace Roslynator.CSharp; | ||
|
||
[Flags] | ||
internal enum PreprocessorDirectiveRemoveOptions | ||
{ | ||
None, | ||
IncludeContent, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
src/Tests/Refactorings.Tests/RR0100RemovePreprocessorDirectiveTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using Roslynator.Testing.CSharp; | ||
using Xunit; | ||
|
||
namespace Roslynator.CSharp.Refactorings.Tests; | ||
|
||
public class RR0100RemovePreprocessorDirectiveTests : AbstractCSharpRefactoringVerifier | ||
{ | ||
public override string RefactoringId { get; } = RefactoringIdentifiers.RemovePreprocessorDirective; | ||
|
||
[Fact, Trait(Traits.Refactoring, RefactoringIdentifiers.RemovePreprocessorDirective)] | ||
public async Task RemovePreprocessorDirectiveIncludingContent_If() | ||
{ | ||
await VerifyRefactoringAsync(@" | ||
class C | ||
{ | ||
#if [||]DEBUG // if | ||
void M() | ||
{ | ||
} | ||
#endif // endif | ||
} | ||
", @" | ||
class C | ||
{ | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(RefactoringId) + ".IncludingContent"); | ||
} | ||
|
||
[Fact, Trait(Traits.Refactoring, RefactoringIdentifiers.RemovePreprocessorDirective)] | ||
public async Task RemovePreprocessorDirectiveIncludingContent_EndIf() | ||
{ | ||
await VerifyRefactoringAsync(@" | ||
class C | ||
{ | ||
#if DEBUG // if | ||
void M() | ||
{ | ||
} | ||
#[||]endif // endif | ||
} | ||
", @" | ||
class C | ||
{ | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(RefactoringId) + ".IncludingContent"); | ||
} | ||
|
||
[Fact, Trait(Traits.Refactoring, RefactoringIdentifiers.RemovePreprocessorDirective)] | ||
public async Task RemovePreprocessorDirectiveIncludingContent_Else() | ||
{ | ||
await VerifyRefactoringAsync(@" | ||
class C | ||
{ | ||
#if DEBUG // if | ||
void M() | ||
{ | ||
} | ||
#[||]else | ||
void M2() | ||
{ | ||
} | ||
#endif // endif | ||
} | ||
", @" | ||
class C | ||
{ | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(RefactoringId) + ".IncludingContent"); | ||
} | ||
|
||
[Fact, Trait(Traits.Refactoring, RefactoringIdentifiers.RemovePreprocessorDirective)] | ||
public async Task RemovePreprocessorDirectiveIncludingContent_Elif() | ||
{ | ||
await VerifyRefactoringAsync(@" | ||
class C | ||
{ | ||
#if DEBUG // if | ||
void M() | ||
{ | ||
} | ||
#[||]elif FOO | ||
void M2() | ||
{ | ||
} | ||
#else | ||
void M3() | ||
{ | ||
} | ||
#endif // endif | ||
} | ||
", @" | ||
class C | ||
{ | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(RefactoringId) + ".IncludingContent"); | ||
} | ||
|
||
[Fact, Trait(Traits.Refactoring, RefactoringIdentifiers.RemovePreprocessorDirective)] | ||
public async Task RemovePreprocessorDirectiveIncludingContent_Region() | ||
{ | ||
await VerifyRefactoringAsync(@" | ||
class C | ||
{ | ||
#[||]region // region | ||
void M() | ||
{ | ||
} | ||
#endregion // endregion | ||
} | ||
", @" | ||
class C | ||
{ | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(RefactoringId) + ".IncludingContent"); | ||
} | ||
|
||
[Fact, Trait(Traits.Refactoring, RefactoringIdentifiers.RemovePreprocessorDirective)] | ||
public async Task RemovePreprocessorDirectiveIncludingContent_EndRegion() | ||
{ | ||
await VerifyRefactoringAsync(@" | ||
class C | ||
{ | ||
#region // region | ||
void M() | ||
{ | ||
} | ||
#[||]endregion // endregion | ||
} | ||
", @" | ||
class C | ||
{ | ||
} | ||
", equivalenceKey: EquivalenceKey.Create(RefactoringId) + ".IncludingContent"); | ||
} | ||
} |