You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .claude/CLAUDE.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,7 @@ All types must be declared as `partial`. Source generators produce: factory meth
98
98
- Factory methods: when any member triggers factory method generation (type parameter, interface, `System.Object`, or duplicate type), factory methods (`Create{MemberName}`) are generated for **all** members — not just the triggering ones. Constructors retain their configured access modifier; conversion operators are still generated for eligible members. Use `FactoryMethodGeneration` to override: `None` suppresses all factory methods (even for type parameters/duplicates), `Always` generates for all members unconditionally.
99
99
-`allows ref struct` is **not supported** on ad-hoc union type parameters (TTRESG073). Ref structs cannot be boxed, which conflicts with equality, `Value` property, and Switch/Map delegate patterns.
100
100
- Stateless types (`TXIsStateless = true`): store only discriminator, not instance. Prefer structs.
101
-
- Backing fields: with 2+ distinct non-stateless reference types, reference types auto-share a single `object? _obj` field (value types keep typed fields). `UseSingleBackingField = true` forces all types (including value types, with boxing) into `_obj`.
101
+
- Backing fields: with 2+ distinct non-stateless reference types, reference types auto-share a single `object? _obj` field (value types keep typed fields). `UseSingleBackingField = true` forces all types (including value types, with boxing) into `_obj`.`SingleBackingFieldType = typeof(TBase)` additionally types `_obj` and `Value` as `TBase` (implies `UseSingleBackingField = true`); stateless struct members use a `private static readonly` cached boxed default to avoid per-instance allocation. Supports `TypeParamRef1`–`TypeParamRef5` placeholders for generic unions.
102
102
103
103
**Regular Unions** (`[Union]`):
104
104
@@ -116,6 +116,7 @@ Several attribute settings cascade to other settings. The AI assistant must acco
-**`UseSingleBackingField = true`** (Ad-hoc Unions): Forces all member types into a single `object? _obj` backing field. Without this setting, the generator already auto-merges reference types into `_obj` when there are 2+ distinct non-stateless reference types; this setting additionally forces value types into `_obj` (causing boxing)
119
+
-**`SingleBackingFieldType` set** (Ad-hoc Unions): Forces `UseSingleBackingField = true`. `typeof(object)` is normalized to "not set" but still triggers the cascade. Backing field and `Value` are typed as the specified base type instead of `object`. Stateless struct members are stored via a `private static readonly` cached boxed default; stateless reference types leave `_obj` null. For struct unions, `Value` throws `InvalidOperationException` on `default(TUnion)` (discriminator check on every access), matching `AsTx`/`Switch`/`Map`. Conflict with explicit `UseSingleBackingField = false` produces TTRESG075
119
120
-**`ConstructorAccessModifier`** (Unions): Also controls accessibility of implicit conversion operators and factory method accessibility
120
121
-**`FactoryMethodGeneration`** (Ad-hoc Unions): `None` suppresses all factory methods — including for type parameters and duplicates (user must provide custom creation methods). `Always` generates factory methods for all members even without triggers. `Default` auto-detects based on trigger conditions (type parameter, interface, `System.Object`, duplicate type) and generates for all members when any trigger is present
Copy file name to clipboardExpand all lines: src/Thinktecture.Runtime.Extensions.Analyzers/CodeAnalysis/Diagnostics/ThinktectureRuntimeExtensionsAnalyzer.cs
+20-2Lines changed: 20 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,7 @@ public sealed class ThinktectureRuntimeExtensionsAnalyzer : DiagnosticAnalyzer
0 commit comments