I found an issue upgrading to the .NET 6 LogErrorInterpolatedStringHandler in my logger method.
Here is the classic method:
public static void Log(string message, params object[] pars)
{
// Log message
}
and here is the upgraded one:
public static void Log(ref LogErrorInterpolatedStringHandler message, params object[] pars)
{
// Log message
}
I upgraded the method in order to get the performance improvements of C# 10 and .NET 6 described here.
The new version of the method works well except when passing dynamic object in the interpolated string.
Here is an example:
// Works well
Logger.Log($"Log: {stringOrEverythingElseObject}");
// Exception
Logger.Log($"Log: {dynamicObject}");
The exception thrown is
The generic type '<>A{00000004}`3' was used with an invalid instantiation in assembly 'MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
I found a pull request similar to my problem but could not understand how to fix in my code.
Do you have any idea? Thanks!