Source generator and analyzer to create fixed-length string structs.
Add a partial struct and decorate it with FixedStringBuilderAttribute:
[FixedStringBuilderAttribute(10)]
public partial struct FixedStringBuilder10;The generator emits:
Microsoft.CodeAnalysis.EmbeddedAttributeFixedStringBuilderAttribute(internal partial class)- members for the target struct (constructors, interpolation support,
TryFormat, equality, etc.)
Generated fixed strings enforce capacity and throw ArgumentException when data does not fit.
| Id | Category | Description | Severity | Enabled |
|---|---|---|---|---|
MFFSG0001 |
FixedStringBuilderGenerator | FixedStringBuilderAttribute requires one argument | Error | ✔️ |
MFFSG0002 |
FixedStringBuilderGenerator | FixedStringBuilderAttribute argument type is invalid | Error | ✔️ |
MFFSG0003 |
FixedStringBuilderGenerator | FixedStringBuilderAttribute length must be positive | Error | ✔️ |
MFFSG0004 |
FixedStringBuilderGenerator | FixedStringBuilderAttribute length is too large | Error | ✔️ |
MFFSG0005 |
FixedStringBuilderGenerator | FixedStringBuilderAttribute requires a partial struct | Error | ✔️ |
MFFSG0006 |
FixedStringBuilderGenerator | FixedStringBuilderAttribute does not support readonly or ref structs | Error | ✔️ |