IndQuestEnums.EntityFramework
1.0.1
dotnet add package IndQuestEnums.EntityFramework --version 1.0.1
NuGet\Install-Package IndQuestEnums.EntityFramework -Version 1.0.1
<PackageReference Include="IndQuestEnums.EntityFramework" Version="1.0.1" />
<PackageVersion Include="IndQuestEnums.EntityFramework" Version="1.0.1" />
<PackageReference Include="IndQuestEnums.EntityFramework" />
paket add IndQuestEnums.EntityFramework --version 1.0.1
#r "nuget: IndQuestEnums.EntityFramework, 1.0.1"
#:package IndQuestEnums.EntityFramework@1.0.1
#addin nuget:?package=IndQuestEnums.EntityFramework&version=1.0.1
#tool nuget:?package=IndQuestEnums.EntityFramework&version=1.0.1
IndQuestEnums
Owned NuGet package providing the house SmartEnum base (EnumModel) — the single source
of truth for strongly-typed enumerations across IndTrace, ExxerCube.Prisma, EMIP/CubeXplorer,
and future solutions. Named for consistency with its sibling IndQuestResults.
Seed folder. This directory was scaffolded as a starting point. Build the real package / solution from here in a fresh session, then publish to nuget.org (or the house private feed). The decision and rationale are recorded in
ADR-0001(copied here asADR-0001.md; the authoritative copy lives in the EMIP repo atdocs/architecture/adr/).
Why this package exists
Two divergent in-house copies already exist and are drifting:
- IndTrace
Core/Domain/Enum/Enumeration.cs— the original. LinearFromValue, couples toLookUpTable, and carries a display-name bug (assigns the unsetDisplayNameproperty instead of the constructor parameter, so display names silently collapse toName). - ExxerCube.Prisma
01 Core/Domain/Enum/EnumModel.cs— "production-tested, ported from IndTrace." Bug fixed; adds an O(1) thread-safeConcurrentDictionarylookup cache; couples toIEnumModel/ILookupEntity/EnumLookUpTable+ an EFEnumModelConversionshelper.
A third copy would keep diverging. This package consolidates the bug-fixed, O(1)-cached core.
Design decisions (from ADR-0001)
- Not bundled into
IndQuestResults— different concern; bundling would couple semver and force everyResult<T>consumer to take a SmartEnum base. - Core is dependency-free — no EF, no lookup-table machinery — so it is safe in a pure Domain.
src/EnumModel.csis that core (provided here as the starting point; namespaceIndQuestEnums).
- EF integration is a separate companion package
IndQuestEnums.EntityFramework(a genericValueConverter<TEnum,int>+ValueComparer<TEnum>), referenced only by Infrastructure. - Based on the Prisma (bug-fixed + cached) version, not the IndTrace original.
Suggested layout to grow into
IndQuestEnums/
├── README.md
├── ADR-0001.md
├── src/
│ └── EnumModel.cs # ← provided (core; dependency-free)
├── IndQuestEnums/ # core csproj (net10.0, no deps)
│ └── IndQuestEnums.csproj
├── IndQuestEnums.EntityFramework/ # EF companion (generic converter + comparer)
│ └── IndQuestEnums.EntityFramework.csproj
├── IndQuestEnums.Tests/ # xUnit v3 + Shouldly
│ └── EnumModelTests.cs # FromValue/FromName/Invalid/equality/cache round-trips
└── IndQuestEnums.sln
Example derived SmartEnum (consumer pattern)
using IndQuestEnums;
public sealed class ZoneTag : EnumModel
{
public static readonly ZoneTag Invalid = new(EnumModel.InvalidValue, EnumModel.InvalidName);
public static readonly ZoneTag Z1 = new(1, "Z1", "Zone 1 — production/reasoning");
public static readonly ZoneTag Z2 = new(2, "Z2", "Zone 2 — grader/validation");
public static readonly ZoneTag Z3 = new(3, "Z3", "Zone 3 — held-out orchestrator");
public ZoneTag() { } // required for new() factory fallback
private ZoneTag(int value, string name, string displayName = "")
: base(value, name, displayName) { }
public static ZoneTag FromValue(int value) => FromValue<ZoneTag>(value);
public static ZoneTag FromName(string name) => FromName<ZoneTag>(name);
}
EF companion sketch (for IndQuestEnums.EntityFramework)
// Generic value converter: store the int, rehydrate via the cached FromValue.
public sealed class EnumModelConverter<TEnum> : ValueConverter<TEnum, int>
where TEnum : EnumModel, new()
{
public EnumModelConverter()
: base(e => e.Value, v => EnumModel.FromValue<TEnum>(v)) { }
}
public sealed class EnumModelComparer<TEnum> : ValueComparer<TEnum>
where TEnum : EnumModel
{
public EnumModelComparer()
: base((a, b) => a!.Value == b!.Value, e => e.Value, e => e) { }
}
Next steps (you take it from here)
dotnet new classlibfor the core (net10.0,LangVersion=latest,Nullable=enable,GenerateDocumentationFile=true); drop insrc/EnumModel.cs.- Add the EF companion + a test project (xUnit v3 mtp-v2 + Shouldly), prove: value/name/display
round-trips,
Invalidfallback, equality by type+value, cache correctness, duplicate-value safety. - Pack + publish
IndQuestEnums(andIndQuestEnums.EntityFramework) to nuget.org. - Back in EMIP: pin
IndQuestEnumsinSrc/Directory.Packages.props, reference it from the Domain csproj, addglobal using IndQuestEnums;, and finish Story 1.2 Task 5 (the SmartEnums).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- IndQuestEnums (>= 1.0.1)
- Microsoft.EntityFrameworkCore (>= 10.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.