diff --git a/CSM Foundation Core.UnitTests/CSM Foundation Core.UnitTests.csproj b/CSM Foundation Core.UnitTests/Unit Tests.csproj similarity index 91% rename from CSM Foundation Core.UnitTests/CSM Foundation Core.UnitTests.csproj rename to CSM Foundation Core.UnitTests/Unit Tests.csproj index e1076fc..777c6cd 100644 --- a/CSM Foundation Core.UnitTests/CSM Foundation Core.UnitTests.csproj +++ b/CSM Foundation Core.UnitTests/Unit Tests.csproj @@ -2,7 +2,7 @@ net8.0 - CSM_Foundation_Core.UnitTests + Unit_Tests enable enable false diff --git a/CSM Foundation Core.UnitTests/Utils/SystemUtils_UnitTests.cs b/CSM Foundation Core.UnitTests/Utils/SystemUtils_UnitTests.cs index bcc6bb4..334f7c4 100644 --- a/CSM Foundation Core.UnitTests/Utils/SystemUtils_UnitTests.cs +++ b/CSM Foundation Core.UnitTests/Utils/SystemUtils_UnitTests.cs @@ -1,6 +1,7 @@ -using CSM_Foundation_Core.Utils; +using CSM_Foundation_Core; +using CSM_Foundation_Core.Core.Utils; -namespace CSM_Foundation_Core.UnitTests.Utils; +namespace Unit_Tests.Utils; /// diff --git a/CSM Foundation Core.sln b/CSM Foundation Core.sln index 685f8f7..c9b59dd 100644 --- a/CSM Foundation Core.sln +++ b/CSM Foundation Core.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.36310.24 +# Visual Studio Version 18 +VisualStudioVersion = 18.0.11222.15 d18.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSM Foundation Core", "CSM Foundation Core\CSM Foundation Core.csproj", "{E39161C8-353E-40B7-B1E0-ED3E17DCC51F}" EndProject @@ -11,7 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .gitignore = .gitignore EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSM Foundation Core.UnitTests", "CSM Foundation Core.UnitTests\CSM Foundation Core.UnitTests.csproj", "{A64FDEEE-0D9E-4311-A8F1-92F389F0285D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit Tests", "CSM Foundation Core.UnitTests\Unit Tests.csproj", "{A64FDEEE-0D9E-4311-A8F1-92F389F0285D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/CSM Foundation Core/BObject.cs b/CSM Foundation Core/Abstractions/Bases/ObjectBase.cs similarity index 97% rename from CSM Foundation Core/BObject.cs rename to CSM Foundation Core/Abstractions/Bases/ObjectBase.cs index 8c6bc9f..8bd02c9 100644 --- a/CSM Foundation Core/BObject.cs +++ b/CSM Foundation Core/Abstractions/Bases/ObjectBase.cs @@ -2,13 +2,13 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace CSM_Foundation_Core; +namespace CSM_Foundation_Core.Abstractions.Bases; /// /// Represents an inheritance link between datasource objects /// that need specific equality comparisson between their properties. /// -public abstract class BObject { +public abstract class ObjectBase { public override bool Equals(object? comparer) { PropertyInfo[] exceptions = []; diff --git a/CSM Foundation Core/IDisposer.cs b/CSM Foundation Core/Abstractions/Interfaces/IDisposer.cs similarity index 95% rename from CSM Foundation Core/IDisposer.cs rename to CSM Foundation Core/Abstractions/Interfaces/IDisposer.cs index 1747dcb..bc4d384 100644 --- a/CSM Foundation Core/IDisposer.cs +++ b/CSM Foundation Core/Abstractions/Interfaces/IDisposer.cs @@ -1,4 +1,4 @@ -namespace CSM_Foundation_Core; +namespace CSM_Foundation_Core.Abstractions.Interfaces; /// /// Represents a disposition manager wich stores objects in their context to be disposed at the end of a process. diff --git a/CSM Foundation Core/CHANGELOG.md b/CSM Foundation Core/CHANGELOG.md index 799b726..623208e 100644 --- a/CSM Foundation Core/CHANGELOG.md +++ b/CSM Foundation Core/CHANGELOG.md @@ -1,5 +1,20 @@ # CSM Foundation Core CHANGELOG +## [2.0.0] - 24.11-2025 + +### Changed + +- Renamed and reorganized the project structure to CSM Foundation Core to better reflect its purpose as a foundational library for CSM systems. +- Changed concept from [Exception] to [Error]. + +#### Dependencies + +| Package | Previous Version | New Version | +|:----------------------------------------|:----------------:|:---------------:| +| | | | + +### Removed + ## [1.3.0] - 27.08-2025 ### Added diff --git a/CSM Foundation Core/CSM Foundation Core.csproj b/CSM Foundation Core/CSM Foundation Core.csproj index 391c50b..2da1ae3 100644 --- a/CSM Foundation Core/CSM Foundation Core.csproj +++ b/CSM Foundation Core/CSM Foundation Core.csproj @@ -4,7 +4,7 @@ net8.0 CSM_Foundation_Core CSM.Foundation.Core - 1.3.0 + 2.0.0 Renato Urrea Cosmos (CSM) https://github.com/Cosmos-CSM/csm_foundation_core diff --git a/CSM Foundation Core/Convertion/BConverter.cs b/CSM Foundation Core/Convertion/Abstractions/Bases/ConverterBase.cs similarity index 53% rename from CSM Foundation Core/Convertion/BConverter.cs rename to CSM Foundation Core/Convertion/Abstractions/Bases/ConverterBase.cs index fa41671..55ecdbf 100644 --- a/CSM Foundation Core/Convertion/BConverter.cs +++ b/CSM Foundation Core/Convertion/Abstractions/Bases/ConverterBase.cs @@ -1,75 +1,66 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace CSM_Foundation_Core.Convertion; +using CSM_Foundation_Core.Convertion.Abstractions.Interfaces; +using CSM_Foundation_Core.Core.Exceptions; -/// -/// [Abstraction] for serialization/deseralization custom converters. -/// +namespace CSM_Foundation_Core.Convertion.Abstractions.Bases; + +/// /// /// Type of the common inherited interface/class from the variants. /// -public abstract class BConverter +public abstract class ConverterBase : JsonConverter, IConverter - where TBase : IConverterVariation { + where TBase : IConverterVariant { /// /// Stores all the possible variations classes types to find the correct one. /// - public Type[] Variations { get; init; } + public Type[] Variants { get; init; } /// - /// Creates a new instance. + /// Creates a new instance. /// - public BConverter(Type[] variations) { - Variations = variations; + /// + /// Converter known variants. + /// + public ConverterBase(Type[] variants) { + Variants = variants; + ValidateVariations(); } - #region Private Methods - /// - /// Validates if the configured correctly inherit from the . + /// Validates if the configured correctly inherit from the . /// - /// + /// /// Thrown when a wrong variation is found. /// void ValidateVariations() { - if (Variations.Length == 0) return; + if (Variants.Length == 0) return; - IEnumerable wrongTypes = Variations.Where( + IEnumerable wrongTypes = Variants.Where( (variation) => { return !variation.IsAssignableTo(typeof(TBase)); } ); if (wrongTypes.Any()) { - throw new XBConverter( - XBConverterEvents.WRONG_VARIATIONS, + throw new ConverterBaseError( + ConverterBaseErrorEvents.WRONG_VARIANTS, [.. wrongTypes] ); } } - #endregion - - #region JSON Converter Methods - - /// - /// - /// - /// - /// - /// - /// - /// public override TBase? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { JsonDocument document = JsonDocument.ParseValue(ref reader); JsonElement element = document.RootElement; // Determine the type from the Discriminator property. string? discriminator; - string discriminatorToken = nameof(IConverterVariation.Discriminator); + string discriminatorToken = nameof(IConverterVariant.Discriminator); try { discriminator = element.GetProperty(discriminatorToken).GetString(); } catch { @@ -77,37 +68,29 @@ [.. wrongTypes] } if (string.IsNullOrWhiteSpace(discriminator)) { - throw new XBConverter(XBConverterEvents.NO_DISCRIMINATOR); + throw new ConverterBaseError(ConverterBaseErrorEvents.NO_DISCRIMINATOR); } - foreach (Type variation in Variations) { + foreach (Type variation in Variants) { if (discriminator == variation.GetType().Name) { return (TBase?)element.Deserialize(variation.GetType(), options); } } - throw new XBConverter( - XBConverterEvents.NO_VARIATION, + throw new ConverterBaseError( + ConverterBaseErrorEvents.NO_VARIATION, discriminator: discriminator ); } - /// - /// - /// - /// - /// - /// public override void Write(Utf8JsonWriter writer, TBase value, JsonSerializerOptions options) { - foreach (Type variation in Variations) { + foreach (Type variation in Variants) { if (value.GetType().GUID == variation.GUID) { JsonSerializer.Serialize(writer, variation, options); } } - throw new XBConverter(XBConverterEvents.NO_VARIATION); + throw new ConverterBaseError(ConverterBaseErrorEvents.NO_VARIATION); } - - #endregion } diff --git a/CSM Foundation Core/Convertion/Abstractions/Bases/ConverterVariantBase.cs b/CSM Foundation Core/Convertion/Abstractions/Bases/ConverterVariantBase.cs new file mode 100644 index 0000000..e74ae19 --- /dev/null +++ b/CSM Foundation Core/Convertion/Abstractions/Bases/ConverterVariantBase.cs @@ -0,0 +1,17 @@ +using CSM_Foundation_Core.Convertion.Abstractions.Interfaces; + +namespace CSM_Foundation_Core.Convertion.Abstractions.Bases; + +/// +public abstract class ConverterVariantBase + : IConverterVariant { + + public string Discriminator { get; init; } + + /// + /// Creates a new instance. + /// + public ConverterVariantBase() { + Discriminator = $"{GetType().GUID}"; + } +} diff --git a/CSM Foundation Core/Convertion/Abstractions/Interfaces/IConverter.cs b/CSM Foundation Core/Convertion/Abstractions/Interfaces/IConverter.cs new file mode 100644 index 0000000..e5334aa --- /dev/null +++ b/CSM Foundation Core/Convertion/Abstractions/Interfaces/IConverter.cs @@ -0,0 +1,15 @@ +namespace CSM_Foundation_Core.Convertion.Abstractions.Interfaces; + +/// +/// Represents a JSON converter. +/// +/// +/// Type of the common inherited interface/class from the variants. +/// +public interface IConverter { + + /// + /// Converter handled derived types from . + /// + public Type[] Variants { get; } +} diff --git a/CSM Foundation Core/Convertion/IConverterVariation.cs b/CSM Foundation Core/Convertion/Abstractions/Interfaces/IConverterVariant.cs similarity index 56% rename from CSM Foundation Core/Convertion/IConverterVariation.cs rename to CSM Foundation Core/Convertion/Abstractions/Interfaces/IConverterVariant.cs index 62fa98d..c5e9f5f 100644 --- a/CSM Foundation Core/Convertion/IConverterVariation.cs +++ b/CSM Foundation Core/Convertion/Abstractions/Interfaces/IConverterVariant.cs @@ -1,15 +1,15 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; -namespace CSM_Foundation_Core.Convertion; +namespace CSM_Foundation_Core.Convertion.Abstractions.Interfaces; /// -/// Interface to determine a variation to the implementation. +/// Represents a handled variant. /// -public interface IConverterVariation { +public interface IConverterVariant { /// - /// Unique operation time variation identification for transaction convertions. + /// Unique runtime variation identification for transaction convertions. /// /// /// Additional has set as 0 to always be the first @@ -17,5 +17,5 @@ public interface IConverterVariation { /// /// [JsonPropertyOrder(0), NotMapped] - string Discriminator { get; init; } + string Discriminator { get; } } diff --git a/CSM Foundation Core/Convertion/BConverterVariation.cs b/CSM Foundation Core/Convertion/BConverterVariation.cs deleted file mode 100644 index 145a2a4..0000000 --- a/CSM Foundation Core/Convertion/BConverterVariation.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace CSM_Foundation_Core.Convertion; - -/// -/// Generates the base managing data and operations for a [Convertable] object, used by -/// the [CSM Convertion] concept. This Base class automatically loads primary information and methods -/// to make the [CSM Convertion] implementation easier. -/// -/// -/// By default must be the GUID runtime type of the object () -/// -/// -public abstract class BConverterVariation - : IConverterVariation { - - public string Discriminator { get; init; } - - /// - /// Creates a new base object. - /// - public BConverterVariation() { - Discriminator = $"{GetType().GUID}"; - } -} diff --git a/CSM Foundation Core/Convertion/IConverter.cs b/CSM Foundation Core/Convertion/IConverter.cs deleted file mode 100644 index 57d082b..0000000 --- a/CSM Foundation Core/Convertion/IConverter.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace CSM_Foundation_Core.Convertion; - - -/// -/// to access required implementation -/// contract. -/// -/// This [Converter] concepto is composed to create a self-managed object convertion for complex -/// data structures. -/// -public interface IConverter { - /// - /// Stores all the derived information from this - /// implementation. - /// - public Type[] Variations { get; init; } -} diff --git a/CSM Foundation Core/Convertion/XBConverter.cs b/CSM Foundation Core/Convertion/XBConverter.cs deleted file mode 100644 index ace48c3..0000000 --- a/CSM Foundation Core/Convertion/XBConverter.cs +++ /dev/null @@ -1,51 +0,0 @@ -using CSM_Foundation_Core.Exceptions; - -namespace CSM_Foundation_Core.Convertion; - -/// -/// Exception situations enumerator. -/// -public enum XBConverterEvents { - /// - /// When the couldn't find property. - /// - NO_DISCRIMINATOR, - - /// - /// When the didn't find the correct variation configured based - /// on the value. - /// - NO_VARIATION, - - /// - /// When the validations found an invalid variation. - /// - WRONG_VARIATIONS, -} - -/// -/// [Exception] for operations. -/// -public class XBConverter - : BException { - - /// - /// Creates a new instance. - /// - /// - /// Exception situation. - /// - /// - /// - /// Discriminator when the variation convertion fails. - /// - public XBConverter(XBConverterEvents situation, Type[]? wrongVariations = null, string discriminator = "") - : base("CSM Converter Exception", situation) { - - wrongVariations ??= []; - Data = new Dictionary { - { nameof(discriminator), discriminator }, - { nameof(wrongVariations), wrongVariations }, - }; - } -} diff --git a/CSM Foundation Core/Core/Exceptions/ConverterBaseError.cs b/CSM Foundation Core/Core/Exceptions/ConverterBaseError.cs new file mode 100644 index 0000000..6991d1e --- /dev/null +++ b/CSM Foundation Core/Core/Exceptions/ConverterBaseError.cs @@ -0,0 +1,53 @@ +using CSM_Foundation_Core.Convertion.Abstractions.Bases; +using CSM_Foundation_Core.Convertion.Abstractions.Interfaces; +using CSM_Foundation_Core.Errors.Abstractions.Bases; + +namespace CSM_Foundation_Core.Core.Exceptions; + +/// +/// Exception situations enumerator. +/// +public enum ConverterBaseErrorEvents { + /// + /// When the couldn't find property. + /// + NO_DISCRIMINATOR, + + /// + /// When the didn't find the correct variation configured based + /// on the value. + /// + NO_VARIATION, + + /// + /// When the validations found an invalid variation. + /// + WRONG_VARIANTS, +} + +/// +/// [Exception] for operations. +/// +public class ConverterBaseError + : ErrorBase { + + /// + /// Creates a new instance. + /// + /// + /// Exception situation. + /// + /// + /// + /// Discriminator when the variation convertion fails. + /// + public ConverterBaseError(ConverterBaseErrorEvents situation, Type[]? wrongVariations = null, string discriminator = "") + : base("CSM Converter Exception", situation) { + + wrongVariations ??= []; + Data = new Dictionary { + { nameof(discriminator), discriminator }, + { nameof(wrongVariations), wrongVariations }, + }; + } +} diff --git a/CSM Foundation Core/Exceptions/XSystem.cs b/CSM Foundation Core/Core/Exceptions/SystemError.cs similarity index 58% rename from CSM Foundation Core/Exceptions/XSystem.cs rename to CSM Foundation Core/Core/Exceptions/SystemError.cs index 63e6a54..208b925 100644 --- a/CSM Foundation Core/Exceptions/XSystem.cs +++ b/CSM Foundation Core/Core/Exceptions/SystemError.cs @@ -1,14 +1,13 @@ - +using CSM_Foundation_Core.Errors.Abstractions.Bases; +using CSM_Foundation_Core.Errors.Models; -using CSM_Foundation_Core.Exceptions.Models; - -namespace CSM_Foundation_Core.Exceptions; +namespace CSM_Foundation_Core.Core.Exceptions; /// -/// Represents exception triggering events for . +/// Represents exception triggering events for . /// -public enum XSystemEvents { +public enum SystemErrorEvents { /// /// The inner framework related validations triggered an exception. @@ -19,8 +18,8 @@ public enum XSystemEvents { /// /// Represents a CSM native framework exception in order to provide solutions from a basic exception management system integrated. /// -public class XSystem - : BException { +public class SystemError + : ErrorBase { /// /// Creates a new instance. @@ -37,7 +36,7 @@ public class XSystem /// /// Internal debugging exception data. /// - public XSystem(string message, Exception? frameworkException = null, ExceptionFeedback[]? feedback = null, IDictionary? data = null) - : base(message, XSystemEvents.FRAMEWORK, frameworkException, feedback ?? [], data ?? new Dictionary()) { + public SystemError(string message, Exception? frameworkException = null, ErrorFeedback[]? feedback = null, IDictionary? data = null) + : base(message, SystemErrorEvents.FRAMEWORK, frameworkException, feedback ?? [], data ?? new Dictionary()) { } } diff --git a/CSM Foundation Core/Extensions/DateTimeExtensions.cs b/CSM Foundation Core/Core/Extensions/DateTimeExtensions.cs similarity index 81% rename from CSM Foundation Core/Extensions/DateTimeExtensions.cs rename to CSM Foundation Core/Core/Extensions/DateTimeExtensions.cs index d48686c..51c05de 100644 --- a/CSM Foundation Core/Extensions/DateTimeExtensions.cs +++ b/CSM Foundation Core/Core/Extensions/DateTimeExtensions.cs @@ -1,4 +1,4 @@ -namespace CSM_Foundation_Core.Extensions; +namespace CSM_Foundation_Core.Core.Extensions; public static class DateTimeExtensions { public static DateTime Trim(this DateTime Current) { diff --git a/CSM Foundation Core/Extensions/EnumerableExtension.cs b/CSM Foundation Core/Core/Extensions/EnumerableExtension.cs similarity index 73% rename from CSM Foundation Core/Extensions/EnumerableExtension.cs rename to CSM Foundation Core/Core/Extensions/EnumerableExtension.cs index 3204538..8f7889a 100644 --- a/CSM Foundation Core/Extensions/EnumerableExtension.cs +++ b/CSM Foundation Core/Core/Extensions/EnumerableExtension.cs @@ -1,4 +1,4 @@ -namespace CSM_Foundation_Core.Extensions; +namespace CSM_Foundation_Core.Core.Extensions; public static class EnumerableExtension { public static bool Empty(this IEnumerable List) { return !List.Any(); diff --git a/CSM Foundation Core/Utils/ConsoleUtils.cs b/CSM Foundation Core/Core/Utils/ConsoleUtils.cs similarity index 97% rename from CSM Foundation Core/Utils/ConsoleUtils.cs rename to CSM Foundation Core/Core/Utils/ConsoleUtils.cs index 792463c..ed067bc 100644 --- a/CSM Foundation Core/Utils/ConsoleUtils.cs +++ b/CSM Foundation Core/Core/Utils/ConsoleUtils.cs @@ -1,11 +1,11 @@ using System.Text.Json; -using CSM_Foundation_Core.Exceptions; +using CSM_Foundation_Core.Errors.Abstractions.Interfaces; using Detail = System.Collections.Generic.KeyValuePair; using Details = System.Collections.Generic.Dictionary; -namespace CSM_Foundation_Core.Utils; +namespace CSM_Foundation_Core.Core.Utils; /// /// Provides utils methods related with the .Net Console integration. @@ -111,7 +111,7 @@ public static void Error(string title, Details? details = null) { /// /// Exception to write down into the console. /// - public static void Exception(IException exception) { + public static void Exception(IError exception) { Write( "Exception", exception.Message, diff --git a/CSM Foundation Core/Utils/FileUtils.cs b/CSM Foundation Core/Core/Utils/FileUtils.cs similarity index 93% rename from CSM Foundation Core/Utils/FileUtils.cs rename to CSM Foundation Core/Core/Utils/FileUtils.cs index 545b9c9..8c454eb 100644 --- a/CSM Foundation Core/Utils/FileUtils.cs +++ b/CSM Foundation Core/Core/Utils/FileUtils.cs @@ -1,6 +1,6 @@ using System.Text.Json; -namespace CSM_Foundation_Core.Utils; +namespace CSM_Foundation_Core.Core.Utils; public class FileUtils { public static string FormatLocation(string Location) { string wd = Directory.GetCurrentDirectory(); diff --git a/CSM Foundation Core/Utils/GenericUtils.cs b/CSM Foundation Core/Core/Utils/GenericUtils.cs similarity index 98% rename from CSM Foundation Core/Utils/GenericUtils.cs rename to CSM Foundation Core/Core/Utils/GenericUtils.cs index 25ec865..c1141ee 100644 --- a/CSM Foundation Core/Utils/GenericUtils.cs +++ b/CSM Foundation Core/Core/Utils/GenericUtils.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Reflection; -namespace CSM_Foundation_Core.Utils; +namespace CSM_Foundation_Core.Core.Utils; public static class GenericUtils { public static TObject DeepCopy(this TObject target, bool isParentProperty = true, Dictionary? visited = null) { visited ??= []; diff --git a/CSM Foundation Core/Utils/RandomUtils.cs b/CSM Foundation Core/Core/Utils/RandomUtils.cs similarity index 90% rename from CSM Foundation Core/Utils/RandomUtils.cs rename to CSM Foundation Core/Core/Utils/RandomUtils.cs index 63b3735..5f7279e 100644 --- a/CSM Foundation Core/Utils/RandomUtils.cs +++ b/CSM Foundation Core/Core/Utils/RandomUtils.cs @@ -1,4 +1,4 @@ -namespace CSM_Foundation_Core.Utils; +namespace CSM_Foundation_Core.Core.Utils; public static class RandomUtils { private static readonly Random Randomizer = new(); diff --git a/CSM Foundation Core/Utils/SystemUtils.cs b/CSM Foundation Core/Core/Utils/SystemUtils.cs similarity index 96% rename from CSM Foundation Core/Utils/SystemUtils.cs rename to CSM Foundation Core/Core/Utils/SystemUtils.cs index 2ad0166..1168dd4 100644 --- a/CSM Foundation Core/Utils/SystemUtils.cs +++ b/CSM Foundation Core/Core/Utils/SystemUtils.cs @@ -1,7 +1,6 @@ - -using CSM_Foundation_Core.Exceptions; +using CSM_Foundation_Core.Errors.Abstractions.Bases; -namespace CSM_Foundation_Core.Utils; +namespace CSM_Foundation_Core.Core.Utils; /// @@ -40,7 +39,7 @@ public enum XSystemUtilsEvents { /// Represents an exception thrown by operations. /// public class XSystemUtils - : BException { + : ErrorBase { /// /// Creates a new instance. diff --git a/CSM Foundation Core/Exceptions/BException.cs b/CSM Foundation Core/Errors/Abstractions/Bases/ErrorBase.cs similarity index 60% rename from CSM Foundation Core/Exceptions/BException.cs rename to CSM Foundation Core/Errors/Abstractions/Bases/ErrorBase.cs index 25a9218..736b8c8 100644 --- a/CSM Foundation Core/Exceptions/BException.cs +++ b/CSM Foundation Core/Errors/Abstractions/Bases/ErrorBase.cs @@ -1,61 +1,7 @@ -using System.Text.Json.Serialization; +using CSM_Foundation_Core.Errors.Abstractions.Interfaces; +using CSM_Foundation_Core.Errors.Models; -using CSM_Foundation_Core.Exceptions.Models; - -namespace CSM_Foundation_Core.Exceptions; - -/// -/// Represents a CSM Exception thrown by the system. -/// -public interface IException { - - /// - /// Exception message. - /// - string Message { get; } - - /// - /// Exception stacking trace. - /// - string? StackTrace { get; } - - /// - /// An user friendly message, meant to be displayed instead of the complex framework exception messages. - /// - string Advise { get; } - - /// - /// The internal system exception object caught. - /// - Exception? Exception { get; } - - /// - /// Exception feedback data. - /// - ExceptionFeedback[] Feedback { get; } - - /// - /// Data relevant during operation that triggered the exception. - /// - [JsonIgnore] - IDictionary Data { get; } -} - -/// -/// Represents a CSM Exception thrown by the system. -/// -/// -/// Exception scoped reasons enumerator. -/// -public interface IException - : IException - where TEvent : Enum { - - /// - /// Exception trigger event. - /// - TEvent Event { get; } -} +namespace CSM_Foundation_Core.Errors.Abstractions.Bases; /// /// Represents a CSM Exception thrown by the system. @@ -63,7 +9,7 @@ public interface IException /// /// Exception scoped event enumerator. /// -public abstract class BException +public abstract class ErrorBase : Exception, IException where TEvent : Enum { @@ -73,7 +19,7 @@ public abstract class BException public Exception? Exception { get; init; } - public ExceptionFeedback[] Feedback { get; init; } + public ErrorFeedback[] Feedback { get; init; } public new IDictionary Data { get; init; } @@ -95,7 +41,7 @@ public abstract class BException /// /// Operation data relevant for analysis of the exception. /// - public BException(string message, TEvent @event, Exception? exception = null, ExceptionFeedback[]? feedback = null, IDictionary? data = null) + public ErrorBase(string message, TEvent @event, Exception? exception = null, ErrorFeedback[]? feedback = null, IDictionary? data = null) : base(message) { Event = @event; diff --git a/CSM Foundation Core/Errors/Abstractions/Interfaces/IError.cs b/CSM Foundation Core/Errors/Abstractions/Interfaces/IError.cs new file mode 100644 index 0000000..6ea3196 --- /dev/null +++ b/CSM Foundation Core/Errors/Abstractions/Interfaces/IError.cs @@ -0,0 +1,58 @@ +using System.Text.Json.Serialization; + +using CSM_Foundation_Core.Errors.Models; + +namespace CSM_Foundation_Core.Errors.Abstractions.Interfaces; + +/// +/// Represents a CSM Exception thrown by the system. +/// +public interface IError { + + /// + /// Exception message. + /// + string Message { get; } + + /// + /// Exception stacking trace. + /// + string? StackTrace { get; } + + /// + /// An user friendly message, meant to be displayed instead of the complex framework exception messages. + /// + string Advise { get; } + + /// + /// The internal system exception object caught. + /// + Exception? Exception { get; } + + /// + /// Exception feedback data. + /// + ErrorFeedback[] Feedback { get; } + + /// + /// Data relevant during operation that triggered the exception. + /// + [JsonIgnore] + IDictionary Data { get; } +} + +/// +/// Represents a CSM Exception thrown by the system. +/// +/// +/// Exception scoped reasons enumerator. +/// +public interface IException + : IError + where TEvent : Enum { + + /// + /// Exception trigger event. + /// + TEvent Event { get; } +} \ No newline at end of file diff --git a/CSM Foundation Core/Exceptions/Models/ExceptionFeedback.cs b/CSM Foundation Core/Errors/Models/ErrorFeedback.cs similarity index 89% rename from CSM Foundation Core/Exceptions/Models/ExceptionFeedback.cs rename to CSM Foundation Core/Errors/Models/ErrorFeedback.cs index d008a71..d92460e 100644 --- a/CSM Foundation Core/Exceptions/Models/ExceptionFeedback.cs +++ b/CSM Foundation Core/Errors/Models/ErrorFeedback.cs @@ -1,4 +1,4 @@ -namespace CSM_Foundation_Core.Exceptions.Models; +namespace CSM_Foundation_Core.Errors.Models; /// /// Enumerates the severity of the exception feedback. @@ -21,7 +21,7 @@ public enum ExceptionFeedbackSeverity { /// /// Represents a solution user friendly exception feedback message. /// -public record ExceptionFeedback { +public record ErrorFeedback { /// /// Feedback message. diff --git a/CSM Foundation Core/Exceptions/Models/ExceptionInfo.cs b/CSM Foundation Core/Errors/Models/ErrorInfo.cs similarity index 86% rename from CSM Foundation Core/Exceptions/Models/ExceptionInfo.cs rename to CSM Foundation Core/Errors/Models/ErrorInfo.cs index bf2a18f..a0bd8e8 100644 --- a/CSM Foundation Core/Exceptions/Models/ExceptionInfo.cs +++ b/CSM Foundation Core/Errors/Models/ErrorInfo.cs @@ -1,13 +1,13 @@ -namespace CSM_Foundation_Core.Exceptions.Models; +namespace CSM_Foundation_Core.Errors.Models; /// -/// {model} record for . +/// {model} record for . /// /// /// Stores public information to expose an Exception details. /// /// -public record ExceptionInfo { +public record ErrorInfo { /// /// Where the exception got thrown. ///