Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Override of function? 30 Aug 2022 14:42 #23516

  • ic2
  • ic2's Avatar
  • Topic Author


  • Posts: 1574
  • 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
    PUBLIC OVERRIDE FUNCTION LoadResString(uDef AS USUAL , uid AS USUAL , uModule AS USUAL ) AS STRING

    and got:

    Error XS9002 Parser: unexpected input 'FUNCTION'


    Dick

    Please Log in or Create an account to join the conversation.

    Override of function? 30 Aug 2022 15:08 #23517

    • robert
    • robert's Avatar


  • Posts: 3289
  • 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
    [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
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Override of function? 30 Aug 2022 17:32 #23522

    • VR
    • VR's Avatar


  • Posts: 84
  • 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

    Please Log in or Create an account to join the conversation.

    Override of function? 30 Aug 2022 18:47 #23524

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1574
  • Hello Robert, Volkmar,

    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
    [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

    Please Log in or Create an account to join the conversation.

    Override of function? 30 Aug 2022 18:54 #23525

    • FFF
    • FFF's Avatar


  • Posts: 1392
  • 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.
    Regards
    Karl (X# 2.14.0.4; Xide 1.33; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    Last edit: by FFF.

    Override of function? 30 Aug 2022 21:25 #23526

    • Chris
    • Chris's Avatar


  • Posts: 3750
  • 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).
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Override of function? 31 Aug 2022 09:54 #23531

    • robert
    • robert's Avatar


  • Posts: 3289
  • 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
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Override of function? 31 Aug 2022 10:29 #23536

    • Chris
    • Chris's Avatar


  • Posts: 3750
  • Robert,

    Yeah, PreferredOverloadAttribute sounds better!
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Override of function? 31 Aug 2022 15:00 #23542

    • VR
    • VR's Avatar


  • Posts: 84
  • 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...

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1