Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

Invalid parameter name when writing explicit interface property implementations #565

Closed

Description

@jpobst

We generate this:

// This method is explicitly implemented as a member of an instantiated Google.Android.Material.DatePicker.IDateSelector
global::Java.Lang.Object global::Google.Android.Material.DatePicker.IDateSelector.Selection {
	// Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.material.datepicker']/interface[@name='DateSelector']/method[@name='getSelection' and count(parameter)=0]"
	[Register ("getSelection", "()Ljava/lang/Object;", "GetGetSelectionHandler:Google.Android.Material.DatePicker.IDateSelectorInvoker, Xamarin.Google.Android.Material")] get {
		return Selection;
	}
	// Metadata.xml XPath method reference: path="/api/package[@name='com.google.android.material.datepicker']/interface[@name='DateSelector']/method[@name='setSelection' and count(parameter)=1 and parameter[1][@type='S']]"
	[Register ("setSelection", "(Ljava/lang/Object;)V", "GetSetSelection_Ljava_lang_Object_Handler:Google.Android.Material.DatePicker.IDateSelectorInvoker, Xamarin.Google.Android.Material")] set {
		Selection = global::Java.Interop.JavaObjectExtensions.JavaCast<global::Java.Lang.Long>(p0);
	}
}

which results in this error:

Severity	Code	Description	Project	File	Line	Suppression State
Error	CS0103	The name 'p0' does not exist in the current context	com.google.android.material.material	D:\X\AndroidX-material\generated\com.google.android.material.material\obj\Debug\monoandroid90\generated\src\Google.Android.Material.DatePicker.SingleDateSelector.cs	397	Active

We need to temporarily modify the parameter name here:
https://github.com/xamarin/java.interop/blob/master/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs#L1608

writer.WriteLine ("{0}\t\t{1} = {2};", indent, property.Name, property.Setter.Parameters.GetGenericCall (opt, mappings));

Like we do here:
https://github.com/xamarin/java.interop/blob/master/tools/generator/Java.Interop.Tools.Generator.CodeGeneration/CodeGenerator.cs#L1508

string pname = property.Setter.Parameters [0].Name;
property.Setter.Parameters [0].Name = "value";
WriteMethodBody (property.Setter, indent + "\t\t", gen);
property.Setter.Parameters [0].Name = pname;

Activity

  1. brendanzagaeski commented on Mar 17, 2020

    @brendanzagaeski
    Contributor

    Release status update

    A new Preview version of Xamarin.Android has now been published on Windows that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.

    The fix is not yet available on macOS. I will update this item again when a Preview version with the fix is available on macOS.

    Fix included in Xamarin.Android 10.2.100.7

    Fix included on Windows in Visual Studio 2019 version 16.6 Preview 1. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

    Fix not yet available on macOS.

  2. brendanzagaeski commented on Mar 27, 2020

    @brendanzagaeski
    Contributor

    Release status update

    A new Preview version of Xamarin.Android has now been published on macOS that includes the fix for this item. The fix is not yet included in a Release version. I will update this again when a Release version is available that includes the fix.

    Fix included in Xamarin.Android 10.3.0.33.

    Fix included on macOS in Visual Studio 2019 for Mac version 8.6 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

    (Fix also included on Windows in Visual Studio 2019 version 16.6 Preview 1 and higher. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.)

  3. brendanzagaeski commented on May 20, 2020

    @brendanzagaeski
    Contributor

    Release status update

    A new Release version of Xamarin.Android has now been published that includes the fix for this item.

    Fix included in Xamarin.Android 10.3.1.0.

    Fix included on Windows in Visual Studio 2019 version 16.6. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.

    Fix included on macOS in Visual Studio 2019 for Mac version 8.6. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

  4. locked and limited conversation to collaborators on Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions