I would like to use Linq expression trees to call the indexer of a Span<T>. The code looks like:
var spanGetter = typeof(Span<>)
.MakeGenericType(typeof(float)).GetMethod("get_Item");
var myFloatSpan = Expression.Parameter(typeof(Span<float>), "s");
var myValue = Expression.Call(
myFloatSpan,
spanGetter,
Expression.Constant(42));
var myAdd = Expression.Add(
myValue,
Expression.Constant(13f));
Yet, this code fails because myValue is of type Single& (aka ref struct) instead of type Single (aka struct).
How to evaluate a Span<T> from an expression tree?