Show/Hide Toolbars

XSharp Bandol

This warning has been introduced in version 2.0.0.4 to help you find name conflicts between (built-in) functions and methods.

 

The following code demonstrates this new warning:
 

 

FUNCTION Left(c AS STRING , dwLen AS INT) AS STRING
RETURN NULL
 
CLASS TestClass
  METHOD Test(cPath AS STRING) AS STRING
     Left(cPath , 1)
  STATIC METHOD Left(c AS STRING,n AS Int32) AS STRING
     // do something
  RETURN NULL
END CLASS
 
 

 

A warning will be generated for the call to Left inside TestClass:Test():

Method 'Left' is ambiguous. Could be 'Functions.Left(string, int)' or 'TestClass.Left(string, int)'. Using the function because in X# functions take precedence over static methods. To call the method use the fully qualified name.

This behavior has been changed to be compatible with Visual Objects. In Visual Objects the concept of static methods does not exist and you would always call the Left() function in this code.
If you want to call the method from the class instead of the function you need to change the code to
 

 
 TestClass.Left(cPath , 1)
 

 

If you change the code in the class and make Left() an instance method, then you need to prefix the call to Left with SELF: if you want to call the method in the class like in the example below:
 

FUNCTION Left(c AS STRING , dwLen AS INT) AS STRING
RETURN NULL
 
CLASS TestClass
  METHOD Test(cPath AS STRING) AS STRING
     SELF:Left(cPath , 1)
  METHOD Left(c AS STRING,n AS Int32) AS STRING
     // Do something
  RETURN NULL
END CLASS