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 | optional boolean | |
| attributes | optional AttributesProp | Define attributes to attach |
| baseType | optional Children | Base class that this class extends |
| doc | optional Children | Doc comment |
| file | optional boolean | |
| interfaceTypes | optional Children[] | Interfaces this class implements |
| internal | optional boolean | |
| name | string | Namekey | |
| partial | optional boolean | |
| primaryConstructor | optional ParameterProps[] | Set the primary constructor parameters |
| private | optional boolean | |
| protected | optional boolean | |
| public | optional boolean | |
| refkey | optional Refkey | |
| sealed | optional boolean | |
| static | optional boolean | |
| 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;
}
}