Skip to content

Commit

Permalink
Format with 29 (#1322)
Browse files Browse the repository at this point in the history
  • Loading branch information
belav authored Aug 17, 2024
1 parent 0abbc1d commit 6cb3821
Show file tree
Hide file tree
Showing 67 changed files with 198 additions and 199 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.28.1",
"version": "0.29.0",
"commands": [
"dotnet-csharpier"
]
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli.Tests/ServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task Stuff()
var data = new FormatFileParameter
{
fileName = "/Temp/test.cs",
fileContents = "public class TestClass { }"
fileContents = "public class TestClass { }",
};

var response = await httpClient.PostAsJsonAsync(
Expand Down
4 changes: 2 additions & 2 deletions Src/CSharpier.Cli/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static RootCommand Create()
{
Arity = ArgumentArity.ZeroOrMore,
Description =
"One or more paths to a directory containing C# files to format or a C# file to format. It may be ommited when piping data via stdin."
"One or more paths to a directory containing C# files to format or a C# file to format. It may be ommited when piping data via stdin.",
}.LegalFilePathsOnly(),
new Option(
new[] { "--check" },
Expand Down Expand Up @@ -99,7 +99,7 @@ public static RootCommand Create()
new Option(
new[] { "--compilation-errors-as-warnings" },
"Treat compilation errors from files as warnings instead of errors."
)
),
};

rootCommand.AddValidator(cmd =>
Expand Down
4 changes: 2 additions & 2 deletions Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal static class ConfigFileParser
AllowDuplicateSections = true,
OverrideDuplicateKeys = true,
SkipInvalidLines = true,
ThrowExceptionsOnError = false
ThrowExceptionsOnError = false,
};

public static ConfigFile Parse(string filePath, IFileSystem fileSystem)
Expand All @@ -44,7 +44,7 @@ public static ConfigFile Parse(string filePath, IFileSystem fileSystem)
return new ConfigFile
{
IsRoot = configData?.Global["root"] == "true",
Sections = sections
Sections = sections,
};
}
}
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ IgnoreFile ignoreFile
return new EditorConfigSections
{
DirectoryName = dirName,
SectionsIncludingParentFiles = FindSections(o.FullName, fileSystem)
SectionsIncludingParentFiles = FindSections(o.FullName, fileSystem),
};
})
.OrderByDescending(o => o.DirectoryName.Length)
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/EditorConfig/Globber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static string FixGlob(string glob, string directory)
{
-1 => "**/" + glob,
0 => glob[1..],
_ => glob
_ => glob,
};
directory = directory.Replace(@"\", "/");
if (!directory.EndsWith("/"))
Expand Down
4 changes: 2 additions & 2 deletions Src/CSharpier.Cli/FileToFormatInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CancellationToken cancellationToken
Path = path,
FileContents = fileContents,
Encoding = encoding,
UnableToDetectEncoding = unableToDetectEncoding
UnableToDetectEncoding = unableToDetectEncoding,
};
}

Expand All @@ -41,7 +41,7 @@ public static FileToFormatInfo Create(string path, string fileContents, Encoding
{
Path = path,
FileContents = fileContents,
Encoding = encoding
Encoding = encoding,
};
}
}
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/IgnoreFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class IgnoreFile
private static readonly string[] alwaysIgnored =
{
"**/node_modules/**/*.cs",
"**/obj/**/*.cs"
"**/obj/**/*.cs",
};

protected IgnoreFile(Ignore.Ignore ignore, string ignoreBaseDirectoryPath)
Expand Down
4 changes: 2 additions & 2 deletions Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class ConfigurationFileOptions
UseTabs = matchingOverride.UseTabs,
Width = matchingOverride.PrintWidth,
EndOfLine = matchingOverride.EndOfLine,
Formatter = matchingOverride.Formatter
Formatter = matchingOverride.Formatter,
};
}

Expand All @@ -38,7 +38,7 @@ internal class ConfigurationFileOptions
UseTabs = this.UseTabs,
Width = this.PrintWidth,
EndOfLine = this.EndOfLine,
Formatter = "csharp"
Formatter = "csharp",
};
}

Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/Options/OptionsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public string Serialize()
{
specified = this.specifiedConfigFile,
csharpierConfigs = this.csharpierConfigs,
editorConfigs = this.editorConfigs
editorConfigs = this.editorConfigs,
}
);
}
Expand Down
12 changes: 5 additions & 7 deletions Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,18 @@ CancellationToken cancellationToken
{
DirectoryOrFilePaths = new[]
{
Path.Combine(Directory.GetCurrentDirectory(), fileName)
Path.Combine(Directory.GetCurrentDirectory(), fileName),
},
OriginalDirectoryOrFilePaths = new[]
{
Path.IsPathRooted(fileName)
? fileName
: fileName.StartsWith(".")
? fileName
: "./" + fileName
Path.IsPathRooted(fileName) ? fileName
: fileName.StartsWith(".") ? fileName
: "./" + fileName,
},
StandardInFileContents = stringBuilder.ToString(),
Fast = true,
WriteStdout = true,
ConfigPath = configPath
ConfigPath = configPath,
};

try
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ CancellationToken cancellationToken
DebugLogger.Log(ex.ToString());
return new FormatFileResult(Status.Failed)
{
errorMessage = "An exception was thrown\n" + ex
errorMessage = "An exception was thrown\n" + ex,
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/Server/Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ public enum Status
Formatted,
Ignored,
Failed,
UnsupportedFile
UnsupportedFile,
}
2 changes: 1 addition & 1 deletion Src/CSharpier.FakeGenerators/Ignored.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class Ignored
"isStructuredTrivia",
"hasStructuredTrivia",
"containsSkippedText",
"containsAnnotations"
"containsAnnotations",
};

public static readonly Type[] Types = { typeof(TextSpan), typeof(SyntaxTree) };
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Generators/NodePrinterGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override object GetModel(GeneratorExecutionContext context)
{
PrinterName = fileName,
SyntaxNodeName = fileName + "Syntax",
VariableName = char.ToLower(fileName[0]) + fileName[1..]
VariableName = char.ToLower(fileName[0]) + fileName[1..],
})
.OrderBy(o => o.SyntaxNodeName)
.ToArray();
Expand Down
8 changes: 4 additions & 4 deletions Src/CSharpier.Playground/Controllers/FormatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CancellationToken cancellationToken
IncludeDocTree = true,
Width = model.PrintWidth,
IndentSize = model.IndentSize,
UseTabs = model.UseTabs
UseTabs = model.UseTabs,
},
sourceCodeKind,
cancellationToken
Expand All @@ -90,14 +90,14 @@ CancellationToken cancellationToken
Json = result.AST,
Doc = result.DocTree,
Errors = result.CompilationErrors.Select(this.ConvertError).ToList(),
SyntaxValidation = await comparer.CompareSourceAsync(CancellationToken.None)
SyntaxValidation = await comparer.CompareSourceAsync(CancellationToken.None),
};
}

private FormatError ConvertError(Diagnostic diagnostic)
{
var lineSpan = diagnostic.Location.SourceTree!.GetLineSpan(diagnostic.Location.SourceSpan);
return new FormatError { LineSpan = lineSpan, Description = diagnostic.ToString(), };
return new FormatError { LineSpan = lineSpan, Description = diagnostic.ToString() };
}

public string ExecuteApplication(string pathToExe, string workingDirectory, string args)
Expand All @@ -108,7 +108,7 @@ public string ExecuteApplication(string pathToExe, string workingDirectory, stri
RedirectStandardError = true,
WindowStyle = ProcessWindowStyle.Hidden,
WorkingDirectory = workingDirectory,
CreateNoWindow = true
CreateNoWindow = true,
};

var process = Process.Start(processStartInfo);
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Tests.Generators/FormattingTestsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override object GetModel(GeneratorExecutionContext context)
{
Name = Path.GetFileNameWithoutExtension(o.Path),
FileExtension = new FileInfo(o.Path).Directory!.Name,
UseTabs = Path.GetFileNameWithoutExtension(o.Path).EndsWith("_Tabs")
UseTabs = Path.GetFileNameWithoutExtension(o.Path).EndsWith("_Tabs"),
});

return new { Tests = tests };
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Tests/CSharpierIgnoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private string PrintWithoutFormatting(string code)
{
LineEnding = Environment.NewLine,
IndentSize = 4,
UseTabs = false
UseTabs = false,
}
)
.ReplaceLineEndings("\n");
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Tests/DocPrinterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ private static string Print(
{
Width = width,
TrimInitialLines = trimInitialLines,
UseTabs = useTabs
UseTabs = useTabs,
},
Environment.NewLine
)
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Tests/MissingTypeChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ public void Ensure_There_Are_No_Missing_Types()
"XmlNameAttributeSyntax",
"XmlNameSyntax",
"XmlPrefixSyntax",
"XmlTextAttributeSyntax"
"XmlTextAttributeSyntax",
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async Task SaveOptions(Func<Task<string?>> getFilePath, OptionsDto optionsDto)

await SaveOptions(
this.GetSolutionOptionsFileNameAsync,
new OptionsDto { RunOnSave = this.SolutionRunOnSave, }
new OptionsDto { RunOnSave = this.SolutionRunOnSave }
);

await SaveOptions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void StartProcess()
StandardErrorEncoding = Encoding.UTF8,
UseShellExecute = false,
CreateNoWindow = true,
EnvironmentVariables = { ["DOTNET_NOLOGO"] = "1" }
EnvironmentVariables = { ["DOTNET_NOLOGO"] = "1" },
};
this.process = new Process { StartInfo = processStartInfo };
this.process.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ private void DisplayFailureMessage()
new ProcessStartInfo
{
FileName = "https://csharpier.com/docs/EditorsTroubleshooting",
UseShellExecute = true
UseShellExecute = true,
}
);
}
},
};

InfoBarService.Instance.ShowInfoBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private bool StartProcess()
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
Environment = { ["DOTNET_NOLOGO"] = "1" }
Environment = { ["DOTNET_NOLOGO"] = "1" },
};
this.process = Process.Start(processStartInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public string FormatFile(string content, string fileName)
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
CreateNoWindow = true,
};
processStartInfo.EnvironmentVariables["DOTNET_NOLOGO"] = "1";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void UpdateText(string formattedText)
var parameter = new FormatFileParameter
{
fileContents = text,
fileName = document.FullName
fileName = document.FullName,
};
var result = csharpierProcess2.formatFile(parameter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public enum Status
{
Formatted,
Ignored,
Failed
Failed,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ IProcessKiller processKiller
this.logger.Debug("Installing CSharpier globally");
ProcessHelper.ExecuteCommand("dotnet", "tool install -g csharpier");
processKiller.KillRunningProcesses();
}
}
},
},
};

if (!isOnlyGlobal)
Expand Down Expand Up @@ -101,7 +101,7 @@ IProcessKiller processKiller
solutionBasePath
);
processKiller.KillRunningProcesses();
}
},
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions Src/CSharpier/CSharpFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool TryGetCompilationFailure(out CodeFormatterResult compilationResult)
{
Code = syntaxTree.ToString(),
CompilationErrors = diagnostics,
AST = printerOptions.IncludeAST ? PrintAST(rootNode) : string.Empty
AST = printerOptions.IncludeAST ? PrintAST(rootNode) : string.Empty,
};

return true;
Expand Down Expand Up @@ -172,7 +172,7 @@ await syntaxTree.GetRootAsync(cancellationToken),
{
return new CodeFormatterResult
{
FailureMessage = "We can't handle this deep of recursion yet."
FailureMessage = "We can't handle this deep of recursion yet.",
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions Src/CSharpier/CodeFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static Task<CodeFormatterResult> FormatAsync(
IndentSize = options.IndentSize,
EndOfLine = options.EndOfLine,
IncludeGenerated = options.IncludeGenerated,
Formatter = "csharp"
Formatter = "csharp",
},
cancellationToken
);
Expand Down Expand Up @@ -58,7 +58,7 @@ public static Task<CodeFormatterResult> FormatAsync(
UseTabs = options.IndentStyle == IndentStyle.Tabs,
IndentSize = options.IndentSize,
EndOfLine = options.EndOfLine,
Formatter = "csharp"
Formatter = "csharp",
},
SourceCodeKind.Regular,
cancellationToken
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier/CodeFormatterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public class CodeFormatterOptions
public enum IndentStyle
{
Spaces,
Tabs
Tabs,
}
2 changes: 1 addition & 1 deletion Src/CSharpier/DocPrinter/DocFitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void Push(Doc doc, PrintMode printMode, Indent indent)
var (currentIndent, currentMode, currentDoc) = newCommands switch
{
{ Count: > 0 } => newCommands.Pop(),
_ => remainingCommands.ElementAt(x++)
_ => remainingCommands.ElementAt(x++),
};

switch (currentDoc)
Expand Down
Loading

0 comments on commit 6cb3821

Please sign in to comment.