Class mapping for C# (C# code)
For each Class that is not nested, ACS generates a code file (.cs) unless the tagged value of the C# Parent File Scoped tag definition is set to True. Within the code file, ACS generates the Class as a class. ACS generates nested Classes within the parent class declaration.
ACS ignores Classes that are stereotyped by the «requirement» stereotype, which is available in the SysML Requirements profile.
The class declaration and body is derived from the items it owns, properties of the Class, and the tagged values set for Tag Definitions applied by the «C# Classifier» stereotype.
ACS generates the child items, properties and tagged values of a Class as follows.
Child items:
• If the Class owns any
Attributes, ACS generates each Attribute as a constant, event, field or property. For more information about Attribute mapping, click here
Attribute mapping • If the Class owns any Classes, ACS generates the Classes as nested classes.
• If the Class owns any
Data Types, ACS generates the Data Types as nested structs. For more information about Data Type mapping, click here
Data type mapping • If the Class owns any
Interfaces, ACS generates the Data Types as nested interfaces. For more information about Interface mapping, click here
Data interface mapping • If the Class owns any
Operations, ACS generates each Operation as a constructor, delegate, finalizer, indexer, method or operator. For more information about Operation mapping, click here
Operation mapping • If the Class owns any
Roles, ACS generates the each Role as a constant, field or property. For more information about Role mapping, click here
Association mapping • If the Class owns any
Type Definitions whose Construction is Enumeration, ACS generates each Type Definition as an enum. For more information about Type Definition mapping, click here
Definition mapping Other child items are ignored.
Properties:
• If the Abstract property is set to true (Abstract check box selected on Property Pages) and the Class is not static or sealed, ACS generates the class with the abstract modifier.
• If a
Description is specified, ACS generates the text of a Class' Description property on the line before the code generated for the class. For information about how comments are generated, click here
Generating code comments • ACS generates the Name property as the identifier of the class.
| ACS may modify the class identifier that is added to the code to make it valid for C#. You can specify the exact identifier to use through the CODE_GENERATION_NAME property of a Class. Tell me more... |
• If the Template property is set to True (Template check box selected on Property Pages), ACS generates the Modeler Class as a generic class. ACS generates the Formal Template Parameters as the type parameters between angle brackets after the class identifier.
• If the Visibility property is set to public or package: ACS generates the class with a public or internal modifier accordingly – ACS generates private and protected modifiers only for nested Classes.
Other properties are ignored.
Tag Definitions:
The «C# Classifier» stereotype applies the following Tag Definitions to a Class:
• If a value is set for the tagged value of the C# Attributes tag definition, ACS generates the value as the set of attributes for the class.
• If a value is set for the tagged value of the C# Extern Alias Directives tag definition and the Class is generated as a compilation unit, ACS generates the value as the external alias directives. Use this tag definition when defining directives for the Class that cannot be modeled within the model.
• The tagged value of the read-only C# File tag definition is used for opening generated code files from Modeler. This value is set by ACS.
| Note that the tagged value of the derived C# File tag definition is stored in your computer's registry (not the model) – the path and file name you see does not apply to other users of the model. |
• If the tagged value of the C# Internal tag definition is set to Internal, ACS generates the class with the internal modifier.
• If the Class is a child of another Class and the C# Internal tag definition is set to Protected Internal, ACS generates the class with the protected internal modifiers.
• If the tagged value of the C# New tag definition is set to True, ACS generates the new keyword when appropriate.
• If the tagged value of the C# Parent File Scoped tag definition is set to True, ACS does not generate a code file for the Class and the class is defined in the code file that is generated for the owning Model, Package or Class.
• If the tagged value of the C# Partial tag definition is set to True - ACS generates the class with the Partial modifier.
• If the tagged value of the C# Sealedtag definition is set to True (and the Class is not abstract or static), ACS generates the class with the sealed modifier.
• If the tagged value of the C# Statictag definition is set to True (and the Class is not abstract or sealed), ACS generates the class with the static modifier.
• If the Class is a template Class (generates a generic type - see Template property) and a value is set for the tagged value of the C# Type Parameters Constraints tag definition, ACS generates the value as the constraints that apply to the type parameters of a generic type. ACS generates the value after the class declaration and before the body code.
• If the tagged value of the C# Unsafetag definition is set to True, ACS generates the class with the Unsafe modifier.
• If a value is set for the tagged value of the C# Using Directives tag definition, ACS generates the value as the using directives of the class.
ACS generates the using directives that are required for the code it generates; however, should you require additional using directives that cannot be derived from the model, use the C# Using Directives to specify them.