|
| 1 | +# 0.23.0 |
| 2 | +## Breaking Changes |
| 3 | +#### Make compile errors public when using CSharpier.Core [#799](https://github.com/belav/csharpier/issues/799) |
| 4 | +Previously `CodeFormatter.Format(unformattedCode)` and its overloads returned only the formatted code. It now returns a result object. |
| 5 | +```c# |
| 6 | +public class CodeFormatterResult |
| 7 | +{ |
| 8 | + public string Code { get; } |
| 9 | + public IEnumerable<Diagnostic> CompilationErrors { get; } |
| 10 | +} |
| 11 | +``` |
| 12 | + |
| 13 | +This is a breaking change. There were also a number of types that should not have been `public` that were made `internal`. |
| 14 | + |
| 15 | +Thanks go to @verdverm for the suggestion |
| 16 | +## What's Changed |
| 17 | +#### Allow comment-description suffix on csharpier-ignore comments [#835](https://github.com/belav/csharpier/issues/835) |
| 18 | +It is now possible to include a suffix on `csharpier-ignore` comments. The description must be seperated from the comment by at least one - character. |
| 19 | +```c# |
| 20 | +// csharpier-ignore - class copied as-is from another project |
| 21 | +public class Unformatted { |
| 22 | + private string unformatted; |
| 23 | +} |
| 24 | + |
| 25 | +// csharpier-ignore-start -- class copied as-is from another project |
| 26 | +public class Unformatted1 { } |
| 27 | +public class Unformatted2 { } |
| 28 | +// csharpier-ignore-end |
| 29 | +``` |
| 30 | +Thanks go to @strepto for the suggestion |
| 31 | + |
| 32 | +#### Fix formatting for open generics [#832](https://github.com/belav/csharpier/issues/832) |
| 33 | +```c# |
| 34 | +// 0.22.1 |
| 35 | +typeof(AnExceptionallyLongAndElaborateClassNameToMakeAnExampleRegardingOpenGenerics< |
| 36 | + , |
| 37 | +>).MakeGenericType(typeof(string), typeof(int)); |
| 38 | + |
| 39 | +// 0.23.0 |
| 40 | +typeof(AnExceptionallyLongAndElaborateClassNameToMakeAnExampleRegardingOpenGenerics<,>).MakeGenericType( |
| 41 | + typeof(string), |
| 42 | + typeof(int) |
| 43 | +); |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +Thanks go to @jonstodle for reporting the issue |
| 48 | + |
| 49 | +#### #region should be indented based on context [#812](https://github.com/belav/csharpier/issues/812) |
| 50 | +Previously the preceding whitespace was left as is on `#region` and `#endregion` which resulted undesired formatting. |
| 51 | +```c# |
| 52 | +// 0.22.1 |
| 53 | +public class ClassName |
| 54 | +{ |
| 55 | + #region Ugly methods |
| 56 | + public int LongUglyMethod() |
| 57 | + { |
| 58 | + return 42; |
| 59 | + } |
| 60 | + #endregion |
| 61 | +} |
| 62 | + |
| 63 | +// 0.23.0 |
| 64 | +public class ClassName |
| 65 | +{ |
| 66 | + #region Ugly methods |
| 67 | + public int LongUglyMethod() |
| 68 | + { |
| 69 | + return 42; |
| 70 | + } |
| 71 | + #endregion |
| 72 | +} |
| 73 | +``` |
| 74 | +Thanks go to @jods4 for reporting the issue |
| 75 | +#### Return statement followed by linq query syntax not indenting correctly [#811](https://github.com/belav/csharpier/issues/811) |
| 76 | +```c# |
| 77 | +// 0.22.1 |
| 78 | +return from i in Enumerable.Range(0, 10) |
| 79 | +let i2 = i * i |
| 80 | +where i2 < 100 |
| 81 | +select new { Square = i2, Root = i }; |
| 82 | + |
| 83 | +// 0.23.0 |
| 84 | +return from i in Enumerable.Range(0, 10) |
| 85 | + let i2 = i * i |
| 86 | + where i2 < 100 |
| 87 | + select new { Square = i2, Root = i }; |
| 88 | +``` |
| 89 | + |
| 90 | +Thanks go to @jods4 for reporting the issue |
| 91 | + |
| 92 | +#### Array and dictionary initializers should break in some cases to improve readability [#809](https://github.com/belav/csharpier/issues/809) |
| 93 | +```c# |
| 94 | +// 0.22.1 |
| 95 | +var dictionaryInitializer = new Dictionary<int, string> { { 1, "" }, { 2, "a" }, { 3, "b" } }; |
| 96 | +int[,,] cube = { { { 111, 112 }, { 121, 122 } }, { { 211, 212 }, { 221, 222 } } }; |
| 97 | +int[][] jagged = { { 111 }, { 121, 122 } }; |
| 98 | + |
| 99 | +// 0.23.0 |
| 100 | +var dictionaryInitializer = new Dictionary<int, string> |
| 101 | +{ |
| 102 | + { 1, "" }, |
| 103 | + { 2, "a" }, |
| 104 | + { 3, "b" } |
| 105 | +}; |
| 106 | +int[,,] cube = |
| 107 | +{ |
| 108 | + { |
| 109 | + { 111, 112 }, |
| 110 | + { 121, 122 } |
| 111 | + }, |
| 112 | + { |
| 113 | + { 211, 212 }, |
| 114 | + { 221, 222 } |
| 115 | + } |
| 116 | +}; |
| 117 | +int[][] jagged = |
| 118 | +{ |
| 119 | + { 111 }, |
| 120 | + { 121, 122 } |
| 121 | +}; |
| 122 | +``` |
| 123 | +#### List initializer inside object initializer breaks poorly [#802](https://github.com/belav/csharpier/issues/802) |
| 124 | +```c# |
| 125 | +// 0.22.1 |
| 126 | +var someObject = new SomeObject { SomeArray = new SomeOtherObject[] |
| 127 | + { |
| 128 | + new SomeOtherObject { SomeProperty = 1 }, |
| 129 | + new SomeOtherObject() |
| 130 | + }.CallMethod().CallMethod() }; |
| 131 | + |
| 132 | +// 0.23.0 |
| 133 | +var someObject = new SomeObject |
| 134 | +{ |
| 135 | + SomeArray = new SomeOtherObject[] |
| 136 | + { |
| 137 | + new SomeOtherObject { SomeProperty = 1 }, |
| 138 | + new SomeOtherObject() |
| 139 | + } |
| 140 | + .CallMethod() |
| 141 | + .CallMethod() |
| 142 | +}; |
| 143 | + |
| 144 | +``` |
| 145 | + |
| 146 | +Thanks go to @shocklateboy92 for reporting the issue |
| 147 | +#### Allow passing --config-path to cli [#777](https://github.com/belav/csharpier/issues/777) |
| 148 | +It is now possible to pass `--config-path` to the cli for cases where it is not in the root or you want to bypass the auto location and speed up formatting requests. |
| 149 | +```bash |
| 150 | +dotnet csharpier . --config-path "./config/.csharpierrc" |
| 151 | +``` |
| 152 | + |
| 153 | +Thanks go to @bdovaz for the suggestion |
| 154 | + |
| 155 | +#### Allow blank lines in query syntax [#754](https://github.com/belav/csharpier/issues/754) |
| 156 | +It is now possible to add blank lines in query syntax expressions which can aid in readability |
| 157 | +```c# |
| 158 | +var result = await ( |
| 159 | + from post in dbContext.Posts |
| 160 | + join blog in dbContext.Blogs on post.BlogId equals blog.Id |
| 161 | + |
| 162 | + let count = dbContext.Posts.Count(p => p.Name == post.Name) |
| 163 | + |
| 164 | + where post.Id == 1 |
| 165 | + select new |
| 166 | + { |
| 167 | + Post = post, |
| 168 | + Blog = blog, |
| 169 | + SamePostNameCount = count |
| 170 | + } |
| 171 | +) |
| 172 | + .AsNoTracking() |
| 173 | + .FirstAsync(); |
| 174 | +``` |
| 175 | + |
| 176 | +Thanks go to @TwentyFourMinutes for the suggestion |
| 177 | + |
| 178 | +#### #if causes line after it to break when it contains an if [#666](https://github.com/belav/csharpier/issues/666) |
| 179 | +```c# |
| 180 | +// 0.22.1 |
| 181 | +class ClassName |
| 182 | +{ |
| 183 | + public void MethodName() |
| 184 | + { |
| 185 | +#if !IF_STATEMENT_HERE_SHOULD_NOT_BREAK_INVOCATION_AFTER_ENDIF |
| 186 | + if (true) |
| 187 | + { |
| 188 | + return; |
| 189 | + } |
| 190 | +#endif |
| 191 | + SomeObject |
| 192 | + .CallMethod() |
| 193 | + .CallOtherMethod(shouldNotBreak); |
| 194 | + } |
| 195 | +} |
| 196 | + |
| 197 | +// 0.23.0 |
| 198 | +class ClassName |
| 199 | +{ |
| 200 | + public void MethodName() |
| 201 | + { |
| 202 | +#if !IF_STATEMENT_HERE_SHOULD_NOT_BREAK_INVOCATION_AFTER_ENDIF |
| 203 | + if (true) |
| 204 | + { |
| 205 | + return; |
| 206 | + } |
| 207 | +#endif |
| 208 | + SomeObject.CallMethod().CallOtherMethod(shouldNotBreak); |
| 209 | + } |
| 210 | +} |
| 211 | + |
| 212 | +``` |
| 213 | + |
| 214 | +**Full Changelog**: https://github.com/belav/csharpier/compare/0.22.0...0.23.0 |
| 215 | + |
1 | 216 | # 0.22.1 |
2 | 217 | ## What's Changed |
3 | 218 | #### Fix for CSharpier.MsBuild so it selects a compatible framework if the project does not target net6 or net7 [#797](https://github.com/belav/csharpier/pull/797) |
|
0 commit comments