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
-**`SkipEqualityComparison = true`**: Forces `ComparisonOperators` and `EqualityComparisonOperators` to `None`
94
+
-**`EqualityComparisonOperators = None`**: Forces `ComparisonOperators` to `None` in generated code (enforced by the generator settings, not the attribute getter — circular dependency prevents getter enforcement)
95
+
-**`ComparisonOperators` > `EqualityComparisonOperators`**: `EqualityComparisonOperators` is coerced upward to match
|`SkipFactoryMethods`|`bool`|`false`| Do not generate `Create`, `TryCreate`, `Validate` methods|
21
+
|`SkipFactoryMethods`|`bool`|`false`| Do not generate `Create`, `TryCreate`, `Validate` methods. Also suppresses: `TypeConverter` attribute, `IObjectFactory<T>` implementation, conversion operator from key type, `IParsable<T>` and `ISpanParsable<T>` implementations, all arithmetic operators, and serialization converters (JSON, Newtonsoft, MessagePack) — unless an `[ObjectFactory<T>(UseForSerialization = ...)]` is present|
22
22
|`ConstructorAccessModifier`|`AccessModifier`|`Private`| Access modifier for generated constructor |
23
23
|`CreateFactoryMethodName`|`string`|`"Create"`| Name for the Create factory method (whitespace resets to default) |
24
24
|`TryCreateFactoryMethodName`|`string`|`"TryCreate"`| Name for the TryCreate factory method (whitespace resets to default) |
@@ -38,7 +38,7 @@ Base class for `AdHocUnionAttribute` and generic `UnionAttribute<T1, T2, ...>`.
|`ConstructorAccessModifier`|`UnionConstructorAccessModifier`|`Public`| Access modifier for generated constructor|
41
+
|`ConstructorAccessModifier`|`UnionConstructorAccessModifier`|`Public`| Access modifier for generated constructor; also affects accessibility of implicit conversion operators|
42
42
|`ConversionFromValue`|`ConversionOperatorsGeneration`|`Implicit`| Generate implicit conversion operators from member types to union |
43
43
|`ConversionToValue`|`ConversionOperatorsGeneration`|`Explicit`| Generate explicit conversion operators from union to member types |
|`EqualityComparisonOperators`|`OperatorsGeneration`|`Default`| Generation of equality operators (`==`, `!=`) |
68
+
|`EqualityComparisonOperators`|`OperatorsGeneration`|`Default`| Generation of equality operators (`==`, `!=`). Note: `DefaultWithKeyTypeOverloads` produces the same code as `Default` for keyless enums (no key member to overload with)|
|`EqualityComparisonOperators`|`OperatorsGeneration`|`Default`| Equality operators (`==`, `!=`) - coerced to at least ComparisonOperators|
94
+
|`SkipIParsable`|`bool`|`false`| Skip `IParsable<T>` implementation; setting to `true` also forces `SkipISpanParsable` to `true`|
95
+
|`SkipISpanParsable`|`bool`|`false`| Skip `ISpanParsable<T>` implementation; forced to `true` when `SkipIParsable` is `true` (`ISpanParsable<T>` inherits from `IParsable<T>`); NET9+|
96
+
|`ComparisonOperators`|`OperatorsGeneration`|`Default`| Comparison operators (`<`, `<=`, `>`, `>=`) - depends on EqualityComparisonOperators; forced to `None` when `EqualityComparisonOperators` is `None`|
97
+
|`EqualityComparisonOperators`|`OperatorsGeneration`|`Default`| Equality operators (`==`, `!=`) - coerced upward to at least `ComparisonOperators`|
98
98
|`SkipIFormattable`|`bool`|`false`| Skip `IFormattable` implementation (when key not IFormattable) |
|`DisableSpanBasedJsonConversion`|`bool`|`false`| Disables ReadOnlySpan-based zero-allocation JSON conversion, falling back to string-based conversion (string keys only; NET9+) |
106
106
|`SwitchMapStateParameterName`|`string?`|`"state"`| Name of state parameter in Switch/Map methods |
107
107
108
-
**Note**: `ISpanParsable<T>` inherits from `IParsable<T>`, so setting`SkipISpanParsable = false` will automatically set `SkipIParsable = false` if needed.
108
+
**Note**: `SkipIParsable = true` automatically forces`SkipISpanParsable = true` because `ISpanParsable<T>` inherits from `IParsable<T>`.
|`SkipIComparable`|`bool`|`false`| Skip `IComparable<T>` implementation (if key not comparable and no custom comparer) |
138
-
|`SkipIParsable`|`bool`|`false`| Skip `IParsable<T>` implementation (if factories skipped or key not string/IParsable; independent from SkipISpanParsable) |
139
-
|`SkipISpanParsable`|`bool`|`false`| Skip `ISpanParsable<T>` implementation (if factories skipped or key not string/ISpanParsable; independent from SkipIParsable; NET9+)|
138
+
|`SkipIParsable`|`bool`|`false`| Skip `IParsable<T>` implementation (if factories skipped or key not string/IParsable); setting to `true` also forces `SkipISpanParsable` to `true`|
139
+
|`SkipISpanParsable`|`bool`|`false`| Skip `ISpanParsable<T>` implementation; forced to `true` when `SkipIParsable` or `SkipFactoryMethods` is `true`; NET9+|
|`EqualityComparisonOperators`|`OperatorsGeneration`|`Default`| Equality operators (`==`, `!=`) - coerced to at least ComparisonOperators|
144
+
|`ComparisonOperators`|`OperatorsGeneration`|`Default`| Comparison operators (`<`, `<=`, `>`, `>=`) - depends on EqualityComparisonOperators; forced to `None` when `EqualityComparisonOperators` is `None`|
145
+
|`EqualityComparisonOperators`|`OperatorsGeneration`|`Default`| Equality operators (`==`, `!=`) - coerced upward to at least `ComparisonOperators`|
146
146
|`SkipIFormattable`|`bool`|`false`| Skip `IFormattable` implementation (if key not IFormattable) |
147
147
|`ConversionToKeyMemberType`|`ConversionOperatorsGeneration`|`Implicit`| Generate implicit conversion operator from value object to key type |
148
148
|`UnsafeConversionToKeyMemberType`|`ConversionOperatorsGeneration`|`Explicit`| Generate explicit conversion operator from value object to key type (may throw if validation fails) |
149
149
|`ConversionFromKeyMemberType`|`ConversionOperatorsGeneration`|`Explicit`| Generate explicit conversion operator from key type to value object |
150
150
151
-
**Note**: `ISpanParsable<T>` inherits from `IParsable<T>`, so setting`SkipISpanParsable = false` will automatically set `SkipIParsable = false` if needed.
151
+
**Note**: `SkipIParsable = true` automatically forces`SkipISpanParsable = true` because `ISpanParsable<T>` inherits from `IParsable<T>`.
152
152
153
153
**Inherits all properties from `ValueObjectAttributeBase`** (see above).
Copy file name to clipboardExpand all lines: src/Thinktecture.Runtime.Extensions/SmartEnumAttribute.cs
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,10 @@ public string KeyMemberName
80
80
/// This setting has no effect if:
81
81
/// - the key is neither a <see cref="string"/> nor an <see cref="IParsable{T}"/> itself.
82
82
/// </summary>
83
+
/// <remarks>
84
+
/// Setting this to <c>true</c> also forces <see cref="SkipISpanParsable"/> to <c>true</c>,
85
+
/// because <see cref="ISpanParsable{T}"/> inherits from <see cref="IParsable{T}"/>.
86
+
/// </remarks>
83
87
publicboolSkipIParsable{get;set;}
84
88
85
89
/// <summary>
@@ -112,6 +116,10 @@ public bool SkipISpanParsable
112
116
/// This setting has no effect:
113
117
/// - if key-member is not an <see cref="IComparisonOperators{TSelf,TOther,TResult}"/> itself and has no corresponding operators (<c>op_GreaterThan</c>, <c>op_GreaterThanOrEqual</c>, <c>op_LessThan</c>, <c>op_LessThanOrEqual</c>).
114
118
/// </summary>
119
+
/// <remarks>
120
+
/// In generated code, this is also forced to <see cref="OperatorsGeneration.None"/> when <see cref="EqualityComparisonOperators"/> is <see cref="OperatorsGeneration.None"/>,
121
+
/// because comparison operators require equality operators.
@@ -120,6 +128,10 @@ public bool SkipISpanParsable
120
128
/// This setting has no effect:
121
129
/// - if key-member is not an <see cref="IEqualityOperators{TSelf,TOther,TResult}"/> itself and has no corresponding operators (<c>op_Equality</c>, <c>op_Inequality</c>).
122
130
/// </summary>
131
+
/// <remarks>
132
+
/// This value is coerced upward to match <see cref="ComparisonOperators"/> when <see cref="ComparisonOperators"/> is greater,
133
+
/// because comparison operators require equality operators.
0 commit comments