Skip to content

Commit 72dee0b

Browse files
committed
style: Reformatted code
1 parent a28e58f commit 72dee0b

7 files changed

Lines changed: 29 additions & 70 deletions

src/NetEvolve.CodeBuilder/CSharpCodeBuilder.AppendFormat.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ public CSharpCodeBuilder AppendFormat(string format, params object?[] args) =>
3939
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
4040
/// <exception cref="ArgumentNullException">Thrown when <paramref name="format"/> is <see langword="null"/>.</exception>
4141
/// <exception cref="FormatException">Thrown when <paramref name="format"/> is invalid or the index of a format item is greater than the number of elements in <paramref name="args"/> minus 1.</exception>
42-
public CSharpCodeBuilder AppendFormat(
43-
IFormatProvider? provider,
44-
string format,
45-
params object?[] args
46-
)
42+
public CSharpCodeBuilder AppendFormat(IFormatProvider? provider, string format, params object?[] args)
4743
{
4844
EnsureIndented();
4945
_ = _builder.AppendFormat(provider, format, args);

src/NetEvolve.CodeBuilder/CSharpCodeBuilder.AppendIf.cs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public partial record CSharpCodeBuilder
1313
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
1414
/// <remarks>Appends either "true" or "false" based on the value if the condition is true.</remarks>
1515
[MethodImpl(MethodImplOptions.AggressiveInlining)]
16-
public CSharpCodeBuilder AppendIf(bool condition, bool value) =>
17-
condition ? Append(value) : this;
16+
public CSharpCodeBuilder AppendIf(bool condition, bool value) => condition ? Append(value) : this;
1817

1918
/// <summary>
2019
/// Appends a character repeated a specified number of times to the current builder if the specified condition is true.
@@ -35,8 +34,7 @@ public CSharpCodeBuilder AppendIf(bool condition, char value, int repeatCount) =
3534
/// <param name="value">The character to append.</param>
3635
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
3736
[MethodImpl(MethodImplOptions.AggressiveInlining)]
38-
public CSharpCodeBuilder AppendIf(bool condition, char value) =>
39-
condition ? Append(value) : this;
37+
public CSharpCodeBuilder AppendIf(bool condition, char value) => condition ? Append(value) : this;
4038

4139
/// <summary>
4240
/// Appends a subset of an array of characters to the current builder if the specified condition is true.
@@ -48,12 +46,8 @@ public CSharpCodeBuilder AppendIf(bool condition, char value) =>
4846
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
4947
/// <remarks>If the array is null or empty, the method returns without appending anything.</remarks>
5048
[MethodImpl(MethodImplOptions.AggressiveInlining)]
51-
public CSharpCodeBuilder AppendIf(
52-
bool condition,
53-
char[]? value,
54-
int startIndex,
55-
int charCount
56-
) => condition ? Append(value, startIndex, charCount) : this;
49+
public CSharpCodeBuilder AppendIf(bool condition, char[]? value, int startIndex, int charCount) =>
50+
condition ? Append(value, startIndex, charCount) : this;
5751

5852
/// <summary>
5953
/// Appends an array of characters to the current builder if the specified condition is true.
@@ -63,8 +57,7 @@ int charCount
6357
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
6458
/// <remarks>If the array is null or empty, the method returns without appending anything.</remarks>
6559
[MethodImpl(MethodImplOptions.AggressiveInlining)]
66-
public CSharpCodeBuilder AppendIf(bool condition, char[]? value) =>
67-
condition ? Append(value) : this;
60+
public CSharpCodeBuilder AppendIf(bool condition, char[]? value) => condition ? Append(value) : this;
6861

6962
/// <summary>
7063
/// Appends characters from a pointer to the current builder if the specified condition is true.
@@ -86,8 +79,7 @@ public unsafe CSharpCodeBuilder AppendIf(bool condition, char* value, int length
8679
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
8780
/// <remarks>If the memory is empty, the method returns without appending anything.</remarks>
8881
[MethodImpl(MethodImplOptions.AggressiveInlining)]
89-
public CSharpCodeBuilder AppendIf(bool condition, ReadOnlyMemory<char> value) =>
90-
condition ? Append(value) : this;
82+
public CSharpCodeBuilder AppendIf(bool condition, ReadOnlyMemory<char> value) => condition ? Append(value) : this;
9183

9284
/// <summary>
9385
/// Appends a subset of a read-only memory of characters to the current builder if the specified condition is true.
@@ -99,12 +91,8 @@ public CSharpCodeBuilder AppendIf(bool condition, ReadOnlyMemory<char> value) =>
9991
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
10092
/// <remarks>If the memory is empty, the method returns without appending anything.</remarks>
10193
[MethodImpl(MethodImplOptions.AggressiveInlining)]
102-
public CSharpCodeBuilder AppendIf(
103-
bool condition,
104-
ReadOnlyMemory<char> value,
105-
int startIndex,
106-
int count
107-
) => condition ? Append(value, startIndex, count) : this;
94+
public CSharpCodeBuilder AppendIf(bool condition, ReadOnlyMemory<char> value, int startIndex, int count) =>
95+
condition ? Append(value, startIndex, count) : this;
10896

10997
/// <summary>
11098
/// Appends a subset of a string to the current builder if the specified condition is true.
@@ -127,6 +115,5 @@ public CSharpCodeBuilder AppendIf(bool condition, string? value, int startIndex,
127115
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
128116
/// <remarks>If the string is null or empty, the method returns without appending anything.</remarks>
129117
[MethodImpl(MethodImplOptions.AggressiveInlining)]
130-
public CSharpCodeBuilder AppendIf(bool condition, string? value) =>
131-
condition ? Append(value) : this;
118+
public CSharpCodeBuilder AppendIf(bool condition, string? value) => condition ? Append(value) : this;
132119
}

src/NetEvolve.CodeBuilder/CSharpCodeBuilder.AppendLine.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ public CSharpCodeBuilder AppendLine(char[]? value, int startIndex, int charCount
8080
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
8181
/// <remarks>If the pointer is null or length is negative, only the line terminator is appended.</remarks>
8282
[MethodImpl(MethodImplOptions.AggressiveInlining)]
83-
public unsafe CSharpCodeBuilder AppendLine(char* value, int length) =>
84-
Append(value, length).AppendLine();
83+
public unsafe CSharpCodeBuilder AppendLine(char* value, int length) => Append(value, length).AppendLine();
8584

8685
/// <summary>
8786
/// Appends a character followed by a line terminator to the current builder.
@@ -99,8 +98,7 @@ public unsafe CSharpCodeBuilder AppendLine(char* value, int length) =>
9998
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
10099
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="repeatCount"/> is less than zero.</exception>
101100
[MethodImpl(MethodImplOptions.AggressiveInlining)]
102-
public CSharpCodeBuilder AppendLine(char value, int repeatCount) =>
103-
Append(value, repeatCount).AppendLine();
101+
public CSharpCodeBuilder AppendLine(char value, int repeatCount) => Append(value, repeatCount).AppendLine();
104102

105103
/// <summary>
106104
/// Appends a boolean value followed by a line terminator to the current builder.

src/NetEvolve.CodeBuilder/CSharpCodeBuilder.AppendLineIf.cs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public partial record CSharpCodeBuilder
2121
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
2222
/// <remarks>If the string is null or empty, the method returns without appending anything.</remarks>
2323
[MethodImpl(MethodImplOptions.AggressiveInlining)]
24-
public CSharpCodeBuilder AppendLineIf(bool condition, string? value) =>
25-
condition ? AppendLine(value) : this;
24+
public CSharpCodeBuilder AppendLineIf(bool condition, string? value) => condition ? AppendLine(value) : this;
2625

2726
/// <summary>
2827
/// Appends a read-only memory of characters followed by a line terminator to the current builder if the specified condition is true.
@@ -45,12 +44,8 @@ public CSharpCodeBuilder AppendLineIf(bool condition, ReadOnlyMemory<char> value
4544
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
4645
/// <remarks>If the memory is empty, the method returns without appending anything.</remarks>
4746
[MethodImpl(MethodImplOptions.AggressiveInlining)]
48-
public CSharpCodeBuilder AppendLineIf(
49-
bool condition,
50-
ReadOnlyMemory<char> value,
51-
int startIndex,
52-
int count
53-
) => condition ? AppendLine(value, startIndex, count) : this;
47+
public CSharpCodeBuilder AppendLineIf(bool condition, ReadOnlyMemory<char> value, int startIndex, int count) =>
48+
condition ? AppendLine(value, startIndex, count) : this;
5449

5550
/// <summary>
5651
/// Appends an array of characters followed by a line terminator to the current builder if the specified condition is true.
@@ -60,8 +55,7 @@ int count
6055
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
6156
/// <remarks>If the array is null or empty, the method returns without appending anything.</remarks>
6257
[MethodImpl(MethodImplOptions.AggressiveInlining)]
63-
public CSharpCodeBuilder AppendLineIf(bool condition, char[]? value) =>
64-
condition ? AppendLine(value) : this;
58+
public CSharpCodeBuilder AppendLineIf(bool condition, char[]? value) => condition ? AppendLine(value) : this;
6559

6660
/// <summary>
6761
/// Appends a subset of an array of characters followed by a line terminator to the current builder if the specified condition is true.
@@ -73,12 +67,8 @@ public CSharpCodeBuilder AppendLineIf(bool condition, char[]? value) =>
7367
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
7468
/// <remarks>If the array is null or empty, the method returns without appending anything.</remarks>
7569
[MethodImpl(MethodImplOptions.AggressiveInlining)]
76-
public CSharpCodeBuilder AppendLineIf(
77-
bool condition,
78-
char[]? value,
79-
int startIndex,
80-
int charCount
81-
) => condition ? AppendLine(value, startIndex, charCount) : this;
70+
public CSharpCodeBuilder AppendLineIf(bool condition, char[]? value, int startIndex, int charCount) =>
71+
condition ? AppendLine(value, startIndex, charCount) : this;
8272

8373
/// <summary>
8474
/// Appends characters from a pointer followed by a line terminator to the current builder if the specified condition is true.
@@ -99,8 +89,7 @@ public unsafe CSharpCodeBuilder AppendLineIf(bool condition, char* value, int le
9989
/// <param name="value">The character to append.</param>
10090
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
10191
[MethodImpl(MethodImplOptions.AggressiveInlining)]
102-
public CSharpCodeBuilder AppendLineIf(bool condition, char value) =>
103-
condition ? AppendLine(value) : this;
92+
public CSharpCodeBuilder AppendLineIf(bool condition, char value) => condition ? AppendLine(value) : this;
10493

10594
/// <summary>
10695
/// Appends a character repeated a specified number of times followed by a line terminator to the current builder if the specified condition is true.
@@ -122,6 +111,5 @@ public CSharpCodeBuilder AppendLineIf(bool condition, char value, int repeatCoun
122111
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
123112
/// <remarks>Appends either "true" or "false" based on the value if the condition is true.</remarks>
124113
[MethodImpl(MethodImplOptions.AggressiveInlining)]
125-
public CSharpCodeBuilder AppendLineIf(bool condition, bool value) =>
126-
condition ? AppendLine(value) : this;
114+
public CSharpCodeBuilder AppendLineIf(bool condition, bool value) => condition ? AppendLine(value) : this;
127115
}

src/NetEvolve.CodeBuilder/CSharpCodeBuilder.Documentation.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ public partial record CSharpCodeBuilder
1414
/// <remarks>If the content is null or empty, the method returns without appending anything.</remarks>
1515
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1616
public CSharpCodeBuilder AppendXmlDoc(string? content) =>
17-
string.IsNullOrEmpty(content)
18-
? this
19-
: EnsureNewLineForXmlDoc().AppendLine($"/// {content}");
17+
string.IsNullOrEmpty(content) ? this : EnsureNewLineForXmlDoc().AppendLine($"/// {content}");
2018

2119
/// <summary>
2220
/// Appends an XML documentation summary element.
@@ -79,8 +77,7 @@ public CSharpCodeBuilder AppendXmlDocParam(string? paramName, string? descriptio
7977
return this;
8078
}
8179

82-
return EnsureNewLineForXmlDoc()
83-
.AppendLine($"/// <param name=\"{paramName}\">{description}</param>");
80+
return EnsureNewLineForXmlDoc().AppendLine($"/// <param name=\"{paramName}\">{description}</param>");
8481
}
8582

8683
/// <summary>
@@ -89,9 +86,7 @@ public CSharpCodeBuilder AppendXmlDocParam(string? paramName, string? descriptio
8986
/// <param name="parameters">A collection of parameter name and description pairs.</param>
9087
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
9188
/// <remarks>If the parameters collection is null or empty, the method returns without appending anything.</remarks>
92-
public CSharpCodeBuilder AppendXmlDocParams(
93-
IEnumerable<(string Name, string Description)>? parameters
94-
)
89+
public CSharpCodeBuilder AppendXmlDocParams(IEnumerable<(string Name, string Description)>? parameters)
9590
{
9691
if (parameters is null)
9792
{
@@ -194,9 +189,7 @@ public CSharpCodeBuilder AppendXmlDocException(string? exceptionType, string? de
194189
/// <param name="exceptions">A collection of exception type and description pairs.</param>
195190
/// <returns>The current <see cref="CSharpCodeBuilder"/> instance to allow for method chaining.</returns>
196191
/// <remarks>If the exceptions collection is null or empty, the method returns without appending anything.</remarks>
197-
public CSharpCodeBuilder AppendXmlDocExceptions(
198-
IEnumerable<(string Type, string Description)>? exceptions
199-
)
192+
public CSharpCodeBuilder AppendXmlDocExceptions(IEnumerable<(string Type, string Description)>? exceptions)
200193
{
201194
if (exceptions is null)
202195
{
@@ -321,8 +314,7 @@ public CSharpCodeBuilder AppendXmlDocTypeParam(string? paramName, string? descri
321314
return this;
322315
}
323316

324-
return EnsureNewLineForXmlDoc()
325-
.AppendLine($"/// <typeparam name=\"{paramName}\">{description}</typeparam>");
317+
return EnsureNewLineForXmlDoc().AppendLine($"/// <typeparam name=\"{paramName}\">{description}</typeparam>");
326318
}
327319

328320
/// <summary>
@@ -384,8 +376,7 @@ public CSharpCodeBuilder AppendXmlDocCustomElement(
384376
return EnsureNewLineForXmlDoc().AppendLine($"/// <{elementName}{attributesPart} />");
385377
}
386378

387-
return EnsureNewLineForXmlDoc()
388-
.AppendLine($"/// <{elementName}{attributesPart}>{content}</{elementName}>");
379+
return EnsureNewLineForXmlDoc().AppendLine($"/// <{elementName}{attributesPart}>{content}</{elementName}>");
389380
}
390381

391382
/// <summary>

src/NetEvolve.CodeBuilder/CodeBuilderBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public abstract partial record CodeBuilderBase
2020
/// Initializes a new instance of the <see cref="CodeBuilderBase"/> class with the specified initial capacity.
2121
/// </summary>
2222
/// <param name="initialCapacity">The initial capacity of the internal <see cref="StringBuilder"/>.</param>
23-
private protected CodeBuilderBase(int initialCapacity) =>
24-
_builder = new StringBuilder(initialCapacity);
23+
private protected CodeBuilderBase(int initialCapacity) => _builder = new StringBuilder(initialCapacity);
2524

2625
/// <summary>
2726
/// Gets the current capacity of the internal <see cref="StringBuilder"/>.

tests/NetEvolve.CodeBuilder.Tests.Unit/NetEvolve.CodeBuilder.Tests.Unit.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
</PropertyGroup>
99
<ItemGroup>
10-
<PackageReference Include="NetEvolve.Extensions.TUnit" />
1110
<PackageReference Include="TUnit" />
1211
</ItemGroup>
1312
<ItemGroup>
1413
<ProjectReference Include="..\..\src\NetEvolve.CodeBuilder\NetEvolve.CodeBuilder.csproj" />
1514
</ItemGroup>
16-
<ItemGroup>
15+
<ItemGroup Condition=" '$(TargetFramework)' != 'net6.0' and '$(TargetFramework)' != 'net7.0' ">
16+
<PackageReference Include="NetEvolve.Extensions.TUnit" />
1717
<AssemblyAttribute Include="NetEvolve.Extensions.TUnit.UnitTestAttribute" />
1818
</ItemGroup>
1919
</Project>

0 commit comments

Comments
 (0)