Skip to content

Commit 70a32fa

Browse files
committed
Source gen should regenerate the code if SkipToString, SkipSwitchMethods or SkipMapMethods change their values.
1 parent 1c9a687 commit 70a32fa

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Copyright>(c) $([System.DateTime]::Now.Year), Pawel Gerr. All rights reserved.</Copyright>
5-
<VersionPrefix>6.4.0</VersionPrefix>
5+
<VersionPrefix>6.4.1</VersionPrefix>
66
<Authors>Pawel Gerr</Authors>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageProjectUrl>https://github.com/PawelGerr/Thinktecture.Runtime.Extensions</PackageProjectUrl>

samples/Thinktecture.Runtime.Extensions.Samples/SmartEnums/ProductGroup.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Thinktecture.SmartEnums;
22

3-
[EnumGeneration(ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)]
3+
[EnumGeneration(ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads,
4+
SkipToString = true)]
45
public sealed partial class ProductGroup : IValidatableEnum<int>
56
{
67
public static readonly ProductGroup Apple = new(1, "Apple", ProductCategory.Fruits);
@@ -30,4 +31,9 @@ private static ProductGroup CreateInvalidItem(int key)
3031
// the key must not be null
3132
return new(key, false, "Unknown product group", ProductCategory.Get("Unknown"));
3233
}
34+
35+
public override string ToString()
36+
{
37+
return DisplayName;
38+
}
3339
}

src/Thinktecture.Runtime.Extensions.SourceGenerator/CodeAnalysis/SmartEnums/EnumSourceGeneratorState.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ public bool Equals(EnumSourceGeneratorState? other)
9797
&& IsReferenceType == other.IsReferenceType
9898
&& IsAbstract == other.IsAbstract
9999
&& HasStructLayoutAttribute == other.HasStructLayoutAttribute
100+
&& SkipToString == other.SkipToString
101+
&& SkipSwitchMethods == other.SkipSwitchMethods
102+
&& SkipMapMethods == other.SkipMapMethods
100103
&& KeyProperty.Equals(other.KeyProperty)
101104
&& Equals(BaseType, other.BaseType)
102105
&& ItemNames.EqualsTo(other.ItemNames)
@@ -114,6 +117,9 @@ public override int GetHashCode()
114117
hashCode = (hashCode * 397) ^ IsReferenceType.GetHashCode();
115118
hashCode = (hashCode * 397) ^ IsAbstract.GetHashCode();
116119
hashCode = (hashCode * 397) ^ HasStructLayoutAttribute.GetHashCode();
120+
hashCode = (hashCode * 397) ^ SkipToString.GetHashCode();
121+
hashCode = (hashCode * 397) ^ SkipSwitchMethods.GetHashCode();
122+
hashCode = (hashCode * 397) ^ SkipMapMethods.GetHashCode();
117123
hashCode = (hashCode * 397) ^ KeyProperty.GetHashCode();
118124
hashCode = (hashCode * 397) ^ (BaseType?.GetHashCode() ?? 0);
119125
hashCode = (hashCode * 397) ^ ItemNames.ComputeHashCode();

0 commit comments

Comments
 (0)