From da33a0dd84759148f80123365cd8983c986c81da Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 14:21:15 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #9 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Disposables/issues/9 --- 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..b732c79 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Disposables/issues/9 +Your prepared branch: issue-9-d3d7ec5f +Your prepared working directory: /tmp/gh-issue-solver-1757848871205 + +Proceed. \ No newline at end of file From e409905793c72bedd649f4b4392a72f7b5544392 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 14:28:58 +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 - Add Resources.resx and Resources.ru.resx for English and Russian localization - Create strongly-typed Resources.Designer.cs for accessing localized strings - Update DisposableBase.cs to use localized exception message for multiple dispose calls - Add comprehensive unit test for verifying internationalization works across cultures - Fix test framework reference from net7 to net8 to resolve DisposalOrderTest failure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../DisposableTests.cs | 36 ++++- csharp/Platform.Disposables/DisposableBase.cs | 2 +- .../Resources.Designer.cs | 72 ++++++++++ csharp/Platform.Disposables/Resources.resx | 123 ++++++++++++++++++ csharp/Platform.Disposables/Resources.ru.resx | 65 +++++++++ 5 files changed, 296 insertions(+), 2 deletions(-) create mode 100644 csharp/Platform.Disposables/Resources.Designer.cs create mode 100644 csharp/Platform.Disposables/Resources.resx create mode 100644 csharp/Platform.Disposables/Resources.ru.resx diff --git a/csharp/Platform.Disposables.Tests/DisposableTests.cs b/csharp/Platform.Disposables.Tests/DisposableTests.cs index caa19fb..a4d6523 100644 --- a/csharp/Platform.Disposables.Tests/DisposableTests.cs +++ b/csharp/Platform.Disposables.Tests/DisposableTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Threading; @@ -42,7 +43,7 @@ private static ProcessStartInfo CreateProcessStartInfo(string logPath, bool wait return new ProcessStartInfo { FileName = "dotnet", - Arguments = $"run -p \"{projectPath}\" -f net7 \"{logPath}\" {waitForCancellation.ToString()}", + Arguments = $"run -p \"{projectPath}\" -f net8 \"{logPath}\" {waitForCancellation.ToString()}", UseShellExecute = false, CreateNoWindow = true }; @@ -79,5 +80,38 @@ private static string GetDisposalObjectTestProjectFilePath() } return path; } + + [Fact] + public static void MultipleDisposeExceptionMessageInternationalizationTest() + { + var testDisposable = new TestDisposable(); + testDisposable.Dispose(); + + // Test English (default) culture + var originalCulture = CultureInfo.CurrentUICulture; + try + { + CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var englishException = Assert.Throws(() => testDisposable.Dispose()); + Assert.Contains("Multiple dispose calls are not allowed", englishException.Message); + + // Test Russian culture + CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("ru-RU"); + var russianException = Assert.Throws(() => testDisposable.Dispose()); + Assert.Contains("Множественные вызовы Dispose не разрешены", russianException.Message); + } + finally + { + CultureInfo.CurrentUICulture = originalCulture; + } + } + + private class TestDisposable : DisposableBase + { + protected override void Dispose(bool manual, bool wasDisposed) + { + // Empty implementation for testing + } + } } } diff --git a/csharp/Platform.Disposables/DisposableBase.cs b/csharp/Platform.Disposables/DisposableBase.cs index c030a61..d5f5bd9 100644 --- a/csharp/Platform.Disposables/DisposableBase.cs +++ b/csharp/Platform.Disposables/DisposableBase.cs @@ -147,7 +147,7 @@ protected virtual void Dispose(bool manual) var wasDisposed = originalDisposedValue > 0; if (wasDisposed && !AllowMultipleDisposeCalls && manual) { - Ensure.Always.NotDisposed(this, ObjectName, "Multiple dispose calls are not allowed. Override AllowMultipleDisposeCalls property to modify behavior."); + Ensure.Always.NotDisposed(this, ObjectName, Resources.MultipleDisposeCallsNotAllowed); } if (AllowMultipleDisposeAttempts || !wasDisposed) { diff --git a/csharp/Platform.Disposables/Resources.Designer.cs b/csharp/Platform.Disposables/Resources.Designer.cs new file mode 100644 index 0000000..17d5478 --- /dev/null +++ b/csharp/Platform.Disposables/Resources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace Platform.Disposables { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Platform.Disposables.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Multiple dispose calls are not allowed. Override AllowMultipleDisposeCalls property to modify behavior.. + /// + internal static string MultipleDisposeCallsNotAllowed { + get { + return ResourceManager.GetString("MultipleDisposeCallsNotAllowed", resourceCulture); + } + } + } +} \ No newline at end of file diff --git a/csharp/Platform.Disposables/Resources.resx b/csharp/Platform.Disposables/Resources.resx new file mode 100644 index 0000000..4ddc5f0 --- /dev/null +++ b/csharp/Platform.Disposables/Resources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Multiple dispose calls are not allowed. Override AllowMultipleDisposeCalls property to modify behavior. + Exception message when multiple dispose calls are made on an object that doesn't allow them + + \ No newline at end of file diff --git a/csharp/Platform.Disposables/Resources.ru.resx b/csharp/Platform.Disposables/Resources.ru.resx new file mode 100644 index 0000000..78d47f6 --- /dev/null +++ b/csharp/Platform.Disposables/Resources.ru.resx @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Множественные вызовы Dispose не разрешены. Переопределите свойство AllowMultipleDisposeCalls для изменения поведения. + Сообщение исключения, когда выполняется несколько вызовов dispose для объекта, который их не разрешает + + \ No newline at end of file From b1710bf00a1386b4ea62835f9b1e14eee5df2d75 Mon Sep 17 00:00:00 2001 From: konard Date: Sun, 14 Sep 2025 14:29:30 +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 b732c79..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Disposables/issues/9 -Your prepared branch: issue-9-d3d7ec5f -Your prepared working directory: /tmp/gh-issue-solver-1757848871205 - -Proceed. \ No newline at end of file