From cc88664ee17216d8b8da015a9ce792abd76cba93 Mon Sep 17 00:00:00 2001 From: Ivan Pehsterski Date: Mon, 26 Jan 2026 05:00:39 +0200 Subject: [PATCH 1/4] Conver old syntaxis to old one using StringBuilder --- core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs b/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs index da3fe685fd1..66864c65c49 100644 --- a/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs +++ b/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs @@ -86,8 +86,14 @@ static void Main() private static void ShowSyntax() { - Console.WriteLine("\nSyntax: CyrillicToRoman "); - Console.WriteLine(" where = source filename"); - Console.WriteLine(" = destination filename\n"); + StringBuilder sb = new StringBuilder(); + + sb.AppendLine(); + sb.AppendLine("Syntax: CyrillicToRoman "); + sb.AppendLine(" where = source filename"); + sb.AppendLine(" = destination filename"); + sb.AppendLine(); + + Console.WriteLine(sb.ToString()); } } From f043deb58bdd9b9b6c5d2c6957f188e1d7cfc7b2 Mon Sep 17 00:00:00 2001 From: Ivan Pehsterski Date: Tue, 27 Jan 2026 05:38:43 +0200 Subject: [PATCH 2/4] Refactor part of the code --- .../cyrillic-to-latin/cs/Common/Common.cs | 15 +++++++++++ .../cyrillic-to-latin/cs/ConsoleModule.cs | 13 ++++++---- .../cs/CyrillicToLatin.csproj | 6 +++++ .../cyrillic-to-latin/cs/CyrillicToLatin.sln | 25 +++++++++++++++++++ .../cs/CyrillicToLatinFallback.cs | 10 ++++---- 5 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 core/encoding/cyrillic-to-latin/cs/Common/Common.cs create mode 100644 core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.sln diff --git a/core/encoding/cyrillic-to-latin/cs/Common/Common.cs b/core/encoding/cyrillic-to-latin/cs/Common/Common.cs new file mode 100644 index 00000000000..511ca3c3107 --- /dev/null +++ b/core/encoding/cyrillic-to-latin/cs/Common/Common.cs @@ -0,0 +1,15 @@ +using System; +namespace CyrillicToLatin.Common +{ + public static class Common + { + public const string NoSourceOrDestinationFile = "There must be a source and a destination file."; + + public const string FileDoesntExist = "The source file does not exist."; + + public const string WrongDirectory = "Invalid directory: {0}"; + + public const string WrongIO = "I/O exception: {0}"; + } +} + diff --git a/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs b/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs index 66864c65c49..a1b2cd71bf4 100644 --- a/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs +++ b/core/encoding/cyrillic-to-latin/cs/ConsoleModule.cs @@ -1,6 +1,9 @@ using System; using System.IO; +using System.Security.AccessControl; using System.Text; +using CyrillicToLatin.Common; + class ConsoleModule { @@ -9,9 +12,9 @@ static void Main() string[] args = Environment.GetCommandLineArgs(); // Get command line arguments. - if (args.Length != 3 || String.IsNullOrWhiteSpace(args[1]) || String.IsNullOrWhiteSpace(args[2])) + if (args.Length != 3 || string.IsNullOrWhiteSpace(args[1]) || string.IsNullOrWhiteSpace(args[2])) { - Console.WriteLine("There must be a source and a destination file."); + Console.WriteLine(Common.NoSourceOrDestinationFile); ShowSyntax(); return; } @@ -21,7 +24,7 @@ static void Main() if (!File.Exists(source)) { - Console.WriteLine("The source file does not exist."); + Console.WriteLine(Common.NoSourceOrDestinationFile); return; } @@ -74,12 +77,12 @@ static void Main() } catch (DirectoryNotFoundException e) { - Console.WriteLine($"Invalid directory: {e.Message}"); + Console.WriteLine(Common.WrongDirectory); return; } catch (IOException e) { - Console.WriteLine($"I/O exception: {e.Message}"); + Console.WriteLine(Common.WrongIO); return; } } diff --git a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj index a4fb324cffe..92301346999 100644 --- a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj +++ b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.csproj @@ -9,4 +9,10 @@ + + + + + + diff --git a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.sln b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.sln new file mode 100644 index 00000000000..b4fdc349cd4 --- /dev/null +++ b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1706.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CyrillicToLatin", "CyrillicToLatin.csproj", "{4802E97A-431C-4BAA-9C01-2B72D44719E4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4802E97A-431C-4BAA-9C01-2B72D44719E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4802E97A-431C-4BAA-9C01-2B72D44719E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4802E97A-431C-4BAA-9C01-2B72D44719E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4802E97A-431C-4BAA-9C01-2B72D44719E4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F93E5FBF-BBA2-4C11-8137-3B7726D29CA0} + EndGlobalSection +EndGlobal diff --git a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs index 8fdee54dea8..c0d09e321c6 100644 --- a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs +++ b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatinFallback.cs @@ -5,11 +5,11 @@ class CyrillicToLatinFallback : EncoderFallback { - private Dictionary table; + private Dictionary table; public CyrillicToLatinFallback() { - table = new Dictionary(); + table = new Dictionary(); // Define mappings. // Uppercase modern Cyrillic characters. table.Add('\u0410', "A"); @@ -92,12 +92,12 @@ public override int MaxCharCount public class CyrillicToLatinFallbackBuffer : EncoderFallbackBuffer { - private Dictionary table; + private Dictionary table; private int bufferIndex; private string buffer; private int leftToReturn; - internal CyrillicToLatinFallbackBuffer(Dictionary table) + internal CyrillicToLatinFallbackBuffer(Dictionary table) { this.table = table; this.bufferIndex = -1; @@ -153,4 +153,4 @@ public override int Remaining { get { return leftToReturn; } } -} +} \ No newline at end of file From 385385a720838f7db317cee3685165377558dc21 Mon Sep 17 00:00:00 2001 From: Ivan Pehsterski Date: Tue, 27 Jan 2026 05:40:38 +0200 Subject: [PATCH 3/4] Delete sln file --- .../cyrillic-to-latin/cs/CyrillicToLatin.sln | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.sln diff --git a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.sln b/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.sln deleted file mode 100644 index b4fdc349cd4..00000000000 --- a/core/encoding/cyrillic-to-latin/cs/CyrillicToLatin.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 25.0.1706.14 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CyrillicToLatin", "CyrillicToLatin.csproj", "{4802E97A-431C-4BAA-9C01-2B72D44719E4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4802E97A-431C-4BAA-9C01-2B72D44719E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4802E97A-431C-4BAA-9C01-2B72D44719E4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4802E97A-431C-4BAA-9C01-2B72D44719E4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4802E97A-431C-4BAA-9C01-2B72D44719E4}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F93E5FBF-BBA2-4C11-8137-3B7726D29CA0} - EndGlobalSection -EndGlobal From b8cc9e5b3b329f64542ebcea9d1d2e35deb8d931 Mon Sep 17 00:00:00 2001 From: Ivan Pehsterski Date: Thu, 29 Jan 2026 01:39:01 +0200 Subject: [PATCH 4/4] Introduce interfaces to improve adherence to SOLID principles --- csharp/classes-quickstart/BankAccount.cs | 11 +++++++---- csharp/classes-quickstart/Contracts/IBank.cs | 14 ++++++++++++++ .../classes-quickstart/Contracts/ITransaction.cs | 12 ++++++++++++ csharp/classes-quickstart/classes.csproj | 6 ++++++ csharp/classes-quickstart/transaction.cs | 9 +++++---- 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 csharp/classes-quickstart/Contracts/IBank.cs create mode 100644 csharp/classes-quickstart/Contracts/ITransaction.cs diff --git a/csharp/classes-quickstart/BankAccount.cs b/csharp/classes-quickstart/BankAccount.cs index 6385c069d07..01ae6e84e36 100644 --- a/csharp/classes-quickstart/BankAccount.cs +++ b/csharp/classes-quickstart/BankAccount.cs @@ -1,11 +1,12 @@ using System; using System.Collections.Generic; +using classes.Contracts; namespace classes { - public class BankAccount + public class BankAccount : IBank { - public string Number { get; } + public string Number { get; set; } public string Owner { get; set; } #region BalanceComputation public decimal Balance @@ -21,6 +22,7 @@ public decimal Balance return balance; } } + #endregion private static int accountNumberSeed = 1234567890; @@ -36,7 +38,8 @@ public BankAccount(string name, decimal initialBalance) #endregion #region TransactionDeclaration - private List allTransactions = new List(); + + private List allTransactions = new List(); #endregion #region DepositAndWithdrawal @@ -82,4 +85,4 @@ public string GetAccountHistory() } #endregion } -} +} \ No newline at end of file diff --git a/csharp/classes-quickstart/Contracts/IBank.cs b/csharp/classes-quickstart/Contracts/IBank.cs new file mode 100644 index 00000000000..ac1bcd4995a --- /dev/null +++ b/csharp/classes-quickstart/Contracts/IBank.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace classes.Contracts +{ + public interface IBank + { + public string Number { get; } + + public string Owner { get; } + + public decimal Balance { get; } + } +} \ No newline at end of file diff --git a/csharp/classes-quickstart/Contracts/ITransaction.cs b/csharp/classes-quickstart/Contracts/ITransaction.cs new file mode 100644 index 00000000000..02c4d382a44 --- /dev/null +++ b/csharp/classes-quickstart/Contracts/ITransaction.cs @@ -0,0 +1,12 @@ +using System; +namespace classes.Contracts +{ + public interface ITransaction + { + public decimal Amount { get; } + + public DateTime Date { get; } + + public string Notes { get; } + } +} \ No newline at end of file diff --git a/csharp/classes-quickstart/classes.csproj b/csharp/classes-quickstart/classes.csproj index 120e38c3150..5c938e63a4c 100644 --- a/csharp/classes-quickstart/classes.csproj +++ b/csharp/classes-quickstart/classes.csproj @@ -5,4 +5,10 @@ net7.0 + + + + + + diff --git a/csharp/classes-quickstart/transaction.cs b/csharp/classes-quickstart/transaction.cs index 198418c62dd..ca256132329 100644 --- a/csharp/classes-quickstart/transaction.cs +++ b/csharp/classes-quickstart/transaction.cs @@ -1,12 +1,13 @@ using System; +using classes.Contracts; namespace classes { - public class Transaction + public class Transaction : ITransaction { - public decimal Amount { get; } + public decimal Amount { get; set; } public DateTime Date { get; } - public string Notes { get; } + public string Notes { get; set; } public Transaction(decimal amount, DateTime date, string note) { @@ -15,4 +16,4 @@ public Transaction(decimal amount, DateTime date, string note) this.Notes = note; } } -} +} \ No newline at end of file