Skip to content

Commit

Permalink
[generator] fixed new warnings introduced (#224)
Browse files Browse the repository at this point in the history
Context: 5b18729

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 5b18729, 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.
  • Loading branch information
jonathanpeppers authored and jonpryor committed Dec 14, 2017
1 parent cc1bb5f commit 8da427b
Show file tree
Hide file tree
Showing 24 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tools/generator/InterfaceGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tools/generator/Tests/Adapters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tools/generator/Tests/GenericArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tools/generator/Tests/InterfaceMethodsConflict.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tools/generator/Tests/Interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tools/generator/Tests/Java_Lang_Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tools/generator/Tests/NestedTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions tools/generator/Tests/NormalMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 8da427b

Please sign in to comment.