Class FoundationIdentityRules
Canonical identity rule every IFoundationSettings asset must satisfy: Id must be unique
within its own settings type (services resolve a definition by its Id, scoped to that type), and
Guid must be unique across ALL foundation assets (it is the cross-type serialization key). This
rule previously existed twice, independently: an ad hoc per-editor check in
FoundationEditor<T>.CheckGuid/FindDuplicateId (Unity-editor, scoped to one open
inspector) and a formal cross-project sweep in SerenityHealthCheckValidator (Unity-editor,
scans every asset) -- never in Domain, so a hand-written or recipe-imported asset with a colliding
id/guid was only ever caught by whichever editor tool happened to run. Both should delegate here so the
rule is defined exactly once and stays engine-agnostic (works over plain (id, guid, typeName) records,
no Unity types).
Inherited Members
Namespace: Serenity.Global.Application.Validation
Assembly: Serenity.Global.Application.dll
Syntax
public static class FoundationIdentityRules
Methods
FindDuplicateGuidGroups(IEnumerable<IdentityRecord>)
Finds every group of 2+ records sharing the same non-empty Guid, across all types (Guid uniqueness is global).
Declaration
public static List<IGrouping<string, FoundationIdentityRules.IdentityRecord>> FindDuplicateGuidGroups(IEnumerable<FoundationIdentityRules.IdentityRecord> records)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<FoundationIdentityRules.IdentityRecord> | records | The records to scan, typically every foundation asset in the project. |
Returns
| Type | Description |
|---|---|
| List<IGrouping<string, FoundationIdentityRules.IdentityRecord>> | One group per colliding Guid, each with 2+ members. |
FindDuplicateIdGroups(IEnumerable<IdentityRecord>)
Finds every group of 2+ records sharing the same non-empty Id AND type name (Id uniqueness is per-type, so a collision across different types is not reported here).
Declaration
public static List<IGrouping<string, FoundationIdentityRules.IdentityRecord>> FindDuplicateIdGroups(IEnumerable<FoundationIdentityRules.IdentityRecord> records)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<FoundationIdentityRules.IdentityRecord> | records | The records to scan, typically every foundation asset in the project. |
Returns
| Type | Description |
|---|---|
| List<IGrouping<string, FoundationIdentityRules.IdentityRecord>> | One group per colliding (TypeName, Id) pair, each with 2+ members. |
IsGuidDuplicated(IReadOnlyList<IdentityRecord>, string, int)
Determines whether candidateGuid is already used by another record. Guids are
the serialization key and must be unique across every foundation asset, regardless of type.
Declaration
public static bool IsGuidDuplicated(IReadOnlyList<FoundationIdentityRules.IdentityRecord> records, string candidateGuid, int excludeIndex = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<FoundationIdentityRules.IdentityRecord> | records | All known records to check against (typically every foundation asset, or all of one type). |
| string | candidateGuid | The guid to check. |
| int | excludeIndex | Index within |
Returns
| Type | Description |
|---|---|
| bool | True when another record already has this guid. |
IsIdDuplicated(IReadOnlyList<IdentityRecord>, string, int)
Determines whether candidateId is already used by another record of the SAME
type. Ids are only required to be unique within a settings type, not globally.
Declaration
public static bool IsIdDuplicated(IReadOnlyList<FoundationIdentityRules.IdentityRecord> records, string candidateId, int excludeIndex = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<FoundationIdentityRules.IdentityRecord> | records | All known records of the same type as the candidate (the caller scopes this). |
| string | candidateId | The id to check. |
| int | excludeIndex | Index within |
Returns
| Type | Description |
|---|---|
| bool | True when another record already has this id. |