MLLIF
a MLIR-based Language to Language Interoperability Flyover
Loading...
Searching...
No Matches
BindingDiagnostic.cs
Go to the documentation of this file.
1using Microsoft.CodeAnalysis;
2
4
5public class BindingDiagnostic(WorkspaceDiagnosticKind kind, string message, Project project, Document? document)
6 : WorkspaceDiagnostic(kind, message)
7{
8 public Project Project { get; } = project;
9 public Document? Document { get; } = document;
10
11 public override string ToString()
12 {
13 var kindText = Kind switch
14 {
15 WorkspaceDiagnosticKind.Failure => "error",
16 WorkspaceDiagnosticKind.Warning => "warning",
17 _ => throw new ArgumentOutOfRangeException()
18 };
19
20 return $"{Document?.FilePath ?? Project.Name}: {kindText}: {Message}";
21 }
22
23 public static BindingDiagnostic Error(Project project, ISymbol symbol, string message)
24 {
25 return new BindingDiagnostic(WorkspaceDiagnosticKind.Failure, message, project, project.GetDocument(symbol));
26 }
27}
Microsoft.CodeAnalysis.Project Project
Definition Program.cs:6
class BindingDiagnostic(WorkspaceDiagnosticKind kind, string message, Project project, Document? document)