From 6dd41b160b7db18d5ed4043eaa663c53fedd2c80 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 12:33:29 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #12 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Ranges/issues/12 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..024874f --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Ranges/issues/12 +Your prepared branch: issue-12-4604bc3a +Your prepared working directory: /tmp/gh-issue-solver-1757842406215 + +Proceed. \ No newline at end of file From eca9eb9fd8d312ee9f60fe7cf95d62eb1b33b84b Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 12:40:43 +0300 Subject: [PATCH 2/3] Implement internationalization of exception messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create resource-based localization system using .resx files - Replace hardcoded English exception messages with localized versions - Add ExceptionMessages.resx with structured message definitions - Update EnsureExtensions to use localized messages from resources - Add comprehensive unit tests to verify localized messages work correctly - Make ExceptionMessages class public for programmatic access - Support future multi-language capabilities through .NET resource system All exception messages now use Unicode-compatible resource strings instead of hardcoded English text, addressing issue #12. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../EnsureExtensionsTests.cs | 23 ++++++ csharp/Platform.Ranges/EnsureExtensions.cs | 5 +- csharp/Platform.Ranges/Platform.Ranges.csproj | 7 ++ .../Resources/ExceptionMessages.Designer.cs | 81 +++++++++++++++++++ .../Resources/ExceptionMessages.resx | 42 ++++++++++ 5 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 csharp/Platform.Ranges/Resources/ExceptionMessages.Designer.cs create mode 100644 csharp/Platform.Ranges/Resources/ExceptionMessages.resx diff --git a/csharp/Platform.Ranges.Tests/EnsureExtensionsTests.cs b/csharp/Platform.Ranges.Tests/EnsureExtensionsTests.cs index f8e6de0..0ef5f33 100644 --- a/csharp/Platform.Ranges.Tests/EnsureExtensionsTests.cs +++ b/csharp/Platform.Ranges.Tests/EnsureExtensionsTests.cs @@ -1,6 +1,7 @@ using System; using Xunit; using Platform.Exceptions; +using Platform.Ranges.Resources; namespace Platform.Ranges.Tests { @@ -11,5 +12,27 @@ public static class EnsureExtensionsTests [Fact] public static void ArgumentInRangeExceptionTest() => Assert.Throws(() => Ensure.Always.ArgumentInRange(5, (6, 7))); + + [Fact] + public static void MaximumArgumentIsGreaterOrEqualToMinimumMessageTest() + { + var exception = Assert.Throws(() => Ensure.Always.MaximumArgumentIsGreaterOrEqualToMinimum(5, 3)); + Assert.Contains(ExceptionMessages.MaximumShouldBeGreaterOrEqualToMinimum, exception.Message); + } + + [Fact] + public static void ArgumentInRangeMessageTest() + { + var exception = Assert.Throws(() => Ensure.Always.ArgumentInRange(10, (1, 5), "testArgument")); + var expectedMessage = string.Format(ExceptionMessages.ArgumentOutOfRange, 10, new Range(1, 5)); + Assert.Contains(expectedMessage, exception.Message); + } + + [Fact] + public static void ExceptionMessagesResourcesTest() + { + Assert.Equal("Maximum should be greater or equal to minimum.", ExceptionMessages.MaximumShouldBeGreaterOrEqualToMinimum); + Assert.Equal("Argument value [{0}] is out of range {1}.", ExceptionMessages.ArgumentOutOfRange); + } } } diff --git a/csharp/Platform.Ranges/EnsureExtensions.cs b/csharp/Platform.Ranges/EnsureExtensions.cs index 1747d55..ff13a05 100644 --- a/csharp/Platform.Ranges/EnsureExtensions.cs +++ b/csharp/Platform.Ranges/EnsureExtensions.cs @@ -4,6 +4,7 @@ using System.Runtime.CompilerServices; using Platform.Exceptions; using Platform.Exceptions.ExtensionRoots; +using Platform.Ranges.Resources; #pragma warning disable IDE0060 // Remove unused parameter @@ -15,7 +16,7 @@ namespace Platform.Ranges /// public static class EnsureExtensions { - private const string DefaultMaximumShouldBeGreaterOrEqualToMinimumMessage = "Maximum should be greater or equal to minimum."; + private static string DefaultMaximumShouldBeGreaterOrEqualToMinimumMessage => ExceptionMessages.MaximumShouldBeGreaterOrEqualToMinimum; #region Always @@ -126,7 +127,7 @@ public static void ArgumentInRange(this EnsureAlwaysExtensionRoot roo [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ArgumentInRange(this EnsureAlwaysExtensionRoot root, TArgument argumentValue, Range range, string argumentName) { - string messageBuilder() => $"Argument value [{argumentValue}] is out of range {range}."; + string messageBuilder() => string.Format(ExceptionMessages.ArgumentOutOfRange, argumentValue, range); ArgumentInRange(root, argumentValue, range, argumentName, messageBuilder); } diff --git a/csharp/Platform.Ranges/Platform.Ranges.csproj b/csharp/Platform.Ranges/Platform.Ranges.csproj index 6d7584f..253c58b 100644 --- a/csharp/Platform.Ranges/Platform.Ranges.csproj +++ b/csharp/Platform.Ranges/Platform.Ranges.csproj @@ -39,6 +39,13 @@ + + + ResXFileCodeGenerator + ExceptionMessages.Designer.cs + + + diff --git a/csharp/Platform.Ranges/Resources/ExceptionMessages.Designer.cs b/csharp/Platform.Ranges/Resources/ExceptionMessages.Designer.cs new file mode 100644 index 0000000..19c5af8 --- /dev/null +++ b/csharp/Platform.Ranges/Resources/ExceptionMessages.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Platform.Ranges.Resources { + using System; + + + /// <summary> + /// A strongly-typed resource class, for looking up localized strings, etc. + /// </summary> + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class ExceptionMessages { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + public ExceptionMessages() { + } + + /// <summary> + /// Returns the cached ResourceManager instance used by this class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Platform.Ranges.Resources.ExceptionMessages", typeof(ExceptionMessages).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// <summary> + /// Looks up a localized string similar to Argument value [{0}] is out of range {1}.. + /// </summary> + public static string ArgumentOutOfRange { + get { + return ResourceManager.GetString("ArgumentOutOfRange", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Maximum should be greater or equal to minimum.. + /// </summary> + public static string MaximumShouldBeGreaterOrEqualToMinimum { + get { + return ResourceManager.GetString("MaximumShouldBeGreaterOrEqualToMinimum", resourceCulture); + } + } + } +} \ No newline at end of file diff --git a/csharp/Platform.Ranges/Resources/ExceptionMessages.resx b/csharp/Platform.Ranges/Resources/ExceptionMessages.resx new file mode 100644 index 0000000..60430c9 --- /dev/null +++ b/csharp/Platform.Ranges/Resources/ExceptionMessages.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Maximum should be greater or equal to minimum. + Error message when maximum value is less than minimum value in a range + + + Argument value [{0}] is out of range {1}. + Error message when an argument value is outside the allowed range. {0} is the value, {1} is the range + + From e61c9a781255a8ca226d6607333682f39c092fce Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 12:41:23 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 024874f..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Ranges/issues/12 -Your prepared branch: issue-12-4604bc3a -Your prepared working directory: /tmp/gh-issue-solver-1757842406215 - -Proceed. \ No newline at end of file