Skip to content

Releases: belav/csharpier

0.30.6

10 Jan 16:57
ccaca15
Compare
Choose a tag to compare

What's Changed

Trailing comma is placed on new line if last enum value is followed by a comment #1429

// input
enum MyEnum
{
    First,
    Second // the second value
}

// 0.30.5
enum MyEnum
{
    First,
    Second // the second value
    ,
}

// 0.30.6
enum MyEnum
{
    First,
    Second, // the second value
}

Full Changelog: 0.30.5...0.30.6

0.30.5

03 Jan 17:26
Compare
Choose a tag to compare

What's Changed

Extra blank line added to file each time csharpier runs on this file #1426

When a file ended in a comment and that comment had multiple blank lines before it, a new blank line was being added each time it was formatted.
// input

// input
namespace MyCompany.MyNamespace;


// Comment block

// 0.30.4
namespace MyCompany.MyNamespace;



// Comment block

// 0.30.5
namespace MyCompany.MyNamespace;

// Comment block

**Full Changelog**: https://github.com/belav/csharpier/compare/0.30.4...0.30.5

0.30.4

28 Dec 02:41
064d35f
Compare
Choose a tag to compare

0.30.4

What's Changed

Formatting deletes unsafe modifier #1416

Formatting a using directive with an unsafe modifier resulted in the lose of the unsafe keyword

// input & expected output
using unsafe NvapiQueryInterface = delegate* unmanaged[Cdecl]<uint, nint>;

// 0.30.3
using NvapiQueryInterface = delegate* unmanaged[Cdecl]<uint, nint>;

CSharpier keeps adding a newline every time a file is formatted #1408

In some cases if a file ended with a comment, CSharpier would add a new extra blank line above the comment each time it formatted the file

// input & expected outpet
using System;

namespace MyCompany.MyNamespace;

// Comment block

// 0.30.3
using System;

namespace MyCompany.MyNamespace;


// Comment block

Full Changelog: 0.30.3...0.30.4

0.30.3

07 Dec 19:56
0bec7d2
Compare
Choose a tag to compare

What's Changed

CSharpier.MsBuild doesn't fail the github action anymore #1357

The changes for 1311 caused CSharpier.MsBuild to not report unformatted files as errors on linux.

Thanks go to @PetSerAl for the fix

0.30.2

22 Nov 16:56
384f7a1
Compare
Choose a tag to compare

What's Changed

CSharpier.MsBuild now uses DOTNET_HOST_PATH instead of just dotnet #1387

Use current dotnet binary from DOTNET_HOST_PATH instead of just dotnet.

Collection expression inside a dictionary adds unexpected new line #1390

// input & expected output
Dictionary<string, string[]> dictionary = new()
{
    {
        "Key",
        [
            "SomeValue__________________________________________",
            "SomeValue__________________________________________",
        ]
    },
};

// 0.30.1
Dictionary<string, string[]> dictionary = new()
{
    {
        "Key",

        [
            "SomeValue__________________________________________",
            "SomeValue__________________________________________",
        ]
    },
};

Failed syntax tree validation reported when trailing comma added before a trailing comment #1388

With the following code, CSharpier will add a trailing comma before the trailing comment.
CSharpier's syntax tree validation was incorrectly reporting this as a failure.

// input
var someObject = new SomeObject()
{
    Property1 = 1,
    Property2 = 2 // Trailing Comment
};

// output
var someObject = new SomeObject()
{
    Property1 = 1,
    Property2 = 2, // Trailing Comment
};

Full Changelog: 0.30.1...0.30.2

0.30.0

17 Nov 17:13
0425539
Compare
Choose a tag to compare

Breaking Changes

The CSharpier dotnet tool no longer supports net6 & net7.

What's Changed

Support C# 13 & dotnet 9. #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

Implicit and explicit object initialization with constructors was not formatted consistently

// 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

When an interpolated verbatim string contained line breaks, the code within the interpolations would contain extra spaces.

// 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

CSharpier would insert a trailing comma after a trailing comment and format the end result poorly.

// 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

CSharpier was inserting an extra line break on a long field name followed by a collection expression to initialize it.

// input & expected output
class ClassName
{
    public SomeType[] LongName____________________________________________________________________________ =
    [
        someLongValue___________________________________________________,
        someLongValue___________________________________________________,
    ];
}

// 0.29.2
class ClassName
{
    public SomeType[] LongName____________________________________________________________________________ =

        [
            someLongValue___________________________________________________,
            someLongValue___________________________________________________,
        ];
}

Full Changelog: 0.29.2...0.30.0

0.29.2

15 Sep 17:55
57c3ca1
Compare
Choose a tag to compare

What's Changed

Comments don't follow tabs indent style #1343

Prior to 0.29.2 CSharpier was converting any tabs within the block of a multiline comment to spaces.

public void SomeFunction()
{
	/*
	The following line is an example with an indent:
		This line is indented by one tab. (prior to 0.29.2 this would end up as a tab followed by 4 spaces)
	*/
	/*
	The following line is an example with an indent:
		This line is indented by 4 spaces but will be converted to 1 tab (prior to 0.29.2 this would end up as a tab followed by 4 spaces)
	*/
	/*
	The following line is an example with an indent:
	   This line is indented by 3 spaces but will be left as 3 spaces
	*/
}

csharpier-ignore-start now supported in object initializers #1342

// input & expected output
return new SomeClass
{
    // csharpier-ignore-start
    SomeProperty =     someValue,
    SomeProperty2 =     someValue
    // csharpier-ignore-end
};

// 0.29.1
return new SomeClass
{
    // csharpier-ignore-start
    SomeProperty = someValue,
    SomeProperty2 = someValue
    // csharpier-ignore-end
};

Fixed extra new line between cast and collection expression. #1334

// input & expected output
CallMethod(
    (string[])
        [
            longerValue_____________________________________________,
            longerValue_____________________________________________,
        ]
);

// 0.29.1
CallMethod(
    (string[])

        [
            longerValue_____________________________________________,
            longerValue_____________________________________________,
        ]
);

Support custom extensions in .editorconfig #1273

As of 0.29.0 CSharpier could format non-standard file extensions, but only if configured in the csharpierrc file. This is now supported with an .editorconfig

[*.cst]
csharpier_formatter = csharp
indent_style = space
indent_size = 2
max_line_length = 80

Full Changelog: 0.29.1...0.29.2

0.29.1

23 Aug 15:31
b87b4df
Compare
Choose a tag to compare

What's Changed

Sorting of usings with underscore differs from Visual Studio #1327

CSharpier now sorts _ to the bottom of usings.

using SomeCompany.MWord;
using SomeCompany.ZWord;
using SomeCompany._Word;

Process cannot access the file "....net8.0\any\server.log" while running multiple extensions. #1324

CSharpier Server now uses a log file name based on the port that it is starting on to avoid concurrency issues trying to access the same log file

Full Changelog: 0.29.0...0.29.1

0.29.0

17 Aug 18:17
5d73fe3
Compare
Choose a tag to compare

Breaking Changes

The formatting command will now exit with an error code of 1 if one of the target files cannot be compiled #1131

Prior to 0.29.0 if csharpier encountered a file that could not be compiled it would treat it as a warning and exit with a code of 0.
As of 0.29.0 a file that cannot be compiled is now treated as an error and csharpier will exit with code 1

What's Changed

Enforce trailing commas in object and collection initializer #668

CSharpier will now add trailing commas automatically where appropriate. It will collapse to a single line and remove the trailing comma in cases where everything fits on one line.

// input
public enum SomeEnum
{
    Value1,
    Value2
}

string[] someArray = new string[]
{
    someLongValue_____________________________________________,
    someLongValue_____________________________________________
};

string[] someArray = new string[]
{
    someValue,
    someValue,
};

// 0.29.0
public enum SomeEnum
{
    Value1,
    Value2,
}

string[] someArray = new string[]
{
    someLongValue_____________________________________________,
    someLongValue_____________________________________________,
}

string[] someArray = new string[] { someValue, someValue };

Many thanks go to @dawust for the contribution.

Support for formatting custom file extensions #1220

Prior to 0.29.0 csharpier would only format files with an extension of .cs or .csx. It is now possible to configure csharpier to format other files extensions, and to specify configuration options per file extension.
See https://csharpier.com/docs/Configuration#configuration-overrides for more details.

Invalid blank line being added with lambda returning collection expression #1306

// input & expected output
CallMethod(_ =>
    [
        LongValue________________________________________________,
        LongValue________________________________________________,
    ]
);

// 0.28.2
CallMethod(_ =>

    [
        LongValue________________________________________________,
        LongValue________________________________________________,
    ]
);

Switch expressions do not break consistently with other lambdas #1282

Prior to 0.29.0 csharpier would break before the => in switch expression arms. It now breaks after them to be consistent with other lambda expressions.

// 0.28.2
return someEnum switch
{
    Value1 => someOtherValue,
    Value2
    or Value3
        => someValue________________________________________________________________________,
    Value4
        => someValue_____________________________________________________________________________,
};

// 0.29.0
return someEnum switch
{
    Value1 => someOtherValue,
    Value2 or Value3 =>
        someValue________________________________________________________________________,
    Value4 =>
        someValue_____________________________________________________________________________,
};

Formatting of empty collection initializer for huge type #1268

Empty collection expression initializers formatting was including a break plus indentation resulting in poor formatting.

// 0.28.2
var someObject = new List<(
    int Field1__________________________________,
    int Field2__________________________________
)>
{
    };

// 0.29.0
var someObject = new List<(
    int Field1__________________________________,
    int Field2__________________________________
)>
{ };

Thanks go to @Rudomitori for the contribution

Switch expression single line broken when preceded by comment #1262

Improved formatting for short expression arms that have a leading comment.

// 0.28.2
return someValue switch
{
    // comment
    Some.One
        => 1,
    Some.Two => 2,
};

return someValue switch
{
    Some.One => 1,
    // comment
    Some.Two
        => 2,
};

// 0.29.0
return someValue switch
{
    // comment
    Some.One => 1,
    Some.Two => 2,
};

return someValue switch
{
    Some.One => 1,
    // comment
    Some.Two => 2,
};

Incorrect formatting of ternary expression with a comment after an interpolated string #1258

Fixed bug with comments on a ternary expression that resulted in invalid code.

// input & expected output
public string TrailingComment = someCondition
    ? $"empty" // trailing comment
    : someString;

// 0.28.2
public string TrailingComment = someCondition ? $"empty" // trailing comment : someString;

Formatting for indexer parameters should mostly be the same as for method parameters. #1255

Improved formatting of indexed properties that contained attributes.

// input & expected output
public class ClassName
{
    public string this[
        [SomeAttribute] int a________________________________,
        [SomeAttribute] int b________________________________
    ] => someValue;
}

// 0.28.2
public class ClassName
{
    public string this[[SomeAttribute] int a________________________________, [SomeAttribute]
        int b________________________________] => someValue;
}

Do not overwrite CSharpier_Check when already set. #1314

Fixed a bug with csharpier.msbuild where it would overwrite the CSharpier_Check value in some cases.

Thanks go to @PetSerAl for the contribution

The CLI has contradictory message about directoryOrFile being required #1296

The help text for the cli has been improved to better indicate when directoryOrFile is required.

Thanks go to @marcinjahn for the contribution

Fullwidth unicode characters should be accounted for in print width #260

CSharpier now considers full width unicode characters such as to be 2 spaces wide when determining how to format code.

Full Changelog: 0.28.2...0.29.0

0.28.2

26 Apr 16:39
3e4366c
Compare
Choose a tag to compare

What's Changed

Pipe to dotnet csharpier fails when subdirectory is inaccessible #1240

When running the following CSharpier would look for config files in subdirectories of the pwd. This could lead to exceptions if some of those directories were inaccessible.

echo "namespace Foo { public class Bar { public string Baz {get;set;}}}" | dotnet csharpier

Thanks go to @jamesfoster for reporting the issue.

Full Changelog: 0.28.1...0.28.2