Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: cosmo on March 03, 2008, 07:21:28 am
-
When doing a property implementation for an attribute in C#, the operation signature isn't what I expected (? correct ?). Perhaps this is just an issue with not understanding how to make the tool do what I want.
For example, the attribute '- _Foo : decimal', might need to be associated with a setter property '+ Foo (decimal) : void'. Despite unchecking the 'read' checkbox and only leaving the 'write' checkbox checked, only the signature for the getter was created. Why didn't it create a signature that reflects an assignment instead of a value fetch? Also in those cases where the property is read/write, why aren't both get and set signatures present?
-
It all looks okay to me.
private decimal _ReadWrite;
private decimal _ReadOnly;
private decimal _WriteOnly;
public decimal ReadWrite{
get{
return _ReadWrite;
}
set{
_ReadWrite = value;
}
}
public decimal ReadOnly{
get{
return _ReadOnly;
}
}
public decimal WriteOnly{
set{
_WriteOnly = value;
}
}
The fact that you're getting a parameter and return type suggests that something is causing EA to think it's not generating C#. So I'd check you class language and that the C# radio button is selected in the properties dialog.
-
Hey Simon, thnx for the quick response. I guess I should have clarified that my question was more on EA's UML class diagram than it was on the generated code. But that certainly answered the other question that I didn't ask. Very cool!
But when using the UML class diagram to convey some of the underlying model to other developers/companies, the getter signature displayed in the UML class diagram isn't clear that one should implement just a getter, or a setter, or both.
I like using the property checkbox from the attribute popup, but if the class diagram doesn't show the setter signature, then I'm left wondering if this is a UML 2.1 limitation, a tool limitation, or a spot where I should not use the tool feature and come up with my own stereotypes (where the operation signature is to be ignored because of a 'perceived' tool limitation).
-
Well, on the UML diagram EA shows the stereotype (which specifies that it is a property) and the parameter type shows the type of the property.
What it doesn't show (but the code generation uses) is the tagged values on the operation.