diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b439c8ade..a0f59deb2 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "csharpier": { - "version": "0.29.2", + "version": "0.30.1", "commands": [ "dotnet-csharpier" ] diff --git a/CHANGELOG.md b/CHANGELOG.md index e8a4d5130..7ef0f0c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,118 @@ -# 0.29.2 +# 0.30.1 +## What's Changed +Revert tool command back to `dotnet-csharpier`, it was supposed to be changed to `csharpier` for 1.0.0 + +# 0.30.0 +## Breaking Changes +The CSharpier dotnet tool no longer supports net6 & net7. +## What's Changed +### Support C# 13 & dotnet 9. [#1318](https://github.com/belav/csharpier/issues/1318) +CSharpier now supports dotnet 9 along with formatting all C# 13 language features. +### Inconsistent Formatting for new() Operator Compared to Explicit Object Constructors [#1364](https://github.com/belav/csharpier/issues/1364) +Implicit and explicit object initialization with constructors was not formatted consistently +```c# +// input & expected output +SomeObject someObject = new( + someLongParameter___________________, + someLongParameter___________________ +) +{ + Property = longValue_______________________________________________________________________, +}; + +SomeObject someObject = new SomeObject( + someLongParameter___________________, + someLongParameter___________________ +) +{ + Property = longValue_______________________________________________________________________, +}; + +// 0.29.2 +SomeObject someObject = + new(someLongParameter___________________, someLongParameter___________________) + { + Property = longValue_______________________________________________________________________, + }; + +SomeObject someObject = new SomeObject( + someLongParameter___________________, + someLongParameter___________________ +) +{ + Property = longValue_______________________________________________________________________, +}; + +``` +### Adds additional space before each member access in verbatim interpolated multiline string [#1358](https://github.com/belav/csharpier/issues/1358) +When an interpolated verbatim string contained line breaks, the code within the interpolations would contain extra spaces. +```c# +// input & expected output +var someStringWithLineBreakAndLongValue = + $@" +{someValue.GetValue().Name} someLongText________________________________________________________________"; + +// 0.29.2 +var someStringWithLineBreakAndLongValue = + $@" + {someValue .GetValue() .Name} someLongText________________________________________________________________"; +``` + +### Inserting trailing comma with trailing comment causes problems. [#1354](https://github.com/belav/csharpier/issues/1354) +CSharpier would insert a trailing comma after a trailing comment and format the end result poorly. +```c# +// input +var someObject = new SomeObject() +{ + Property1 = 1, + Property2 = 2 // Trailing Comment +}; + +// 0.29.2 +var someObject = new SomeObject() +{ + Property1 = 1, + Property2 = + 2 // Trailing Comment + , +}; + +// 0.30.0 +var someObject = new SomeObject() +{ + Property1 = 1, + Property2 = 2, // Trailing Comment +}; +``` + +### Double line break before collection expression in field [#1351](https://github.com/belav/csharpier/issues/1351) +CSharpier was inserting an extra line break on a long field name followed by a collection expression to initialize it. +```c# +// input & expected output +class ClassName +{ + public SomeType[] LongName____________________________________________________________________________ = + [ + someLongValue___________________________________________________, + someLongValue___________________________________________________, + ]; +} + +// 0.29.2 +class ClassName +{ + public SomeType[] LongName____________________________________________________________________________ = + + [ + someLongValue___________________________________________________, + someLongValue___________________________________________________, + ]; +} + +``` + +**Full Changelog**: https://github.com/belav/csharpier/compare/0.29.2...0.30.0 +# 0.29.2 ## What's Changed ### Comments don't follow tabs indent style [#1343](https://github.com/belav/csharpier/issues/1343) Prior to `0.29.2` CSharpier was converting any tabs within the block of a multiline comment to spaces. @@ -2653,3 +2767,4 @@ Thanks go to @pingzing + diff --git a/Dockerfile b/Dockerfile index 57dcd3ed1..142514c8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-bookworm-slim-amd64 AS base +FROM mcr.microsoft.com/dotnet/aspnet:9.0.0-bookworm-slim-amd64 AS base WORKDIR /app ENV ASPNETCORE_URLS=http://+:80 EXPOSE 80 -FROM mcr.microsoft.com/dotnet/sdk:8.0.100-bookworm-slim-amd64 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0.100-bookworm-slim-amd64 AS build RUN set -uex \ && apt-get update \ diff --git a/Nuget/Build.props b/Nuget/Build.props index ad5774fd5..c75d7165f 100644 --- a/Nuget/Build.props +++ b/Nuget/Build.props @@ -1,6 +1,6 @@ - 0.29.2 + 0.30.1 MIT https://github.com/belav/csharpier git diff --git a/Src/CSharpier.Cli/CSharpier.Cli.csproj b/Src/CSharpier.Cli/CSharpier.Cli.csproj index 3992eb21f..8fffade6d 100644 --- a/Src/CSharpier.Cli/CSharpier.Cli.csproj +++ b/Src/CSharpier.Cli/CSharpier.Cli.csproj @@ -6,8 +6,8 @@ dotnet-csharpier net8.0;net9.0 true - csharpier ../../Nuget/csharpier.snk + Major True 002400000480000094000000060200000024000052534131000400000100010049d266ea1aeae09c0abfce28b8728314d4e4807126ee8bc56155a7ddc765997ed3522908b469ae133fc49ef0bfa957df36082c1c2e0ec8cdc05a4ca4dbd4e1bea6c17fc1008555e15af13a8fc871a04ffc38f5e60e6203bfaf01d16a2a283b90572ade79135801c1675bf38b7a5a60ec8353069796eb53a26ffdddc9ee1273be diff --git a/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs b/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs index 8f1a0cd4b..65066c9c4 100644 --- a/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs +++ b/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs @@ -12,16 +12,15 @@ internal static class ConfigFileParser // "Comment: starts with a ; or a #." private static readonly Regex CommentRegex = new("^[;#].*$"); - private static readonly IniParserConfiguration Configuration = - new() - { - CommentRegex = CommentRegex, - AllowDuplicateKeys = true, - AllowDuplicateSections = true, - OverrideDuplicateKeys = true, - SkipInvalidLines = true, - ThrowExceptionsOnError = false, - }; + private static readonly IniParserConfiguration Configuration = new() + { + CommentRegex = CommentRegex, + AllowDuplicateKeys = true, + AllowDuplicateSections = true, + OverrideDuplicateKeys = true, + SkipInvalidLines = true, + ThrowExceptionsOnError = false, + }; public static ConfigFile Parse(string filePath, IFileSystem fileSystem) { diff --git a/Src/CSharpier.Cli/EditorConfig/Globber.cs b/Src/CSharpier.Cli/EditorConfig/Globber.cs index 9d9a46a59..d8fe6709b 100644 --- a/Src/CSharpier.Cli/EditorConfig/Globber.cs +++ b/Src/CSharpier.Cli/EditorConfig/Globber.cs @@ -2,14 +2,13 @@ namespace CSharpier.Cli.EditorConfig; internal static class Globber { - private static readonly GlobMatcherOptions globOptions = - new() - { - MatchBase = true, - Dot = true, - AllowWindowsPaths = true, - AllowSingleBraceSets = true, - }; + private static readonly GlobMatcherOptions globOptions = new() + { + MatchBase = true, + Dot = true, + AllowWindowsPaths = true, + AllowSingleBraceSets = true, + }; public static GlobMatcher Create(string files, string directory) { diff --git a/Src/CSharpier.FakeGenerators/Ignored.cs b/Src/CSharpier.FakeGenerators/Ignored.cs index 64749e215..05b0c4051 100644 --- a/Src/CSharpier.FakeGenerators/Ignored.cs +++ b/Src/CSharpier.FakeGenerators/Ignored.cs @@ -23,24 +23,22 @@ public static class Ignored public static readonly Type[] Types = { typeof(TextSpan), typeof(SyntaxTree) }; - public static readonly Dictionary PropertiesByType = - new() - { - { typeof(PropertyDeclarationSyntax), new[] { "semicolon" } }, - { typeof(IndexerDeclarationSyntax), new[] { "semicolon" } }, - { typeof(SyntaxTrivia), new[] { "token" } }, - { typeof(SyntaxToken), new[] { "value", "valueText" } }, - { typeof(ParameterSyntax), new[] { "exclamationExclamationToken" } }, - }; + public static readonly Dictionary PropertiesByType = new() + { + { typeof(PropertyDeclarationSyntax), new[] { "semicolon" } }, + { typeof(IndexerDeclarationSyntax), new[] { "semicolon" } }, + { typeof(SyntaxTrivia), new[] { "token" } }, + { typeof(SyntaxToken), new[] { "value", "valueText" } }, + { typeof(ParameterSyntax), new[] { "exclamationExclamationToken" } }, + }; - public static readonly HashSet UnsupportedNodes = - new() - { - // if new versions of c# add node types, we need to ignore them in the generators - // until codeAnalysis + sdks are updated - // global.json doesn't seem to always be respected for builds (namely VS but rider started having the same problem) - // which causes the generators to generate code for the new node types - // but then the build fails because those types don't exist in the packages the actual project references - // "ListPatternSyntax", "SlicePatternSyntax" - }; + public static readonly HashSet UnsupportedNodes = new() + { + // if new versions of c# add node types, we need to ignore them in the generators + // until codeAnalysis + sdks are updated + // global.json doesn't seem to always be respected for builds (namely VS but rider started having the same problem) + // which causes the generators to generate code for the new node types + // but then the build fails because those types don't exist in the packages the actual project references + // "ListPatternSyntax", "SlicePatternSyntax" + }; } diff --git a/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets b/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets index b9f292b3b..10d4787a6 100644 --- a/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets +++ b/Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets @@ -4,6 +4,8 @@ net8.0 net8.0 $(MSBuildThisFileDirectory)../tools/csharpier/$(CSharpier_FrameworkVersion)/dotnet-csharpier.dll + $(DOTNET_HOST_PATH) + dotnet $(CSharpierArgs) --check $(CSharpierArgs) --loglevel $(CSharpier_LogLevel) $(TargetFramework) @@ -23,7 +25,7 @@ StdOutEncoding="utf-8" StdErrEncoding="utf-8" IgnoreExitCode="true" - Command="dotnet "$(CSharpierDllPath)" $(CSharpierArgs) --no-msbuild-check --compilation-errors-as-warnings "$(MSBuildProjectDirectory)" > $(NullOutput) " /> + Command=""$(CSharpier_dotnet_Path)" exec "$(CSharpierDllPath)" $(CSharpierArgs) --no-msbuild-check --compilation-errors-as-warnings "$(MSBuildProjectDirectory)" > $(NullOutput) " />