From 523ab8ae6b0921be5d5e7f30fb1a4464e7800f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A8n?= Date: Wed, 14 Feb 2024 19:56:01 +0100 Subject: [PATCH 1/6] #27 NW.UnivariateForecasting.Serializations => NW.Shared.Serialization. --- .../Bags/ComponentBag.cs | 2 +- .../NW.UnivariateForecasting.csproj | 1 + .../Serializations/ISerializer.cs | 28 ------- .../Serializations/ISerializerFactory.cs | 16 ---- .../Serializations/Serializer.cs | 83 ------------------- .../Serializations/SerializerFactory.cs | 43 ---------- .../UnivariateForecaster.cs | 6 +- .../NW.UnivariateForecastingClient.csproj | 1 + .../Bags/ComponentBagTests.cs | 2 +- .../NW.UnivariateForecasting.UnitTests.csproj | 1 + .../SerializerFactoryTests.cs | 2 +- .../SerializerTests.cs | 2 +- .../UnivariateForecasterTests.cs | 2 +- ...ivariateForecastingClient.UnitTests.csproj | 1 + .../Shared/LibraryBrokerTests.cs | 2 +- 15 files changed, 13 insertions(+), 179 deletions(-) delete mode 100644 src/NW.UnivariateForecasting/Serializations/ISerializer.cs delete mode 100644 src/NW.UnivariateForecasting/Serializations/ISerializerFactory.cs delete mode 100644 src/NW.UnivariateForecasting/Serializations/Serializer.cs delete mode 100644 src/NW.UnivariateForecasting/Serializations/SerializerFactory.cs rename tests/NW.UnivariateForecasting.UnitTests/{Serializations => Serialization}/SerializerFactoryTests.cs (96%) rename tests/NW.UnivariateForecasting.UnitTests/{Serializations => Serialization}/SerializerTests.cs (99%) diff --git a/src/NW.UnivariateForecasting/Bags/ComponentBag.cs b/src/NW.UnivariateForecasting/Bags/ComponentBag.cs index 163d6aa..6d27f2f 100644 --- a/src/NW.UnivariateForecasting/Bags/ComponentBag.cs +++ b/src/NW.UnivariateForecasting/Bags/ComponentBag.cs @@ -4,7 +4,7 @@ using NW.Shared.Files; using NW.UnivariateForecasting.Forecasts; using NW.UnivariateForecasting.Observations; -using NW.UnivariateForecasting.Serializations; +using NW.Shared.Serialization; using NW.UnivariateForecasting.SlidingWindows; using NW.Shared.Validation; diff --git a/src/NW.UnivariateForecasting/NW.UnivariateForecasting.csproj b/src/NW.UnivariateForecasting/NW.UnivariateForecasting.csproj index 5d24865..03d8c7a 100644 --- a/src/NW.UnivariateForecasting/NW.UnivariateForecasting.csproj +++ b/src/NW.UnivariateForecasting/NW.UnivariateForecasting.csproj @@ -22,6 +22,7 @@ + diff --git a/src/NW.UnivariateForecasting/Serializations/ISerializer.cs b/src/NW.UnivariateForecasting/Serializations/ISerializer.cs deleted file mode 100644 index ab167e0..0000000 --- a/src/NW.UnivariateForecasting/Serializations/ISerializer.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace NW.UnivariateForecasting.Serializations -{ - /// A general purpose serializer for this library. - public interface ISerializer - { - - /// - /// Serializes the provided object of type T to a Json string. - /// - /// - string Serialize(T obj); - - /// - /// Deserializes the provided Json string to an object of type T. - /// If is null/empty/invalid or an exception is thrown, default of T will be returned. - /// - T DeserializeOrDefault(string json); - - } -} - -/* - Author: numbworks@gmail.com - Last Update: 14.02.2023 -*/ \ No newline at end of file diff --git a/src/NW.UnivariateForecasting/Serializations/ISerializerFactory.cs b/src/NW.UnivariateForecasting/Serializations/ISerializerFactory.cs deleted file mode 100644 index a31dcaf..0000000 --- a/src/NW.UnivariateForecasting/Serializations/ISerializerFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace NW.UnivariateForecasting.Serializations -{ - /// A factory for . - public interface ISerializerFactory - { - - /// Creates a instance. - ISerializer Create(); - - } -} - -/* - Author: numbworks@gmail.com - Last Update: 12.02.2023 -*/ \ No newline at end of file diff --git a/src/NW.UnivariateForecasting/Serializations/Serializer.cs b/src/NW.UnivariateForecasting/Serializations/Serializer.cs deleted file mode 100644 index 74e16c8..0000000 --- a/src/NW.UnivariateForecasting/Serializations/Serializer.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Text.Encodings.Web; -using System.Text.Json; -using NW.Shared.Validation; - -namespace NW.UnivariateForecasting.Serializations -{ - /// - public class Serializer : ISerializer - { - - #region Fields - - #endregion - - #region Properties - - #endregion - - #region Constructors - - /// Initializes a instance using default parameters. - public Serializer() { } - - #endregion - - #region Methods_public - - public string Serialize(T obj) - { - - Validator.ValidateObject(obj, nameof(obj)); - - string json = JsonSerializer.Serialize(obj, CreateJsonSerializerOptions()); - - return json; - - } - public T DeserializeOrDefault(string json) - { - - try - { - - T obj = JsonSerializer.Deserialize(json, CreateJsonSerializerOptions()); - - return obj; - - } - catch - { - - return default(T); - - } - - } - - #endregion - - #region Methods_private - - private JsonSerializerOptions CreateJsonSerializerOptions() - { - - JsonSerializerOptions options = new JsonSerializerOptions(); - - options.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping; - options.WriteIndented = true; - - return options; - - } - - #endregion - - } -} - -/* - Author: numbworks@gmail.com - Last Update: 14.02.2023 -*/ \ No newline at end of file diff --git a/src/NW.UnivariateForecasting/Serializations/SerializerFactory.cs b/src/NW.UnivariateForecasting/Serializations/SerializerFactory.cs deleted file mode 100644 index 3fc0afd..0000000 --- a/src/NW.UnivariateForecasting/Serializations/SerializerFactory.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace NW.UnivariateForecasting.Serializations -{ - /// - public class SerializerFactory : ISerializerFactory - { - - #region Fields - - #endregion - - #region Properties - - #endregion - - #region Constructors - - /// Initializes a instance using default parameters. - public SerializerFactory() { } - - #endregion - - #region Methods_public - - public ISerializer Create() - { - - return new Serializer(); - - } - - #endregion - - #region Methods_private - - #endregion - - } -} - -/* - Author: numbworks@gmail.com - Last Update: 12.02.2023 -*/ \ No newline at end of file diff --git a/src/NW.UnivariateForecasting/UnivariateForecaster.cs b/src/NW.UnivariateForecasting/UnivariateForecaster.cs index de43ae3..f1fb71f 100644 --- a/src/NW.UnivariateForecasting/UnivariateForecaster.cs +++ b/src/NW.UnivariateForecasting/UnivariateForecaster.cs @@ -3,11 +3,11 @@ using System.Linq; using System.Reflection; using NW.UnivariateForecasting.Bags; -using NW.Shared.Files; using NW.UnivariateForecasting.Forecasts; using NW.UnivariateForecasting.Observations; -using NW.UnivariateForecasting.Serializations; using NW.UnivariateForecasting.SlidingWindows; +using NW.Shared.Files; +using NW.Shared.Serialization; using NW.Shared.Validation; using NW.Shared.Files.Validation; @@ -233,5 +233,5 @@ private ForecastingInit DuplicateInit(ForecastingInit init) /* Author: numbworks@gmail.com - Last Update: 08.02.2024 + Last Update: 14.02.2024 */ diff --git a/src/NW.UnivariateForecastingClient/NW.UnivariateForecastingClient.csproj b/src/NW.UnivariateForecastingClient/NW.UnivariateForecastingClient.csproj index b26b52f..0bda982 100644 --- a/src/NW.UnivariateForecastingClient/NW.UnivariateForecastingClient.csproj +++ b/src/NW.UnivariateForecastingClient/NW.UnivariateForecastingClient.csproj @@ -32,5 +32,6 @@ + \ No newline at end of file diff --git a/tests/NW.UnivariateForecasting.UnitTests/Bags/ComponentBagTests.cs b/tests/NW.UnivariateForecasting.UnitTests/Bags/ComponentBagTests.cs index 46bf0e3..ea25093 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/Bags/ComponentBagTests.cs +++ b/tests/NW.UnivariateForecasting.UnitTests/Bags/ComponentBagTests.cs @@ -5,7 +5,7 @@ using NW.Shared.Files; using NW.UnivariateForecasting.Forecasts; using NW.UnivariateForecasting.Observations; -using NW.UnivariateForecasting.Serializations; +using NW.Shared.Serialization; using NW.UnivariateForecasting.SlidingWindows; using NUnit.Framework; diff --git a/tests/NW.UnivariateForecasting.UnitTests/NW.UnivariateForecasting.UnitTests.csproj b/tests/NW.UnivariateForecasting.UnitTests/NW.UnivariateForecasting.UnitTests.csproj index c8bf2e9..57b86c1 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/NW.UnivariateForecasting.UnitTests.csproj +++ b/tests/NW.UnivariateForecasting.UnitTests/NW.UnivariateForecasting.UnitTests.csproj @@ -15,6 +15,7 @@ + diff --git a/tests/NW.UnivariateForecasting.UnitTests/Serializations/SerializerFactoryTests.cs b/tests/NW.UnivariateForecasting.UnitTests/Serialization/SerializerFactoryTests.cs similarity index 96% rename from tests/NW.UnivariateForecasting.UnitTests/Serializations/SerializerFactoryTests.cs rename to tests/NW.UnivariateForecasting.UnitTests/Serialization/SerializerFactoryTests.cs index 2d9fe96..6e6297e 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/Serializations/SerializerFactoryTests.cs +++ b/tests/NW.UnivariateForecasting.UnitTests/Serialization/SerializerFactoryTests.cs @@ -1,5 +1,5 @@ using NW.UnivariateForecasting.Forecasts; -using NW.UnivariateForecasting.Serializations; +using NW.Shared.Serialization; using NUnit.Framework; namespace NW.UnivariateForecasting.UnitTests.Serializations diff --git a/tests/NW.UnivariateForecasting.UnitTests/Serializations/SerializerTests.cs b/tests/NW.UnivariateForecasting.UnitTests/Serialization/SerializerTests.cs similarity index 99% rename from tests/NW.UnivariateForecasting.UnitTests/Serializations/SerializerTests.cs rename to tests/NW.UnivariateForecasting.UnitTests/Serialization/SerializerTests.cs index 2bc6913..25d7f48 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/Serializations/SerializerTests.cs +++ b/tests/NW.UnivariateForecasting.UnitTests/Serialization/SerializerTests.cs @@ -1,6 +1,6 @@ using System; using NW.UnivariateForecasting.Forecasts; -using NW.UnivariateForecasting.Serializations; +using NW.Shared.Serialization; using NUnit.Framework; namespace NW.UnivariateForecasting.UnitTests.Serializations diff --git a/tests/NW.UnivariateForecasting.UnitTests/UnivariateForecasterTests.cs b/tests/NW.UnivariateForecasting.UnitTests/UnivariateForecasterTests.cs index 41fefe8..5a4e5f0 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/UnivariateForecasterTests.cs +++ b/tests/NW.UnivariateForecasting.UnitTests/UnivariateForecasterTests.cs @@ -7,7 +7,7 @@ using NW.UnivariateForecasting.Filenames; using NW.UnivariateForecasting.Forecasts; using NW.UnivariateForecasting.Observations; -using NW.UnivariateForecasting.Serializations; +using NW.Shared.Serialization; using NW.UnivariateForecasting.SlidingWindows; using NW.UnivariateForecasting.UnitTests.Utilities; using NW.Shared.Files; diff --git a/tests/NW.UnivariateForecastingClient.UnitTests/NW.UnivariateForecastingClient.UnitTests.csproj b/tests/NW.UnivariateForecastingClient.UnitTests/NW.UnivariateForecastingClient.UnitTests.csproj index acf0f6a..fcf2b20 100644 --- a/tests/NW.UnivariateForecastingClient.UnitTests/NW.UnivariateForecastingClient.UnitTests.csproj +++ b/tests/NW.UnivariateForecastingClient.UnitTests/NW.UnivariateForecastingClient.UnitTests.csproj @@ -19,6 +19,7 @@ + diff --git a/tests/NW.UnivariateForecastingClient.UnitTests/Shared/LibraryBrokerTests.cs b/tests/NW.UnivariateForecastingClient.UnitTests/Shared/LibraryBrokerTests.cs index e4d9c08..dd335c6 100644 --- a/tests/NW.UnivariateForecastingClient.UnitTests/Shared/LibraryBrokerTests.cs +++ b/tests/NW.UnivariateForecastingClient.UnitTests/Shared/LibraryBrokerTests.cs @@ -6,7 +6,7 @@ using NW.UnivariateForecasting.AsciiBanner; using NW.UnivariateForecasting.Filenames; using NW.UnivariateForecasting.Forecasts; -using NW.UnivariateForecasting.Serializations; +using NW.Shared.Serialization; using NW.UnivariateForecastingClient.Shared; using NW.UnivariateForecastingClient.UnitTests.Utilities; using NUnit.Framework; From 182bb98533029f17d6dcb2ffe89f5f0a92943561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A8n?= Date: Wed, 14 Feb 2024 19:57:57 +0100 Subject: [PATCH 2/6] #27 CHANGELOG: updated. --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 93f647b..ec296cb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +v4.2.0 +- Library: + - Refactoring: moved Serializations namespace to NW.Shared.Serialization. + v4.1.0 - Library: - Refactoring: moved Files and Validation to NW.Shared.Files and NW.Shared.Validation. From bbd43f1a6f50f97d827aba282cc95fce9bcd47f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A8n?= Date: Wed, 14 Feb 2024 20:02:06 +0100 Subject: [PATCH 3/6] #27 codecoverage_library*: updated. --- codecoverage_library.svg | 2 +- codecoverage_library.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codecoverage_library.svg b/codecoverage_library.svg index f0ecfbd..1c7d309 100644 --- a/codecoverage_library.svg +++ b/codecoverage_library.svg @@ -1 +1 @@ -coverage: 97.86%coverage97.86% \ No newline at end of file +coverage: 92.72%coverage92.72% \ No newline at end of file diff --git a/codecoverage_library.txt b/codecoverage_library.txt index 05ee472..ff7a04f 100644 --- a/codecoverage_library.txt +++ b/codecoverage_library.txt @@ -1 +1 @@ -https://img.shields.io/badge/coverage-97.86%25-green \ No newline at end of file +https://img.shields.io/badge/coverage-92.72%25-green \ No newline at end of file From 3d4f749d1310e1ce44236389a27470dd00d6f94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A8n?= Date: Wed, 14 Feb 2024 20:05:34 +0100 Subject: [PATCH 4/6] #27 *.csproj: updated. --- .../NW.UnivariateForecasting.csproj | 6 +++--- .../NW.UnivariateForecastingClient.csproj | 6 +++--- .../NW.UnivariateForecasting.UnitTests.csproj | 2 +- .../NW.UnivariateForecastingClient.UnitTests.csproj | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/NW.UnivariateForecasting/NW.UnivariateForecasting.csproj b/src/NW.UnivariateForecasting/NW.UnivariateForecasting.csproj index 03d8c7a..251c736 100644 --- a/src/NW.UnivariateForecasting/NW.UnivariateForecasting.csproj +++ b/src/NW.UnivariateForecasting/NW.UnivariateForecasting.csproj @@ -13,9 +13,9 @@ https://raw.githubusercontent.com/numbworks/numbworks/master/numbworks_logo_128x128px.png - 4.1.0 - 4.1.0.0 - 4.1.0.0 + 4.2.0 + 4.2.0.0 + 4.2.0.0 diff --git a/src/NW.UnivariateForecastingClient/NW.UnivariateForecastingClient.csproj b/src/NW.UnivariateForecastingClient/NW.UnivariateForecastingClient.csproj index 0bda982..b14e53d 100644 --- a/src/NW.UnivariateForecastingClient/NW.UnivariateForecastingClient.csproj +++ b/src/NW.UnivariateForecastingClient/NW.UnivariateForecastingClient.csproj @@ -16,9 +16,9 @@ unifor numbworks_logo_128x128px.ico numbworks_logo_128x128px.png - 4.1.0 - 4.1.0.0 - 4.1.0.0 + 4.2.0 + 4.2.0.0 + 4.2.0.0 diff --git a/tests/NW.UnivariateForecasting.UnitTests/NW.UnivariateForecasting.UnitTests.csproj b/tests/NW.UnivariateForecasting.UnitTests/NW.UnivariateForecasting.UnitTests.csproj index 57b86c1..50e25ff 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/NW.UnivariateForecasting.UnitTests.csproj +++ b/tests/NW.UnivariateForecasting.UnitTests/NW.UnivariateForecasting.UnitTests.csproj @@ -8,7 +8,7 @@ https://github.com/numbworks/NW.UnivariateForecasting https://raw.githubusercontent.com/numbworks/numbworks/master/numbworks_logo_128x128px.png machinelearning csharp library univariate timeseriesanalysis netstandard forecasting - 4.1.0 + 4.2.0 diff --git a/tests/NW.UnivariateForecastingClient.UnitTests/NW.UnivariateForecastingClient.UnitTests.csproj b/tests/NW.UnivariateForecastingClient.UnitTests/NW.UnivariateForecastingClient.UnitTests.csproj index fcf2b20..7b21e48 100644 --- a/tests/NW.UnivariateForecastingClient.UnitTests/NW.UnivariateForecastingClient.UnitTests.csproj +++ b/tests/NW.UnivariateForecastingClient.UnitTests/NW.UnivariateForecastingClient.UnitTests.csproj @@ -6,7 +6,7 @@ Library numbworks 2024 - 4.1.0 + 4.2.0 https://github.com/numbworks/NW.UnivariateForecasting numbworks_logo_128x128px.png From fdf0410b6fabd171221afebd88b9ecdcceccbc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A8n?= Date: Wed, 14 Feb 2024 20:07:05 +0100 Subject: [PATCH 5/6] #27 build.ps1: fixed. --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 82622ff..d2ca2a2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,6 @@ <# - Title: build_client.ps1 + Title: build.ps1 Author: numbworks@gmail.com Last Update: 27.09.2022 Description: From a7e25b9483873b6eefd0e66a990d473a300575ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A8n?= Date: Thu, 15 Feb 2024 17:20:53 +0100 Subject: [PATCH 6/6] #27 Fixed failing tests. --- .../Forecasts/ObjectMother.cs | 2 +- .../Resources/ForecastingSessionDoubleWithCEAsJson.txt | 2 +- .../Resources/ForecastingSessionSingleWithCEAsJson.txt | 2 +- .../Resources/ForecastingSessionSingleWithoutCEAsJson.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/NW.UnivariateForecasting.UnitTests/Forecasts/ObjectMother.cs b/tests/NW.UnivariateForecasting.UnitTests/Forecasts/ObjectMother.cs index bc66a22..dd73634 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/Forecasts/ObjectMother.cs +++ b/tests/NW.UnivariateForecasting.UnitTests/Forecasts/ObjectMother.cs @@ -57,7 +57,7 @@ public static ForecastingInit ForecastingInit_DoubleWithCE steps: ForecastingInit_Steps_MultipleDouble ); - public static string ForecastingSession_Version = "4.1.0.0"; + public static string ForecastingSession_Version = "4.2.0.0"; public static double NextValue = 519.23; public static List ExpandedValues = new List() { 58.5, 615.26, 659.84, 635.69, 612.27, 632.94, NextValue }; diff --git a/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionDoubleWithCEAsJson.txt b/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionDoubleWithCEAsJson.txt index 727ff0c..1cf1a40 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionDoubleWithCEAsJson.txt +++ b/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionDoubleWithCEAsJson.txt @@ -25,5 +25,5 @@ "NextValue": 158.25 } ], - "Version": "4.1.0.0" + "Version": "4.2.0.0" } \ No newline at end of file diff --git a/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionSingleWithCEAsJson.txt b/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionSingleWithCEAsJson.txt index 056317f..040e8db 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionSingleWithCEAsJson.txt +++ b/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionSingleWithCEAsJson.txt @@ -20,5 +20,5 @@ "NextValue": 316.48 } ], - "Version": "4.1.0.0" + "Version": "4.2.0.0" } \ No newline at end of file diff --git a/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionSingleWithoutCEAsJson.txt b/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionSingleWithoutCEAsJson.txt index 09e63cb..db88de0 100644 --- a/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionSingleWithoutCEAsJson.txt +++ b/tests/NW.UnivariateForecasting.UnitTests/Resources/ForecastingSessionSingleWithoutCEAsJson.txt @@ -20,5 +20,5 @@ "NextValue": 519.23 } ], - "Version": "4.1.0.0" + "Version": "4.2.0.0" } \ No newline at end of file