Skip to content

Commit

Permalink
Merge branch 'main' into ivan/bin-prefs
Browse files Browse the repository at this point in the history
  • Loading branch information
imurashka committed Sep 20, 2024
2 parents 6216d9a + ec474ce commit 92a6b90
Show file tree
Hide file tree
Showing 18 changed files with 447 additions and 295 deletions.
6 changes: 2 additions & 4 deletions .BinaryPrefs/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
"dependencies": {
"com.appegy.binary-prefs": "file:../..",
"com.boundfoxstudios.fluentassertions": "6.8.0",
"com.dbrizov.naughtyattributes": "https://github.com/dbrizov/NaughtyAttributes.git#upm",
"com.unity.2d.sprite": "1.0.0",
"com.unity.ide.rider": "3.0.28",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.ide.rider": "3.0.31",
"com.unity.mobile.android-logcat": "1.4.2",
"com.unity.test-framework": "2.0.1-pre.18",
"com.unity.textmeshpro": "3.0.6",
"com.unity.textmeshpro": "3.0.9",
"com.unity.ugui": "1.0.0",
"com.yasirkula.ingamedebugconsole": "https://github.com/yasirkula/UnityIngameDebugConsole.git",
"net.tnrd.nsubstitute": "5.1.0",
Expand Down
20 changes: 2 additions & 18 deletions .BinaryPrefs/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
"dependencies": {},
"url": "https://package.openupm.com"
},
"com.dbrizov.naughtyattributes": {
"version": "https://github.com/dbrizov/NaughtyAttributes.git#upm",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "8a8fa5a9659a6d63f196391c71e06c4286c8acd7"
},
"com.unity.2d.sprite": {
"version": "1.0.0",
"depth": 0,
Expand All @@ -34,23 +27,14 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "3.0.28",
"version": "3.0.31",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ext.nunit": "1.0.6"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.22",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.9"
},
"url": "https://packages.unity.com"
},
"com.unity.mobile.android-logcat": {
"version": "1.4.2",
"depth": 0,
Expand All @@ -70,7 +54,7 @@
"url": "https://packages.unity.com"
},
"com.unity.textmeshpro": {
"version": "3.0.6",
"version": "3.0.9",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down
59 changes: 16 additions & 43 deletions Runtime/BinaryStorage.Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ public partial class BinaryStorage
static partial void ThrowIfFilePathLocked(string filePath);
static partial void UnlockFilePathInEditor(string filePath);

/// <summary>
/// Creates and configures a new instance of <see cref="BinaryStorage"/> with default settings.
/// </summary>
/// <summary> Creates and configures a new instance of <see cref="BinaryStorage"/> with default settings. </summary>
/// <param name="filePath">The file path for the storage.</param>
/// <returns>A configured <see cref="BinaryStorage"/> instance.</returns>
public static BinaryStorage Get(string filePath)
Expand All @@ -24,9 +22,7 @@ public static BinaryStorage Get(string filePath)
.Build();
}

/// <summary>
/// Begins the construction of a new <see cref="BinaryStorage"/> instance.
/// </summary>
/// <summary> Begins the construction of a new <see cref="BinaryStorage"/> instance. </summary>
/// <param name="filePath">The file path for the storage.</param>
/// <returns>A <see cref="Builder"/> for configuring the <see cref="BinaryStorage"/> instance.</returns>
public static Builder Construct(string filePath)
Expand All @@ -36,9 +32,7 @@ public static Builder Construct(string filePath)
return new Builder(filePath);
}

/// <summary>
/// Deletes the storage file at the specified path.
/// </summary>
/// <summary> Deletes the storage file at the specified path. </summary>
/// <param name="storagePath">The path to the storage file.</param>
internal static void Delete(string storagePath)
{
Expand All @@ -48,9 +42,7 @@ internal static void Delete(string storagePath)
}
}

/// <summary>
/// Provides a fluent interface for configuring and building a <see cref="BinaryStorage"/> instance.
/// </summary>
/// <summary> Provides a fluent interface for configuring and building a <see cref="BinaryStorage"/> instance. </summary>
public class Builder
{
private readonly string _filePath;
Expand All @@ -64,28 +56,22 @@ internal Builder(string filePath)
_filePath = filePath;
}

/// <summary>
/// Enables automatic saving of changes to the storage.
/// </summary>
/// <summary> Enables automatic saving of changes to the storage. </summary>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
public Builder EnableAutoSaveOnChange()
{
_autoSave = true;
return this;
}

/// <summary>
/// Specifies the behavior when a requested key is not found in the storage.
/// </summary>
/// <summary> Specifies the behavior when a requested key is not found in the storage. </summary>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
public Builder SetMissingKeyBehaviour(MissingKeyBehavior behavior)
{
_missingKeyBehavior = behavior;
return this;
}
/// <summary>
/// Specifies the behavior when the type of value associated with a key does not match the expected type.
/// </summary>
/// <summary> Specifies the behavior when the type of value associated with a key does not match the expected type. </summary>
/// <param name="behavior">The type mismatch behavior.</param>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
public Builder SetTypeMismatchBehaviour(TypeMismatchBehaviour behavior)
Expand All @@ -94,9 +80,7 @@ public Builder SetTypeMismatchBehaviour(TypeMismatchBehaviour behavior)
return this;
}

/// <summary>
/// Adds serializers for primitive types to the storage configuration.
/// </summary>
/// <summary> Adds serializers for primitive types to the storage configuration. </summary>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
public Builder AddPrimitiveTypes()
{
Expand Down Expand Up @@ -124,9 +108,7 @@ public Builder AddPrimitiveTypes()
.AddTypeSerializer(Vector3IntSerializer.Shared);
}

/// <summary>
/// Adds a serializer for a specified type to the storage configuration.
/// </summary>
/// <summary> Adds a serializer for a specified type to the storage configuration. </summary>
/// <typeparam name="T">The type to be serialized.</typeparam>
/// <param name="typeSerializer">The serializer for the specified type.</param>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
Expand All @@ -141,9 +123,7 @@ public Builder AddTypeSerializer<T>(TypeSerializer<T> typeSerializer)
return this;
}

/// <summary>
/// Adds support for a specified enum type to the storage configuration.
/// </summary>
/// <summary> Adds support for a specified enum type to the storage configuration. </summary>
/// <typeparam name="T">The enum type to be supported.</typeparam>
/// <param name="useFullName">Whether to use the full name of the enum type.</param>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
Expand Down Expand Up @@ -185,9 +165,7 @@ public Builder SupportEnum<T>(bool useFullName = false)
return this;
}

/// <summary>
/// Adds support for lists of a specified type to the storage configuration.
/// </summary>
/// <summary> Adds support for lists of a specified type to the storage configuration. </summary>
/// <typeparam name="T">The type of elements in the list.</typeparam>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
/// <exception cref="CantSupportCollectionOfException">Thrown if the specified type is not supported.</exception>
Expand All @@ -201,9 +179,7 @@ public Builder SupportListsOf<T>()
return AddTypeSerializer(new CollectionTypeSerializer<T, ReactiveList<T>>(section.Serializer));
}

/// <summary>
/// Adds support for sets of a specified type to the storage configuration.
/// </summary>
/// <summary> Adds support for sets of a specified type to the storage configuration. </summary>
/// <typeparam name="T">The type of elements in the set.</typeparam>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
/// <exception cref="CantSupportCollectionOfException">Thrown if the specified type is not supported.</exception>
Expand All @@ -217,9 +193,7 @@ public Builder SupportSetsOf<T>()
return AddTypeSerializer(new CollectionTypeSerializer<T, ReactiveSet<T>>(section.Serializer));
}

/// <summary>
/// Adds support for dictionaries of specified key and value types to the storage configuration.
/// </summary>
/// <summary> Adds support for dictionaries of specified key and value types to the storage configuration. </summary>
/// <typeparam name="TKey">The type of the dictionary keys.</typeparam>
/// <typeparam name="TValue">The type of the dictionary values.</typeparam>
/// <returns>The current <see cref="Builder"/> instance for method chaining.</returns>
Expand All @@ -236,11 +210,10 @@ public Builder SupportDictionariesOf<TKey, TValue>()
return AddTypeSerializer(new CollectionTypeSerializer<KeyValuePair<TKey, TValue>, ReactiveDictionary<TKey, TValue>>(kvSerializer));
}

/// <summary>
/// Builds and returns the configured <see cref="BinaryStorage"/> instance.
/// </summary>
/// <summary> Builds and returns the configured <see cref="BinaryStorage"/> instance. </summary>
/// <returns>The configured <see cref="BinaryStorage"/> instance.</returns>
/// <exception cref="Exception">Thrown if the storage fails to load data from disk.</exception>
/// <exception cref="ObjectDisposedException">Thrown if the storage is disposed.</exception>
/// <exception cref="IOException"> An I/O error occurred </exception>
public BinaryStorage Build()
{
try
Expand Down
Loading

0 comments on commit 92a6b90

Please sign in to comment.