From d0992f8e947f4c4c90924411db5349da206e0283 Mon Sep 17 00:00:00 2001 From: David Najar Date: Wed, 16 Feb 2022 15:00:23 +0100 Subject: [PATCH] Changed Fluxor.Persist to netstandard2.0 --- .../Storage/InMemoryStateStorage.cs | 8 ++-- .../Storage/LocalStateStorage.cs | 4 +- Fluxor.Persist/AssemblyInfo.cs | 8 ++++ Fluxor.Persist/Component1.razor | 3 -- Fluxor.Persist/Component1.razor.css | 6 --- Fluxor.Persist/ExampleJsInterop.cs | 39 ------------------- Fluxor.Persist/Fluxor.Persist.csproj | 7 +++- .../Middleware/PersistMiddlewareOptions.cs | 2 +- Fluxor.Persist/Storage/IObjectStateStorage.cs | 4 +- Fluxor.Persist/Storage/IStringStateStorage.cs | 4 +- 10 files changed, 24 insertions(+), 61 deletions(-) create mode 100644 Fluxor.Persist/AssemblyInfo.cs delete mode 100644 Fluxor.Persist/Component1.razor delete mode 100644 Fluxor.Persist/Component1.razor.css delete mode 100644 Fluxor.Persist/ExampleJsInterop.cs diff --git a/Fluxor.Persist.Sample.Shared/Storage/InMemoryStateStorage.cs b/Fluxor.Persist.Sample.Shared/Storage/InMemoryStateStorage.cs index 3e8b85d..87c5e8d 100644 --- a/Fluxor.Persist.Sample.Shared/Storage/InMemoryStateStorage.cs +++ b/Fluxor.Persist.Sample.Shared/Storage/InMemoryStateStorage.cs @@ -10,19 +10,19 @@ public class InMemoryStateStorage : IObjectStateStorage public void ClearStore() => _store.Clear(); - public ValueTask GetStateAsync(string statename) + public Task GetStateAsync(string statename) { if (_store.ContainsKey(statename)) - return ValueTask.FromResult(_store[statename]); + return Task.FromResult(_store[statename]); return default; } - public ValueTask StoreStateAsync(string statename, object state) + public Task StoreStateAsync(string statename, object state) { if (_store.ContainsKey(statename)) _store.TryRemove(statename, out _); _store.TryAdd(statename, state); - return ValueTask.CompletedTask; + return Task.CompletedTask; } } } diff --git a/Fluxor.Persist.Sample.Shared/Storage/LocalStateStorage.cs b/Fluxor.Persist.Sample.Shared/Storage/LocalStateStorage.cs index 9e7515b..96c562f 100644 --- a/Fluxor.Persist.Sample.Shared/Storage/LocalStateStorage.cs +++ b/Fluxor.Persist.Sample.Shared/Storage/LocalStateStorage.cs @@ -14,12 +14,12 @@ public LocalStateStorage(ILocalStorageService localStorage) LocalStorage = localStorage; } - public async ValueTask GetStateJsonAsync(string statename) + public async Task GetStateJsonAsync(string statename) { return await LocalStorage.GetItemAsStringAsync(statename); } - public async ValueTask StoreStateJsonAsync(string statename, string json) + public async Task StoreStateJsonAsync(string statename, string json) { await LocalStorage.SetItemAsStringAsync(statename, json); } diff --git a/Fluxor.Persist/AssemblyInfo.cs b/Fluxor.Persist/AssemblyInfo.cs new file mode 100644 index 0000000..6930828 --- /dev/null +++ b/Fluxor.Persist/AssemblyInfo.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace System.Runtime.CompilerServices +{ + public class IsExternalInit { } +} diff --git a/Fluxor.Persist/Component1.razor b/Fluxor.Persist/Component1.razor deleted file mode 100644 index 2eb470d..0000000 --- a/Fluxor.Persist/Component1.razor +++ /dev/null @@ -1,3 +0,0 @@ -
- This Blazor component is defined in the Fluxor.Blazor.Persist package. -
diff --git a/Fluxor.Persist/Component1.razor.css b/Fluxor.Persist/Component1.razor.css deleted file mode 100644 index c6afca4..0000000 --- a/Fluxor.Persist/Component1.razor.css +++ /dev/null @@ -1,6 +0,0 @@ -.my-component { - border: 2px dashed red; - padding: 1em; - margin: 1em 0; - background-image: url('background.png'); -} diff --git a/Fluxor.Persist/ExampleJsInterop.cs b/Fluxor.Persist/ExampleJsInterop.cs deleted file mode 100644 index cb89a66..0000000 --- a/Fluxor.Persist/ExampleJsInterop.cs +++ /dev/null @@ -1,39 +0,0 @@ -//using Microsoft.JSInterop; -//using System; -//using System.Threading.Tasks; - -//namespace Fluxor.Blazor.Persist -//{ -// // This class provides an example of how JavaScript functionality can be wrapped -// // in a .NET class for easy consumption. The associated JavaScript module is -// // loaded on demand when first needed. -// // -// // This class can be registered as scoped DI service and then injected into Blazor -// // components for use. - -// public class ExampleJsInterop : IAsyncDisposable -// { -// private readonly Lazy> moduleTask; - -// public ExampleJsInterop(IJSRuntime jsRuntime) -// { -// moduleTask = new(() => jsRuntime.InvokeAsync( -// "import", "./_content/Fluxor.Blazor.Persist/exampleJsInterop.js").AsTask()); -// } - -// public async ValueTask Prompt(string message) -// { -// var module = await moduleTask.Value; -// return await module.InvokeAsync("showPrompt", message); -// } - -// public async ValueTask DisposeAsync() -// { -// if (moduleTask.IsValueCreated) -// { -// var module = await moduleTask.Value; -// await module.DisposeAsync(); -// } -// } -// } -//} diff --git a/Fluxor.Persist/Fluxor.Persist.csproj b/Fluxor.Persist/Fluxor.Persist.csproj index 8af95b3..701d3ec 100644 --- a/Fluxor.Persist/Fluxor.Persist.csproj +++ b/Fluxor.Persist/Fluxor.Persist.csproj @@ -1,6 +1,6 @@  - net6.0 + netstandard2.0 Persists fluxor packages 2.0.0 Greg Pringle @@ -13,7 +13,9 @@ true snupkg - + + 9.0 + @@ -38,6 +40,7 @@ + diff --git a/Fluxor.Persist/Middleware/PersistMiddlewareOptions.cs b/Fluxor.Persist/Middleware/PersistMiddlewareOptions.cs index f45f2f8..26f0105 100644 --- a/Fluxor.Persist/Middleware/PersistMiddlewareOptions.cs +++ b/Fluxor.Persist/Middleware/PersistMiddlewareOptions.cs @@ -66,7 +66,7 @@ private class ListComparer : IEqualityComparer> { public bool Equals(KeyValuePair x, KeyValuePair y) => x.Key.Equals(y.Key); - public int GetHashCode([DisallowNull] KeyValuePair obj) => obj.Key.GetHashCode(); + public int GetHashCode( KeyValuePair obj) => !obj.Equals(default(KeyValuePair)) ? obj.Key.GetHashCode():int.MinValue; } } } diff --git a/Fluxor.Persist/Storage/IObjectStateStorage.cs b/Fluxor.Persist/Storage/IObjectStateStorage.cs index 8d49895..c270213 100644 --- a/Fluxor.Persist/Storage/IObjectStateStorage.cs +++ b/Fluxor.Persist/Storage/IObjectStateStorage.cs @@ -4,7 +4,7 @@ namespace Fluxor.Persist.Storage { public interface IObjectStateStorage { - public ValueTask GetStateAsync(string statename); - public ValueTask StoreStateAsync(string statename, object state); + public Task GetStateAsync(string statename); + public Task StoreStateAsync(string statename, object state); } } diff --git a/Fluxor.Persist/Storage/IStringStateStorage.cs b/Fluxor.Persist/Storage/IStringStateStorage.cs index ba4058a..e2c53f7 100644 --- a/Fluxor.Persist/Storage/IStringStateStorage.cs +++ b/Fluxor.Persist/Storage/IStringStateStorage.cs @@ -4,7 +4,7 @@ namespace Fluxor.Persist.Storage { public interface IStringStateStorage { - public ValueTask GetStateJsonAsync(string statename); - public ValueTask StoreStateJsonAsync(string statename, string json); + public Task GetStateJsonAsync(string statename); + public Task StoreStateJsonAsync(string statename, string json); } }