Commit 53d6051
authored
[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.11 parent 5a834d4 commit 53d6051
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
487 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
488 | 491 | | |
| 492 | + | |
489 | 493 | | |
490 | 494 | | |
491 | 495 | | |
| |||
495 | 499 | | |
496 | 500 | | |
497 | 501 | | |
| 502 | + | |
498 | 503 | | |
499 | 504 | | |
500 | 505 | | |
| |||
0 commit comments