fbpx

PROPERTY with different GET and SET modifiers

More
7 months 4 weeks ago #1 by Stefan Hirsch
PROPERTY with different GET and SET modifiers was created by Stefan Hirsch
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.

More
7 months 4 weeks ago - 7 months 4 weeks ago #2 by Karl Faller
Replied by Karl Faller on topic PROPERTY with different GET and SET modifiers
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
Last edit: 7 months 4 weeks ago by Karl Faller. Reason: additional info

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

More
7 months 4 weeks ago #3 by Stefan Hirsch
Replied by Stefan Hirsch on topic PROPERTY with different GET and SET modifiers
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.

More
7 months 4 weeks ago #4 by Robert van der Hulst
Replied by Robert van der Hulst on topic PROPERTY with different GET and SET modifiers
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.

More
7 months 4 weeks ago - 7 months 4 weeks ago #5 by Stefan Hirsch
Replied by Stefan Hirsch on topic PROPERTY with different GET and SET modifiers
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
Last edit: 7 months 4 weeks ago by Stefan Hirsch.

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

More
7 months 4 weeks ago #6 by Chris Pyrgas
Replied by Chris Pyrgas on topic PROPERTY with different GET and SET modifiers
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.