Commit bfc0273
authored
[generator] Ensure property setter parameter name is "value" (#566)
Fixes: #565
In a case with generics, we were not renaming the property setter
parameter to `value`, which meant it could be left as `p0`, which is
not valid C#:
// 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);
}
}
This would result in a C# error:
error CS0103: The name 'p0' does not exist in the current context.
The fix is to temporarily override the property's setter's parameter
name to `value` so that we emit compilable C# code:
set {
Selection = JavaObjectExtensions.JavaCast<Long>(value);
}1 parent 3226a4b commit bfc0273
File tree
2 files changed
+55
-0
lines changed- tests/generator-Tests/Unit-Tests
- tools/generator/Java.Interop.Tools.Generator.CodeGeneration
2 files changed
+55
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
967 | 967 | | |
968 | 968 | | |
969 | 969 | | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
970 | 1019 | | |
971 | 1020 | | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1605 | 1605 | | |
1606 | 1606 | | |
1607 | 1607 | | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
1608 | 1612 | | |
| 1613 | + | |
| 1614 | + | |
1609 | 1615 | | |
1610 | 1616 | | |
1611 | 1617 | | |
| |||
0 commit comments