GetFunctionPointerForDelegateTests tests fail with Specified cast is not valid on Browser #39187
Copy link
Copy link
Open
Labels
arch-wasmWebAssembly architectureWebAssembly architecturearea-Codegen-Interpreter-monodisabled-testThe test is disabled in source code against the issueThe test is disabled in source code against the issue
Milestone
Description
When running System.Runtime.InteropServices library tests on Browser wasm, two functions fail with Specified cast is not valid:
- GetFunctionPointerForDelegate_MarshalledDelegateNonGeneric_ReturnsExpected
- GetFunctionPointerForDelegate_MarshalledDelegateGeneric_ReturnsExpected
Note
When the tests are not ordered, the suite sometimes fails with the two tests above
[FAIL] System.Runtime.InteropServices.Tests.GetFunctionPointerForDelegateTests.GetFunctionPointerForDelegate_MarshalledDelegateNonGeneric_ReturnsExpected
System.InvalidCastException : Specified cast is not valid.
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.Runtime.InteropServices.Tests.GetFunctionPointerForDelegateTests.GetFunctionPointerForDelegate_MarshalledDelegateGeneric_ReturnsExpected
System.InvalidCastException : Specified cast is not valid.
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
And other times, it fails with the six tests from GetDelegateForFunctionPointerTests.cs
[FAIL] System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests.GetDelegateForFunctionPointer_NonGeneric_ReturnsExpected(t: typeof(System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests+NonGenericDelegate))
Assert.IsType() Failure
Expected: System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests+NonGenericDelegate
Actual: System.Runtime.InteropServices.Tests.GetFunctionPointerForDelegateTests+NonGenericDelegate
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests.GetDelegateForFunctionPointer_NonGeneric_ReturnsExpected(t: typeof(System.MulticastDelegate))
Assert.IsType() Failure
Expected: System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests+NonGenericDelegate
Actual: System.Runtime.InteropServices.Tests.GetFunctionPointerForDelegateTests+NonGenericDelegate
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests.GetDelegateForFunctionPointer_NonGeneric_ReturnsExpected(t: typeof(System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests+OtherNonGenericDelegate))
Assert.IsType() Failure
Expected: System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests+NonGenericDelegate
Actual: System.Runtime.InteropServices.Tests.GetFunctionPointerForDelegateTests+NonGenericDelegate
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests.GetDelegateForFunctionPointer_GenericInvalidType_ReturnsExpected
Assert.IsType() Failure
Expected: System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests+NonGenericDelegate
Actual: System.Runtime.InteropServices.Tests.GetFunctionPointerForDelegateTests+NonGenericDelegate
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests.GetDelegateForFunctionPointer_CollectibleType_ReturnsExpected
Assert.IsType() Failure
Expected: System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests+NonGenericDelegate
Actual: System.Runtime.InteropServices.Tests.GetFunctionPointerForDelegateTests+NonGenericDelegate
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.Runtime.InteropServices.Tests.GetDelegateForFunctionPointerTests.GetDelegateForFunctionPointer_Generic_ReturnsExpected
System.InvalidCastException : Specified cast is not valid.
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
arch-wasmWebAssembly architectureWebAssembly architecturearea-Codegen-Interpreter-monodisabled-testThe test is disabled in source code against the issueThe test is disabled in source code against the issue
Activity
WASM: Disable two GetFunctionPointerForDelegate tests
WASM: Disable two GetFunctionPointerForDelegate tests (#39278)
vargaz commentedon Jul 31, 2020
These now fail with:
System.PlatformNotSupportedException : No native to managed transitions on this platform.
They cannot be supported without the pinvoke generator.
lewing commentedon Aug 1, 2020
@vargaz this sounds like net6?
vargaz commentedon Aug 1, 2020
Probably.
12 remaining items
lewing commentedon Jul 11, 2023
@ilonatommy can you check if these tests still fail?
ilonatommy commentedon Jul 11, 2023
The error message changed to:
When we use the hint and add the decorator:
GetFunctionPointerForDelegateTests.cs(124,36): error CS8894: Cannot use 'string' as a parameter type on a method attributed with 'UnmanagedCallersOnly'When we change the method to receive
char*in unsafe context, the message is back tomissing [UnmanagedCallersOnly], so apparently I am not using it correctly.I am not sure how to fix this.
Tests failing with this message:
lewing commentedon Jul 21, 2023
@vargaz is this something we expect to work?
[mono][wasm] Use [UnmanagedCallersOnly] in GetDelegateForFunctionPoin…
lewing commentedon Feb 21, 2024
cc @kg @BrzVlad