NullReferenceException with FastExpressionCompiler
christophwille opened this issue · 1 comments
christophwille commented
Sample with FastExpressionCompiler usage commented out, working as expected:
using FastExpressionCompiler;
using Mapster;
// TypeAdapterConfig.GlobalSettings.Compiler = exp => exp.CompileFast();
TypeAdapterConfig<TestClass, TestEnum>
.NewConfig()
.Map(dest => dest, src => src.Type == (int)TestEnum.A
? TestEnum.A
: src.Type == (int)TestEnum.B
? TestEnum.B
: src.Type == (int)TestEnum.C
? TestEnum.C
: TestEnum.D);
var testClass = new TestClass { Type = 1 };
Console.WriteLine(testClass.Type);
var testEnum = testClass.Adapt<TestEnum>();
Console.WriteLine(testEnum);
class TestClass
{
public int Type { get; set; }
}
enum TestEnum
{
A = 1,
B,
C,
D
}
With the line uncommented though, I get (on line var testEnum = testClass.Adapt<TestEnum>();
)
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
Is this a known limitation, a problem in Mapster, a problem in FastExpressionCompiler, ...? If this is a low-level bug, do you know of a workaround? Thanks.
dadhi commented
@christophwille The issue is fixed on the FEC side and will be released with the next v4.2.0