Class SourceWriter
A utility class for generating indented source code.
public sealed class SourceWriter : IDisposable
- Inheritance
-
SourceWriter
- Implements
- Inherited Members
Constructors
SourceWriter(char, int, int)
Creates a new instance of SourceWriter with the specified indentation settings.
public SourceWriter(char indentationChar, int charsPerIndentation, int capacity = 1024)
Parameters
indentationCharcharThe indentation character to be used.
charsPerIndentationintThe number of characters per indentation to be applied.
capacityintThe initial capacity of the buffer.
SourceWriter(int)
Creates a new instance of SourceWriter.
public SourceWriter(int capacity = 1024)
Parameters
capacityintThe initial capacity of the buffer.
Properties
CharsPerIndentation
Gets the number of characters per indentation.
public int CharsPerIndentation { get; }
Property Value
Indentation
Gets or sets the current indentation level.
public int Indentation { get; set; }
Property Value
IndentationChar
Gets the character used for indentation.
public char IndentationChar { get; }
Property Value
Length
Gets the length of the generated source text.
public int Length { get; }
Property Value
Methods
Dispose()
Disposes the SourceWriter and returns buffers to the pool.
public void Dispose()
ToSourceText()
Encodes the currently written source to a SourceText instance.
public SourceText ToSourceText()
Returns
ToString()
Renders the written text as a string.
public override string ToString()
Returns
WriteLine()
Appends a new line to the source text.
public void WriteLine()
WriteLine(ref WriteLineInterpolatedStringHandler)
Appends a new line with the specified interpolated string.
public void WriteLine(ref SourceWriter.WriteLineInterpolatedStringHandler handler)
Parameters
handlerSourceWriter.WriteLineInterpolatedStringHandlerThe interpolated string handler.
WriteLine(char)
Appends a new line with the current character.
public void WriteLine(char value)
Parameters
valuechar
WriteLine(string, bool, bool)
Appends a new line with the specified text.
public void WriteLine(string text, bool trimDefaultAssignmentLines = false, bool disableIndentation = false)