xsharp.eu • Error XS0505 ..cannot override because .. is not a function
Page 1 of 1

Error XS0505 ..cannot override because .. is not a function

Posted: Tue Mar 10, 2020 7:57 pm
by ic2
Sorry, another one. It is not further documented. The method below originally yielded an error because it was of CLASS TextControl. As it is only used to set the Textcolor of 1 or 2 SLE's I changed it to class IC2SLE (my SingleLineEdit subclass) and moved it (in X#) to a prg with other methods of this class. So it looks now as follows:
PARTIAL CLASS IC2SLE INHERIT SingleLineEdit
....
METHOD TextColor(uValue)
SELF:TextColor:=uValue
RETURN NIL

Works as expected in VO, but in X# it gives this error:

Error XS0505 'IC2SLE.TextColor(params XSharp.__Usual[])': cannot override because 'VO.TextControl.TextColor' is not a function IC2 lib C:XporterOutputOkIC2 libControl.prg 459

What does this mean?

Dick

Error XS0505 ..cannot override because .. is not a function

Posted: Tue Mar 10, 2020 8:09 pm
by robert
Dick,
In DotNet you cannot have a method and a field or property with the same name.
Your code declares a method TextColor and the class already has a property TextColor.
If you enable the compiler option "all methods are virtual" then we add the Override modifier to all methods that you declare in your code. The backend (Roslyn) is getting confused because it finds a TextColor property and tries to override that, but you are overriding the property with a method.

Of course the question is: why did you add a method when there is already a property (ACCESS/ASSIGN in VO)?

Robert

Error XS0505 ..cannot override because .. is not a function

Posted: Tue Mar 10, 2020 9:42 pm
by ic2
Hello Robert,
Of course the question is: why did you add a method when there is already a property (ACCESS/ASSIGN in VO)?
I asked myself the same question: why did I write this 18 years ago. This is the code which uses that method:

SELF:oDCmSomeSLEField:TextColor(Color{nOpmFGR,nOpmFGG,nOpmFGB}) (where the 3 parameters are the foreground RGB colours)

If I rename the METHOD TextColor(uValue) the field is not colored anymore. At least, in VO (I have not yet converted the library where this TextColor call is applied). No idea why not to be honest.

I already set All instance methods are virtual to true but the error remained.

Dick