Bug? Class Properties getters and setters

mindful

Active Member
Licensed User
I have a class with where I define a propery:
B4X:
Public Sub getMyProperty() As Boolean
    Return True
End Sub
Public Sub setMyProperty(Prop As Boolean)
    cMyProperty = Prop
End Sub

The ide doesn't say anything if I have a like this:
B4X:
Dim x as MyClass
Log(x.GetMyProperty)
And if I hover over x.GetMyProperty it sais: getMyProperty As Boolean

It runs correctly but I think at least a warning is to be shown by the ide ...
 

Misterbates

Active Member
Licensed User
Try it without the () on the get sub
B4X:
Public Sub getMyProperty As Boolean
    Return cMyProperty
End Sub
Public Sub setMyProperty(Prop As Boolean)
    cMyProperty = Prop
End Sub
 

Cableguy

Expert
Licensed User
Longtime User
I have a class with where I define a propery:
B4X:
Public Sub getMyProperty() As Boolean
    Return True
End Sub
Public Sub setMyProperty(Prop As Boolean)
    cMyProperty = Prop
End Sub

The ide doesn't say anything if I have a like this:
B4X:
Dim x as MyClass
Log(x.GetMyProperty)
And if I hover over x.GetMyProperty it sais: getMyProperty As Boolean

It runs correctly but I think at least a warning is to be shown by the ide ...
It should be

Log(X.MyProperty)
 

mindful

Active Member
Licensed User
:) I know how it should be. I just thought that the ide should be aware that the sub getMyProperty() is a class property and treat it like one. It works either way: x.MyProperty and also x.GetMyProperty ... The ide should (in my opinion) not let me run with x.GetMyProperty.
 

OliverA

Expert
Licensed User
Longtime User
The ide should (in my opinion) not let me run with x.GetMyProperty
1) The IDE does not "auto" suggest GetMyProperty when you type x., which is fine
2) You have to actually "overwrite" the autosuggestion to get GetMyProperty. Since GetMyProperty is a valid method though, what is wrong with the IDE not flagging it? What if someone else wants to actually use the GetMyProperty instead of the auto-generated getter/setter? Should the IDE stop them?
 

mindful

Active Member
Licensed User
Should the IDE stop them?
No it should not stop them. It should show a warning that the sub is "declared" as a property or something like. Because the ide has this visualbasic properties it should at least show a warning - this is what i meant
 

OliverA

Expert
Licensed User
Longtime User
should at least show a warning
I think at least a warning is to be shown by the ide

I guess you had to say it twice before it went through my thick skull. That does make sense (the warning display, a la "Varible 'y' is never assigned any value. (warning #10)")
 

OliverA

Expert
Licensed User
Longtime User
So should this be a wish instead of a bug?
 
Top