-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempted to access an element as a type incompatible with the array. #860
Comments
@AArnott Could you please release preview/testing nuget with modified "mono" check (that will also work on Android). The current check is not working on Android:
But the following check is: Type.GetType("Mono.RuntimeStructs") != null Source: |
The issue appears only when the method has no parameters. "Mono" (.net 6 on android) returns in that case In that case, static void Main()
{
var type = Type.GetType("System.Object");
TestMethod(type, "ReferenceEquals");
TestMethod(type, "ToString");
}
static void TestMethod(Type type, string name)
{
var method = type.GetMethod(name);
var parameters = method.GetParameters();
new ReadOnlySpan<ParameterInfo>(parameters, 0, 0);
Span<ParameterInfo> sp = parameters.AsSpan(0, 0); // <- this will fail on "mono" in case of method with 0 parameters
} The following example will fail also in "vanilla" .net 6 (on windows): class A { }
class B : A { }
void Main()
{
new ReadOnlySpan<A>(Array.Empty<B>());
((A[])Array.Empty<B>()).AsSpan(); // <- error here
} I think it is correct that So, the fix should not improve "mono" detection, but use Do you agree? |
Excellent analysis, @n9. I'm preparing the change now. |
Version: 2.12.27 (current in nuget, but not as a release in this repo)
Caller: .NET 6 (Windows)
Target: .NET 6 (Android)
Exception:
StreamJsonRpc.RemoteInvocationException
ErrorCode: -32000 (
StreamJsonRpc.Protocol.JsonRpcErrorCode.InvocationError
)ErrorData.TypeName:
System.ArrayTypeMismatchException
ErrorData.Message: Attempted to access an element as a type incompatible with the array.
ErrorData.Stack:
Signature of the called method:
Not sure how mono is currently integrated into .NET 6 (for Android), there is already one ticket with the same error message: #387
The text was updated successfully, but these errors were encountered: