public Diagnostic( CodeFile file, TextSpan span, DiagnosticLevel level, DiagnosticPhase phase, int errorCode, string message) { if (string.IsNullOrWhiteSpace(message)) { throw new ArgumentException("Can't be null or whitespace", nameof(message)); } Requires.ValidEnum(nameof(level), level); Requires.ValidEnum(nameof(phase), phase); File = file; Span = span; StartPosition = file.Code.PositionOfStart(span); EndPosition = file.Code.PositionOfEnd(span); Level = level; Phase = phase; ErrorCode = errorCode; Message = message; }
public static void AssertDiagnostic( this Diagnostic diagnostic, DiagnosticPhase phase, int errorCode, int start, int length) { Assert.NotNull(diagnostic); Assert.Equal(phase, diagnostic.Phase); Assert.Equal(errorCode, diagnostic.ErrorCode); Assert.True(start == diagnostic.Span.Start, $"Expected diagnostic start {start}, was {diagnostic.Span.Start}"); Assert.True(length == diagnostic.Span.Length, $"Expected diagnostic length {length}, was {diagnostic.Span.Length}"); }