Reference
Model Styles
Choose between Class, Record, and ReadonlyRecordStruct for generated model types.
AutoSDK supports three C# code styles for generated model types, controlled by --modelStyle (CLI) or AutoSDK_ModelStyle (MSBuild).
Class (Default)
Generates standard C# classes with get/set properties:
public sealed partial class Pet
{
[JsonPropertyName("name")]
public string Name { get; set; } = default!;
[JsonPropertyName("status")]
public PetStatus? Status { get; set; }
[JsonPropertyName("tags")]
public IList<Tag>? Tags { get; set; }
}Best for: Most use cases. Familiar, mutable, works everywhere.
Record
Generates C# record types with init-only properties:
public sealed partial record Pet
{
[JsonPropertyName("name")]
public string Name { get; init; } = default!;
[JsonPropertyName("status")]
public PetStatus? Status { get; init; }
[JsonPropertyName("tags")]
public IList<Tag>? Tags { get; init; }
}Best for: Immutable-by-default APIs, value equality semantics, with expressions.
Requires: C# 9+ (net5.0 or later)
ReadonlyRecordStruct
Generates readonly record struct types (value types):
public readonly partial record struct Pet
{
[JsonPropertyName("name")]
public string Name { get; init; }
[JsonPropertyName("status")]
public PetStatus? Status { get; init; }
[JsonPropertyName("tags")]
public IList<Tag>? Tags { get; init; }
}Best for: High-performance scenarios where you want to avoid heap allocations. Small models only — large structs have copy overhead.
Requires: C# 10+ (net6.0 or later)
Comparison
| Feature | Class | Record | ReadonlyRecordStruct |
|---|---|---|---|
| Allocation | Heap | Heap | Stack |
| Mutability | Mutable | Immutable (init) | Immutable (init) |
| Equality | Reference | Value | Value |
with expression | No | Yes | Yes |
| Inheritance | Yes | Yes | No |
| Min framework | Any | net5.0+ | net6.0+ |
Configuration
CLI:
autosdk generate spec.json --modelStyle RecordMSBuild:
<AutoSDK_ModelStyle>Record</AutoSDK_ModelStyle>Edit on GitHub
Last updated on