C# Automatic Property Support

For C# at and beyond release 4.0, Enterprise Architect enables you to model automatic properties as «Property» stereotyped attributes.




See also

Properties of Attributes

When you create the attribute, on the General page of the Attributes dialog simply set the Stereotype field to Property; the generated code resembles the following:


public class Class1


 public Class2(   )  Classes {get; set;}



This is in contrast to the Enterprise Architect facilities for modeling get/set methods as properties of an attribute in various other languages, generating code such as:


public class Class1


 public Class3(   )  m_delivery;




 public Class3(   )  delivery


         get{ }

         set{ }




You cannot create properties with get/set methods on an automatic properties attribute; whilst the «Property» stereotype is assigned in the Attributes dialog, the Property checkbox is grayed out

Create Properties

Tagged Values

You can also add the following Tagged Values to automatic properties to denote specific characteristics, if required:

  • writeonly - the property only has a set method;   e.g. public int Prop1 { set; }
  • readonly - the property only has a get method;   e.g. public int Prop2 { get; }
  • GetScope - specifies the property's Get Scope;   e.g. public int Prop3 { protected get; set; }
  • SetScope - specifies the property's Set Scope;   e.g. public int Prop4 {  get; protected set; }


Reverse Engineering

Imported automatic properties generate attributes with a «property» stereotype and appropriate Tagged Values, and - if the property type is a recognized element in the model - an Association connector



Automatic Properties