Skip to content

StructDeclaration

CSharp struct declaration.

import { StructDeclaration } from "@alloy-js/csharp";
<StructDeclaration
attributes={AttributesProp}
doc={core.Children}
file
interfaceTypes={core.Children[]}
internal
name="string"
new
partial
private
protected
public
readonly
ref
refkey={core.Refkey}
typeParameters={(TypeParameterProps | string)[]}
/>
attributesoptionalAttributesProp

Define attributes to attach

docoptionalChildren

Doc comment

fileoptionalboolean
interfaceTypesoptionalChildren[]

Interfaces this struct implements

internaloptionalboolean
namestring
newoptionalboolean
partialoptionalboolean
privateoptionalboolean
protectedoptionalboolean
publicoptionalboolean
readonlyoptionalboolean
refoptionalboolean
refkeyoptionalRefkey
typeParametersoptional(TypeParameterProps | string)[]

Type parameters for the struct

<StructDeclaration public name="IMyStruct">
<StructMember public name="MyProperty" type="int" />
<StructMethod public name="MyMethod" returnType="void">
<Parameter name="value" type="int" />
</StructMethod>
</StructDeclaration>

This will produce:

public struct MyIface
{
public int MyProperty { get; set; }
public void MyMethod(int value);
}