Common.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using Microsoft.CodeAnalysis;
  2. using Microsoft.CodeAnalysis.CSharp.Syntax;
  3. namespace Godot.SourceGenerators
  4. {
  5. public static class Common
  6. {
  7. public static void ReportNonPartialGodotScriptClass(
  8. GeneratorExecutionContext context,
  9. ClassDeclarationSyntax cds, INamedTypeSymbol symbol
  10. )
  11. {
  12. string message =
  13. "Missing partial modifier on declaration of type '" +
  14. $"{symbol.FullQualifiedName()}' which is a subclass of '{GodotClasses.Object}'";
  15. string description = $"{message}. Subclasses of '{GodotClasses.Object}' must be " +
  16. "declared with the partial modifier or annotated with the " +
  17. $"attribute '{GodotClasses.DisableGodotGeneratorsAttr}'.";
  18. context.ReportDiagnostic(Diagnostic.Create(
  19. new DiagnosticDescriptor(id: "GODOT-G0001",
  20. title: message,
  21. messageFormat: message,
  22. category: "Usage",
  23. DiagnosticSeverity.Error,
  24. isEnabledByDefault: true,
  25. description),
  26. cds.GetLocation(),
  27. cds.SyntaxTree.FilePath));
  28. }
  29. }
  30. }