I apologize in advance if the answer is clear in the docs or the forum, I just couldn’t get it that way.
How is a call done when there’s multiple extension methods of the same name and cannot be resolved purely by optional parameter signatures.
My project (thanks to predecessors) has created the following situation when trying the following…
I suspect I’ll have to remove (or rename the method) of one/more of the following choices shown?
Var aStr As String = "Hello World"
If aStr.Contains("World") Then
...
End If
String.Contains(Extends s As String, searchString As String, options As ComparisonOptions = ComparisonOptions.CaseInsensitive, locale As Locale = Nil) As Boolean
StringExtensions.Contains(Extends s As String, value As String) As Boolean
StringUtils.Contains(extends s As String, what As String) As Boolean
I do understand that, except that the distinguishing/difference of the first is complicated by default values for those additional parameters, so it ‘degenerates’ to being the same as the other two.
You cannot namespace extends methods. I assume you got into this situation because you added some 3rd party libraries to your project. String.Contains is a fairly recent addition to Xojo and it seems those libraries predate it. You may want to notify the maintainers of the libraries that there is now a collision. They may be unaware or they may have an updated version you could use.
@Tim_Hare You are correct that I’m working on a project with 10+ years (and multiple successive developers), and quite a few third party libraries - of various (usually old) vintage. I will try to get updated libraries and do some cleaning of the house.
Not being able to namespace extends (extension) methods, seems limiting at times. I guess as you point out, especially with multiple third party libraries that one doesn’t have full control over.
Thank you for pointing out that macOSLib has specifically fixed their lib for String.Contains. I already had obtained that fixed (latest) version. My problem arose from other older accumulated libraries that I have since pared down or fully dumped from this project.