Skip to content

Add Scope method for indentation management #14

@samtrion

Description

@samtrion

Feature Request

Add a method to work with scopes that automatically handles indentation. When a scope is opened, the code is indented, and when the scope is closed, the indentation is reversed.

Example Usage

using (builder.Scope())
{
    builder.AppendLine("return true;");
}

Benefits

  • Simplifies code indentation management
  • Ensures proper indentation when generating code blocks
  • Reduces the chance of incorrect indentation in generated code
  • Improves readability of the generated code builder usage

Implementation Notes

  • Should be available as an extension method or directly on the CodeBuilderBase
  • Should implement IDisposable for use with the 'using' statement
  • Should handle the indentation increment on creation and decrement on disposal

Related Files

  • CodeBuilderBase.cs
  • CSharpCodeBuilder.cs

Metadata

Metadata

Assignees

Labels

type:featureIndicates a new feature or enhancement to be added.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions