Skip to content

Commit

Permalink
Update MnemonicDB to 0.9.92 (#2196)
Browse files Browse the repository at this point in the history
* Update MnemonicDB to 0.9.92

* Update to the fixed version of MnemonicDB

* Fix build failures
  • Loading branch information
halgari authored Oct 24, 2024
1 parent 3b34921 commit c753617
Show file tree
Hide file tree
Showing 41 changed files with 141 additions and 160 deletions.
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PackageVersion Include="NexusMods.Hashing.xxHash3" Version="3.0.2" />
<PackageVersion Include="NexusMods.Hashing.xxHash3.Paths" Version="3.0.2" />
<PackageVersion Include="NexusMods.Paths" Version="0.10.0" />
<PackageVersion Include="NexusMods.MnemonicDB.Abstractions" Version="0.9.91" />
<PackageVersion Include="NexusMods.MnemonicDB" Version="0.9.91" />
<PackageVersion Include="NexusMods.MnemonicDB.Abstractions" Version="0.9.93" />
<PackageVersion Include="NexusMods.MnemonicDB" Version="0.9.93" />
<PackageVersion Include="NexusMods.Paths.Extensions.Nx" Version="0.10.0" />
<PackageVersion Include="NexusMods.Paths.TestingHelpers" Version="0.10.0" />
<PackageVersion Include="NexusMods.Archives.Nx" Version="0.6.1" />
Expand Down Expand Up @@ -128,7 +128,7 @@
<PackageVersion Include="Humanizer" Version="2.14.1" />
<PackageVersion Include="ini-parser-netstandard" Version="2.5.2" />
<PackageVersion Include="Mutagen.Bethesda.Skyrim" Version="0.44.0" />
<PackageVersion Include="NexusMods.MnemonicDB.SourceGenerator" Version="0.9.91" />
<PackageVersion Include="NexusMods.MnemonicDB.SourceGenerator" Version="0.9.93" />
<PackageVersion Include="NLog.Extensions.Logging" Version="5.3.11" />
<PackageVersion Include="OneOf" Version="3.0.271" />
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;

namespace NexusMods.Abstractions.Collections.Attributes;

/// <summary>
/// An attribute representing an MD5 hash value.
/// </summary>
public class Md5Attribute(string ns, string name) : ScalarAttribute<Md5HashValue, UInt128>(ValueTag.UInt128, ns, name)
public class Md5Attribute(string ns, string name) : ScalarAttribute<Md5HashValue, UInt128, UInt128Serializer>(ns, name)
{
/// <inheritdoc />
protected override UInt128 ToLowLevel(Md5HashValue value)
{
return value.Value;
}
protected override UInt128 ToLowLevel(Md5HashValue value) => value.Value;

/// <inheritdoc />
protected override Md5HashValue FromLowLevel(UInt128 value, AttributeResolver resolver)
{
return Md5HashValue.From(value);
}
protected override Md5HashValue FromLowLevel(UInt128 value, AttributeResolver resolver)
=> Md5HashValue.From(value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;

namespace NexusMods.Abstractions.FileStore.Nx.Models;

/// <summary>
/// Stores a NXArchive file entry as a blob.
/// </summary>
public class NxFileEntryAttribute(string ns, string name) : ScalarAttribute<FileEntry, Memory<byte>>(ValueTag.Blob, ns, name)
public class NxFileEntryAttribute(string ns, string name) : ScalarAttribute<FileEntry, Memory<byte>, BlobSerializer>(ns, name)
{
/// <inheritdoc />
protected override unsafe FileEntry FromLowLevel(Memory<byte> value, AttributeResolver resolver)
Expand Down
17 changes: 7 additions & 10 deletions src/Abstractions/NexusMods.Abstractions.GameLocators/GamePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;
using NexusMods.Paths;
using NexusMods.Paths.Extensions;

Expand Down Expand Up @@ -137,7 +138,7 @@ public int CompareTo(GamePath other)
/// <summary>
/// Defines a GamePath attribute.
/// </summary>
public class GamePathAttribute(string ns, string name) : ScalarAttribute<GamePath, string>(ValueTag.Utf8, ns, name)
public class GamePathAttribute(string ns, string name) : ScalarAttribute<GamePath, string, Utf8Serializer>(ns, name)
{
/// <inheritdoc />
protected override string ToLowLevel(GamePath value)
Expand All @@ -159,17 +160,13 @@ protected override GamePath FromLowLevel(string value, AttributeResolver resolve
/// An attribute that combines an EntityId, LocationId and RelativePath into a single attribute. This is used to represent GamePaths prefixed
/// with a parent entity so that range queries only return the paths that are children of the parent entity.
/// </summary>
public class GamePathParentAttribute(string ns, string name) : ScalarAttribute<(EntityId, LocationId, RelativePath), (EntityId, ushort, string)>(ValueTag.Tuple3_Ref_UShort_Utf8I, ns, name)
public class GamePathParentAttribute(string ns, string name) : ScalarAttribute<(EntityId, LocationId, RelativePath), (EntityId, ushort, string), Tuple3_Ref_UShort_Utf8I_Serializer>(ns, name)
{
/// <inheritdoc />
protected override (EntityId, ushort, string) ToLowLevel((EntityId, LocationId, RelativePath) value)
{
return (value.Item1, value.Item2.Value, value.Item3);
}
protected override (EntityId, ushort, string) ToLowLevel((EntityId, LocationId, RelativePath) value)
=> (value.Item1, value.Item2.Value, value.Item3);

/// <inheritdoc />
protected override (EntityId, LocationId, RelativePath) FromLowLevel((EntityId, ushort, string) value, AttributeResolver resolver)
{
return (value.Item1, LocationId.From(value.Item2), RelativePath.FromUnsanitizedInput(value.Item3));
}
protected override (EntityId, LocationId, RelativePath) FromLowLevel((EntityId, ushort, string) value, AttributeResolver resolver)
=> (value.Item1, LocationId.From(value.Item2), RelativePath.FromUnsanitizedInput(value.Item3));
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;
using TransparentValueObjects;

namespace NexusMods.Abstractions.GameLocators;
Expand Down Expand Up @@ -59,17 +60,11 @@ public readonly partial struct GameStore
/// <summary>
/// An attribute that contains the name of a game store.
/// </summary>
public class GameStoreAttribute(string ns, string name) : ScalarAttribute<GameStore, string>(ValueTag.Ascii, ns, name)
public class GameStoreAttribute(string ns, string name) : ScalarAttribute<GameStore, string, AsciiSerializer>(ns, name)
{
/// <inheritdoc />
protected override string ToLowLevel(GameStore value)
{
return value.Value;
}
protected override string ToLowLevel(GameStore value) => value.Value;

/// <inheritdoc />
protected override GameStore FromLowLevel(string value, AttributeResolver resolver)
{
return GameStore.From(value);
}
protected override GameStore FromLowLevel(string value, AttributeResolver resolver) => GameStore.From(value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ await ActionExtractToDisk(groupings, register, tx,

if (gameMetadata.Contains(GameInstallMetadata.LastSyncedLoadout))
{
tx.Retract(gameMetadataId, GameInstallMetadata.LastSyncedLoadout, gameMetadata.LastSyncedLoadout);
tx.Retract(gameMetadataId, GameInstallMetadata.LastSyncedLoadoutTransaction, gameMetadata.LastSyncedLoadoutTransaction);
tx.Retract(gameMetadataId, GameInstallMetadata.LastSyncedLoadout, (EntityId)gameMetadata.LastSyncedLoadout);
tx.Retract(gameMetadataId, GameInstallMetadata.LastSyncedLoadoutTransaction, (EntityId)gameMetadata.LastSyncedLoadoutTransaction);
}
tx.Add(gameMetadataId, GameInstallMetadata.LastScannedDiskStateTransaction, EntityId.From(tx.ThisTxId.Value));

Expand Down Expand Up @@ -549,7 +549,7 @@ private void ActionDeleteFromDisk(SyncActionGroupings<SyncTreeNode> groupings, I
tx.Retract(id, DiskStateEntry.Hash, item.Disk.Value.Hash);
tx.Retract(id, DiskStateEntry.Size, item.Disk.Value.Size);
tx.Retract(id, DiskStateEntry.LastModified, item.Disk.Value.LastModified);
tx.Retract(id, DiskStateEntry.Game, item.Disk.Value.Game);
tx.Retract(id, DiskStateEntry.Game, (EntityId)item.Disk.Value.Game);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;
using NexusMods.Paths;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

/// <summary>
/// An absolute path, stored as a string (case-sensitive)
/// </summary>
public class AbsolutePathAttribute(string ns, string name) : ScalarAttribute<AbsolutePath, string>(ValueTag.Utf8, ns, name)
public class AbsolutePathAttribute(string ns, string name) : ScalarAttribute<AbsolutePath, string, Utf8Serializer>(ns, name)
{
/// <inheritdoc />
protected override string ToLowLevel(AbsolutePath value)
{
return value.ToString();
}
protected override string ToLowLevel(AbsolutePath value) => value.ToString();

/// <inheritdoc />
protected override AbsolutePath FromLowLevel(string value, AttributeResolver resolver)

{
return resolver.ServiceProvider.GetRequiredService<IFileSystem>().FromUnsanitizedFullPath(value);
}
protected override AbsolutePath FromLowLevel(string value, AttributeResolver resolver)
=> resolver.ServiceProvider.GetRequiredService<IFileSystem>().FromUnsanitizedFullPath(value);
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

/// <summary>
/// An attribute that represents a boolean value.
/// </summary>
public class BooleanAttribute(string ns, string name) : ScalarAttribute<bool, byte>(ValueTag.UInt8, ns, name)
public class BooleanAttribute(string ns, string name) : ScalarAttribute<bool, byte, UInt8Serializer>(ns, name)
{
/// <inheritdoc />
protected override byte ToLowLevel(bool value)
{
return value ? (byte) 1 : (byte) 0;
}
protected override byte ToLowLevel(bool value) => value ? (byte) 1 : (byte) 0;

/// <inheritdoc />
protected override bool FromLowLevel(byte value, AttributeResolver resolver)
{
return value == 1;
}
protected override bool FromLowLevel(byte value, AttributeResolver resolver) => value == 1;
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

/// <summary>
/// Attribute for storing a UInt8
/// </summary>
public class ByteAttribute(string ns, string name) : ScalarAttribute<byte, byte>(ValueTag.UInt8, ns, name)
public class ByteAttribute(string ns, string name) : ScalarAttribute<byte, byte, UInt8Serializer>(ns, name)
{
protected override byte ToLowLevel(byte value)
{
return value;
}
/// <inheritdoc />
protected override byte ToLowLevel(byte value) => value;

protected override byte FromLowLevel(byte value, AttributeResolver resolver)
{
return value;
}
/// <inheritdoc />
protected override byte FromLowLevel(byte value, AttributeResolver resolver) => value;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

/// <summary>
/// Bytes.
/// </summary>
public class BytesAttribute(string ns, string name) : ScalarAttribute<Memory<byte>, Memory<byte>>(ValueTag.Blob, ns, name)
public class BytesAttribute(string ns, string name) : ScalarAttribute<Memory<byte>, Memory<byte>, BlobSerializer>(ns, name)
{
/// <inheritdoc />
protected override Memory<byte> ToLowLevel(Memory<byte> value) => value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

Expand All @@ -10,7 +11,7 @@ namespace NexusMods.Abstractions.MnemonicDB.Attributes;
/// <remarks>
/// Depending on use case, consider using transaction timestamps instead of a dedicated DateTimeAttribute.
/// </remarks>
public class DateTimeAttribute(string ns, string name) : ScalarAttribute<DateTime, long>(ValueTag.Int64, ns, name)
public class DateTimeAttribute(string ns, string name) : ScalarAttribute<DateTime, long, Int64Serializer>(ns, name)
{
/// <inheritdoc />
protected override long ToLowLevel(DateTime value) => value.ToBinary();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

/// <summary>
/// An attribute that represents an enum value.
/// </summary>
public class EnumAttribute<T>(string ns, string name) : ScalarAttribute<T, int>(ValueTag.Int32, ns, name)
public class EnumAttribute<T>(string ns, string name) : ScalarAttribute<T, int, Int32Serializer>(ns, name)
where T : Enum
{
/// <inheritdoc />
Expand All @@ -29,7 +30,7 @@ protected override T FromLowLevel(int value, AttributeResolver resolver)
/// <summary>
/// An attribute that represents an enum value with a backing type of a byte.
/// </summary>
public class EnumByteAttribute<T>(string ns, string name) : ScalarAttribute<T, byte>(ValueTag.UInt8, ns, name)
public class EnumByteAttribute<T>(string ns, string name) : ScalarAttribute<T, byte, UInt8Serializer>(ns, name)
where T : Enum
{
/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static TxId MostRecentTxId(this IReadOnlyModel model)
/// <param name="model"></param>
/// <param name="dateTime">A default value to return if the model doesn't exist.</param>
/// <returns></returns>
public static DateTime GetCreatedAt<T>(this T model, DateTime? dateTime = null)
public static DateTimeOffset GetCreatedAt<T>(this T model, DateTime? dateTime = null)
where T : IReadOnlyModel
{
if (model.Count == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

/// <summary>
/// Stores a <see cref="Hash"/> as a <see cref="ulong"/>.
/// </summary>
public class HashAttribute(string ns, string name) : ScalarAttribute<Hash, ulong>(ValueTag.UInt64, ns, name)
public class HashAttribute(string ns, string name) : ScalarAttribute<Hash, ulong, UInt64Serializer>(ns, name)
{
/// <inheritdoc />
protected override ulong ToLowLevel(Hash value)
{
return value.Value;
}

protected override ulong ToLowLevel(Hash value) => value.Value;

/// <inheritdoc />
protected override Hash FromLowLevel(ulong value, AttributeResolver resolver)
{
return Hash.From(value);
}
protected override Hash FromLowLevel(ulong value, AttributeResolver resolver) => Hash.From(value);
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;
using NexusMods.Paths;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

/// <summary>
/// Represents a relative path.
/// </summary>
public class RelativePathAttribute(string ns, string name) : ScalarAttribute<RelativePath, string>(ValueTag.Utf8Insensitive, ns, name)
public class RelativePathAttribute(string ns, string name) : ScalarAttribute<RelativePath, string, Utf8InsensitiveSerializer>(ns, name)
{
/// <inheritdoc />
protected override string ToLowLevel(RelativePath value)
{
return value.Path;
}
protected override string ToLowLevel(RelativePath value) => value.Path;

/// <inheritdoc />
protected override RelativePath FromLowLevel(string value, AttributeResolver resolver)
{
return RelativePath.FromUnsanitizedInput(value);
}
protected override RelativePath FromLowLevel(string value, AttributeResolver resolver)
=> RelativePath.FromUnsanitizedInput(value);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.ValueSerializers;
using NexusMods.Paths;

namespace NexusMods.Abstractions.MnemonicDB.Attributes;

/// <summary>
/// A MneumonicDB attribute for a Size value
/// </summary>
public class SizeAttribute(string ns, string name) : ScalarAttribute<Size, ulong>(ValueTag.UInt64, ns, name)
public class SizeAttribute(string ns, string name) : ScalarAttribute<Size, ulong, UInt64Serializer>(ns, name)
{
/// <inheritdoc />
protected override ulong ToLowLevel(Size value) => value.Value;
Expand Down
Loading

0 comments on commit c753617

Please sign in to comment.