CSharpier is an opinionated code formatter for c#.
CSharpier now supports a file scoped type
file class FileScopedClass
{
// implementation
}
In some instances csharpier was removing empty lines in csharpier-ignore
blocks of code
// input
public class KeepLines1
{
// csharpier-ignore-start
private string first;
private string second;
// csharpier-ignore-end
}
// 0.20.0
public class KeepLines1
{
// csharpier-ignore-start
private string first;private string second;
// csharpier-ignore-end
}
Thanks go to @MonstraG for reporting it
// 0.20.0
var result = await from thing in Things
from otherThing in OtherThings
from finalThing in SomethingAsync(thing, otherThing)
select finalThing;
// 0.21.0
var result = await
from thing in Things
from otherThing in OtherThings
from finalThing in SomethingAsync(thing, otherThing)
select finalThing;
Thanks go to @domn1995 for reporting it.
Object initializers break when they have more than two properties. For example
var x = new Thing
{
Post = post,
Blog = blog,
SamePostNameCount = count
};
Anonymous object initializers were not included in this logic prior to 0.21.0
// 0.20.0
var result =
from post in Posts
select new { Post = post, Blog = blog, SamePostNameCount = count };
// 0.21.0
var result =
from post in Posts
select new
{
Post = post,
Blog = blog,
SamePostNameCount = count
};
Thanks go to @TwentyFourMinutes for reporting it.
The CSharpier dotnet tool now works with net6 or net7.
CSharpier was not properly ignoring .cs files when they were in a subfolder of node_modules
Thanks go to @snebjorn for reporting the bug.
Full Changelog: https://github.com/belav/csharpier/compare/0.20.0...0.21.0
Tuples would break poorly in some cases
// 0.19.2
public async Task<(ILookup<string, int> someLookup, ILookup<int, string> reverseLookup, ILookup<
string,
ClassName
> thirdLookup)> CreateLookups()
{
return (null, null);
}
public void TuplesAsInput(
(int myInt, string myString, ClassName myClassNameInstance, Dictionary<
int,
string
> wordList) inputArgs
)
{
// do something
}
// 0.20.0
public async Task<(
ILookup<string, int> someLookup,
ILookup<int, string> reverseLookup,
ILookup<string, ClassName> thirdLookup
)> CreateLookups()
{
return (null, null);
}
public void TuplesAsInput(
(
int myInt,
string myString,
ClassName myClassNameInstance,
Dictionary<int, string> wordList
) inputArgs
)
{
// do something
}
Thanks go to @BenjaBobs for reporting the bug.
Full Changelog: https://github.com/belav/csharpier/compare/0.19.2...0.20.0
CSharpier now caches information about files that it has formatted to speed up subsequent runs.
By default the following are used as cache keys and a file is only formatted if one of them has changed.
The cache is stored at [LocalApplicationData]/CSharpier/.formattingCache.
CSharpier now ignores any files within a node_modules folder.
Thanks go to @RichiCoder1 for the suggestion and @SubjectAlpha for the implementation.
// 0.18.0
public class ClassName
{
public int[] SomeArray { get; set; } = { 1, 2, 3 };
}
// 0.19.0
public class MyClass
{
public int[] SomeArray { get; set; } = { 1, 2, 3 };
}
Thanks go to @TiraelSedai for reporting the bug.
Full Changelog: https://github.com/belav/csharpier/compare/0.18.0...0.19.0
CSharpier can format the following c# 11 features
CSharpier now outputs relative or absolute file paths so that they are clickable in terminals.
dotnet csharpier .
# csharpier 0.17.0
Error Invalid.cs - Failed to compile so was not formatted.
# csharpier 0.18.0
Error ./Invalid.cs - Failed to compile so was not formatted.
dotnet csharpier c:/src
# csharpier 0.17.0
Error Invalid.cs - Failed to compile so was not formatted.
# csharpier 0.18.0
Error c:/src/Invalid.cs - Failed to compile so was not formatted.
Thanks go to @dlech
// input
var someValue =
$@"
{
// comment
"hi"
}
";
// 0.17.0
var someValue =
$@"
{
// comment "hi"}
";
// 0.18.0
var someValue =
$@"
{
// comment
"hi"
}
";
Thanks go to @ivan-razorenov
CSharpier now has the ability to ignore a range of statements or members. See Ignore for more details
// csharpier-ignore-start
var unformatted = true;
var unformatted = true;
// csharpier-ignore-end
Thanks go to @pingzing
Full Changelog: https://github.com/belav/csharpier/compare/0.17.0...0.18.0
Full Changelog: https://github.com/belav/csharpier/compare/0.16.0...0.17.0
Full Changelog: https://github.com/belav/csharpier/compare/0.15.1...0.16.0
CSharpier.MsBuild
now requires .NET6 #565
Full Changelog: https://github.com/belav/csharpier/compare/0.14.0...0.15.0
assembly
attribute and using
causes two newlines #551
Full Changelog: https://github.com/belav/csharpier/compare/0.13.0...0.14.0
Full Changelog: https://github.com/belav/csharpier/compare/0.12.0...0.13.0
Full Changelog: https://github.com/belav/csharpier/compare/0.11.1...0.12.0