Class ConsoleMessageBuilder
An immutable builder for a structured console message. Each With* call returns a new
instance; a renderer consumes Parts and Kind. At most one part of each
MessagePart role is kept (last write wins is not applied — the first is kept).
public record ConsoleMessageBuilder : IEquatable<ConsoleMessageBuilder>
- Inheritance
-
ConsoleMessageBuilder
- Implements
- Inherited Members
Properties
Body
The body part's text, or Empty.
public string Body { get; }
Property Value
IsWithLineBreak
Whether the renderer should emit a trailing blank line after this message.
public bool IsWithLineBreak { get; init; }
Property Value
Kind
The message severity / intent.
public MessageKind Kind { get; init; }
Property Value
Parts
The parts that make up the message.
public ImmutableArray<ConsoleMessagePart> Parts { get; init; }
Property Value
StackTrace
The stack-trace part's text, or Empty.
public string StackTrace { get; }
Property Value
Title
The title part's text, or Empty.
public string Title { get; }
Property Value
Verbose
The verbose part's text, or Empty.
public string Verbose { get; }
Property Value
Methods
WithKind(MessageKind)
Sets the message MessageKind.
public ConsoleMessageBuilder WithKind(MessageKind kind)
Parameters
kindMessageKind
Returns
WithLineBreak(bool)
Requests a trailing blank line after the message.
public ConsoleMessageBuilder WithLineBreak(bool withLineBreak = true)
Parameters
withLineBreakbool
Returns
WithMessageBody(VBErrorInfo)
Adds a body part from an error's description.
public ConsoleMessageBuilder WithMessageBody(VBErrorInfo error)
Parameters
errorVBErrorInfo
Returns
WithMessageBody(Exception)
Adds a body part from an exception's message.
public ConsoleMessageBuilder WithMessageBody(Exception exception)
Parameters
exceptionException
Returns
WithMessageBody(string)
Adds a body part from literal text.
public ConsoleMessageBuilder WithMessageBody(string body)
Parameters
bodystring
Returns
WithPart(ConsoleMessagePart)
Adds an arbitrary part.
public ConsoleMessageBuilder WithPart(ConsoleMessagePart part)
Parameters
partConsoleMessagePart
Returns
WithPlaceholder(PlaceholderKind, string, double)
Adds a numeric placeholder span, substituted where {$name} appears in the body.
public ConsoleMessageBuilder WithPlaceholder(PlaceholderKind kind, string placeholder, double value)
Parameters
kindPlaceholderKindplaceholderstringvaluedouble
Returns
WithPlaceholder(string, string)
Adds a string placeholder span, substituted where {$name} appears in the body.
public ConsoleMessageBuilder WithPlaceholder(string placeholder, string value)
Parameters
Returns
WithStackTrace(Exception)
Adds a stack-trace part for an exception.
public ConsoleMessageBuilder WithStackTrace(Exception exception)
Parameters
exceptionException
Returns
WithTimestamp(DateTimeOffset)
Adds a timestamp part.
public ConsoleMessageBuilder WithTimestamp(DateTimeOffset timestamp)
Parameters
timestampDateTimeOffset
Returns
WithTitle(VBApplicationErrorInfo)
Adds a title part from an application error's diagnostic code.
public ConsoleMessageBuilder WithTitle(VBApplicationErrorInfo error)
Parameters
errorVBApplicationErrorInfo
Returns
WithTitle(VBCompileErrorInfo)
Adds a title part from a compile error's diagnostic code.
public ConsoleMessageBuilder WithTitle(VBCompileErrorInfo error)
Parameters
errorVBCompileErrorInfo
Returns
WithTitle(VBRuntimeErrorInfo)
Adds a title part from a runtime error's diagnostic code.
public ConsoleMessageBuilder WithTitle(VBRuntimeErrorInfo error)
Parameters
errorVBRuntimeErrorInfo
Returns
WithTitle(VBSyntaxErrorInfo)
Adds a title part from a syntax error's diagnostic code.
public ConsoleMessageBuilder WithTitle(VBSyntaxErrorInfo error)
Parameters
errorVBSyntaxErrorInfo
Returns
WithTitle(Exception)
Adds a title part from an exception's type name.
public ConsoleMessageBuilder WithTitle(Exception exception)
Parameters
exceptionException
Returns
WithTitle(string)
Adds a title part from literal text.
public ConsoleMessageBuilder WithTitle(string title)
Parameters
titlestring
Returns
WithVerbose(VBErrorInfo)
Adds a verbose-detail part from an error's verbose text.
public ConsoleMessageBuilder WithVerbose(VBErrorInfo error)
Parameters
errorVBErrorInfo
Returns
WithVerbose(string)
Adds a verbose-detail part from literal text.
public ConsoleMessageBuilder WithVerbose(string verbose)
Parameters
verbosestring