How to specify the module when calling an extension method

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 think you would have to change one of the method names, or if they do the same thing remove one.

Thank you for confirming that I can only use the Contains method in my post if I rename the other 2 to unique method names.

In C#, the ‘shared method’ syntax can also be used to call extension methods.

For example here, StringUtils.Contains(aStr, "World") would return a Boolean.

Only two of the methods have the same signature. The first requires more parameters and so can be distinguished.

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.

Yes, however the first is built in to the framework and cannot be changed.

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.

If one of the libraries is macOSLib then there already an update that solves that problem.

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.