コード例 #1
0
 public static void ReportDiagnostic(
     this GeneratorExecutionContext context,
     string id,
     string title,
     string message,
     string filePath,
     HotChocolate.Location location) =>
 context.ReportDiagnostic(
     Diagnostic.Create(
         new DiagnosticDescriptor(
             id: id,
             title: title,
             messageFormat: message,
             category: ErrorCategory,
             DiagnosticSeverity.Error,
             isEnabledByDefault: true),
         Microsoft.CodeAnalysis.Location.Create(
             filePath,
             TextSpan.FromBounds(1, 2),
             new LinePositionSpan(
                 new LinePosition(
                     location.Line,
                     location.Column),
                 new LinePosition(
                     location.Line,
                     location.Column + 1)))));
コード例 #2
0
 protected static void WriteErrors(IReadOnlyList <HCError> errors)
 {
     if (errors.Count > 0)
     {
         foreach (HCError error in errors)
         {
             HotChocolate.Location location = error.Locations[0];
             string code = error.Code ?? "GQL";
             Console.WriteLine(
                 $"{IOPath.GetFullPath((string)error.Extensions["fileName"])}" +
                 $"({location.Line},{location.Column}): " +
                 $"error {code}: {error.Message}");
         }
     }
 }
コード例 #3
0
 public static void ReportDiagnostic(
     this GeneratorExecutionContext context,
     DiagnosticDescriptor descriptor,
     string filePath,
     HotChocolate.Location location,
     params object[] messageArgs) =>
 context.ReportDiagnostic(Diagnostic.Create(
                              descriptor,
                              Microsoft.CodeAnalysis.Location.Create(
                                  filePath,
                                  TextSpan.FromBounds(1, 2),
                                  new LinePositionSpan(
                                      new LinePosition(
                                          location.Line,
                                          location.Column),
                                      new LinePosition(
                                          location.Line,
                                          location.Column + 1))),
                              messageArgs));