You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there, found a few little issues while migrating a project to .NET 8 today 😄
Here's some sample code:
List<string>items=[// My item"Hello",];items.AddRange(["More really long words","which span multiple lines","are added here","and something bad","happens"]);classMyClass{privatereadonlyList<string>_items;publicMyClass(){_items=[];_items??=[];}}
And reformatted via the CSharpier CLI as follows:
~\source\ConsoleApp1 via .NET v8.0.100 🎯 net8.0
🕙 [ 06:57:50 PM ] ❯ dotnet csharpier --version
0.26.3+6bcc339686b935c644c660a45dc2722ef3567303
~\source\ConsoleApp1 via .NET v8.0.100 🎯 net8.0
🕙 [ 06:57:54 PM ] ❯ dotnet csharpier .
Error ./Program.cs - Failed syntax tree validation.
----------------------------- Original: Around Line 1 -----------------------------
List<string> items =
[
// My item
"Hello",
];
items.AddRange(
[
----------------------------- Formatted: Around Line 0 -----------------------------
List<string> items = [// My item
"Hello",];
items.AddRange(
[
"More really long words",
"which span multiple lines",
Formatted 1 files in 274ms.
The result is as follows:
List<string>items=[// My item"Hello",];items.AddRange(["More really long words","which span multiple lines","are added here","and something bad","happens"]);classMyClass{privatereadonlyList<string>_items;publicMyClass(){_items=[];_items??=[];}}
Here's the same code with comments for each issue:
// CSharpier should have kept the original formatting here.List<string>items=[// My item"Hello",];// An additional empty line was added below.items.AddRange(["More really long words","which span multiple lines","are added here","and something bad","happens"]);classMyClass{privatereadonlyList<string>_items;publicMyClass(){// Two spaces were added after the = sign in this scenario._items=[];_items??=[];}}
Any help is greatly appreciated
Fotis
The text was updated successfully, but these errors were encountered:
* Fixing a number of bugs with collection expressions
closes#1049closes#1047
* Found a few more edge cases
* and another
---------
Co-authored-by: Lasath Fernando <[email protected]>
Hey there, found a few little issues while migrating a project to .NET 8 today 😄
Here's some sample code:
And reformatted via the CSharpier CLI as follows:
The result is as follows:
Here's the same code with comments for each issue:
Any help is greatly appreciated
Fotis
The text was updated successfully, but these errors were encountered: