braintree / braintree_dotnet

Braintree .NET library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
136 stars 73 forks source link

API issues with VB.NET #64

Closed dolphinsd closed 6 years ago

dolphinsd commented 6 years ago

ClientTokenRequest has 2 generate methods with same signature.

Using in VB.NET is causes error as its not case sensitive

error BC31429: 'Generate' is ambiguous because multiple kinds of members with this name exist in interface 'IClientTokenGateway'.

crookedneighbor commented 6 years ago

This library is written in c#, not visual basic. It's not intended for use with VB.net.

If you have some kind of converter from c# to VB, you can always fork the method and remove the version of generate with a lowercase G. This was a mistake originally, but we can't remove it without breaking backwards compatibility.

redoc209 commented 6 years ago

So the code is not CLS compliant? You do understand that the tradeoff here is completely breaking all vb.net apps using the library, not just a backward compatibility issue? Our application is completely broken with no work around other than downloading and recompiling our own CLS compliant dll therefore not allowing us to do NuGet updates. I think the reasonable trade off is to fix it. Make it industry standard quality and when C# folks do an update they change the little g to a bit G. Not a big deal. Please reconsider.

redoc209 commented 6 years ago

It is , as you pointed out, a mistake after all.

crookedneighbor commented 6 years ago

The next major version will drop the generate method. But until then, we will not remove it, as other people who integrated with generate before Generate was added will be broken if they do automatic updates.

This SDK does not officially support VB.net.

As I said, you can fork the repo and make the change yourself if you need to.

redoc209 commented 6 years ago

What was the last version update before this change. We're just going to revert it and wait it out for the next update. Much easier. Thanks

crookedneighbor commented 6 years ago

3.8.0

redoc209 commented 6 years ago

Ok. Thanks!

gavinblanshard commented 6 years ago

I just raised the same issue in #65. Didn't see this one! Sorry!

Just in case it helps someone, there is a workaround using reflection. The call:

Dim token As String = gateway.ClientToken.Generate(New ClientTokenRequest())

can be replaced with:

Dim token As String = String.Empty
Dim param(0) As Object
param(0) = New ClientTokenRequest()
token = PaymentGateway.ClientToken.GetType().InvokeMember(
  "Generate",
  Reflection.BindingFlags.InvokeMethod,
  Nothing,
  PaymentGateway.ClientToken,
  param)