xsharp.eu • Override of function?
Page 1 of 1

Override of function?

Posted: Tue Aug 30, 2022 12:42 pm
by ic2
In VO we have written our own version of LoadResString. From X# 2.13 this gives WarningXS9043 'LoadResString' is ambiguous.
Not sure why it didn't do that earlier, because is a correct warning.

However, as LoadResString is Init generated with every caption, it is not simple to replace. Can override be used in some way?

Kees tried

Code: Select all

PUBLIC OVERRIDE FUNCTION LoadResString(uDef AS USUAL , uid AS USUAL , uModule AS USUAL ) AS STRING


and got:

Error XS9002 Parser: unexpected input 'FUNCTION'


Dick

Override of function?

Posted: Tue Aug 30, 2022 1:08 pm
by robert
Dick,

You cannot override functions like this.
Functions become static methods in a static class.
Static classes cannot inherit from another class.
So there is no function to override.

I understand that you want to hide the warning message.

The only thing that I can think of is the following:
- we add an attribute to the X# runtime. Something like the SilentlyReplaceAttribute
- you mark your code with this attribute

Code: Select all

[SilentlyReplace];
PUBLIC FUNCTION LoadResString(uDef AS USUAL , uid AS USUAL , uModule AS USUAL ) AS STRING
- when the compiler detects this attribute then it uses the function or method marked with the attribute without "nagging".

Robert

Override of function?

Posted: Tue Aug 30, 2022 3:32 pm
by VR
If you just want to get rid of the warning, you can also put it's code on the list of the ignored warnings. But this of course get's rid of all the XS9043 warnings, not just the one for the LoadResString function

Override of function?

Posted: Tue Aug 30, 2022 4:47 pm
by ic2
Hello Robert, Volkmar,
robert post=23517 userid=253 wrote: I understand that you want to hide the warning message.

The only thing that I can think of is the following:
- we add an attribute to the X# runtime. Something like the SilentlyReplaceAttribute
- you mark your code with this attribute

Code: Select all

[SilentlyReplace];
PUBLIC FUNCTION LoadResString(uDef AS USUAL , uid AS USUAL , uModule AS USUAL ) AS STRING
- when the compiler detects this attribute then it uses the function or method marked with the attribute without "nagging".
This sounds very good if that's not too much work. Indeed I don't want to completely hide the warning and a quick rename is not the solution given the number of "rerouted" loadressting's in (generated) code.

Thanks,

Dick

Override of function?

Posted: Tue Aug 30, 2022 4:54 pm
by FFF
ic2 post=23524 userid=455 wrote:given the number of "rerouted" loadressting's in (generated) code.
Dick
Renaming was my first thought, when i read your post, then saw the "generated" part... But the generation is to follow some definition, as e.g. in VO's CAVOWed.tpl.
Is this done otherwise in VS? If not, you could edit these files once.

Override of function?

Posted: Tue Aug 30, 2022 7:25 pm
by Chris
Hi Karl,

The code generation for LoadResString() is hardcoded in both VS and XIDE, which I think is the case also in VO (since there's no entry in the template files for that).

Override of function?

Posted: Wed Aug 31, 2022 7:54 am
by robert
Guys,

I'll add the attribute for the next build and will tell the compiler to silently choose the alternative that is marked with the attribute (if any).
In retrospect the name "SilentlyReplaceAttribute" should probably be something like "PreferredOverloadAttribute"

Robert

Override of function?

Posted: Wed Aug 31, 2022 8:29 am
by Chris
Robert,

Yeah, PreferredOverloadAttribute sounds better!

Override of function?

Posted: Wed Aug 31, 2022 1:00 pm
by VR
If this new Attribute is introduced, it might also be a good idea to have some check in the compiler, that there is only one "PreferredOverload" per function overload in a solution and all it's dependencies...