ClassDeclaration
CSharp class declaration.
import { ClassDeclaration } from "@alloy-js/csharp";
<ClassDeclaration abstract attributes={AttributesProp} baseType={Children} doc={Children} file interfaceTypes={Children[]} internal name={string | Namekey} partial primaryConstructor={ParameterProps[]} private protected public refkey={Refkey} sealed static typeParameters={(string | TypeParameterProps)[]} />import { ClassDeclaration } from "@alloy-js/csharp/stc";
ClassDeclaration({ abstract: boolean, attributes: AttributesProp, baseType: Children, doc: Children, file: boolean, interfaceTypes: Children[], internal: boolean, name: string | Namekey, partial: boolean, primaryConstructor: ParameterProps[], private: boolean, protected: boolean, public: boolean, refkey: Refkey, sealed: boolean, static: boolean, typeParameters: (string | TypeParameterProps)[],}).children(children)| abstract | optionalboolean |
| attributes | optionalAttributesPropDefine attributes to attach |
| baseType | optionalChildrenBase class that this class extends |
| doc | optionalChildrenDoc comment |
| file | optionalboolean |
| interfaceTypes | optionalChildren[]Interfaces this class implements |
| internal | optionalboolean |
| name | string | Namekey |
| partial | optionalboolean |
| primaryConstructor | optionalParameterProps[]Set the primary constructor parameters |
| private | optionalboolean |
| protected | optionalboolean |
| public | optionalboolean |
| refkey | optionalRefkey |
| sealed | optionalboolean |
| static | optionalboolean |
| typeParameters | optional(string | TypeParameterProps)[]Type parameters for the class |
Example
Section titled “Example”<ClassDeclaration public name="MyClass"> <ClassMember public name="MyField" type="int" /> <ClassConstructor> <Parameter name="value" type="int" /> this.MyField = value; </ClassConstructor></ClassDeclaration>This will produce:
public class MyClass{ public int MyField; public MyClass(int value) { this.MyField = value; }}