Releases: belav/csharpier
Rider 1.6.2-beta
- Fix issues with lookup of '.NET CLI executable path', csharpier will now wait until rider is ready with the information.
- No more falling back to
PATH
Rider 1.6.1-beta
- Delay lookup of '.NET CLI executable path' until it is needed
- Fall back to looking for dotnet on PATH if '.NET CLI executable path' is not available
Rider 1.6.0-beta
Better support for dotnet commands.
- Uses the Rider setting for '.NET CLI executable path' for running dotnet commands
- If unable to run dotnet commands, show an error message
0.27.3
What's Changed
Add more options to CodeFormatterOptions #1172
The API for CSharpier was only exposing CodeFormatterOptions.PrintWidth
. It is now in sync with the CLI and exposes all of the available options
public class CodeFormatterOptions
{
public int Width { get; init; } = 100;
public IndentStyle IndentStyle { get; init; } = IndentStyle.Spaces;
public int IndentSize { get; init; } = 4;
public EndOfLine EndOfLine { get; init; } = EndOfLine.Auto;
}
Thanks go to @Phault for the contribution
Extra indent when call method on RawStringLiteral #1169
When a raw string literal was the first argument to a method call, it was getting an extra indent.
// input & expected output
CallMethod(
"""
SomeRawString
""".CallMethod()
);
// 0.27.2
CallMethod(
"""
SomeRawString
""".CallMethod()
);
Thanks go to @Rudomitori for reporting the bug.
Using aliases sorting is not always the same depending on the input order #1168
Using aliases were not sorting properly, resulting differing outputs and unstable formatting.
Inputs of
using A = string;
using B = string;
using C = string;
using D = string;
And
using D = string;
using C = string;
using B = string;
using A = string;
Now always result in properly sorted output of
using A = string;
using B = string;
using C = string;
using D = string;
Thanks go to @Araxor for reporting the bug.
Spread (in collection expression) are not formatted #1167
The spread element was unformatted, and left as is. It is now formatted as follows.
int[] someArray = [.. someOtherArray];
int[] someOtherArray = [.. value1, .. value2, .. value3];
int[] someOtherArray =
[
.. value1________________________________,
.. value2________________________________,
.. value3________________________________
];
Thanks go to @jods4 for reporting the bug.
Fix empty line before collection expression in attribute #1164
A collection expression in an attribute resulted in an extra line before the collection expression.
// input & expected output
[SomeAttribute(
[
someValue_______________________________________________,
someValue_______________________________________________,
]
)]
class ClassName { }
// 0.27.2
[SomeAttribute(
[
someValue_______________________________________________,
someValue_______________________________________________,
]
)]
class ClassName { }
Thanks go to @Rudomitori for reporting the bug.
using static System.* usings not ordered before other static usings like using System.* ones #1162
Static usings were not following the rule that System.*
should be sorted to the top.
// input & expected output
using static System;
using static System.Web;
using static AWord;
using static ZWord;
// 0.27.2
using static AWord;
using static System;
using static System.Web;
using static ZWord;
Remove hash from version #1144
When .net8
support was added, CSharpier started including a commit hash in the version number output. This was due to a breaking change in the sdk.
> dotnet csharpier --version
0.27.2+b456544aad8957d0e2026afe1a37544bb74552ba
CSharpier no longer includes the commit hash
> dotnet csharpier --version
0.27.3
vscode-1.5.3-beta1
This adds better support for dotnet commands by
- Using the option for
dotnet.dotnetPath
if it exists - Using the option for
omnisharp.dotNetCliPaths
if it exists - Trying to find
dotnet
on the PATH by runningdotnet --info
- Trying to find
dotnet
on the PATH by runningsh -c "dotnet --info"
0.27.2
What's Changed
Orphan variable since 0.27.1 #1153
0.27.1 introduced the following formatting regression, resulting in short variables being orphaned on a line
// 0.27.1
o
.Property.CallMethod(
someParameter_____________________________,
someParameter_____________________________
)
.CallMethod()
.CallMethod();
// 0.27.2
o.Property.CallMethod(
someParameter_____________________________,
someParameter_____________________________
)
.CallMethod()
.CallMethod();
Thanks go to @aurnoi1 for reporting the bug
Better support for CSharp Script #1141
Version 0.27.1 parsed .csx
files as if they were C#, so it could only format simple ones. It now parses them as CSharpScript files so it can format them properly.
Thanks go to @Eptagone for reporting the bug.
Full Changelog: 0.27.1...0.27.2
0.27.1
What's Changed
Support for CSharp Script #1141
Previously CSharpier would only format files matching *.cs
which prevented it from formatting C# script files. It now formats *.{cs,csx}
Thanks go to @Eptagone for the suggestion
Weird formatting of invocation chain #1130
Invocation chains that started with an identifier <= 4 characters were causing a strange break in the first method call. There were other edge cases cleaned up while working on the fix.
// 0.27.0
var something________________________________________ = x.SomeProperty.CallMethod(
longParameter_____________,
longParameter_____________
)
.CallMethod();
// 0.27.1
var something________________________________________ = x
.SomeProperty.CallMethod(longParameter_____________, longParameter_____________)
.CallMethod();
// 0.27.0
var someLongValue_________________ = memberAccessExpression[
elementAccessExpression
].theMember______________________________();
// 0.27.1
var someLongValue_________________ = memberAccessExpression[elementAccessExpression]
.theMember______________________________();
// 0.27.0
someThing_______________________
?.Property
.CallMethod__________________()
.CallMethod__________________();
// 0.27.1
someThing_______________________
?.Property.CallMethod__________________()
.CallMethod__________________();
Thanks go to @Rudomitori for reporting the issue
"Failed syntax tree validation" for raw string literals #1129
When an interpolated raw string changed indentation due to CSharpier formatting, CSharpier was incorrectly reporting it as failing syntax tree validation.
// input
CallMethod(CallMethod(
$$"""
SomeString
""", someValue));
// output
CallMethod(
CallMethod(
$$"""
SomeString
""",
someValue
)
);
Thanks go to @Rudomitori for reporting the issue
Adding experimental support using HTTP for the extensions to communicate with CSharpier #1137
The GRPC support added in 0.27.0 increased the size of the nuget package significantly and has been removed.
CSharpier can now start a kestrel web server to support communication with the extensions once they are all updated.
Full Changelog: 0.27.0...0.27.1
0.27.0
What's Changed
Improve formatting of lambda expressions #1066
Many thanks go to @Rudomitori for contributing a number of improvements to the formatting of lambda expressions.
Some examples of the improvements.
// input
var affectedRows = await _dbContext.SomeEntities
.ExecuteUpdateAsync(
x =>
x.SetProperty(x => x.Name, x => command.NewName)
.SetProperty(x => x.Title, x => command.NewTItle)
.SetProperty(x => x.Count, x => x.Command.NewCount)
);
// 0.27.0
var affectedRows = await _dbContext.SomeEntities
.ExecuteUpdateAsync(x =>
x.SetProperty(x => x.Name, x => command.NewName)
.SetProperty(x => x.Title, x => command.NewTItle)
.SetProperty(x => x.Count, x => x.Command.NewCount)
);
// input
builder.Entity<IdentityUserToken<string>>(b =>
{
b.HasKey(
l =>
new
{
l.UserId,
l.LoginProvider,
l.Name
}
);
b.ToTable("AspNetUserTokens");
});
// 0.27.0
builder.Entity<IdentityUserToken<string>>(b =>
{
b.HasKey(l => new
{
l.UserId,
l.LoginProvider,
l.Name
});
b.ToTable("AspNetUserTokens");
});
// input
table.PrimaryKey(
"PK_AspNetUserTokens",
x =>
new
{
x.UserId,
x.LoginProvider,
x.Name
}
);
// 0.27.0
table.PrimaryKey(
"PK_AspNetUserTokens",
x => new
{
x.UserId,
x.LoginProvider,
x.Name
}
);
readonly ref
is changed to ref readonly
causing error CS9190 #1123
CSharpier was sorting modifiers in all places they occurred. Resulting the following change that led to code that would not compile.
// input
void Method(ref readonly int someParameter) { }
// 0.26.7
void Method(readonly ref int someParameter) { }
// 0.27.0
void Method(ref readonly int someParameter) { }
Thanks go to @aurnoi1 for reporting the bug
#if at the end of collection expression gets eaten #1119
When a collection expression contained a directive immediately before the closing bracket, that directive was not included in the output.
// input
int[] someArray =
[
1
#if DEBUG
,
2
#endif
];
// 0.26.7
int[] someArray = [1];
// 0.27.0
int[] someArray =
[
1
#if DEBUG
,
2
#endif
];
Thanks go to @Meowtimer for reporting the bug
CSharpier.MsBuild - Set Fallback for dotnetcore3.1 or net5.0 applications #1111
CSharpier.MsBuild made an assumption that the project being built would be built using net6-net8 and failed when the project was built with earlier versions of dotnet.
It now falls back to trying to use net8
Thanks go to @samtrion for the contribution
Allow empty/blank lines in object initializers #1110
Large object initializers now retain single empty lines between initializers.
vvar someObject = new SomeObject
{
NoLineAllowedAboveHere = 1,
ThisLineIsOkay = 2,
// comment
AndThisLine = 3,
DontAddLines = 4,
};
Thanks go to @Qtax for the suggestion
Add option to allow formatting auto generated files. [#1055](#1055
By default CSharpier will not format files that were generated by the SDK, or files that begin with <autogenerated />
comments.
Passing the option --include-generated
to the CLI will cause those files to be formatted.
Format raw string literals indentation #975
CSharpier now adjusts the indentation of raw string literals if the end delimiter is indented.
// input
var someString = """
Indent based on previous line
""";
var doNotIndentIfEndDelimiterIsAtZero = """
Keep This
Where It
Is
""";
// 0.26.7
var someString = """
Indent based on previous line
""";
var doNotIndentIfEndDelimiterIsAtZero = """
Keep This
Where It
Is
""";
// 0.27.0
var someString = """
Indent based on previous line
""";
var doNotIndentIfEndDelimiterIsAtZero = """
Keep This
Where It
Is
""";
Thanks go to @jods4 for reporting the issue
Incorrect indentation on a multi-line statement split by comments [#968](#968
CSharpier was not properly indenting an invocation chain when it was being split by comments.
// input
var someValue =
// Some Comment
CallSomeMethod()
// Another Comment
.CallSomeMethod();
// 0.26.7
var someValue =
// Some Comment
CallSomeMethod()
// Another Comment
.CallSomeMethod();
// 0.27.0
var someValue =
// Some Comment
CallSomeMethod()
// Another Comment
.CallSomeMethod();
Thanks go to @Tyrrrz for reporting the issue
Adding experimental support for GRPC for the extensions to communicate with CSharpier #944
Currently the extensions for CSharpier send data to a running instance of CSharpier by piping stdin/stdout back and forth. This approach has proved problematic and hard to extend.
As of 0.27.0, CSharpier can run a GRPC server to allow communication with the extensions once they are all updated.
Full Changelog: 0.26.7...0.27.0
0.26.7
What's Changed
Keep Field.Method() on the same line when breaking long method chain #1010
0.26.0 introduced changes that broke long invocation chains on fields/properties as well as methods. That change has been reverted after community feedback.
// 0.26.0
var loggerConfiguration = new LoggerConfiguration()
.Enrich
.FromLogContext()
.Enrich
.WithProperty("key", "value")
.Enrich
.WithProperty("key", "value")
.Enrich
.WithProperty("key", "value")
.Enrich
.WithProperty("key", "value")
.WriteTo
.Console(outputTemplate: "template");
// 0.26.7
var loggerConfiguration = new LoggerConfiguration()
.Enrich.FromLogContext()
.Enrich.WithProperty("key", "value")
.Enrich.WithProperty("key", "value")
.Enrich.WithProperty("key", "value")
.Enrich.WithProperty("key", "value")
.WriteTo.Console(outputTemplate: "template");
Full Changelog: 0.26.6...0.26.7
0.26.6
What's Changed
CSharpier incorrectly reports problems with differing line endings as "The file did not end with a single newline"#1067
If CSharpier was validating that a file was formatted, and that file contained only \n
but CSharpier was configured to use \r\n
, then it would report the problem as The file did not end with a single newline
CSharpier added support for reading line ending configuration from an .editorconfig
which could contain end_of_line = crlf
so some users were unknowingly configuring CSharpier to use \r\n
CSharpier now correctly reports the problem as The file contained different line endings than formatting it would result in.
Full Changelog: 0.26.5...0.26.6