IntroduceDependency with record types

The IntroduceDependencyAttribute used within the SimpleLogAttribute to inject an ILogger _logger isn't working on record types at compile-time. I'm getting this error:

Severity Code Description Project File Line Suppression State
Error LAMA0041 'OverrideMethodAspect.BuildAspect' threw 'InvalidCastException' when applied to 'SomeRecord.GetValue()': Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.RecordDeclarationSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.ConstructorDeclarationSyntax'. Exception details are in 'C:\Users\xxxx\AppData\Local\Temp\Metalama\CrashReports\2023.2.5\exception-f187d93b-fe84-4ec8-8ded-e0785ba642aa.txt'. To attach a debugger to the compiler, use the '-p:MetalamaDebugCompiler=True' command-line option. Entities C:\Source\xxxx\SomeRecord.cs 11 Active

Here's the offending record type (I created a tiny reproducible version):
public record SomeRecord(string Value)
{
    public string GetValue()
    {
        return Value;
    }
}
Was this page helpful?