I know it makes Entities.ForEach
subset of SystemAPI
counterparts, but you need to remove all the “I” (readonly) delegates below:
public delegate void VVRI<T0, T1, T2, T3>(T0 t0, T1 t1, ref T2 t2, in T3 t3);
public delegate void VVRR<T0, T1, T2, T3>(T0 t0, T1 t1, ref T2 t2, ref T3 t3);
Because it is basically the same thing (T3& t3
in unsafe, same IL method signature), and the compiler doesn’t recognize that. It only creates confusion.
Sure, It can be defined because it’s delegates; you can define the same delegates over and over, even with the same signature. And I believe this is a mistake.
To prove that, when you test overloads, it gives me the following error:
using System;
public class Program
{
// Overload #1
public static void Foo(in int data)
=> Console.WriteLine("Called the 'in' version");
// Overload #2
public static void Foo(ref int data)
=> Console.WriteLine("Called the 'ref' version");
}
0>Program.cs(10,24): Error CS0663 : 'Program' cannot define an overloaded method that differs only on parameter modifiers 'ref' and 'in'
And Entities.ForEach((int, int, ref a, in b) => …) doesn’t compile because it’s ambiguous (two same ref methods (ref and in))
The call is ambiguous between the following methods or properties: 'LambdaForEachDescriptionConstructionMethods.ForEach<TDescription, T0, T1, T2, T3>(TDescription, VVRI<T0, T1, T2, T3>)' and 'LambdaForEachDescriptionConstructionMethods.ForEach<TDescription, T0, T1, T2, T3>(TDescription, VVRR<T0, T1, T2, T3>)'