Skip to content

Releases: belav/csharpier

1.2.5

31 Dec 22:15
12ac464

Choose a tag to compare

What's Changed

Performance issue when running CLI in project with pnpm on Windows #1781

1.2.4 did not properly address this

The code to determine if there is a version of CSharpier.MsBuild referenced that does not match the version of CSharpier being run has been optimized to not look in node_modules or .git. This significantly speeds things up in some setups.

Full Changelog: 1.2.4...1.2.5

1.2.4

23 Dec 23:24
c3b87f8

Choose a tag to compare

1.2.4

What's Changed

Weird enter in closing when formatting XAML TextBlock #1785

CSharpier was breaking an end element to a new line when it did not need to.

<!-- input & expected output -->
<root>
  <TextBlock Foreground="DarkGray">
    I saw the sign. When I opened up my eyes, I saw the sign.
  </TextBlock>
  <TextBlock>
    I saw the sign. When I opened up my eyes, I saw the sign.
  </TextBlock>
</root>

<!-- 1.2.3 -->
<root>
  <TextBlock Foreground="DarkGray">
    I saw the sign. When I opened up my eyes, I saw the sign.
  </TextBlock
  >
  <TextBlock>
    I saw the sign. When I opened up my eyes, I saw the sign.
  </TextBlock>
</root>

Order Modifiers (IDE0036) not formatting when code is preceded by a comment. #1784

When incorrectly ordered modifiers were preceded by a comment they were not being reordered. Thanks go to @TimothyMakkison for the contribution

// input & 1.2.3

// Comment
required public int Prop1 { get; set; }

// expected output
// Comment
public required int Prop1 { get; set; }

Performance issue when running CLI in project with pnpm on Windows #1781

The code to determine if there is a version of CSharpier.MsBuild referenced that does not match the version of CSharpier being run has been optimized to not look in node_modules or .git. This significantly speeds things up in some setups.

Full Changelog: 1.2.3...1.2.4

1.2.3

14 Dec 18:02
d9beb9f

Choose a tag to compare

What's Changed

Large directories ignored in .gitignore significantly impact performance. #1776

CSharpier was enumerating all files within all subdirectories and then determining if they should be formatted or not. That logic was optimized to only enumerate files in directories that are not ignored.

Full Changelog: 1.2.2...1.2.3

1.2.2

13 Dec 17:13
4316fe8

Choose a tag to compare

What's Changed

The null coalescing operator is grouped in an unexpected place #1769

Null coalescing is now consistently broken thanks to a contribution from @ogaken-1

// input & expected output
var x =
    someValue.SomeCall().SomeProperty.SomeProperty
    ?? someValue.SomeCall().SomeProperty.SomeProperty;

var x =
    someValue.SomeCall().SomeProperty?.SomeCall().SomeProperty
    ?? someValue.SomeCall().SomeProperty?.SomeCall().SomeProperty;

var x =
    someValue.SomeCall().A_______.B_______.C_______
    ?? someValue.SomeCall().A_______.B_______.C_______;

// 1.2.1
var x =
    someValue.SomeCall().SomeProperty.SomeProperty ?? someValue
        .SomeCall()
        .SomeProperty.SomeProperty;

var x =
    someValue.SomeCall().SomeProperty?.SomeCall().SomeProperty ?? someValue
        .SomeCall()
        .SomeProperty?.SomeCall()
        .SomeProperty;

var x =
    someValue.SomeCall().A_______.B_______.C_______ ?? someValue
        .SomeCall()
        .A_______.B_______.C_______;

Xml formatter should not add a second line #1760

When formatting an xml file with a declaration and extra blank line was being added.

<!-- input & expected output -->
<?xml version="1.0" encoding="utf-8"?>

<Element />

<!-- 1.2.1 -->
<?xml version="1.0" encoding="utf-8"?>


<Element />

Git ignore patterns do not work the same as git #1759

The handling of ignore patterns did not properly match how git handles them. The logic has been reworked and now has tests that compare it directly to git.

Fix server crash when launched without console #1774

If a plugin launched csharpier server without a console it would crash. This has been resolved thanks to @rcdailey

Full Changelog: 1.2.1...1.2.2

1.2.1

10 Nov 23:58
1ad752d

Choose a tag to compare

What's Changed

Multiline comments are now formatted in a single line in XML format #1747

The 1.2.0 release was combining xml comments into a single line.

<!-- input & expected output -->
<Root>
  <!-- This is the first line comment-->
  <!-- This is the second line of my comment-->
</Root>

<!-- 1.2.0 -->
<Root>
  <!-- This is the first line comment--><!-- This is the second line of my comment-->
</Root>

Full Changelog: 1.2.0...1.2.1

1.2.0

10 Nov 01:25
adf7026

Choose a tag to compare

What's Changed

Custom XML Parser #1679

CSharpier now has a custom xml parser. XmlDocument and XDocument do not provide the original white space or the original attribute values from the file that was parsed which blocked the ability to implement supporting keeping empty new lines and not automatically encoding attributes.

Support for keeping empty lines in xml files #1599

CSharpier now supports keeping a single empty line between elements in xml files. It will remove any initial or trailing empty lines.

<!-- input -->
<Root>

  <Element />


  <Element />

</Root>

<!-- expected output -->
<Root>
  <Element />

  <Element />
</Root>

<!-- 1.1.2 -->
<Root>
  <Element />
  <Element />
</Root>

Xml - don't automatically encode attribute values #1610

CSharpier will no longer encode attribute values. It will leave them encoded if they are supplied that way.

<!-- input & expected output -->
<Target Name="Transform" BeforeTargets="Build">
  <Message Importance="high" Text="@(MyItems->'MyItems has %(Identity)', ', ')" />
</Target>

<!-- 1.1.2 -->
<Target Name="Transform" BeforeTargets="Build">
  <Message Importance="high" Text="@(MyItems-&gt;'MyItems has %(Identity)', ', ')" />
</Target>

Add option to all integrations to report incorrect formatting as a warning instead of error #1687

Formatting "using" import split on multiple lines requires formatting it twice to get the expected result #1698

When a using contained a newline before the namespace it was not being sorted properly.

// input
using System.Net;
using
    SomeProject.Bar;
using Microsoft.Extensions.Logging;

// expected output
using System.Net;
using Microsoft.Extensions.Logging;
using SomeProject.Bar;

// 1.1.2
using System.Net;
using SomeProject.Bar;
using Microsoft.Extensions.Logging;

An empty line is inserted in lambda #1694

CSharpier was inserting an extra blank line in some situations with a lambda and a collection expression

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

// 1.1.2
CallMethod(
    (parameter1, parameter2) =>

        [
            LongValue________________________________________________,
            LongValue________________________________________________,
        ]
);

Indent .ThenInclude() for clearer navigation hierarchy in EF Core queries #1602

CSharpier now treats .ThenInclude as a special case to improve formatting of EF queries

// input & expected output
websiteQueryable = websiteQueryable
    .Include(o => o.Categories)
    .Include(o => o.Categories)
        .ThenInclude(c => c.Products)
    .Include(o => o.Categories)
        .ThenInclude(c => c.RuleManager)
            .ThenInclude(rm => rm.RuleClauses)
    .Include(o => o.Categories)
        .ThenInclude(c => c.RuleManager)
            .ThenInclude(rm => rm.RuleClauses)
                .ThenInclude(rc => rc.RuleTypeOption);

// 1.1.2
websiteQueryable = websiteQueryable
    .Include(o => o.Categories)
    .Include(o => o.Categories)
    .ThenInclude(c => c.Products)
    .Include(o => o.Categories)
    .ThenInclude(c => c.RuleManager)
    .ThenInclude(rm => rm.RuleClauses)
    .Include(o => o.Categories)
    .ThenInclude(c => c.RuleManager)
    .ThenInclude(rm => rm.RuleClauses)
    .ThenInclude(rc => rc.RuleTypeOption);

Inconsistent indentation between is and other operators #1601

Pattern operators were being indented inconsistently with other operators. The formatting is now more consistent

// input & expected output
var b2 = (
    System.Environment.SpecialFolder.AdminTools
    is System.Environment.SpecialFolder.AdminTools
        or System.Environment.SpecialFolder.AdminTools
        or System.Environment.SpecialFolder.AdminTools
);

var b2 =
    System.Environment.SpecialFolder.AdminTools
    is System.Environment.SpecialFolder.AdminTools
        or System.Environment.SpecialFolder.AdminTools
        or System.Environment.SpecialFolder.AdminTools;

var b2 =
    someLongValue____________________________________________
    == someOtherLongValue______________________________
        + someOtherLongValue______________________________;

var b2 = (
    someLongValue____________________________________________
    == someOtherLongValue______________________________
        + someOtherLongValue______________________________
);

// 1.1.2
var b2 = (
    System.Environment.SpecialFolder.AdminTools
        is System.Environment.SpecialFolder.AdminTools
            or System.Environment.SpecialFolder.AdminTools
            or System.Environment.SpecialFolder.AdminTools
);

var b2 =
    System.Environment.SpecialFolder.AdminTools
        is System.Environment.SpecialFolder.AdminTools
            or System.Environment.SpecialFolder.AdminTools
            or System.Environment.SpecialFolder.AdminTools;

var b2 =
    someLongValue____________________________________________
    == someOtherLongValue______________________________
        + someOtherLongValue______________________________;

var b2 = (
    someLongValue____________________________________________
    == someOtherLongValue______________________________
        + someOtherLongValue______________________________
);

Error when formatting with an indent size <= 0 #1741

Previously csharpier would attempt to format code when indent size was set to 0. This was not intentional and had a number of bugs. CSharpier now error out when encountering an indent size of 0

Fix condition causing FirstTargetFramework build property erasure #1696

In some situations CSharpier.Msbuild was running into a build failure.

Full Changelog: 1.1.2...1.2.0

1.1.2

16 Aug 20:05
068b1df

Choose a tag to compare

What's Changed

Inconsistencies with null-coalescing wrapping on method chains #1573

On longer method chains, depending on the exact chain a null coalescing expression wouldn't always be preceded by a new line.

// input & expected output
var x =
    someValue
        .Property.CallLongMethod_____________________________________()
        .CallMethod__________()
    ?? throw new Exception();

var x =
    someValue
        .Property.CallLongMethod_____________________________________()
        .CallLongMethod___________________________________________________()
    ?? throw new Exception();

// 1.1.1
var x =
    someValue
        .Property.CallLongMethod_____________________________________()
        .CallMethod__________() ?? throw new Exception();

var x =
    someValue
        .Property.CallLongMethod_____________________________________()
        .CallLongMethod___________________________________________________()
    ?? throw new Exception();

Full Changelog: 1.1.1...1.1.2

1.1.1

04 Aug 02:24

Choose a tag to compare

What's Changed

Unhandled exception: System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter 'startIndex') #1673

CSharpier was throwing an exception when formating a directory contained a file without an extension.

1.1.0

03 Aug 16:54
3a063a1

Choose a tag to compare

What's Changed

.gitignore from parent folders impacts formatting of children #1627

CSharpier will no longer consider .gitignore files located above the root of the current git repository.

Changes to stdin formatting #288 #1657

There is a new option --stdin-filepath that is used to specify the filepath CSharpier should use for resolving options and ignore files.
When no path is specified via stdin-path

  • No ignore files are considered.
  • The current directory is considered when locating options
  • The file is assumed to be c# unless the first non-whitespace character is < in which case it is assumed to be xml.

Support for C# 14 and .NET 10 #1654 #1646

Changes were required to support the following

  • Extension Declarations
  • File level directives in file based C# Apps

Support --ignore-path CLI option #1585

It is now possible to specify the path to an ignore file

dotnet csharpier format . --ignore-path .config/.csharpierignore

Format xaml and slnx by default #1628 #1604

CSharpier now formats xaml and slnx by default without the need for configuration changes.

XML formatting is not taking into account EOL configuration on multiline comments #1660

When formatting the following XML, CSharpier would always use the system system default for ending lines within the comment instead of the respecting the configured EOL setting.

<Element>
  <!--
  Comment with EOL
  -->
</Element>

Error when no read access to intermediate containing folder #1656

In the case that CSharpier had access to a sub directory but not the parent of that sub directory, it was failing with an exception. That has been resolved.

Misleading message after "csharpier check" #1645

Previously the format and check commands both used the same output message. The check command now correctly reports that it checked files and did not format them.

# 1.0.3
dotnet csharpier check .
Formatted 13226 files in 21986ms.

# 1.1.0
dotnet csharpier check .
Checked 13226 files in 21986ms.

Multiline collection expressions should not be indented #1635

CSharpier now formats collection expressions consistently when they are in a property

// input & expected output
public class ClassName
{
    public SomeObject LongValue = new
    {
        One = "One",
        Two = "Two",
        ThreeThreeThree = "ThreeThreeThree",
    };

    public SomeObject LongValue { get; } = new
    {
        One = "One",
        Two = "Two",
        ThreeThreeThree = "ThreeThreeThree",
    };
}

// 1.0.3
public class ClassName
{
    public SomeObject LongValue = new
    {
        One = "One",
        Two = "Two",
        ThreeThreeThree = "ThreeThreeThree",
    };

    public SomeObject LongValue { get; } =
        new
        {
            One = "One",
            Two = "Two",
            ThreeThreeThree = "ThreeThreeThree",
        };
}

.editorconfig is not considered, when its part of the .gitignore #1582

Previously if an .editorconfig was in the .gitignore it would not be considered when determining the configuration options for formatting a given file. That behavior has been changed so it will be considered.

Full Changelog: 1.0.3...1.1.0

1.0.3

What's Changed

Switch block case with conditionals adding newlines #1630

Switch blocks were breaking on conditions within patterns.

// input and expected output
switch ("")
{
    case "" or "":
        break;
}

// 1.0.2
switch ("")
{
    case ""
    or "":
        break;
}

switch expression formatting adds odd newlines #1620

CSharpier was breaking after a discard with a when, resulting in extra new lines

// input and expected output
_ = someValue switch
{
    _ when KeepWhenWithDiscard() => "",
    _ when KeepWhenWithDiscard_________________(
            SomeObject_______________________________________________
        ) => "",
    _ when KeepWhenWithDiscard_________________(
            SomeObject_______________________________________________
        ) => "LongString_____________________________________________________________________",
};

// 1.0.2
_ = someValue switch
{
    _ when KeepWhenWithDiscard() => "",
    _
        when KeepWhenWithDiscard_________________(
            SomeObject_______________________________________________
        ) => "",
    _
        when KeepWhenWithDiscard_________________(
            SomeObject_______________________________________________
        ) => "LongString_____________________________________________________________________",
};

multi-line raw string in linq query causes a subsequent linq query to be printed on one line #1617

If a query syntax linq expression contained a raw string, it could result in method invocations not breaking.

// input and expected output
(
    from x in SomeMethod()
    select """
        someString
        """
)
    .CallMethod_____________________________________________()
    .CallMethod_____________________________________________();

// 1.0.2
(
    from x in SomeMethod()
    select """
        someString
        """
).CallMethod_____________________________________________().CallMethod_____________________________________________();

Full Changelog: 1.0.2...1.0.3

1.0.3

29 Jun 17:19

Choose a tag to compare

What's Changed

Switch block case with conditionals adding newlines #1630

Switch blocks were breaking on conditions within patterns.

// input and expected output
switch ("")
{
    case "" or "":
        break;
}

// 1.0.2
switch ("")
{
    case ""
    or "":
        break;
}

switch expression formatting adds odd newlines #1620

CSharpier was breaking after a discard with a when, resulting in extra new lines

// input and expected output
_ = someValue switch
{
    _ when KeepWhenWithDiscard() => "",
    _ when KeepWhenWithDiscard_________________(
            SomeObject_______________________________________________
        ) => "",
    _ when KeepWhenWithDiscard_________________(
            SomeObject_______________________________________________
        ) => "LongString_____________________________________________________________________",
};

// 1.0.2
_ = someValue switch
{
    _ when KeepWhenWithDiscard() => "",
    _
        when KeepWhenWithDiscard_________________(
            SomeObject_______________________________________________
        ) => "",
    _
        when KeepWhenWithDiscard_________________(
            SomeObject_______________________________________________
        ) => "LongString_____________________________________________________________________",
};

multi-line raw string in linq query causes a subsequent linq query to be printed on one line #1617

If a query syntax linq expression contained a raw string, it could result in method invocations not breaking.

// input and expected output
(
    from x in SomeMethod()
    select """
        someString
        """
)
    .CallMethod_____________________________________________()
    .CallMethod_____________________________________________();

// 1.0.2
(
    from x in SomeMethod()
    select """
        someString
        """
).CallMethod_____________________________________________().CallMethod_____________________________________________();

Full Changelog: 1.0.2...1.0.3