From 61514db3be8abdd2c1b996f31337b8047cd6deed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tjorven=20K=C3=A4mpfer?= <62958434+tjorvenK@users.noreply.github.com> Date: Wed, 28 Feb 2024 10:37:59 +0100 Subject: [PATCH 1/2] refactor: use stronlgy package --- .../Ashampoo.Translation.Systems.Formats.Abstractions.csproj | 2 +- .../src/Models/Language.cs | 4 ++-- .../src/JavaProperties/JavaPropertiesFormat.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/Ashampoo.Translation.Systems.Formats.Abstractions.csproj b/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/Ashampoo.Translation.Systems.Formats.Abstractions.csproj index 90e873d..d927bdd 100644 --- a/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/Ashampoo.Translation.Systems.Formats.Abstractions.csproj +++ b/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/Ashampoo.Translation.Systems.Formats.Abstractions.csproj @@ -32,6 +32,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/Models/Language.cs b/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/Models/Language.cs index 8548974..4adbc2b 100644 --- a/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/Models/Language.cs +++ b/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/Models/Language.cs @@ -1,11 +1,11 @@ -using StronglyTypedIds; +using Strongly; namespace Ashampoo.Translation.Systems.Formats.Abstractions.Models; /// /// Represents a strongly typed identifier for a language. /// -[StronglyTypedId(Template.String)] +[Strongly(StronglyType.String, StronglyConverter.SystemTextJson, StronglyImplementations.IEquatable |StronglyImplementations.Parsable)] public readonly partial struct Language; /// diff --git a/src/Ashampoo.Translation.Systems.Formats/src/JavaProperties/JavaPropertiesFormat.cs b/src/Ashampoo.Translation.Systems.Formats/src/JavaProperties/JavaPropertiesFormat.cs index d167311..3563b95 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/JavaProperties/JavaPropertiesFormat.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/JavaProperties/JavaPropertiesFormat.cs @@ -71,7 +71,7 @@ private async Task ConfigureOptionsAsync(FormatReadOptions? options) } else { - Header.TargetLanguage = (Language)options.TargetLanguage!; + Header.TargetLanguage = options.TargetLanguage!; } return true; From 03b1d02438d7095512e3c925d388f81680c85afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tjorven=20K=C3=A4mpfer?= <62958434+tjorvenK@users.noreply.github.com> Date: Wed, 28 Feb 2024 10:53:34 +0100 Subject: [PATCH 2/2] cleanup --- .../src/IFormatProvider.cs | 2 +- .../src/AshLang/AshLangFormatProvider.cs | 4 ++-- .../src/Gengo/GengoFormatProvider.cs | 4 ++-- .../src/JavaProperties/JavaPropertiesFormatProvider.cs | 5 +++-- .../src/Json/JsonFormatProvider.cs | 4 ++-- .../src/NLang/NLangFormatProvider.cs | 6 +++--- .../src/PO/POFormatProvider.cs | 4 ++-- .../src/ResX/ResXFormatProvider.cs | 6 +++--- .../src/TsProj/TsProjFormatProvider.cs | 4 ++-- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/IFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/IFormatProvider.cs index 57722d6..a0d97ef 100644 --- a/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/IFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats.Abstractions/src/IFormatProvider.cs @@ -27,7 +27,7 @@ public interface IFormatProvider where T : class, IFormat /// /// Returns the supported file extensions of the format provider. /// - string[] SupportedFileExtensions { get; } + IEnumerable SupportedFileExtensions { get; } /// /// Creates a new instance of the format builder. diff --git a/src/Ashampoo.Translation.Systems.Formats/src/AshLang/AshLangFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats/src/AshLang/AshLangFormatProvider.cs index 2632ff5..8e45c98 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/AshLang/AshLangFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/AshLang/AshLangFormatProvider.cs @@ -8,7 +8,7 @@ namespace Ashampoo.Translation.Systems.Formats.AshLang; public sealed class AshLangFormatProvider : IFormatProvider { /// - public string Id { get; } = "ashlang"; + public string Id => "ashlang"; /// public AshLangFormat Create() => new(); @@ -20,7 +20,7 @@ public bool SupportsFileName(string fileName) } /// - public string[] SupportedFileExtensions => [".ashlang"]; + public IEnumerable SupportedFileExtensions => [".ashlang"]; /// public IFormatBuilder GetFormatBuilder() => new AshLangFormatBuilder(); diff --git a/src/Ashampoo.Translation.Systems.Formats/src/Gengo/GengoFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats/src/Gengo/GengoFormatProvider.cs index fafa2d9..f64c1a7 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/Gengo/GengoFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/Gengo/GengoFormatProvider.cs @@ -8,7 +8,7 @@ namespace Ashampoo.Translation.Systems.Formats.Gengo; public sealed class GengoFormatProvider : IFormatProvider { /// - public string Id { get; } = "gengo"; + public string Id => "gengo"; /// public GengoFormat Create() => new(); @@ -20,7 +20,7 @@ public bool SupportsFileName(string fileName) } /// - public string[] SupportedFileExtensions { get; } = [".xlsx", ".xls"]; + public IEnumerable SupportedFileExtensions { get; } = [".xlsx", ".xls"]; /// public IFormatBuilder GetFormatBuilder() => new GengoFormatBuilder(); diff --git a/src/Ashampoo.Translation.Systems.Formats/src/JavaProperties/JavaPropertiesFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats/src/JavaProperties/JavaPropertiesFormatProvider.cs index dc5e260..7cd2b83 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/JavaProperties/JavaPropertiesFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/JavaProperties/JavaPropertiesFormatProvider.cs @@ -8,7 +8,8 @@ namespace Ashampoo.Translation.Systems.Formats.JavaProperties; public sealed class JavaPropertiesFormatProvider : IFormatProvider { /// - public string Id { get; } = "javaProperties"; + public string Id => "javaProperties"; + /// public JavaPropertiesFormat Create() => new(); @@ -19,7 +20,7 @@ public bool SupportsFileName(string fileName) } /// - public string[] SupportedFileExtensions { get; } = [".properties"]; + public IEnumerable SupportedFileExtensions { get; } = [".properties"]; /// public IFormatBuilder GetFormatBuilder() => new JavaPropertiesFormatBuilder(); } \ No newline at end of file diff --git a/src/Ashampoo.Translation.Systems.Formats/src/Json/JsonFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats/src/Json/JsonFormatProvider.cs index 0e6b388..63ba05d 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/Json/JsonFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/Json/JsonFormatProvider.cs @@ -8,7 +8,7 @@ namespace Ashampoo.Translation.Systems.Formats.Json; public sealed class JsonFormatProvider : IFormatProvider { /// - public string Id { get; } = "json"; + public string Id => "json"; /// public JsonFormat Create() => new(); @@ -20,7 +20,7 @@ public bool SupportsFileName(string fileName) } /// - public string[] SupportedFileExtensions { get; } = [".json"]; + public IEnumerable SupportedFileExtensions { get; } = [".json"]; /// public IFormatBuilder GetFormatBuilder() => new JsonFormatBuilder(); diff --git a/src/Ashampoo.Translation.Systems.Formats/src/NLang/NLangFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats/src/NLang/NLangFormatProvider.cs index 17d928c..a4ca006 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/NLang/NLangFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/NLang/NLangFormatProvider.cs @@ -3,12 +3,12 @@ namespace Ashampoo.Translation.Systems.Formats.NLang; /// -/// Implementation of for the NLang format. +/// Implementation of for the NLang format. /// public sealed class NLangFormatProvider : IFormatProvider { /// - public string Id { get; } = "nlang"; + public string Id => "nlang"; /// public NLangFormat Create() => new(); @@ -20,7 +20,7 @@ public bool SupportsFileName(string fileName) } /// - public string[] SupportedFileExtensions { get; } = [".nlang3"]; + public IEnumerable SupportedFileExtensions { get; } = [".nlang3"]; /// public IFormatBuilder GetFormatBuilder() => new NLangFormatBuilder(); diff --git a/src/Ashampoo.Translation.Systems.Formats/src/PO/POFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats/src/PO/POFormatProvider.cs index 5e55926..f6c400d 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/PO/POFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/PO/POFormatProvider.cs @@ -9,7 +9,7 @@ namespace Ashampoo.Translation.Systems.Formats.PO; public sealed class POFormatProvider : IFormatProvider { /// - public string Id { get; } = "po"; + public string Id => "po"; /// public POFormat Create() => new(); @@ -21,7 +21,7 @@ public bool SupportsFileName(string fileName) } /// - public string[] SupportedFileExtensions { get; } = [".po"]; + public IEnumerable SupportedFileExtensions { get; } = [".po"]; /// public IFormatBuilder GetFormatBuilder() => new POFormatBuilder(); diff --git a/src/Ashampoo.Translation.Systems.Formats/src/ResX/ResXFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats/src/ResX/ResXFormatProvider.cs index c6a99cc..47360ac 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/ResX/ResXFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/ResX/ResXFormatProvider.cs @@ -3,12 +3,12 @@ namespace Ashampoo.Translation.Systems.Formats.ResX; /// -/// Implementation of interface for the ResX format. +/// Implementation of interface for the ResX format. /// public sealed class ResXFormatProvider : IFormatProvider { /// - public string Id { get; } = "resx"; + public string Id => "resx"; /// public ResXFormat Create() => new(); @@ -20,7 +20,7 @@ public bool SupportsFileName(string fileName) } /// - public string[] SupportedFileExtensions { get; } = [".resx"]; + public IEnumerable SupportedFileExtensions { get; } = [".resx"]; /// public IFormatBuilder GetFormatBuilder() => new ResXFormatBuilder(); diff --git a/src/Ashampoo.Translation.Systems.Formats/src/TsProj/TsProjFormatProvider.cs b/src/Ashampoo.Translation.Systems.Formats/src/TsProj/TsProjFormatProvider.cs index 4ca07be..2261b49 100644 --- a/src/Ashampoo.Translation.Systems.Formats/src/TsProj/TsProjFormatProvider.cs +++ b/src/Ashampoo.Translation.Systems.Formats/src/TsProj/TsProjFormatProvider.cs @@ -6,7 +6,7 @@ namespace Ashampoo.Translation.Systems.Formats.TsProj; public sealed class TsProjFormatProvider : IFormatProvider { /// - public string Id { get; } = "tsproj"; + public string Id => "tsproj"; /// public TsProjFormat Create() => new(); @@ -18,7 +18,7 @@ public bool SupportsFileName(string fileName) } /// - public string[] SupportedFileExtensions { get; } = [".tsproj"]; + public IEnumerable SupportedFileExtensions { get; } = [".tsproj"]; /// public IFormatBuilder GetFormatBuilder() => new TsProjFormatBuilder();