title: Override methods generated by Xamarin Java Binding
body: <p>When using Xamarin to create a Java Bindings project so that Android Java jars may be referenced through C#, how would one go about overriding the generated C# only?</p>
  
  <p>I am encountering an error post binding generation that seems as though it is easily fixed by using an explicit cast instead of the generated use of the JavaCast utility.  I am not sure how I can go about telling the Xamarin binding generator to skip this method generation without excluding it entirely. </p>
  
  <p>I have tried including the overridden methods in the Library Binding Project in both the Additions folder, and in the general project, but the error I am receiving when I do that indicates that that type already defines a member with the same parameter types, so it is recognizing it, but not before the bindings are generated.  </p>
  
  <p>I realize that I could generate the bindings once, make the modifications to the generated files and try and ensure that the Library Binding Project is never built again, but I would like to avoid that upkeep cost, or the check in of generated files. This is a complete last resort work around.</p>
  
  <p>Java code:</p>
  
  <pre><code>public interface IUpdateListener&lt;T&gt; {
      public void onUpdate(T data);
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>// This method is explicitly implemented as a member of an instantiated x.y.z.IUpdateListener
  private class UpdateListener implements IUpdateListener&lt;byte[]&gt; {
      @Override
      public void onUpdate(byte[] data) {
         //Does some stuff
      }
  }
  </code></pre>
  
  <p>Resulting Xamarin generated C# code:</p>
  
  <pre><code>void global::x.y.z.IUpdateListener.OnUpdate (global::Java.Lang.Object p0)
  {
      // This line has an error with the call to JavaCast
      OnUpdate (global::Java.Interop.JavaObjectExtensions.JavaCast&lt;byte[]&gt;(p0));
  }
  </code></pre>
  
  <p>Error on Generated line:</p>
  
  <p><code>Error  362 The type 'byte[]' cannot be used as type parameter 'TResult' in the generic type or method 'Java.Interop.JavaObjectExtensions.JavaCast&lt;TResult&gt;(Android.Runtime.IJavaObject)'. There is no implicit reference conversion from 'byte[]' to 'Android.Runtime.IJavaObject'.</code></p>
  
  <p>Caveat - We are consuming the jars, not producing them, so I cannot change the Java code at all.</p>
  
  <p>Thank you for your help!</p>
  
  <p>Update 11/10:
  The issue I was encountering was confirmed a bug buy Xamarin and can be found here: <a href="https://bugzilla.xamarin.com/show_bug.cgi?id=24312" rel="nofollow">https://bugzilla.xamarin.com/show_bug.cgi?id=24312</a></p>
  
  <p>The work around I was given <a href="https://gist.github.com/rob-derosa/61429e8967faf263e635#file-gistfile1-xml" rel="nofollow">https://gist.github.com/rob-derosa/61429e8967faf263e635#file-gistfile1-xml</a></p>
  
  <p>When I add the work around to my metadata file, I get a more manageable error stating that those classes which update with a byte[] implementations <code>does not implement interface member 'foo.bar.IUpdateListener.OnUpdate(Java.Lang.Object)'</code>, which is fairly expected as they do not.</p>
  
  <p>I was then able to create partial classes in the additions folder which implement the <code>OnUpdate(Java.Lang.Object)</code> method, and perform the explicit cast, and call into the generated OnUpdate from the actual code.  This method has no errors or warnings.</p>
  
  <p>I suppose there really isn't a good way to perform an actual override of generated code, but I was able to work around the issue prompting the original question.</p>