Skip to content

Commit

Permalink
Add diagnostic descriptr
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed Nov 18, 2024
1 parent 15b25bc commit c312107
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions VContainer.SourceGenerator/DiagnosticDescriptors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,13 @@ static class DiagnosticDescriptors
category: Category,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);

public static readonly DiagnosticDescriptor ConstructorNotFound = new(
id: "VCON0011",
title: "The any callbale constructor is not found. Cannot support to code generation.",
messageFormat: "Cannot find any constructor of '{0}' that can be called from internal. It cannot support source generator.",
category: Category,
defaultSeverity: DiagnosticSeverity.Warning,
isEnabledByDefault: true);
}
}
4 changes: 4 additions & 0 deletions VContainer.SourceGenerator/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ public static bool TryEmitCreateInstanceMethod(

if (constructorSymbol == null)
{
context.ReportDiagnostic(Diagnostic.Create(
DiagnosticDescriptors.ConstructorNotFound,
typeMeta.GetLocation(),
typeMeta.TypeName));
return false;
}

Expand Down

0 comments on commit c312107

Please sign in to comment.