|
| 1 | +using Microsoft.CodeAnalysis; |
| 2 | + |
| 3 | +namespace TypedRest.CodeGeneration.CSharp; |
| 4 | + |
| 5 | +/// <summary> |
| 6 | +/// The diagnostics reported by <see cref="TypedRestSourceGenerator"/>. |
| 7 | +/// </summary> |
| 8 | +internal static class Diagnostics |
| 9 | +{ |
| 10 | + private const string Category = "TypedRest"; |
| 11 | + private const string HelpLink = "https://code-generation.typedrest.net/"; |
| 12 | + |
| 13 | + public static readonly DiagnosticDescriptor MissingServiceName = new( |
| 14 | + "TRCG001", "Missing ServiceName", |
| 15 | + "The TypedRestOpenApi item '{0}' has no ServiceName metadata and no $(TypedRestServiceName) fallback", |
| 16 | + Category, DiagnosticSeverity.Error, isEnabledByDefault: true, helpLinkUri: HelpLink); |
| 17 | + |
| 18 | + public static readonly DiagnosticDescriptor SpecError = new( |
| 19 | + "TRCG002", "OpenAPI specification error", |
| 20 | + "Error in OpenAPI specification '{0}': {1}", |
| 21 | + Category, DiagnosticSeverity.Error, isEnabledByDefault: true, helpLinkUri: HelpLink); |
| 22 | + |
| 23 | + public static readonly DiagnosticDescriptor SpecWarning = new( |
| 24 | + "TRCG003", "OpenAPI specification warning", |
| 25 | + "Warning in OpenAPI specification '{0}': {1}", |
| 26 | + Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, helpLinkUri: HelpLink); |
| 27 | + |
| 28 | + public static readonly DiagnosticDescriptor InvalidLangVersion = new( |
| 29 | + "TRCG004", "Invalid LangVersion", |
| 30 | + "Invalid LangVersion '{0}'. Expected a value such as '8', '11.0' or 'latest'. Falling back to the language version of the project.", |
| 31 | + Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, helpLinkUri: HelpLink); |
| 32 | + |
| 33 | + public static readonly DiagnosticDescriptor GenerationFailed = new( |
| 34 | + "TRCG005", "Code generation failed", |
| 35 | + "Failed to generate a TypedRest client from '{0}': {1}: {2}", |
| 36 | + Category, DiagnosticSeverity.Error, isEnabledByDefault: true, helpLinkUri: HelpLink); |
| 37 | + |
| 38 | + public static readonly DiagnosticDescriptor UnreadableSpec = new( |
| 39 | + "TRCG006", "Unreadable OpenAPI specification", |
| 40 | + "Could not read the content of '{0}'", |
| 41 | + Category, DiagnosticSeverity.Warning, isEnabledByDefault: true, helpLinkUri: HelpLink); |
| 42 | +} |
0 commit comments