PROPERTY with different GET and SET modifiers

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
SHirsch
Posts: 281
Joined: Tue Jan 30, 2018 8:23 am

PROPERTY with different GET and SET modifiers

Post by SHirsch »

Hi,

in C# following code is valid (the set is protected)

Code: Select all

public Exception LastException { get; protected set; }
in ILSpy with X# is shown:

Code: Select all

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?

Code: Select all

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.
FFF
Posts: 1522
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

PROPERTY with different GET and SET modifiers

Post by FFF »

Stefan,
the "getend" points you should re-download Fabrice' tool, there was initially a glitch which resulted in this oddity ;)
Have a look at: https://www.xsharp.eu/forum/public-prod ... lugin#4661

Regards
Karl
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
SHirsch
Posts: 281
Joined: Tue Jan 30, 2018 8:23 am

PROPERTY with different GET and SET modifiers

Post by SHirsch »

Hi Karl,

thanks. The new version shows exactly the syntax I had expected.

Code: Select all

	
public property LastException as Exception get protected set 
But results in error: XS0106: The modifier 'override' is not valid for this item

Regards,
Stefan
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

PROPERTY with different GET and SET modifiers

Post by robert »

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
robert@xsharp.eu
User avatar
SHirsch
Posts: 281
Joined: Tue Jan 30, 2018 8:23 am

PROPERTY with different GET and SET modifiers

Post by SHirsch »

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:

Code: Select all

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
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

PROPERTY with different GET and SET modifiers

Post by Chris »

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
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply