ValidateMessage
Description
- Derived from
Represents a validation message.
A validation message is created from a localized message text and a message type, using the constructor of this class directly or indirectly via some factory method. After creation, a ValidateMessage object can be augmented with additional context information, usually for error reporting:
Validation messages have a well-defined string representation which is intended for human consumption but also provides a trivial structure for parsing. Here is a made-up example for CxInspection.CX01001:
## /path/to/the/File.cs
>> Category / Error
@: CodeUnits['File'].Declaration
1234: #region Native {0D12D3E3-8D90-4264-B264-73C00431DE47}
___/"""""""""""""""""""""""""""""""""""""""""""""""""""""\
[CX01001] missing native code: CPP
The string representation can be interpreted line-by-line as follows (assuming ValidateMessageFormat.All):
-
ValidateMessageFormat.File:
If the line starts with"##", the trimmed remainder contains the value of FilePath. -
ValidateMessageFormat.Type:
If the line starts with">>", the trimmed remainder contains the values of Category and Type, separated by" / ". If the former isnullor empty, only the latter is used without a separator. -
ValidateMessageFormat.Path:
If the line starts with"@:", the trimmed remainder contains the value of DataPath. -
ValidateMessageFormat.Input:
If the line starts with a digit ('0'..'9'), the part up to the colon (':') gives the one-base row number in the input (see Input) and the trimmed remainder contains the trimmed input text line. The subsequent lines are indented with two whitespaces. The first subsequent line uses ASCII art to mark the input range (see InputRange). -
ValidateMessageFormat.Text
The second subsequent line (see 4) and following contain the value of Text, indented with two whitespaces, unless there are no other format flags: then the message text will then output without indenting. -
Empty lines (i.e. with a length of zero) have no meaning and can be ignored safely. They are included in the string representation as visual separators where the value of a part (1 to 3) changes.
Public / Methods
ToString
3 overloads
Returns the string representation of this message.
Returns the string representation of this message.
WithInput
2 overloads
Uses the given range in for InputRange.
Uses the given range in for InputRange.
Public / Attributes
DataPath
The logical data model path that leads to the error source.
Defaults to ValidatePath.Empty.
- See also
FilePath
Returns the file path associated with this message.
The file path is found as follows:
-
If Input returns a non-null value, use its IPathInfo.PathInfo value, if it is not unknown.
-
If ValidatePath.ContextAs for IPathInfo on DataPath returns a non-null value, use its IPathInfo.PathInfo value, if it is not unknown.
-
If ValidatePath.ContextAs for Path on DataPath returns a non-null value, use it.
-
Otherwise, use Path.Unknown.
Input
Returns the source code input associated with this message.
The source code input is found as follows: as follows:
-
If ValidatePath.ContextAs for ICodeInput on DataPath returns a non-null value, use its ICodeInput.Original value.
-
Otherwise, use
null.
- See also
InputRange
Returns the source code input range associated with this message.
The default value is RangeI.Inv, in which case the value is found as follows:
-
If ValidatePath.ContextAs for ICodeRange on DataPath is not
null, use its ICodeRange.Range value, if not undefined. -
Otherwise, return RangeI.Inv.