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)[]} />import { StructDeclaration } from "@alloy-js/csharp/stc";
StructDeclaration({ attributes: AttributesProp, doc: core.Children, file: boolean, interfaceTypes: core.Children[], internal: boolean, name: string | core.Namekey, new: boolean, partial: boolean, private: boolean, protected: boolean, public: boolean, readonly: boolean, ref: boolean, refkey: core.Refkey, typeParameters: (TypeParameterProps | string)[],}).children(children)| attributes | optional AttributesProp | Define attributes to attach |
| doc | optional Children | Doc comment |
| file | optional boolean | |
| interfaceTypes | optional Children[] | Interfaces this struct implements |
| internal | optional boolean | |
| name | string | Namekey | |
| new | optional boolean | |
| partial | optional boolean | |
| private | optional boolean | |
| protected | optional boolean | |
| public | optional boolean | |
| readonly | optional boolean | |
| ref | optional boolean | |
| refkey | optional Refkey | |
| typeParameters | optional (TypeParameterProps | string)[] | Type parameters for the struct |
Example
Section titled “Example”<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);
}