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

TOPIC: PROPERTY with different GET and SET modifiers

PROPERTY with different GET and SET modifiers 10 months 5 days ago #1

  • SHirsch
  • SHirsch's Avatar Topic Author
  • Offline
  • Posts: 86
Hi,

in C# following code is valid (the set is protected)
public Exception LastException { get; protected set; }

in ILSpy with X# is shown:
public property LastException as Exception 
  getend get
  protected setend set
'getend' and 'setend' seems to be strange. But 'protected' as modifier for set is recognized.

Now my question, how to set different access modifiers for get and set?
PUBLIC PROPERTY LastException AS Exception GET PROTECTED SET
results in XS0106: The modifier 'override' is not valid for this item

Regards,
Stefan

PS: This should not result in discussion how to do error handling. This is just a sample about property and modifiers.

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

PROPERTY with different GET and SET modifiers 10 months 5 days ago #2

Stefan,
the "getend" points you should re-download Fabrice' tool, there was initially a glitch which resulted in this oddity ;)
Have a look at: www.xsharp.info/forum/public-product/662...ge-ilspy-plugin#4661

Regards
Karl

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

Last edit: by FFF. Reason: additional info

PROPERTY with different GET and SET modifiers 10 months 5 days ago #3

  • SHirsch
  • SHirsch's Avatar Topic Author
  • Offline
  • Posts: 86
Hi Karl,

thanks. The new version shows exactly the syntax I had expected.
public property LastException as Exception get protected set 
But results in error: XS0106: The modifier 'override' is not valid for this item

Regards,
Stefan

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

PROPERTY with different GET and SET modifiers 10 months 5 days ago #4

Stefan,

- Is this in a class or an interface ?
- If it is in a class, Is the property LastException already defined in the parent class ?
- What is the compiler setting for "treat all methods as Virtual" (/vo3)
- Your property does not define a body. Do you want this to be an "auto" property ?

Robert
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

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

PROPERTY with different GET and SET modifiers 10 months 5 days ago #5

  • SHirsch
  • SHirsch's Avatar Topic Author
  • Offline
  • Posts: 86
Hi Robert,

- Is this in a class or an interface ?
class

- If it is in a class, Is the property LastException already defined in the parent class ?
it has no parent class.

- What is the compiler setting for "treat all methods as Virtual" (/vo3)
none of the compiler settings is set


- Your property does not define a body. Do you want this to be an "auto" property ?
is some cases yes, in others no. Both does result in same message.

Source from app where this occured first:
CLASS Config
    STATIC PRIVATE __instance AS Config  
    PRIVATE _ini AS KoelndataSoftware.Tools.IniFile
    
PUBLIC PROPERTY Ini AS KoelndataSoftware.Tools.IniFile 
    GET 
        RETURN SELF:_ini
    END
    PROTECTED SET 
        SELF:_ini := VALUE
    END
END 
....
END CLASS

Regards,
Stefan

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

Last edit: by SHirsch.

PROPERTY with different GET and SET modifiers 10 months 5 days ago #6

Thanks Stefan, this is a bug indeed and I think I am seeing some more similar related issues. Will add a comprehensive sample in our test suite for Robert to take care of.

Chris
XSharp Development Team
chris(at)xsharp.eu

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

  • Page:
  • 1