generated from Nexus-Mods/NexusMods.App.Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from Nexus-Mods/really-fix-unique-ids
Really fix unique ids
- Loading branch information
Showing
55 changed files
with
562 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/NexusMods.MnemonicDB.Abstractions/Attributes/IndexedFlagsAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using NexusMods.MnemonicDB.Abstractions.BuiltInEntities; | ||
using NexusMods.MnemonicDB.Abstractions.ElementComparers; | ||
using NexusMods.MnemonicDB.Abstractions.ValueSerializers; | ||
|
||
namespace NexusMods.MnemonicDB.Abstractions.Attributes; | ||
|
||
/// <summary> | ||
/// An attribute that defines the indexing status of an attribute, this is stored as a custom attribute type because | ||
/// older DBs store data in a different format and a conversion on read is required. | ||
/// </summary> | ||
public class IndexedFlagsAttribute : ScalarAttribute<IndexedFlags, byte, UInt8Serializer> | ||
{ | ||
/// <inheritdoc /> | ||
public IndexedFlagsAttribute(string ns, string name) : | ||
base(ns, name) | ||
{ | ||
DefaultValue = IndexedFlags.None; | ||
} | ||
|
||
/// <summary> | ||
/// This performs the proper conversion from the low level representation to the high level representation. Taking | ||
/// into consideration old attribute formats | ||
/// </summary> | ||
public override IndexedFlags ReadValue(ReadOnlySpan<byte> span, ValueTag tag, AttributeResolver resolver) | ||
{ | ||
// Old format, an attribute's existance means it's indexed | ||
if (tag == ValueTag.Null) | ||
return IndexedFlags.Indexed; | ||
if (tag == ValueTag.UInt8) | ||
return (IndexedFlags)span[0]; | ||
return IndexedFlags.None; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override byte ToLowLevel(IndexedFlags value) | ||
{ | ||
return (byte)value; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override IndexedFlags FromLowLevel(byte value, AttributeResolver resolver) | ||
{ | ||
throw new NotSupportedException("This method should never be called."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/NexusMods.MnemonicDB.Abstractions/BuiltInEntities/IndexedFlags.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
|
||
namespace NexusMods.MnemonicDB.Abstractions.BuiltInEntities; | ||
|
||
/// <summary> | ||
/// The indexed flags for an attribute | ||
/// </summary> | ||
[Flags] | ||
public enum IndexedFlags : byte | ||
{ | ||
/// <summary> | ||
/// Attribute is not indexed | ||
/// </summary> | ||
None = 0b0000, | ||
/// <summary> | ||
/// The attribute values are indexed | ||
/// </summary> | ||
Indexed = 0b0001, | ||
|
||
/// <summary> | ||
/// The attribute values have a unique index | ||
/// </summary> | ||
Unique = 0b0011, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
src/NexusMods.MnemonicDB/InternalTxFunctions/Migrations/AddIndex.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.