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 | core.Namekey}
new
partial
private
protected
public
readonly
ref
refkey={core.Refkey}
typeParameters={(TypeParameterProps | string)[]}
/>
attributesoptional AttributesPropDefine attributes to attach
docoptional ChildrenDoc comment
fileoptional boolean
interfaceTypesoptional Children[]Interfaces this struct implements
internaloptional boolean
namestring | Namekey
newoptional boolean
partialoptional boolean
privateoptional boolean
protectedoptional boolean
publicoptional boolean
readonlyoptional boolean
refoptional boolean
refkeyoptional Refkey
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);
}