Skip to content

Commit

Permalink
Source gen should regenerate the code if SkipToString, SkipSwitchMeth…
Browse files Browse the repository at this point in the history
…ods or SkipMapMethods change their values.
  • Loading branch information
PawelGerr committed Nov 9, 2023
1 parent 1c9a687 commit 70a32fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Copyright>(c) $([System.DateTime]::Now.Year), Pawel Gerr. All rights reserved.</Copyright>
<VersionPrefix>6.4.0</VersionPrefix>
<VersionPrefix>6.4.1</VersionPrefix>
<Authors>Pawel Gerr</Authors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageProjectUrl>https://github.com/PawelGerr/Thinktecture.Runtime.Extensions</PackageProjectUrl>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Thinktecture.SmartEnums;

[EnumGeneration(ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads)]
[EnumGeneration(ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads,
SkipToString = true)]
public sealed partial class ProductGroup : IValidatableEnum<int>
{
public static readonly ProductGroup Apple = new(1, "Apple", ProductCategory.Fruits);
Expand Down Expand Up @@ -30,4 +31,9 @@ private static ProductGroup CreateInvalidItem(int key)
// the key must not be null
return new(key, false, "Unknown product group", ProductCategory.Get("Unknown"));
}

public override string ToString()
{
return DisplayName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public bool Equals(EnumSourceGeneratorState? other)
&& IsReferenceType == other.IsReferenceType
&& IsAbstract == other.IsAbstract
&& HasStructLayoutAttribute == other.HasStructLayoutAttribute
&& SkipToString == other.SkipToString
&& SkipSwitchMethods == other.SkipSwitchMethods
&& SkipMapMethods == other.SkipMapMethods
&& KeyProperty.Equals(other.KeyProperty)
&& Equals(BaseType, other.BaseType)
&& ItemNames.EqualsTo(other.ItemNames)
Expand All @@ -114,6 +117,9 @@ public override int GetHashCode()
hashCode = (hashCode * 397) ^ IsReferenceType.GetHashCode();
hashCode = (hashCode * 397) ^ IsAbstract.GetHashCode();
hashCode = (hashCode * 397) ^ HasStructLayoutAttribute.GetHashCode();
hashCode = (hashCode * 397) ^ SkipToString.GetHashCode();
hashCode = (hashCode * 397) ^ SkipSwitchMethods.GetHashCode();
hashCode = (hashCode * 397) ^ SkipMapMethods.GetHashCode();
hashCode = (hashCode * 397) ^ KeyProperty.GetHashCode();
hashCode = (hashCode * 397) ^ (BaseType?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ ItemNames.ComputeHashCode();
Expand Down

0 comments on commit 70a32fa

Please sign in to comment.