Skip to content

Commit

Permalink
Fix exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Feb 17, 2024
1 parent d0db90a commit d020a48
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sourcegeneration/StereologueSourceGenerator/LogGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public class LogGenerator : IIncrementalGenerator
}
token.ThrowIfCancellationRequested();

var diagnosticList = new ImmutableArray<DiagnosticInfo>();
var diagnosticList = ImmutableArray.CreateBuilder<DiagnosticInfo>();

var diagnostic = GetDiagnosticIfInvalidClassForGeneration((TypeDeclarationSyntax)context.TargetNode, classSymbol);
if (diagnostic is { } ds)
{
diagnosticList.Add(ds);
return new(null, diagnosticList);
return new(null, diagnosticList.ToImmutable());
}

var ns = classSymbol.ContainingNamespace?.ToDisplayString();
Expand Down Expand Up @@ -149,7 +149,7 @@ public class LogGenerator : IIncrementalGenerator
var fmt = new SymbolDisplayFormat(genericsOptions: SymbolDisplayGenericsOptions.None);
var fileName = $"{classSymbol.ContainingNamespace}{classSymbol.ToDisplayString(fmt)}{classSymbol.MetadataName}";

return new ClassOrDiagnostic(new ClassData(loggableMembers.ToImmutable(), $"{classSymbol.ContainingNamespace}{classSymbol.ToDisplayString(fmt)}{classSymbol.MetadataName}", typeBuilder.ToString(), ns), diagnosticList);
return new ClassOrDiagnostic(new ClassData(loggableMembers.ToImmutable(), $"{classSymbol.ContainingNamespace}{classSymbol.ToDisplayString(fmt)}{classSymbol.MetadataName}", typeBuilder.ToString(), ns), diagnosticList.ToImmutable());
}

private static LogData ComputeOperation(ITypeSymbol logType, string getOp, LogAttributeInfo attributeInfo)
Expand Down Expand Up @@ -258,7 +258,7 @@ static void ConstructCall(LogData data, StringBuilder builder, SourceProductionC

if (ret.LogMethod is null)
{
//context.ReportDiagnostic(DiagnosticInfo.Create(GeneratorDiagnostics.LoggableTypeNotSupported, null, [data.Type]).CreateDiagnostic());
context.ReportDiagnostic(DiagnosticInfo.Create(GeneratorDiagnostics.LoggableTypeNotSupported, null, [data.Type]).CreateDiagnostic());
builder.AppendLine();
return;
}
Expand Down Expand Up @@ -305,7 +305,6 @@ static void Execute(ClassOrDiagnostic? classData, SourceProductionContext contex
if (!syntax.IsInPartialContext(out var nonPartialIdentifier))
{
return DiagnosticInfo.Create(GeneratorDiagnostics.GeneratedTypeNotPartial, syntax.Identifier.GetLocation(), [symbol.Name, nonPartialIdentifier]);
;
}

// Ensure class doesn't implement ILogged
Expand Down

0 comments on commit d020a48

Please sign in to comment.