Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[jnimarshalmethod-gen] Fix registration on Windows (#721)
`jnimarshalmethod-gen` didn't call [`MethodBuilder.SetParameters()`][0] when creating the marshal method. While this worked under Mono, the lack of a `MethodBuilder.SetParameters()` invocation caused `jnimarshalmethod-gen` to crash when running under .NET Framework: error JM4006: jnimarshalmethod-gen: Unable to process assembly '.\bin\TestDebug\Java.Interop.Export-Tests.dll' Specified argument was out of the range of valid values. Parameter name: The specified parameter index is not in range. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: The specified parameter index is not in range. at System.Reflection.Emit.MethodBuilder.DefineParameter(Int32 position, ParameterAttributes attributes, String strParamName) at System.Linq.Expressions.Compiler.LambdaCompiler..ctor(AnalyzedTree tree, LambdaExpression lambda, MethodBuilder method) at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, MethodBuilder method, DebugInfoGenerator debugInfoGenerator) at Xamarin.Android.Tools.JniMarshalMethodGenerator.App.AddRegisterNativeMembers(TypeBuilder dt, ParameterExpression targetType, List`1 registrationElements) in C:\Users\rodo\git\java.interop\tools\jnimarshalmethod-gen\App.cs:line 564 at Xamarin.Android.Tools.JniMarshalMethodGenerator.App.CreateMarshalMethodAssembly(String path) in C:\Users\rodo\git\java.interop\tools\jnimarshalmethod-gen\App.cs:line 426 at Xamarin.Android.Tools.JniMarshalMethodGenerator.App.ProcessAssemblies(List`1 assemblies) in C:\Users\rodo\git\java.interop\tools\jnimarshalmethod-gen\App.cs:line 201 Add a call to `MethodBuilder.SetParameters()` for Windows support. Additionally, when `jnimarshalmethod-gen -v` (verbose) is used, print out the type(s) for which`__RegisterNativeMembers()` is being emitted. [0]: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.emit.methodbuilder.setparameters?view=netcore-3.1
- Loading branch information