I am working around the limitations of #74 and I have code like this, which is working:
[Projectable(UseMemberBody = nameof(MyFuncInternal), AllowBlockBody = true)]
public virtual string? MyFunc() {
return ...;
}
internal string? MyFuncInternal(){
if(this is DerivedType1)
return ((DerivedType1)this).MyFunc();
else if(this is DerivedType2)
return ((DerivedType2)this).MyFunc();
else
return null;
}
However since Type casting is not supported inside ifs (if(this is DerivedType1 t1) t1...) I have to resort to switch expressions, however this doesn't seem to work I'm just getting a silent message ArgumentExpression "Syntax node is not within syntax tree" in ProjectionExpressionGenerator and not much else, and no source files are generated.
[Projectable(UseMemberBody = nameof(MyFuncInternal))]
public virtual string? MyFunc() {
return ...;
}
internal string? MyFuncInternal() => this switch {
DerivedType1 t1 => t1.MyFunc(),
DerivedType2 t2 => t2.MyFunc(),
_ => null
};
I am working around the limitations of #74 and I have code like this, which is working:
However since Type casting is not supported inside ifs (
if(this is DerivedType1 t1) t1...) I have to resort to switch expressions, however this doesn't seem to work I'm just getting a silent message ArgumentExpression "Syntax node is not within syntax tree" in ProjectionExpressionGenerator and not much else, and no source files are generated.