Skip to content

ClassDeclaration

CSharp class declaration.

import { ClassDeclaration } from "@alloy-js/csharp";
<ClassDeclaration
abstract
attributes={AttributesProp}
baseType={Children}
doc={Children}
file
interfaceTypes={Children[]}
internal
name="string"
partial
primaryConstructor={ParameterProps[]}
private
protected
public
refkey={Refkey}
sealed
static
typeParameters={(string | TypeParameterProps)[]}
/>
abstractoptionalboolean
attributesoptionalAttributesProp

Define attributes to attach

baseTypeoptionalChildren

Base class that this class extends

docoptionalChildren

Doc comment

fileoptionalboolean
interfaceTypesoptionalChildren[]

Interfaces this class implements

internaloptionalboolean
namestring
partialoptionalboolean
primaryConstructoroptionalParameterProps[]

Set the primary constructor parameters

privateoptionalboolean
protectedoptionalboolean
publicoptionalboolean
refkeyoptionalRefkey
sealedoptionalboolean
staticoptionalboolean
typeParametersoptional(string | TypeParameterProps)[]

Type parameters for the class

<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;
}
}