You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
Compilation error using parameter arrays in EventArgs #817
I have a C# wrapper library for a native Android Java library. The wrapper library compiles just fine with Xamarin.Android, but gives me compile-time errors when trying to migrate to .NET 6.0 Android.
Take note on the last few lines where the params keyword is used incorrectly.
The above auto-generated code fails to compile with the following build error:
"Invalid token 'params' in class, record, struct, or interface member declaration"
changed the title [-].NET 6 Android: Java ellipsis construct confuses the generator[/-][+].NET 6 Android: Java ellipsis construct causes compile-time errors in C#[/+]on Mar 18, 2021
There are no differences between the code-generation process generator.exe in "legacy" and .NET 6, so it seems odd that you would get different code between the two. These issues also all seem like things that should fail on legacy bindings projects as well.
My guess is that you have fixed these issues in metadata.xml file(s), and these files are not getting picked up in your .NET 6 project. There hasn't been much testing yet on .NET6 binding projects, so this could be an issue on our side or an issue with the way you have constructed your project.
So for first steps, let's confirm that your legacy project does indeed rely on metadata.xml files, and then please try to determine if you think you have set them up correctly in your .NET6 project. If everything looks good on your side, let me know, and I can dig deeper on our side.
The only other thing I can think of is if you were using <AndroidCodegenTarget>XamarinAndroid</AndroidCodegenTarget> previously, which is no longer available in .NET6, but I really don't think that change would cause issues of this type.
OK, thank you for the tip. I'll double-check if I have messed up my metadata.xml when migrating the project. Still, I believe placing the params keyword as a part of the type signature is a bug in the C# code generator. Ideally, we should not workaround such things by hand.
I have double-checked my metadata.xml files and there is nothing in there to suppress the generation of the offending classes. Since nothing has changed, except migrating my Xamarin.Android projects to .NET SDK projects targeting .NET 6.0 android, I have no explanation why this is failing now. Regretfully, I cannot share the source code of the library, because it is owned by my company. What I can do is to create a small repro project, if you cannot reproduce the issue on your side.
Out of curiousity, what version of Visual Studio are you using to compile the "legacy" version? There was a large generator refactor in 16.9 that may have caused this breakage. The .NET 6 version is the same as the 16.9 version.
The workaround would be to use metadata to override the parameter array type.
changed the title [-].NET 6 Android: Java ellipsis construct causes compile-time errors in C#[/-][+]Compilation error using parameter arrays in EventArgs[/+]on Mar 26, 2021
I am using Visual Studio 16.10 preview 1. The official Visual Studio version 16.9 complains that it cannot recognize the net6.0-android target, even though I have installed the necessary workloads and created the EnableWorkloadResolver.sentinel file, as described here: https://github.com/dotnet/net6-mobile-samples.
Activity
[-].NET 6 Android: Java ellipsis construct confuses the generator[/-][+].NET 6 Android: Java ellipsis construct causes compile-time errors in C#[/+]jpobst commentedon Mar 18, 2021
There are no differences between the code-generation process
generator.exein "legacy" and .NET 6, so it seems odd that you would get different code between the two. These issues also all seem like things that should fail on legacy bindings projects as well.My guess is that you have fixed these issues in
metadata.xmlfile(s), and these files are not getting picked up in your .NET 6 project. There hasn't been much testing yet on .NET6 binding projects, so this could be an issue on our side or an issue with the way you have constructed your project.Here's some documentation on how they are supposed to work:
https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNet.md#consolidation-of-binding-projects
So for first steps, let's confirm that your legacy project does indeed rely on
metadata.xmlfiles, and then please try to determine if you think you have set them up correctly in your .NET6 project. If everything looks good on your side, let me know, and I can dig deeper on our side.The only other thing I can think of is if you were using
<AndroidCodegenTarget>XamarinAndroid</AndroidCodegenTarget>previously, which is no longer available in .NET6, but I really don't think that change would cause issues of this type.vanka78bg commentedon Mar 19, 2021
OK, thank you for the tip. I'll double-check if I have messed up my
metadata.xmlwhen migrating the project. Still, I believe placing theparamskeyword as a part of the type signature is a bug in the C# code generator. Ideally, we should not workaround such things by hand.vanka78bg commentedon Mar 26, 2021
I have double-checked my
metadata.xmlfiles and there is nothing in there to suppress the generation of the offending classes. Since nothing has changed, except migrating my Xamarin.Android projects to .NET SDK projects targeting .NET 6.0 android, I have no explanation why this is failing now. Regretfully, I cannot share the source code of the library, because it is owned by my company. What I can do is to create a small repro project, if you cannot reproduce the issue on your side.jpobst commentedon Mar 26, 2021
Out of curiousity, what version of Visual Studio are you using to compile the "legacy" version? There was a large
generatorrefactor in 16.9 that may have caused this breakage. The .NET 6 version is the same as the 16.9 version.The workaround would be to use
metadatato override the parameter array type.[-].NET 6 Android: Java ellipsis construct causes compile-time errors in C#[/-][+]Compilation error using parameter arrays in EventArgs[/+]vanka78bg commentedon Mar 26, 2021
I am using Visual Studio 16.10 preview 1. The official Visual Studio version 16.9 complains that it cannot recognize the net6.0-android target, even though I have installed the necessary workloads and created the
EnableWorkloadResolver.sentinelfile, as described here: https://github.com/dotnet/net6-mobile-samples.[generator] Support varargs arrays in event listener methods (#832)
[generator] Support varargs arrays in event listener methods (#832)