From 6cb38216c9e3abd545966e7f98b2b4025d6f8e8b Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sat, 17 Aug 2024 13:21:30 -0500 Subject: [PATCH] Format with 29 (#1322) --- .config/dotnet-tools.json | 2 +- Src/CSharpier.Cli.Tests/ServerTests.cs | 2 +- Src/CSharpier.Cli/CommandLineOptions.cs | 4 +- .../EditorConfig/ConfigFileParser.cs | 4 +- .../EditorConfig/EditorConfigParser.cs | 2 +- Src/CSharpier.Cli/EditorConfig/Globber.cs | 2 +- Src/CSharpier.Cli/FileToFormatInfo.cs | 4 +- Src/CSharpier.Cli/IgnoreFile.cs | 2 +- .../Options/ConfigurationFileOptions.cs | 4 +- Src/CSharpier.Cli/Options/OptionsProvider.cs | 2 +- .../PipeMultipleFilesFormatter.cs | 12 ++- .../Server/CSharpierServiceImplementation.cs | 2 +- Src/CSharpier.Cli/Server/Status.cs | 2 +- Src/CSharpier.FakeGenerators/Ignored.cs | 2 +- .../NodePrinterGenerator.cs | 2 +- .../Controllers/FormatController.cs | 8 +- .../FormattingTestsGenerator.cs | 2 +- Src/CSharpier.Tests/CSharpierIgnoreTests.cs | 2 +- Src/CSharpier.Tests/DocPrinterTests.cs | 2 +- Src/CSharpier.Tests/MissingTypeChecker.cs | 2 +- .../CSharpierOptions.cs | 2 +- .../CSharpierProcessPipeMultipleFiles.cs | 2 +- .../CSharpierProcessProvider.cs | 4 +- .../CSharpierProcessServer.cs | 2 +- .../CSharpierProcessSingleFile.cs | 2 +- .../FormattingService.cs | 2 +- .../ICSharpierProcess.cs | 2 +- .../InstallerService.cs | 6 +- Src/CSharpier/CSharpFormatter.cs | 4 +- Src/CSharpier/CodeFormatter.cs | 4 +- Src/CSharpier/CodeFormatterOptions.cs | 2 +- Src/CSharpier/DocPrinter/DocFitter.cs | 2 +- Src/CSharpier/DocPrinter/DocPrinter.cs | 2 +- Src/CSharpier/DocPrinter/Indent.cs | 8 +- Src/CSharpier/DocTypes/Doc.cs | 2 +- Src/CSharpier/DocTypes/DocUtilities.cs | 4 +- Src/CSharpier/DocTypes/LineDoc.cs | 2 +- Src/CSharpier/EndOfLine.cs | 2 +- .../CSharp/BooleanExpressionParser.cs | 4 +- .../Formatters/CSharp/PreprocessorSymbols.cs | 6 +- Src/CSharpier/GeneratedCodeUtilities.cs | 2 +- Src/CSharpier/SyntaxNodeComparer.cs | 4 +- .../SyntaxPrinter/ArgumentListLikeSyntax.cs | 83 +++++++++---------- Src/CSharpier/SyntaxPrinter/RightHandSide.cs | 73 ++++++++-------- .../AnonymousMethodExpression.cs | 2 +- .../BaseFieldDeclaration.cs | 2 +- .../SyntaxNodePrinters/BinaryExpression.cs | 2 +- .../CommonForEachStatement.cs | 27 +++--- .../ConditionalExpression.cs | 4 +- .../SyntaxNodePrinters/DelegateDeclaration.cs | 2 +- .../EnumMemberDeclaration.cs | 2 +- .../FileScopedNamespaceDeclaration.cs | 2 +- .../SyntaxNodePrinters/ForStatement.cs | 4 +- .../InterpolatedStringExpression.cs | 4 +- .../SyntaxNodePrinters/Interpolation.cs | 2 +- .../SyntaxNodePrinters/LabeledStatement.cs | 2 +- .../NamespaceDeclaration.cs | 2 +- .../SyntaxNodePrinters/Parameter.cs | 8 +- .../ParenthesizedLambdaExpression.cs | 9 +- .../SyntaxNodePrinters/QueryBody.cs | 2 +- .../SimpleLambdaExpression.cs | 9 +- .../SyntaxNodePrinters/SwitchSection.cs | 2 +- .../SyntaxNodePrinters/TryStatement.cs | 2 +- .../SyntaxNodePrinters/UsingStatement.cs | 2 +- .../SyntaxNodePrinters/WhileStatement.cs | 8 +- Src/CSharpier/SyntaxPrinter/Token.cs | 4 +- .../SyntaxPrinter/UsingDirectives.cs | 4 +- 67 files changed, 198 insertions(+), 199 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 958431769..8cd9d9f72 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "csharpier": { - "version": "0.28.1", + "version": "0.29.0", "commands": [ "dotnet-csharpier" ] diff --git a/Src/CSharpier.Cli.Tests/ServerTests.cs b/Src/CSharpier.Cli.Tests/ServerTests.cs index e89688199..d28eedf26 100644 --- a/Src/CSharpier.Cli.Tests/ServerTests.cs +++ b/Src/CSharpier.Cli.Tests/ServerTests.cs @@ -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( diff --git a/Src/CSharpier.Cli/CommandLineOptions.cs b/Src/CSharpier.Cli/CommandLineOptions.cs index 04b17041d..d12dfc1fd 100644 --- a/Src/CSharpier.Cli/CommandLineOptions.cs +++ b/Src/CSharpier.Cli/CommandLineOptions.cs @@ -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" }, @@ -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 => diff --git a/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs b/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs index 4e21971fc..8f1a0cd4b 100644 --- a/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs +++ b/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs @@ -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) @@ -44,7 +44,7 @@ public static ConfigFile Parse(string filePath, IFileSystem fileSystem) return new ConfigFile { IsRoot = configData?.Global["root"] == "true", - Sections = sections + Sections = sections, }; } } diff --git a/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs b/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs index b54a6eb4a..dade14f49 100644 --- a/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs +++ b/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs @@ -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) diff --git a/Src/CSharpier.Cli/EditorConfig/Globber.cs b/Src/CSharpier.Cli/EditorConfig/Globber.cs index 3ef3c2879..9d9a46a59 100644 --- a/Src/CSharpier.Cli/EditorConfig/Globber.cs +++ b/Src/CSharpier.Cli/EditorConfig/Globber.cs @@ -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("/")) diff --git a/Src/CSharpier.Cli/FileToFormatInfo.cs b/Src/CSharpier.Cli/FileToFormatInfo.cs index 195517b1c..3d8296899 100644 --- a/Src/CSharpier.Cli/FileToFormatInfo.cs +++ b/Src/CSharpier.Cli/FileToFormatInfo.cs @@ -31,7 +31,7 @@ CancellationToken cancellationToken Path = path, FileContents = fileContents, Encoding = encoding, - UnableToDetectEncoding = unableToDetectEncoding + UnableToDetectEncoding = unableToDetectEncoding, }; } @@ -41,7 +41,7 @@ public static FileToFormatInfo Create(string path, string fileContents, Encoding { Path = path, FileContents = fileContents, - Encoding = encoding + Encoding = encoding, }; } } diff --git a/Src/CSharpier.Cli/IgnoreFile.cs b/Src/CSharpier.Cli/IgnoreFile.cs index 1f1817701..5542f77c3 100644 --- a/Src/CSharpier.Cli/IgnoreFile.cs +++ b/Src/CSharpier.Cli/IgnoreFile.cs @@ -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) diff --git a/Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs b/Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs index e6cb1a16f..eeaaa72ac 100644 --- a/Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs +++ b/Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs @@ -26,7 +26,7 @@ internal class ConfigurationFileOptions UseTabs = matchingOverride.UseTabs, Width = matchingOverride.PrintWidth, EndOfLine = matchingOverride.EndOfLine, - Formatter = matchingOverride.Formatter + Formatter = matchingOverride.Formatter, }; } @@ -38,7 +38,7 @@ internal class ConfigurationFileOptions UseTabs = this.UseTabs, Width = this.PrintWidth, EndOfLine = this.EndOfLine, - Formatter = "csharp" + Formatter = "csharp", }; } diff --git a/Src/CSharpier.Cli/Options/OptionsProvider.cs b/Src/CSharpier.Cli/Options/OptionsProvider.cs index 2874bd609..2497b0be2 100644 --- a/Src/CSharpier.Cli/Options/OptionsProvider.cs +++ b/Src/CSharpier.Cli/Options/OptionsProvider.cs @@ -130,7 +130,7 @@ public string Serialize() { specified = this.specifiedConfigFile, csharpierConfigs = this.csharpierConfigs, - editorConfigs = this.editorConfigs + editorConfigs = this.editorConfigs, } ); } diff --git a/Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs b/Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs index 3fa202e0a..861455f5d 100644 --- a/Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs +++ b/Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs @@ -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 diff --git a/Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs b/Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs index 22f156ddd..11771c437 100644 --- a/Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs +++ b/Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs @@ -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, }; } } diff --git a/Src/CSharpier.Cli/Server/Status.cs b/Src/CSharpier.Cli/Server/Status.cs index d2fefb166..2748eae81 100644 --- a/Src/CSharpier.Cli/Server/Status.cs +++ b/Src/CSharpier.Cli/Server/Status.cs @@ -5,5 +5,5 @@ public enum Status Formatted, Ignored, Failed, - UnsupportedFile + UnsupportedFile, } diff --git a/Src/CSharpier.FakeGenerators/Ignored.cs b/Src/CSharpier.FakeGenerators/Ignored.cs index c6cca5d3b..64749e215 100644 --- a/Src/CSharpier.FakeGenerators/Ignored.cs +++ b/Src/CSharpier.FakeGenerators/Ignored.cs @@ -18,7 +18,7 @@ public static class Ignored "isStructuredTrivia", "hasStructuredTrivia", "containsSkippedText", - "containsAnnotations" + "containsAnnotations", }; public static readonly Type[] Types = { typeof(TextSpan), typeof(SyntaxTree) }; diff --git a/Src/CSharpier.Generators/NodePrinterGenerator.cs b/Src/CSharpier.Generators/NodePrinterGenerator.cs index 1c12a959d..c8f24024c 100644 --- a/Src/CSharpier.Generators/NodePrinterGenerator.cs +++ b/Src/CSharpier.Generators/NodePrinterGenerator.cs @@ -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(); diff --git a/Src/CSharpier.Playground/Controllers/FormatController.cs b/Src/CSharpier.Playground/Controllers/FormatController.cs index 2fd4c262c..07a74a617 100644 --- a/Src/CSharpier.Playground/Controllers/FormatController.cs +++ b/Src/CSharpier.Playground/Controllers/FormatController.cs @@ -69,7 +69,7 @@ CancellationToken cancellationToken IncludeDocTree = true, Width = model.PrintWidth, IndentSize = model.IndentSize, - UseTabs = model.UseTabs + UseTabs = model.UseTabs, }, sourceCodeKind, cancellationToken @@ -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) @@ -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); diff --git a/Src/CSharpier.Tests.Generators/FormattingTestsGenerator.cs b/Src/CSharpier.Tests.Generators/FormattingTestsGenerator.cs index 5b78aa36c..2320850c9 100644 --- a/Src/CSharpier.Tests.Generators/FormattingTestsGenerator.cs +++ b/Src/CSharpier.Tests.Generators/FormattingTestsGenerator.cs @@ -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 }; diff --git a/Src/CSharpier.Tests/CSharpierIgnoreTests.cs b/Src/CSharpier.Tests/CSharpierIgnoreTests.cs index 9178aa906..264d3e1d2 100644 --- a/Src/CSharpier.Tests/CSharpierIgnoreTests.cs +++ b/Src/CSharpier.Tests/CSharpierIgnoreTests.cs @@ -71,7 +71,7 @@ private string PrintWithoutFormatting(string code) { LineEnding = Environment.NewLine, IndentSize = 4, - UseTabs = false + UseTabs = false, } ) .ReplaceLineEndings("\n"); diff --git a/Src/CSharpier.Tests/DocPrinterTests.cs b/Src/CSharpier.Tests/DocPrinterTests.cs index 66591c15e..a5604a296 100644 --- a/Src/CSharpier.Tests/DocPrinterTests.cs +++ b/Src/CSharpier.Tests/DocPrinterTests.cs @@ -848,7 +848,7 @@ private static string Print( { Width = width, TrimInitialLines = trimInitialLines, - UseTabs = useTabs + UseTabs = useTabs, }, Environment.NewLine ) diff --git a/Src/CSharpier.Tests/MissingTypeChecker.cs b/Src/CSharpier.Tests/MissingTypeChecker.cs index 137a4c616..6f1f78495 100644 --- a/Src/CSharpier.Tests/MissingTypeChecker.cs +++ b/Src/CSharpier.Tests/MissingTypeChecker.cs @@ -113,6 +113,6 @@ public void Ensure_There_Are_No_Missing_Types() "XmlNameAttributeSyntax", "XmlNameSyntax", "XmlPrefixSyntax", - "XmlTextAttributeSyntax" + "XmlTextAttributeSyntax", }; } diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs index ac603689e..7ef8fbab3 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierOptions.cs @@ -171,7 +171,7 @@ async Task SaveOptions(Func> getFilePath, OptionsDto optionsDto) await SaveOptions( this.GetSolutionOptionsFileNameAsync, - new OptionsDto { RunOnSave = this.SolutionRunOnSave, } + new OptionsDto { RunOnSave = this.SolutionRunOnSave } ); await SaveOptions( diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessPipeMultipleFiles.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessPipeMultipleFiles.cs index c00338168..859f965bb 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessPipeMultipleFiles.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessPipeMultipleFiles.cs @@ -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(); diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessProvider.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessProvider.cs index 7cdd737e9..78b200fcd 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessProvider.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessProvider.cs @@ -312,10 +312,10 @@ private void DisplayFailureMessage() new ProcessStartInfo { FileName = "https://csharpier.com/docs/EditorsTroubleshooting", - UseShellExecute = true + UseShellExecute = true, } ); - } + }, }; InfoBarService.Instance.ShowInfoBar( diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessServer.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessServer.cs index bd9b34abc..e261bf242 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessServer.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessServer.cs @@ -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); diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessSingleFile.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessSingleFile.cs index aeafbbaa1..0173bd4d4 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessSingleFile.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/CSharpierProcessSingleFile.cs @@ -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"; diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/FormattingService.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/FormattingService.cs index 79b8726a6..cca21723d 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/FormattingService.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/FormattingService.cs @@ -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); diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/ICSharpierProcess.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/ICSharpierProcess.cs index a48485f4f..79c6d9fbb 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/ICSharpierProcess.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/ICSharpierProcess.cs @@ -30,6 +30,6 @@ public enum Status { Formatted, Ignored, - Failed + Failed, } } diff --git a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/InstallerService.cs b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/InstallerService.cs index 1849a55ad..4106fc76e 100644 --- a/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/InstallerService.cs +++ b/Src/CSharpier.VisualStudio/CSharpier.VisualStudioShared/InstallerService.cs @@ -67,8 +67,8 @@ IProcessKiller processKiller this.logger.Debug("Installing CSharpier globally"); ProcessHelper.ExecuteCommand("dotnet", "tool install -g csharpier"); processKiller.KillRunningProcesses(); - } - } + }, + }, }; if (!isOnlyGlobal) @@ -101,7 +101,7 @@ IProcessKiller processKiller solutionBasePath ); processKiller.KillRunningProcesses(); - } + }, } ); } diff --git a/Src/CSharpier/CSharpFormatter.cs b/Src/CSharpier/CSharpFormatter.cs index 76cc54c6a..46ad87820 100644 --- a/Src/CSharpier/CSharpFormatter.cs +++ b/Src/CSharpier/CSharpFormatter.cs @@ -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; @@ -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.", }; } } diff --git a/Src/CSharpier/CodeFormatter.cs b/Src/CSharpier/CodeFormatter.cs index cae0b26d0..47a4466ef 100644 --- a/Src/CSharpier/CodeFormatter.cs +++ b/Src/CSharpier/CodeFormatter.cs @@ -28,7 +28,7 @@ public static Task FormatAsync( IndentSize = options.IndentSize, EndOfLine = options.EndOfLine, IncludeGenerated = options.IncludeGenerated, - Formatter = "csharp" + Formatter = "csharp", }, cancellationToken ); @@ -58,7 +58,7 @@ public static Task FormatAsync( UseTabs = options.IndentStyle == IndentStyle.Tabs, IndentSize = options.IndentSize, EndOfLine = options.EndOfLine, - Formatter = "csharp" + Formatter = "csharp", }, SourceCodeKind.Regular, cancellationToken diff --git a/Src/CSharpier/CodeFormatterOptions.cs b/Src/CSharpier/CodeFormatterOptions.cs index ef6841089..c4815e59b 100644 --- a/Src/CSharpier/CodeFormatterOptions.cs +++ b/Src/CSharpier/CodeFormatterOptions.cs @@ -12,5 +12,5 @@ public class CodeFormatterOptions public enum IndentStyle { Spaces, - Tabs + Tabs, } diff --git a/Src/CSharpier/DocPrinter/DocFitter.cs b/Src/CSharpier/DocPrinter/DocFitter.cs index 3ff8f8cb5..fa4b7f677 100644 --- a/Src/CSharpier/DocPrinter/DocFitter.cs +++ b/Src/CSharpier/DocPrinter/DocFitter.cs @@ -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) diff --git a/Src/CSharpier/DocPrinter/DocPrinter.cs b/Src/CSharpier/DocPrinter/DocPrinter.cs index 03c5440a4..0bdc3895c 100644 --- a/Src/CSharpier/DocPrinter/DocPrinter.cs +++ b/Src/CSharpier/DocPrinter/DocPrinter.cs @@ -399,5 +399,5 @@ internal enum PrintMode { Flat, Break, - ForceFlat + ForceFlat, } diff --git a/Src/CSharpier/DocPrinter/Indent.cs b/Src/CSharpier/DocPrinter/Indent.cs index 8ee95c702..1fe31d3d1 100644 --- a/Src/CSharpier/DocPrinter/Indent.cs +++ b/Src/CSharpier/DocPrinter/Indent.cs @@ -49,7 +49,7 @@ public Indent IncreaseIndent(Indent indent) return new Indent { Value = indent.Value + "\t", - Length = indent.Length + this.PrinterOptions.IndentSize + Length = indent.Length + this.PrinterOptions.IndentSize, }; } else @@ -57,7 +57,7 @@ public Indent IncreaseIndent(Indent indent) return new Indent { Value = indent.Value + new string(' ', this.PrinterOptions.IndentSize), - Length = indent.Length + this.PrinterOptions.IndentSize + Length = indent.Length + this.PrinterOptions.IndentSize, }; } } @@ -73,7 +73,7 @@ public Indent AddAlign(Indent indent, int alignment) return new Indent { Value = indent.Value + new string(' ', alignment), - Length = indent.Length + alignment + Length = indent.Length + alignment, }; } } @@ -145,7 +145,7 @@ private Indent MakeIndentWithTypesForTabs(Indent indent, IIndentType nextIndentT { Length = length, Value = value.ToString(), - TypesForTabs = types + TypesForTabs = types, }; } } diff --git a/Src/CSharpier/DocTypes/Doc.cs b/Src/CSharpier/DocTypes/Doc.cs index e7e423732..10edb115b 100644 --- a/Src/CSharpier/DocTypes/Doc.cs +++ b/Src/CSharpier/DocTypes/Doc.cs @@ -160,7 +160,7 @@ public static AlwaysFits AlwaysFits(Doc printedTrivia) internal enum CommentType { SingleLine, - MultiLine + MultiLine, } interface IHasContents diff --git a/Src/CSharpier/DocTypes/DocUtilities.cs b/Src/CSharpier/DocTypes/DocUtilities.cs index d2792bc2a..8338eb0ef 100644 --- a/Src/CSharpier/DocTypes/DocUtilities.cs +++ b/Src/CSharpier/DocTypes/DocUtilities.cs @@ -16,7 +16,7 @@ public static bool ContainsBreak(Doc doc) IHasContents hasContents => ContainsBreak(hasContents.Contents), Concat concat => concat.Contents.Any(ContainsBreak), IfBreak ifBreak => ContainsBreak(ifBreak.FlatContents), - _ => false + _ => false, }; } @@ -28,7 +28,7 @@ private static bool CheckForBreak(Doc doc) HardLine => true, LiteralLine => true, BreakParent => true, - _ => false + _ => false, }; } diff --git a/Src/CSharpier/DocTypes/LineDoc.cs b/Src/CSharpier/DocTypes/LineDoc.cs index 47eed4754..432262fd5 100644 --- a/Src/CSharpier/DocTypes/LineDoc.cs +++ b/Src/CSharpier/DocTypes/LineDoc.cs @@ -6,7 +6,7 @@ public enum LineType { Normal, Hard, - Soft + Soft, } public LineType Type { get; set; } diff --git a/Src/CSharpier/EndOfLine.cs b/Src/CSharpier/EndOfLine.cs index 192a0d2aa..53e743cad 100644 --- a/Src/CSharpier/EndOfLine.cs +++ b/Src/CSharpier/EndOfLine.cs @@ -4,5 +4,5 @@ public enum EndOfLine { Auto, CRLF, - LF + LF, } diff --git a/Src/CSharpier/Formatters/CSharp/BooleanExpressionParser.cs b/Src/CSharpier/Formatters/CSharp/BooleanExpressionParser.cs index b497800c2..8c8f62f28 100644 --- a/Src/CSharpier/Formatters/CSharp/BooleanExpressionParser.cs +++ b/Src/CSharpier/Formatters/CSharp/BooleanExpressionParser.cs @@ -211,7 +211,7 @@ private static BooleanExpression BuildFunction(Queue tokens) return new BooleanExpression { Function = lambda.Compile(), - Parameters = variables.Select(o => o.Key).ToList() + Parameters = variables.Select(o => o.Key).ToList(), }; } } @@ -227,7 +227,7 @@ internal enum TokenType Equals, True, False, - NotEquals + NotEquals, } internal class Token diff --git a/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs b/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs index 45d7e22e6..3b2ed0ff4 100644 --- a/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs +++ b/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs @@ -86,7 +86,7 @@ public override void VisitElseDirectiveTrivia(ElseDirectiveTriviaSyntax node) new BooleanExpression { Parameters = combination.Where(o => o.Value).Select(o => o.Key).ToList(), - Function = o => o.All(p => p.Value) + Function = o => o.All(p => p.Value), } ); } @@ -162,11 +162,11 @@ private static List> GenerateCombinations(List { var falseCombination = new Dictionary(subCombination) { - { parameterNames[0], false } + { parameterNames[0], false }, }; var trueCombination = new Dictionary(subCombination) { - { parameterNames[0], true } + { parameterNames[0], true }, }; combinations.Add(falseCombination); diff --git a/Src/CSharpier/GeneratedCodeUtilities.cs b/Src/CSharpier/GeneratedCodeUtilities.cs index dde39d1ad..638126326 100644 --- a/Src/CSharpier/GeneratedCodeUtilities.cs +++ b/Src/CSharpier/GeneratedCodeUtilities.cs @@ -26,7 +26,7 @@ public static bool IsGeneratedCodeFile(string filePath) private static readonly string[] AutoGeneratedStrings = new[] { " Doc.Concat( - Doc.GroupWithId( - $"LambdaArguments{lambdaId}", - Doc.Indent( - Doc.SoftLine, - Argument.PrintModifiers(arg, context), - SimpleLambdaExpression.PrintHead(lambda, context) - ) - ), - Doc.IfBreak( - Doc.Indent(Doc.Group(SimpleLambdaExpression.PrintBody(lambda, context))), - SimpleLambdaExpression.PrintBody(lambda, context), - $"LambdaArguments{lambdaId}" - ), - lambda.Body - is BlockSyntax - or ObjectCreationExpressionSyntax - or AnonymousObjectCreationExpressionSyntax - ? Doc.IfBreak(Doc.SoftLine, Doc.Null, $"LambdaArguments{lambdaId}") - : Doc.SoftLine + [{ Expression: SimpleLambdaExpressionSyntax lambda } arg] => Doc.Concat( + Doc.GroupWithId( + $"LambdaArguments{lambdaId}", + Doc.Indent( + Doc.SoftLine, + Argument.PrintModifiers(arg, context), + SimpleLambdaExpression.PrintHead(lambda, context) + ) ), - [{ Expression: ParenthesizedLambdaExpressionSyntax lambda } arg] - when lambda is { ParameterList.Parameters: [], Block: { } } - => Doc.Concat( - Doc.GroupWithId( - $"LambdaArguments{lambdaId}", - Doc.Indent( - Doc.SoftLine, - Argument.PrintModifiers(arg, context), - ParenthesizedLambdaExpression.PrintHead(lambda, context) - ) - ), - Doc.IndentIfBreak( - ParenthesizedLambdaExpression.PrintBody(lambda, context), - $"LambdaArguments{lambdaId}" - ), - Doc.IfBreak(Doc.SoftLine, Doc.Null, $"LambdaArguments{lambdaId}") + Doc.IfBreak( + Doc.Indent(Doc.Group(SimpleLambdaExpression.PrintBody(lambda, context))), + SimpleLambdaExpression.PrintBody(lambda, context), + $"LambdaArguments{lambdaId}" ), - [_, ..] - => Doc.Concat( + lambda.Body + is BlockSyntax + or ObjectCreationExpressionSyntax + or AnonymousObjectCreationExpressionSyntax + ? Doc.IfBreak(Doc.SoftLine, Doc.Null, $"LambdaArguments{lambdaId}") + : Doc.SoftLine + ), + [{ Expression: ParenthesizedLambdaExpressionSyntax lambda } arg] + when lambda is { ParameterList.Parameters: [], Block: { } } => Doc.Concat( + Doc.GroupWithId( + $"LambdaArguments{lambdaId}", Doc.Indent( Doc.SoftLine, - SeparatedSyntaxList.Print(arguments, Argument.Print, Doc.Line, context) - ), - Doc.SoftLine + Argument.PrintModifiers(arg, context), + ParenthesizedLambdaExpression.PrintHead(lambda, context) + ) + ), + Doc.IndentIfBreak( + ParenthesizedLambdaExpression.PrintBody(lambda, context), + $"LambdaArguments{lambdaId}" + ), + Doc.IfBreak(Doc.SoftLine, Doc.Null, $"LambdaArguments{lambdaId}") + ), + [_, ..] => Doc.Concat( + Doc.Indent( + Doc.SoftLine, + SeparatedSyntaxList.Print(arguments, Argument.Print, Doc.Line, context) ), - _ => Doc.Null + Doc.SoftLine + ), + _ => Doc.Null, }; return Doc.Concat( diff --git a/Src/CSharpier/SyntaxPrinter/RightHandSide.cs b/Src/CSharpier/SyntaxPrinter/RightHandSide.cs index a35b626ba..29f15af56 100644 --- a/Src/CSharpier/SyntaxPrinter/RightHandSide.cs +++ b/Src/CSharpier/SyntaxPrinter/RightHandSide.cs @@ -16,37 +16,40 @@ FormattingContext context return layout switch { - Layout.BasicConcatWithoutLine - => Doc.Concat(leftDoc, operatorDoc, Node.Print(rightNode, context)), - Layout.BasicConcatWithSpace - => Doc.Concat(leftDoc, operatorDoc, " ", Node.Print(rightNode, context)), - Layout.BreakAfterOperator - => Doc.Group( - Doc.Group(leftDoc), - operatorDoc, - Doc.Group(Doc.Indent(Doc.Line, Node.Print(rightNode, context))) - ), - Layout.Chain - => Doc.Concat( - Doc.Group(leftDoc), - operatorDoc, - Doc.Line, - Node.Print(rightNode, context) - ), - Layout.ChainTail - => Doc.Concat( - Doc.Group(leftDoc), - operatorDoc, - Doc.Indent(Doc.Line, Node.Print(rightNode, context)) - ), - Layout.Fluid - => Doc.Group( - Doc.Group(leftDoc), - operatorDoc, - Doc.GroupWithId(groupId, Doc.Indent(Doc.Line)), - Doc.IndentIfBreak(Node.Print(rightNode, context), groupId) - ), - _ => throw new Exception("The layout type of " + layout + " was not handled.") + Layout.BasicConcatWithoutLine => Doc.Concat( + leftDoc, + operatorDoc, + Node.Print(rightNode, context) + ), + Layout.BasicConcatWithSpace => Doc.Concat( + leftDoc, + operatorDoc, + " ", + Node.Print(rightNode, context) + ), + Layout.BreakAfterOperator => Doc.Group( + Doc.Group(leftDoc), + operatorDoc, + Doc.Group(Doc.Indent(Doc.Line, Node.Print(rightNode, context))) + ), + Layout.Chain => Doc.Concat( + Doc.Group(leftDoc), + operatorDoc, + Doc.Line, + Node.Print(rightNode, context) + ), + Layout.ChainTail => Doc.Concat( + Doc.Group(leftDoc), + operatorDoc, + Doc.Indent(Doc.Line, Node.Print(rightNode, context)) + ), + Layout.Fluid => Doc.Group( + Doc.Group(leftDoc), + operatorDoc, + Doc.GroupWithId(groupId, Doc.Indent(Doc.Line)), + Doc.IndentIfBreak(Node.Print(rightNode, context), groupId) + ), + _ => throw new Exception("The layout type of " + layout + " was not handled."), }; } @@ -102,8 +105,7 @@ is ObjectCreationExpressionSyntax or InterpolatedStringExpressionSyntax { StringStartToken.RawKind: (int)SyntaxKind.InterpolatedMultiLineRawStringStartToken - } - => Layout.BasicConcatWithSpace, + } => Layout.BasicConcatWithSpace, InitializerExpressionSyntax => Layout.BasicConcatWithoutLine, BinaryExpressionSyntax or CastExpressionSyntax { Type: GenericNameSyntax } @@ -125,9 +127,8 @@ or LiteralExpressionSyntax // TODO ditch fluid? // or MemberAccessExpressionSyntax or StackAllocArrayCreationExpressionSyntax - or QueryExpressionSyntax - => Layout.BreakAfterOperator, - _ => Layout.Fluid + or QueryExpressionSyntax => Layout.BreakAfterOperator, + _ => Layout.Fluid, }; } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousMethodExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousMethodExpression.cs index 636096e4a..c923b23ed 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousMethodExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousMethodExpression.cs @@ -7,7 +7,7 @@ public static Doc Print(AnonymousMethodExpressionSyntax node, FormattingContext var docs = new List { Modifiers.Print(node.Modifiers, context), - Token.Print(node.DelegateKeyword, context) + Token.Print(node.DelegateKeyword, context), }; if (node.ParameterList != null) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseFieldDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseFieldDeclaration.cs index 89483bac8..c4dba0534 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseFieldDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseFieldDeclaration.cs @@ -7,7 +7,7 @@ public static Doc Print(BaseFieldDeclarationSyntax node, FormattingContext conte var docs = new List { AttributeLists.Print(node, node.AttributeLists, context), - Modifiers.PrintSorted(node.Modifiers, context) + Modifiers.PrintSorted(node.Modifiers, context), }; if (node is EventFieldDeclarationSyntax eventFieldDeclarationSyntax) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryExpression.cs index ffd9da352..7387952eb 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryExpression.cs @@ -174,7 +174,7 @@ private static int GetPrecedence(SyntaxToken syntaxToken) SyntaxKind.AsteriskToken => 12, SyntaxKind.SlashToken => 12, SyntaxKind.PercentToken => 12, - _ => throw new Exception($"No precedence defined for {syntaxToken}") + _ => throw new Exception($"No precedence defined for {syntaxToken}"), }; } } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CommonForEachStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CommonForEachStatement.cs index d59bb9652..6c54c129b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CommonForEachStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CommonForEachStatement.cs @@ -6,15 +6,16 @@ public static Doc Print(CommonForEachStatementSyntax node, FormattingContext con { var variable = node switch { - ForEachStatementSyntax forEach - => Doc.Concat( - Node.Print(forEach.Type, context), - " ", - Token.Print(forEach.Identifier, context) - ), - ForEachVariableStatementSyntax forEachVariable - => Node.Print(forEachVariable.Variable, context), - _ => Doc.Null + ForEachStatementSyntax forEach => Doc.Concat( + Node.Print(forEach.Type, context), + " ", + Token.Print(forEach.Identifier, context) + ), + ForEachVariableStatementSyntax forEachVariable => Node.Print( + forEachVariable.Variable, + context + ), + _ => Doc.Null, }; var docs = Doc.Concat( @@ -40,9 +41,11 @@ ForEachVariableStatementSyntax forEachVariable ), node.Statement switch { - CommonForEachStatementSyntax - => Doc.Group(Doc.HardLine, Node.Print(node.Statement, context)), - _ => OptionalBraces.Print(node.Statement, context) + CommonForEachStatementSyntax => Doc.Group( + Doc.HardLine, + Node.Print(node.Statement, context) + ), + _ => OptionalBraces.Print(node.Statement, context), } ); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalExpression.cs index 2e31f47bc..e75f859f1 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalExpression.cs @@ -39,7 +39,7 @@ FormattingContext context Doc.Concat(whenTrue), Doc.Line, Token.PrintWithSuffix(node.ColonToken, " ", context), - Doc.Concat(whenFalse) + Doc.Concat(whenFalse), ]; Doc[] outerContents = @@ -60,7 +60,7 @@ FormattingContext context node.Parent is ConditionalExpressionSyntax or ArgumentSyntax or ReturnStatementSyntax || node.Condition is InvocationExpressionSyntax ? Doc.Indent(innerContents) - : Doc.Indent(innerContents) + : Doc.Indent(innerContents), ]; return node.Parent is ConditionalExpressionSyntax diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DelegateDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DelegateDeclaration.cs index ae339b1fb..029dba5ce 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DelegateDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DelegateDeclaration.cs @@ -10,7 +10,7 @@ public static Doc Print(DelegateDeclarationSyntax node, FormattingContext contex Modifiers.PrintSorted(node.Modifiers, context), Token.PrintWithSuffix(node.DelegateKeyword, " ", context), Node.Print(node.ReturnType, context), - { " ", Token.Print(node.Identifier, context) } + { " ", Token.Print(node.Identifier, context) }, }; if (node.TypeParameterList != null) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EnumMemberDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EnumMemberDeclaration.cs index ab34d76c5..6c0460187 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EnumMemberDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EnumMemberDeclaration.cs @@ -8,7 +8,7 @@ public static Doc Print(EnumMemberDeclarationSyntax node, FormattingContext cont { AttributeLists.Print(node, node.AttributeLists, context), Modifiers.Print(node.Modifiers, context), - Token.Print(node.Identifier, context) + Token.Print(node.Identifier, context), }; if (node.EqualsValue != null) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FileScopedNamespaceDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FileScopedNamespaceDeclaration.cs index 57e6fc5d7..96bf3049c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FileScopedNamespaceDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FileScopedNamespaceDeclaration.cs @@ -13,7 +13,7 @@ public static Doc Print(FileScopedNamespaceDeclarationSyntax node, FormattingCon Node.Print(node.Name, context), Token.Print(node.SemicolonToken, context), Doc.HardLine, - Doc.HardLine + Doc.HardLine, }; NamespaceLikePrinter.Print(node, docs, context); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ForStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ForStatement.cs index 97854cc28..a246b5c3b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ForStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ForStatement.cs @@ -44,8 +44,8 @@ public static Doc Print(ForStatementSyntax node, FormattingContext context) node.Statement switch { ForStatementSyntax => Doc.Group(Doc.HardLine, Node.Print(node.Statement, context)), - _ => OptionalBraces.Print(node.Statement, context) - } + _ => OptionalBraces.Print(node.Statement, context), + }, }; return Doc.Concat(docs); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringExpression.cs index bcfb74baa..9d1a7b6db 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringExpression.cs @@ -27,7 +27,7 @@ public static Doc Print(InterpolatedStringExpressionSyntax node, FormattingConte var docs = new List { - Token.PrintWithoutLeadingTrivia(node.StringStartToken, context) + Token.PrintWithoutLeadingTrivia(node.StringStartToken, context), }; docs.AddRange(node.Contents.Select(o => Node.Print(o, context))); @@ -51,7 +51,7 @@ private static Doc RawString(InterpolatedStringExpressionSyntax node, Formatting var contents = new List { Token.Print(node.StringStartToken, context), - lastLineIsIndented ? Doc.HardLineNoTrim : Doc.LiteralLine + lastLineIsIndented ? Doc.HardLineNoTrim : Doc.LiteralLine, }; foreach (var content in node.Contents) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Interpolation.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Interpolation.cs index 26e24dfee..5da86c342 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Interpolation.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Interpolation.cs @@ -7,7 +7,7 @@ public static Doc Print(InterpolationSyntax node, FormattingContext context) var docs = new List { Token.Print(node.OpenBraceToken, context), - Node.Print(node.Expression, context) + Node.Print(node.Expression, context), }; if (node.AlignmentClause != null) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LabeledStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LabeledStatement.cs index 0961bcfc2..8cf8afe53 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LabeledStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LabeledStatement.cs @@ -9,7 +9,7 @@ public static Doc Print(LabeledStatementSyntax node, FormattingContext context) ExtraNewLines.Print(node), AttributeLists.Print(node, node.AttributeLists, context), Token.Print(node.Identifier, context), - Token.Print(node.ColonToken, context) + Token.Print(node.ColonToken, context), }; if (node.Statement is BlockSyntax blockSyntax) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NamespaceDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NamespaceDeclaration.cs index 4f791b774..52b4554b1 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NamespaceDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NamespaceDeclaration.cs @@ -10,7 +10,7 @@ public static Doc Print(NamespaceDeclarationSyntax node, FormattingContext conte Modifiers.Print(node.Modifiers, context), Token.Print(node.NamespaceKeyword, context), " ", - Node.Print(node.Name, context) + Node.Print(node.Name, context), }; var innerDocs = new List(); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs index 7cbbc10b7..d5630ad36 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs @@ -30,10 +30,8 @@ public static Doc Print(ParameterSyntax node, FormattingContext context) docs.Add(EqualsValueClause.Print(node.Default, context)); } - return hasAttribute - ? Doc.GroupWithId(groupId, docs) - : docs.Count == 1 - ? docs[0] - : Doc.Concat(docs); + return hasAttribute ? Doc.GroupWithId(groupId, docs) + : docs.Count == 1 ? docs[0] + : Doc.Concat(docs); } } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedLambdaExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedLambdaExpression.cs index 2e76f8fa9..80c949dd4 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedLambdaExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedLambdaExpression.cs @@ -27,11 +27,10 @@ public static Doc PrintBody(ParenthesizedLambdaExpressionSyntax node, Formatting { return node.Body switch { - BlockSyntax block - => Doc.Concat( - block.Statements.Count > 0 ? Doc.HardLine : " ", - Block.Print(block, context) - ), + BlockSyntax block => Doc.Concat( + block.Statements.Count > 0 ? Doc.HardLine : " ", + Block.Print(block, context) + ), _ => Doc.Group(Doc.Indent(Doc.Line, Node.Print(node.Body, context))), }; } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryBody.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryBody.cs index 701bc1d70..f983f443c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryBody.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryBody.cs @@ -6,7 +6,7 @@ public static Doc Print(QueryBodySyntax node, FormattingContext context) { var docs = new List { - Doc.Join(Doc.Line, node.Clauses.Select(o => Node.Print(o, context))) + Doc.Join(Doc.Line, node.Clauses.Select(o => Node.Print(o, context))), }; if (node.Clauses.Count > 0) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs index c001c09e5..4f5ca08cb 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs @@ -22,10 +22,11 @@ public static Doc PrintBody(SimpleLambdaExpressionSyntax node, FormattingContext return node.Body switch { BlockSyntax blockSyntax => Block.Print(blockSyntax, context), - ObjectCreationExpressionSyntax - or AnonymousObjectCreationExpressionSyntax - => Doc.Group(" ", Node.Print(node.Body, context)), - _ => Doc.Indent(Doc.Line, Node.Print(node.Body, context)) + ObjectCreationExpressionSyntax or AnonymousObjectCreationExpressionSyntax => Doc.Group( + " ", + Node.Print(node.Body, context) + ), + _ => Doc.Indent(Doc.Line, Node.Print(node.Body, context)), }; } } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchSection.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchSection.cs index db5fdf400..f3f6d08da 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchSection.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchSection.cs @@ -6,7 +6,7 @@ public static Doc Print(SwitchSectionSyntax node, FormattingContext context) { var docs = new List { - Doc.Join(Doc.HardLine, node.Labels.Select(o => Node.Print(o, context))) + Doc.Join(Doc.HardLine, node.Labels.Select(o => Node.Print(o, context))), }; if (node.Statements is [BlockSyntax blockSyntax]) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs index 30e715e84..10abaf7b1 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs @@ -11,7 +11,7 @@ public static Doc Print(TryStatementSyntax node, FormattingContext context) Token.Print(node.TryKeyword, context), Block.Print(node.Block, context), node.Catches.Any() ? Doc.HardLine : Doc.Null, - Doc.Join(Doc.HardLine, node.Catches.Select(o => CatchClause.Print(o, context))) + Doc.Join(Doc.HardLine, node.Catches.Select(o => CatchClause.Print(o, context))), }; if (node.Finally != null) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingStatement.cs index 37e058074..6b2b7073b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingStatement.cs @@ -25,7 +25,7 @@ public static Doc Print(UsingStatementSyntax node, FormattingContext context) ), Token.Print(node.CloseParenToken, context), Doc.IfBreak(Doc.Null, Doc.SoftLine) - ) + ), }; if (node.Statement is UsingStatementSyntax) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhileStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhileStatement.cs index d87597509..0f01e9282 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhileStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhileStatement.cs @@ -18,9 +18,11 @@ public static Doc Print(WhileStatementSyntax node, FormattingContext context) ), node.Statement switch { - WhileStatementSyntax - => Doc.Group(Doc.HardLine, Node.Print(node.Statement, context)), - _ => OptionalBraces.Print(node.Statement, context) + WhileStatementSyntax => Doc.Group( + Doc.HardLine, + Node.Print(node.Statement, context) + ), + _ => OptionalBraces.Print(node.Statement, context), } ); diff --git a/Src/CSharpier/SyntaxPrinter/Token.cs b/Src/CSharpier/SyntaxPrinter/Token.cs index 6d087a8d1..f7291e2c7 100644 --- a/Src/CSharpier/SyntaxPrinter/Token.cs +++ b/Src/CSharpier/SyntaxPrinter/Token.cs @@ -85,7 +85,7 @@ is InterpolatedStringExpressionSyntax var contents = new List { linesIncludingQuotes[0], - lastLineIsIndented ? Doc.HardLineNoTrim : Doc.LiteralLine + lastLineIsIndented ? Doc.HardLineNoTrim : Doc.LiteralLine, }; var lines = syntaxToken.ValueText.Split(lineSeparators, StringSplitOptions.None); @@ -138,7 +138,7 @@ or SyntaxKind.InterpolatedRawStringEndToken { <= 0 => Doc.Null, 1 => docs.First(), - _ => Doc.Concat(docs) + _ => Doc.Concat(docs), }; } diff --git a/Src/CSharpier/SyntaxPrinter/UsingDirectives.cs b/Src/CSharpier/SyntaxPrinter/UsingDirectives.cs index f8da34f7a..b0131add7 100644 --- a/Src/CSharpier/SyntaxPrinter/UsingDirectives.cs +++ b/Src/CSharpier/SyntaxPrinter/UsingDirectives.cs @@ -168,7 +168,7 @@ FormattingContext context new UsingData { Using = usingDirective, - LeadingTrivia = PrintLeadingTrivia(usingDirective) + LeadingTrivia = PrintLeadingTrivia(usingDirective), } ); } @@ -184,7 +184,7 @@ FormattingContext context var usingData = new UsingData { Using = usingDirective, - LeadingTrivia = !openIf ? PrintLeadingTrivia(usingDirective) : Doc.Null + LeadingTrivia = !openIf ? PrintLeadingTrivia(usingDirective) : Doc.Null, }; if (usingDirective.GlobalKeyword.RawSyntaxKind() != SyntaxKind.None)