From 8da427b41467127780fc6d3b8c4be29fb9eac852 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 14 Dec 2017 14:39:48 -0600 Subject: [PATCH] [generator] fixed new warnings introduced (#224) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Context: 5b18729d When testing generator from xamarin-android/master, I noticed that building a binding project has some *new* warnings: ``` obj/Debug/generated/src/GoogleAnalytics.Tracking.ILogger.cs(159,14): warning CS0109: The member 'ILoggerInvoker.class_ref' does not hide an accessible member. The new keyword is not required. ``` Binding project: https://github.com/jonathanpeppers/GoogleAnalytics/tree/master/GoogleAnalytics.Droid This was due to a change made in 5b18729d, I was *tricked* by how warnings operate differently in `generator-Tests` than what happens in a real Xamarin.Android binding project. The difference is: - `generator-Tests` put everything in one assembly - Real binding projects have `Java.Lang.*` and Android types in a separate assembly This means that some members that are marked `internal` will not need the `new` keyword at all—even though the tests currently *would* need the `new` keyword. The real fix here is to make the tests generate two separate assemblies so that we are more closely reproducing the situation of a Xamarin.Android binding project. Since we are branching for 15-6 soon, it seems better to revert the `new` keyword change in `InterfaceGen`, and set `AllowWarnings=true` where required in `generator-Tests`.. I also included a comment for every test that sets `AllowWarnings=true`, so that it is clear which warning is occurring. --- tools/generator/InterfaceGen.cs | 2 +- tools/generator/Tests/Adapters.cs | 2 ++ tools/generator/Tests/GenericArguments.cs | 2 ++ tools/generator/Tests/InterfaceMethodsConflict.cs | 2 ++ tools/generator/Tests/Interfaces.cs | 2 ++ tools/generator/Tests/Java_Lang_Enum.cs | 2 ++ tools/generator/Tests/NestedTypes.cs | 2 ++ tools/generator/Tests/NormalMethods.cs | 2 ++ .../Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs | 2 +- .../expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs | 2 +- .../Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs | 4 ++-- .../NestedTypes/Xamarin.Test.NotificationCompatBase.cs | 2 +- .../expected.ji/TestInterface/Test.ME.IGenericInterface.cs | 2 +- .../TestInterface/Test.ME.IGenericPropertyInterface.cs | 2 +- .../Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs | 2 +- .../Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs | 2 +- .../Tests/expected/Adapters/Xamarin.Test.IAdapter.cs | 2 +- .../Tests/expected/Adapters/Xamarin.Test.ISpinnerAdapter.cs | 2 +- .../Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs | 4 ++-- .../NestedTypes/Xamarin.Test.NotificationCompatBase.cs | 2 +- .../Tests/expected/TestInterface/Test.ME.IGenericInterface.cs | 2 +- .../TestInterface/Test.ME.IGenericPropertyInterface.cs | 2 +- .../Tests/expected/TestInterface/Test.ME.ITestInterface.cs | 2 +- .../Tests/expected/java.lang.Enum/Java.Lang.IComparable.cs | 2 +- 24 files changed, 33 insertions(+), 19 deletions(-) diff --git a/tools/generator/InterfaceGen.cs b/tools/generator/InterfaceGen.cs index 337327a27..cc08830bc 100644 --- a/tools/generator/InterfaceGen.cs +++ b/tools/generator/InterfaceGen.cs @@ -224,7 +224,7 @@ void GenerateInvoker (StreamWriter sw, string indent, CodeGenerationOptions opt) sw.WriteLine ("{0}internal class {1}Invoker : global::Java.Lang.Object, {1} {{", indent, Name); sw.WriteLine (); opt.CodeGenerator.WriteInterfaceInvokerHandle (this, sw, indent + "\t", opt, Name + "Invoker"); - sw.WriteLine ("{0}\tnew IntPtr class_ref;", indent); + sw.WriteLine ("{0}\tIntPtr class_ref;", indent); sw.WriteLine (); sw.WriteLine ("{0}\tpublic static {1} GetObject (IntPtr handle, JniHandleOwnership transfer)", indent, Name); sw.WriteLine ("{0}\t{{", indent); diff --git a/tools/generator/Tests/Adapters.cs b/tools/generator/Tests/Adapters.cs index 9002f3a53..858358897 100644 --- a/tools/generator/Tests/Adapters.cs +++ b/tools/generator/Tests/Adapters.cs @@ -9,6 +9,8 @@ public class Adapters : BaseGeneratorTest [Test] public void GeneratedOK () { + //hides inherited member `Java.Lang.Object.class_ref' + AllowWarnings = true; RunAllTargets ( outputRelativePath: "Adapters", apiDescriptionFile: "expected/Adapters/Adapters.xml", diff --git a/tools/generator/Tests/GenericArguments.cs b/tools/generator/Tests/GenericArguments.cs index f701bbd92..18130cd0b 100644 --- a/tools/generator/Tests/GenericArguments.cs +++ b/tools/generator/Tests/GenericArguments.cs @@ -9,6 +9,8 @@ public class GenericArguments : BaseGeneratorTest [Test] public void GeneratedOK () { + //hides inherited member `Java.Lang.Object.class_ref' + AllowWarnings = true; RunAllTargets ( outputRelativePath: "GenericArguments", apiDescriptionFile: "expected/GenericArguments/GenericArguments.xml", diff --git a/tools/generator/Tests/InterfaceMethodsConflict.cs b/tools/generator/Tests/InterfaceMethodsConflict.cs index 36b5c9b95..022330252 100644 --- a/tools/generator/Tests/InterfaceMethodsConflict.cs +++ b/tools/generator/Tests/InterfaceMethodsConflict.cs @@ -9,6 +9,8 @@ public class InterfaceMethodsConflict : BaseGeneratorTest [Test] public void GeneratedOK () { + //hides inherited member `Java.Lang.Object.class_ref' + AllowWarnings = true; RunAllTargets ( outputRelativePath: "InterfaceMethodsConflict", apiDescriptionFile: "expected/InterfaceMethodsConflict/InterfaceMethodsConflict.xml", diff --git a/tools/generator/Tests/Interfaces.cs b/tools/generator/Tests/Interfaces.cs index d0c4c6754..1e298e42d 100644 --- a/tools/generator/Tests/Interfaces.cs +++ b/tools/generator/Tests/Interfaces.cs @@ -9,6 +9,8 @@ public class Interfaces : BaseGeneratorTest [Test] public void Generated_OK () { + //hides inherited member `Java.Lang.Object.class_ref' + AllowWarnings = true; RunAllTargets ( outputRelativePath: "TestInterface", apiDescriptionFile: "expected/TestInterface/TestInterface.xml", diff --git a/tools/generator/Tests/Java_Lang_Enum.cs b/tools/generator/Tests/Java_Lang_Enum.cs index 8de599cf4..f8bba1d02 100644 --- a/tools/generator/Tests/Java_Lang_Enum.cs +++ b/tools/generator/Tests/Java_Lang_Enum.cs @@ -9,6 +9,8 @@ public class Java_Lang_Enum : BaseGeneratorTest [Test] public void Generated_OK () { + //hides inherited member `Java.Lang.Object.class_ref' + AllowWarnings = true; RunAllTargets ( outputRelativePath: "java.lang.Enum", apiDescriptionFile: "expected/java.lang.Enum/Java.Lang.Enum.xml", diff --git a/tools/generator/Tests/NestedTypes.cs b/tools/generator/Tests/NestedTypes.cs index 0ee4eec61..816fa2c01 100644 --- a/tools/generator/Tests/NestedTypes.cs +++ b/tools/generator/Tests/NestedTypes.cs @@ -9,6 +9,8 @@ public class NestedTypes : BaseGeneratorTest [Test] public void GeneratedOK () { + //hides inherited member `Java.Lang.Object.class_ref' + AllowWarnings = true; RunAllTargets ( outputRelativePath: "NestedTypes", apiDescriptionFile: "expected/NestedTypes/NestedTypes.xml", diff --git a/tools/generator/Tests/NormalMethods.cs b/tools/generator/Tests/NormalMethods.cs index 0d37526c3..895c15173 100644 --- a/tools/generator/Tests/NormalMethods.cs +++ b/tools/generator/Tests/NormalMethods.cs @@ -9,6 +9,8 @@ public class NormalMethods : BaseGeneratorTest [Test] public void GeneratedOK () { + //`Xamarin.Test.SomeObject.GetType()' hides inherited member `object.GetType()' + //`Xamarin.Test.SomeObject.ObsoleteMethod()' is obsolete AllowWarnings = true; RunAllTargets ( outputRelativePath: "NormalMethods", diff --git a/tools/generator/Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs b/tools/generator/Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs index 95f733283..2d6187ef5 100644 --- a/tools/generator/Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs +++ b/tools/generator/Tests/expected.ji/Adapters/Xamarin.Test.IAdapter.cs @@ -32,7 +32,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static IAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs b/tools/generator/Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs index efb26daa0..9d04b4c0c 100644 --- a/tools/generator/Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs +++ b/tools/generator/Tests/expected.ji/Adapters/Xamarin.Test.ISpinnerAdapter.cs @@ -32,7 +32,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static ISpinnerAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs b/tools/generator/Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs index 99332d91a..e20848e86 100644 --- a/tools/generator/Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs +++ b/tools/generator/Tests/expected.ji/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs @@ -37,7 +37,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static IExoMediaDrmOnEventListener GetObject (IntPtr handle, JniHandleOwnership transfer) { @@ -217,7 +217,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static IExoMediaDrm GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs b/tools/generator/Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs index e48e159b7..8637c3507 100644 --- a/tools/generator/Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs +++ b/tools/generator/Tests/expected.ji/NestedTypes/Xamarin.Test.NotificationCompatBase.cs @@ -44,7 +44,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static IFactory GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs index e065c3cf8..831b1a05f 100644 --- a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs +++ b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.IGenericInterface.cs @@ -37,7 +37,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static IGenericInterface GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs index c9e7b3a58..77f8b9b6d 100644 --- a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs +++ b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.IGenericPropertyInterface.cs @@ -40,7 +40,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static IGenericPropertyInterface GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs index 8e36dbc66..76ec15828 100644 --- a/tools/generator/Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs +++ b/tools/generator/Tests/expected.ji/TestInterface/Test.ME.ITestInterface.cs @@ -98,7 +98,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static ITestInterface GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs b/tools/generator/Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs index 20f968c8b..feafedf01 100644 --- a/tools/generator/Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs +++ b/tools/generator/Tests/expected.ji/java.lang.Enum/Java.Lang.IComparable.cs @@ -37,7 +37,7 @@ protected override IntPtr ThresholdClass { get { return _members.ManagedPeerType; } } - new IntPtr class_ref; + IntPtr class_ref; public static IComparable GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected/Adapters/Xamarin.Test.IAdapter.cs b/tools/generator/Tests/expected/Adapters/Xamarin.Test.IAdapter.cs index 4e5def0a3..42283f0a7 100644 --- a/tools/generator/Tests/expected/Adapters/Xamarin.Test.IAdapter.cs +++ b/tools/generator/Tests/expected/Adapters/Xamarin.Test.IAdapter.cs @@ -23,7 +23,7 @@ protected override IntPtr ThresholdClass { get { return typeof (IAdapterInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static IAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected/Adapters/Xamarin.Test.ISpinnerAdapter.cs b/tools/generator/Tests/expected/Adapters/Xamarin.Test.ISpinnerAdapter.cs index e72c86c1d..9030318b0 100644 --- a/tools/generator/Tests/expected/Adapters/Xamarin.Test.ISpinnerAdapter.cs +++ b/tools/generator/Tests/expected/Adapters/Xamarin.Test.ISpinnerAdapter.cs @@ -23,7 +23,7 @@ protected override IntPtr ThresholdClass { get { return typeof (ISpinnerAdapterInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static ISpinnerAdapter GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs b/tools/generator/Tests/expected/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs index c0be423e5..640be49c6 100644 --- a/tools/generator/Tests/expected/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs +++ b/tools/generator/Tests/expected/GenericArguments/Com.Google.Android.Exoplayer.Drm.IExoMediaDrm.cs @@ -28,7 +28,7 @@ protected override IntPtr ThresholdClass { get { return typeof (IExoMediaDrmOnEventListenerInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static IExoMediaDrmOnEventListener GetObject (IntPtr handle, JniHandleOwnership transfer) { @@ -200,7 +200,7 @@ protected override IntPtr ThresholdClass { get { return typeof (IExoMediaDrmInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static IExoMediaDrm GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected/NestedTypes/Xamarin.Test.NotificationCompatBase.cs b/tools/generator/Tests/expected/NestedTypes/Xamarin.Test.NotificationCompatBase.cs index 5e3c8549b..a4f375d34 100644 --- a/tools/generator/Tests/expected/NestedTypes/Xamarin.Test.NotificationCompatBase.cs +++ b/tools/generator/Tests/expected/NestedTypes/Xamarin.Test.NotificationCompatBase.cs @@ -35,7 +35,7 @@ protected override IntPtr ThresholdClass { get { return typeof (IFactoryInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static IFactory GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected/TestInterface/Test.ME.IGenericInterface.cs b/tools/generator/Tests/expected/TestInterface/Test.ME.IGenericInterface.cs index 190f6165b..e9f632830 100644 --- a/tools/generator/Tests/expected/TestInterface/Test.ME.IGenericInterface.cs +++ b/tools/generator/Tests/expected/TestInterface/Test.ME.IGenericInterface.cs @@ -28,7 +28,7 @@ protected override IntPtr ThresholdClass { get { return typeof (IGenericInterfaceInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static IGenericInterface GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected/TestInterface/Test.ME.IGenericPropertyInterface.cs b/tools/generator/Tests/expected/TestInterface/Test.ME.IGenericPropertyInterface.cs index 89169a526..064858e4d 100644 --- a/tools/generator/Tests/expected/TestInterface/Test.ME.IGenericPropertyInterface.cs +++ b/tools/generator/Tests/expected/TestInterface/Test.ME.IGenericPropertyInterface.cs @@ -31,7 +31,7 @@ protected override IntPtr ThresholdClass { get { return typeof (IGenericPropertyInterfaceInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static IGenericPropertyInterface GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected/TestInterface/Test.ME.ITestInterface.cs b/tools/generator/Tests/expected/TestInterface/Test.ME.ITestInterface.cs index a8b0e999e..0778a3cb3 100644 --- a/tools/generator/Tests/expected/TestInterface/Test.ME.ITestInterface.cs +++ b/tools/generator/Tests/expected/TestInterface/Test.ME.ITestInterface.cs @@ -90,7 +90,7 @@ protected override IntPtr ThresholdClass { get { return typeof (ITestInterfaceInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static ITestInterface GetObject (IntPtr handle, JniHandleOwnership transfer) { diff --git a/tools/generator/Tests/expected/java.lang.Enum/Java.Lang.IComparable.cs b/tools/generator/Tests/expected/java.lang.Enum/Java.Lang.IComparable.cs index 9d55ff188..3c8d3694b 100644 --- a/tools/generator/Tests/expected/java.lang.Enum/Java.Lang.IComparable.cs +++ b/tools/generator/Tests/expected/java.lang.Enum/Java.Lang.IComparable.cs @@ -28,7 +28,7 @@ protected override IntPtr ThresholdClass { get { return typeof (IComparableInvoker); } } - new IntPtr class_ref; + IntPtr class_ref; public static IComparable GetObject (IntPtr handle, JniHandleOwnership transfer) {