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
Copy file name to clipboardExpand all lines: src/NetEvolve.CodeBuilder/CSharpCodeBuilder.Scope.cs
+27-1Lines changed: 27 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
namespaceNetEvolve.CodeBuilder;
1
+
namespaceNetEvolve.CodeBuilder;
2
2
3
3
usingSystem;
4
4
@@ -23,6 +23,32 @@ public partial record CSharpCodeBuilder
23
23
/// </example>
24
24
publicIDisposableScope()=>newScopeHandler(this);
25
25
26
+
/// <summary>
27
+
/// Appends a line of text and creates a scope that automatically manages indentation levels with braces.
28
+
/// </summary>
29
+
/// <param name="value">The string value to append before creating the scope. Can be <see langword="null"/>.</param>
30
+
/// <returns>A <see cref="ScopeHandler"/> that appends an opening brace, increments indentation on creation, and appends a closing brace with decremented indentation on disposal.</returns>
31
+
/// <remarks>
32
+
/// This method combines <see cref="AppendLine(string?)"/> with <see cref="Scope()"/> functionality.
33
+
/// The returned scope handler implements <see cref="IDisposable"/> and is designed for use with the using statement.
34
+
/// When the scope is created, an opening brace is appended and indentation is incremented by one level.
35
+
/// When the scope is disposed, indentation is decremented and a closing brace is appended.
36
+
/// </remarks>
37
+
/// <example>
38
+
/// <code>
39
+
/// var builder = new CSharpCodeBuilder();
40
+
/// using (builder.ScopeLine("public class MyClass"))
41
+
/// {
42
+
/// builder.AppendLine("public string Name { get; set; }");
43
+
/// }
44
+
/// </code>
45
+
/// </example>
46
+
publicIDisposableScopeLine(string?value)
47
+
{
48
+
_=AppendLine(value);
49
+
returnnewScopeHandler(this);
50
+
}
51
+
26
52
/// <summary>
27
53
/// A disposable struct that manages indentation scope for a <see cref="CSharpCodeBuilder"/>.
0 commit comments