Skip to content

Commit

Permalink
Formatting with csharpier 0.9.6 (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
belav authored Jun 14, 2021
1 parent 8d0cdc8 commit 7ed2638
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.9.5",
"version": "0.9.6",
"commands": [
"dotnet-csharpier"
]
Expand Down
5 changes: 1 addition & 4 deletions Src/CSharpier.Playground/Controllers/FormatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ private bool Exists(string filePath)

public string ExecuteApplication(string pathToExe, string workingDirectory, string args)
{
var processStartInfo = new ProcessStartInfo(
pathToExe,
args
)
var processStartInfo = new ProcessStartInfo(pathToExe, args)
{
UseShellExecute = false,
RedirectStandardError = true,
Expand Down
3 changes: 1 addition & 2 deletions Src/CSharpier.Tests/CommandLineFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ params string[] directoryOrFilePaths
}

var fakeConsole = new TestConsole();
var result =
CommandLineFormatter.Format(
var result = CommandLineFormatter.Format(
new CommandLineOptions
{
DirectoryOrFilePaths = directoryOrFilePaths,
Expand Down
7 changes: 5 additions & 2 deletions Src/CSharpier.Tests/TestFiles/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ protected void RunTest(string folderName, string fileName, bool useTabs = false)
folderName,
fileName + ".cst"
);
var fileReaderResult =
FileReader.ReadFile(filePath, new FileSystem(), CancellationToken.None).Result;
var fileReaderResult = FileReader.ReadFile(
filePath,
new FileSystem(),
CancellationToken.None
).Result;

var formatter = new CodeFormatter();
var result = formatter.Format(
Expand Down
3 changes: 1 addition & 2 deletions Src/CSharpier/CommandLineFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ CancellationToken cancellationToken
fileSystem
);

var ignoreFile =
await IgnoreFile.Create(
var ignoreFile = await IgnoreFile.Create(
baseDirectoryPath,
fileSystem,
console,
Expand Down
4 changes: 1 addition & 3 deletions Src/CSharpier/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public static RootCommand Create()
{
var rootCommand = new RootCommand
{
new Argument<string[]>(
"directoryOrFile"
)
new Argument<string[]>("directoryOrFile")
{
Arity = ArgumentArity.ZeroOrMore,
Description = "One or more paths to a directory containing files to format or a file to format. If a path is not specified the current directory is used"
Expand Down
33 changes: 19 additions & 14 deletions Src/CSharpier/DocTypes/Doc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public static implicit operator Doc(string value)

public static readonly HardLine HardLineIfNoPreviousLine = new(true);

public static readonly HardLine HardLineIfNoPreviousLineSkipBreakIfFirstInGroup =
new(true, true);
public static readonly HardLine HardLineIfNoPreviousLineSkipBreakIfFirstInGroup = new(
true,
true
);

public static readonly LiteralLine LiteralLine = new();

Expand All @@ -32,10 +34,12 @@ public static implicit operator Doc(string value)
public static readonly Trim Trim = new();

public static LeadingComment LeadingComment(string comment, CommentType commentType) =>
new() { Type = commentType, Comment = comment };
new()
{ Type = commentType, Comment = comment };

public static TrailingComment TrailingComment(string comment, CommentType commentType) =>
new() { Type = commentType, Comment = comment };
new()
{ Type = commentType, Comment = comment };

public static Concat Concat(List<Doc> contents) => new(contents);

Expand Down Expand Up @@ -66,13 +70,16 @@ public static Doc Join(Doc separator, IEnumerable<Doc> array)
}

public static ForceFlat ForceFlat(List<Doc> contents) =>
new() { Contents = contents.Count == 0 ? contents[0] : Concat(contents) };
new()
{ Contents = contents.Count == 0 ? contents[0] : Concat(contents) };

public static ForceFlat ForceFlat(params Doc[] contents) =>
new() { Contents = contents.Length == 0 ? contents[0] : Concat(contents) };
new()
{ Contents = contents.Length == 0 ? contents[0] : Concat(contents) };

public static Group Group(List<Doc> contents) =>
new() { Contents = contents.Count == 1 ? contents[0] : Concat(contents) };
new()
{ Contents = contents.Count == 1 ? contents[0] : Concat(contents) };

public static Group GroupWithId(string groupId, params Doc[] contents)
{
Expand All @@ -82,10 +89,12 @@ public static Group GroupWithId(string groupId, params Doc[] contents)
}

public static Group Group(params Doc[] contents) =>
new() { Contents = contents.Length == 1 ? contents[0] : Concat(contents) };
new()
{ Contents = contents.Length == 1 ? contents[0] : Concat(contents) };

public static IndentDoc Indent(params Doc[] contents) =>
new() { Contents = contents.Length == 1 ? contents[0] : Concat(contents) };
new()
{ Contents = contents.Length == 1 ? contents[0] : Concat(contents) };

public static IndentDoc Indent(List<Doc> contents) => new() { Contents = Concat(contents) };

Expand All @@ -95,11 +104,7 @@ public static IfBreak IfBreak(
string? groupId = null
) =>
new()
{
FlatContents = flatContents,
BreakContents = breakContents,
GroupId = groupId,
};
{ FlatContents = flatContents, BreakContents = breakContents, GroupId = groupId, };

public static IndentIfBreak IndentIfBreak(Doc contents, string groupId) =>
new(contents, groupId);
Expand Down
6 changes: 4 additions & 2 deletions Src/CSharpier/GeneratedCodeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public static bool IsGeneratedCodeFile(string filePath)
|| fileNameWithoutExtension.EndsWithIgnoreCase(".g.i");
}

private static readonly string[] AutoGeneratedStrings =
new[] { "<autogenerated", "<auto-generated" };
private static readonly string[] AutoGeneratedStrings = new[] {
"<autogenerated",
"<auto-generated"
};

public static bool BeginsWithAutoGeneratedComment(SyntaxNode root)
{
Expand Down
6 changes: 1 addition & 5 deletions Src/CSharpier/SyntaxNodeComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ is SyntaxNode formattedNode
private CompareResult NotEqual(SyntaxNode? originalNode, SyntaxNode? formattedNode)
{
return new()
{
IsInvalid = true,
OriginalSpan = originalNode?.Span,
NewSpan = formattedNode?.Span
};
{ IsInvalid = true, OriginalSpan = originalNode?.Span, NewSpan = formattedNode?.Span };
}

private CompareResult NotEqual(TextSpan? originalSpan, TextSpan? formattedSpan)
Expand Down
3 changes: 1 addition & 2 deletions Src/CSharpier/SyntaxPrinter/SeparatedSyntaxList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public static Doc Print<T>(
SeparatedSyntaxList<T> list,
Func<T, Doc> printFunc,
Doc afterSeparator
)
where T : SyntaxNode {
) where T : SyntaxNode {
var docs = new List<Doc>();
for (var x = 0; x < list.Count; x++)
{
Expand Down
3 changes: 1 addition & 2 deletions Src/Worker/Ignored.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public static class Ignored

public static Type[] Types = { typeof(TextSpan), typeof(SyntaxTree) };

public static Dictionary<Type, string[]> PropertiesByType =
new()
public static Dictionary<Type, string[]> PropertiesByType = new()
{
{ typeof(PropertyDeclarationSyntax), new[] { "semicolon" } },
{ typeof(IndexerDeclarationSyntax), new[] { "semicolon" } },
Expand Down

0 comments on commit 7ed2638

Please sign in to comment.