-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implemented "Egyptian Brackets" fixing
- Fine tuning of "indent alignment"
- Loading branch information
1 parent
d40541f
commit d305db9
Showing
22 changed files
with
830 additions
and
261 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Xunit; | ||
|
||
namespace CMPlus.Tests | ||
{ | ||
public class BracketsNormalizer : TestBase | ||
{ | ||
[Fact] | ||
public void Fix_EgyptianBrackets() | ||
{ | ||
var code = | ||
@"public OptimiserAction Create(SlideArea location) | ||
{ | ||
var parameters = new List<Parameter>{ | ||
_locationParameter.WithValue((ushort)(location == SlideArea.OutputDrawer ? 1 : 0)) | ||
} | ||
}"; | ||
var processedCode = code.GetSyntaxRoot() | ||
.FixBrackets() | ||
.ToString() | ||
.GetLines(); | ||
|
||
Assert.Equal(" var parameters = new List<Parameter>", processedCode[2]); | ||
Assert.Equal(" {", processedCode[3]); | ||
Assert.Equal(" }", processedCode[5]); | ||
} | ||
|
||
[Fact] | ||
public void DoesNot_Change_SameLine_Pair() | ||
{ | ||
var code = | ||
@"class Test | ||
{ | ||
int Index { get; } | ||
}"; | ||
var processedCode = code.GetSyntaxRoot() | ||
.FixBrackets() | ||
.ToString() | ||
.GetLines(); | ||
|
||
Assert.Equal(" int Index { get; }", processedCode[2]); | ||
} | ||
|
||
[Fact] | ||
public void Ignore_StringInterpolations() | ||
{ | ||
var code = | ||
@"public OptimiserAction Create(SlideArea location) | ||
{ | ||
var message = $@""Error: { | ||
1.ToString(). | ||
Length}""; | ||
}"; | ||
var processedCode = code.GetSyntaxRoot() | ||
.FixBrackets() | ||
.ToString() | ||
.GetLines(); | ||
|
||
Assert.Equal(" var message = $@\"Error: {", processedCode[2]); | ||
Assert.Equal(" 1.ToString().", processedCode[3]); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.