Table of Contents

Struct RDCoreDiagnosticCode

Namespace
RDCore.SDK.Extensibility.Diagnostics
Assembly
RDCore.SDK.dll

The code a diagnostic is reported under: a prefix of three letters that says who issues it, and a number of five digits, as in XYZ00042 (RD-VBAL §1.1.4).

[JsonConverter(typeof(RDCoreDiagnosticCodeJsonConverter))]
public readonly record struct RDCoreDiagnosticCode : IEquatable<RDCoreDiagnosticCode>
Implements
Inherited Members

Remarks

The platform issues the VBC, VBR and VBA codes, and its core extension the RDC codes. The RDX codes are those of the platform's first-party extensions, the core extension included. An extension of another publisher reports its own diagnostics under the prefix its manifest declares (DiagnosticPrefix), which no other extension of the platform declares.

A code is serialized as it is written (ToString()), and read back with TryParse(string?, out RDCoreDiagnosticCode).

Constructors

RDCoreDiagnosticCode(string, int)

Creates the code of a prefix and a number.

public RDCoreDiagnosticCode(string prefix, int number)

Parameters

prefix string

Three letters, A to Z.

number int

A number from 0 to MaxNumber.

Exceptions

ArgumentException

prefix is not three letters A to Z.

ArgumentOutOfRangeException

number is not from 0 to MaxNumber.

Fields

ApplicationPrefix

The prefix of the codes of the errors a program raises itself.

public const string ApplicationPrefix = "VBA"

Field Value

string

CompilePrefix

The prefix of the codes of the platform's syntax and compile errors.

public const string CompilePrefix = "VBC"

Field Value

string

CorePrefix

The prefix of the codes of the core diagnostics, which the core extension reports.

public const string CorePrefix = "RDC"

Field Value

string

ExtensionPrefix

The prefix of the codes of the diagnostics of the platform's other first-party extensions.

public const string ExtensionPrefix = "RDX"

Field Value

string

MaxNumber

The largest number a code has: five digits.

public const int MaxNumber = 99999

Field Value

int

RuntimePrefix

The prefix of the codes of the run-time errors of the language.

public const string RuntimePrefix = "VBR"

Field Value

string

Properties

CanBeDisabled

Whether the diagnostics of the code can be disabled (Analysis.DisabledDiagnostics): those of the analyzers of the platform and of its extensions can. The language's own errors (CompilePrefix, RuntimePrefix, ApplicationPrefix) cannot: code that has one does not compile, or stops when it runs, whatever the settings say.

public bool CanBeDisabled { get; }

Property Value

bool

FirstPartyPrefixes

The prefixes of the platform's own codes: the language's errors, and its first-party extensions' diagnostics.

public static IReadOnlyList<string> FirstPartyPrefixes { get; }

Property Value

IReadOnlyList<string>

IsFirstParty

Whether the code is one of the platform's own (FirstPartyPrefixes), which its documentation describes.

public bool IsFirstParty { get; }

Property Value

bool

Number

The number of the diagnostic among those of Prefix.

public int Number { get; }

Property Value

int

Prefix

The three letters that say who issues the diagnostic.

public string Prefix { get; }

Property Value

string

Methods

IsFirstPartyPrefix(string)

Whether a prefix is one of the platform's own (FirstPartyPrefixes).

public static bool IsFirstPartyPrefix(string prefix)

Parameters

prefix string

The prefix to check.

Returns

bool

IsPrefix(string?)

Whether a text is a prefix of a diagnostic code: three letters A to Z.

public static bool IsPrefix(string? prefix)

Parameters

prefix string

The text to check.

Returns

bool

ToString()

The code as it is written: its prefix, and its number in five digits.

public override string ToString()

Returns

string

TryParse(string?, out RDCoreDiagnosticCode)

Reads a code written as its prefix and its five digits, as in XYZ00042.

public static bool TryParse(string? text, out RDCoreDiagnosticCode code)

Parameters

text string

The text to read.

code RDCoreDiagnosticCode

The code read; default when text is not one.

Returns

bool

Whether text is a code.