braintree / braintree_dotnet

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

IClientTokenGateway.Generate is ambiguous in VB.NET #65

Closed gavinblanshard closed 6 years ago

gavinblanshard commented 6 years ago

General information

Issue description

Version 3.9.0 of the Braintree .NET Client Library (installed via the NuGet Package Manager) seems to have a change that breaks it for VB.NET. Unlike C#, VB.NET is not case sensitive so does not permit two methods with the same name that differ only in upper/lower case letters. The ClientToken.Generate method now gives the following error preventing compilation:

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

The Braintree IClientTokenGateway interface appears to declare the following methods:

The two methods “Generate” and “generate” are treated as different by C#, but they are seen as the same in VB.NET - hence it is ambiguous as to which one is being referenced and therefore gives the error reported above.

I would much rather be using C# but legacy code makes that impractical!

bluk commented 6 years ago

Thanks for the report. This is a duplicate of https://github.com/braintree/braintree_dotnet/issues/64 , and we will remove the generate methods in the next major version which we are working towards. It is recommended to use version 3.8.0 for now if possible, or to fork the repository and compile the library.

gavinblanshard commented 6 years ago

Ah! Thanks for the info. Sorry, I didn't see #64. I guess I assumed it would still be an open issue.

I have an interim workaround in case others need it. 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)