From d5cedcf1cf2e04fcf83aa5889c5c11ff96e5ab19 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 31 Aug 2017 23:54:34 -0700 Subject: [PATCH 1/4] Fixing WriteAllLines issue --- .../System/IO/FileImpl.cs | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs b/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs index 86c048bc9..b66c46dbe 100644 --- a/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs +++ b/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs @@ -120,18 +120,25 @@ namespace Cosmos.System_Plugs.System.IO return result; } - public static void WriteAllLines(string aFile, IEnumerable contents) + /* public static void WriteAllLines(string aFile, IEnumerable contents) + * { + * string text = null; + * + * foreach (var line in contents) + * { + * text = string.Concat(text, line, Environment.NewLine); + * } + * + * Global.mFileSystemDebugger.SendInternal("Writing contents"); + * Global.mFileSystemDebugger.SendInternal(text); + * + * WriteAllText(aFile, text); + * } + */ + + public static void WriteAllLines(string aFile, string[] contents) { - string text = null; - - foreach (var line in contents) - { - text = string.Concat(text, line, Environment.NewLine); - } - - Global.mFileSystemDebugger.SendInternal("Writing contents"); - Global.mFileSystemDebugger.SendInternal(text); - + string text = String.Join(Environment.NewLine, contents); WriteAllText(aFile, text); } From 4e10bcdcfcfa9a2723f85db70a56b3c1f11eadbd Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Fri, 1 Sep 2017 00:04:08 -0700 Subject: [PATCH 2/4] Update FileImpl.cs --- source/Cosmos.System2_Plugs/System/IO/FileImpl.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs b/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs index b66c46dbe..22ee26ebb 100644 --- a/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs +++ b/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs @@ -139,6 +139,8 @@ namespace Cosmos.System_Plugs.System.IO public static void WriteAllLines(string aFile, string[] contents) { string text = String.Join(Environment.NewLine, contents); + Global.mFileSystemDebugger.SendInternal("Writing contents"); + Global.mFileSystemDebugger.SendInternal(text); WriteAllText(aFile, text); } From c1e11aabfd2903f3b67a6aa61b487f920614f3de Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Fri, 1 Sep 2017 00:07:27 -0700 Subject: [PATCH 3/4] Update FileImpl.cs --- .../Cosmos.System2_Plugs/System/IO/FileImpl.cs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs b/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs index 22ee26ebb..26f8ab1b0 100644 --- a/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs +++ b/source/Cosmos.System2_Plugs/System/IO/FileImpl.cs @@ -119,28 +119,14 @@ namespace Cosmos.System_Plugs.System.IO return result; } - - /* public static void WriteAllLines(string aFile, IEnumerable contents) - * { - * string text = null; - * - * foreach (var line in contents) - * { - * text = string.Concat(text, line, Environment.NewLine); - * } - * - * Global.mFileSystemDebugger.SendInternal("Writing contents"); - * Global.mFileSystemDebugger.SendInternal(text); - * - * WriteAllText(aFile, text); - * } - */ public static void WriteAllLines(string aFile, string[] contents) { string text = String.Join(Environment.NewLine, contents); + Global.mFileSystemDebugger.SendInternal("Writing contents"); Global.mFileSystemDebugger.SendInternal(text); + WriteAllText(aFile, text); } From 9e868d4623a0f449b53d23274ada16e078bcec6e Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Sat, 2 Sep 2017 09:31:06 -0700 Subject: [PATCH 4/4] Uncomment WriteAllLines Test --- Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs b/Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs index 63be92cc8..0842ce508 100644 --- a/Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs +++ b/Tests/Cosmos.Kernel.Tests.Fat/Kernel.cs @@ -617,20 +617,18 @@ namespace Cosmos.Kernel.Tests.Fat mDebugger.Send("END TEST"); mDebugger.Send(""); } - - // Generic methods on arrays don't work, see https://github.com/CosmosOS/Cosmos/issues/583 - // - //string[] contents = { "One", "Two", "Three" }; - //File.WriteAllLines(@"0:\test3.txt", contents); - //mDebugger.Send("Text written"); - //mDebugger.Send("Now reading with ReadAllLines()"); - //string[] readLines = File.ReadAllLines(@"0:\test3.txt"); - //mDebugger.Send("Contents retrieved after writing"); - //for (int i = 0; i < readLines.Length; i++) - //{ - // mDebugger.Send(readLines[i]); - //} - //Assert.IsTrue(StringArrayAreEquals(contents, readLines), "Contents of test3.txt was written incorrectly!"); + + string[] contents = { "One", "Two", "Three" }; + File.WriteAllLines(@"0:\test3.txt", contents); + mDebugger.Send("Text written"); + mDebugger.Send("Now reading with ReadAllLines()"); + string[] readLines = File.ReadAllLines(@"0:\test3.txt"); + mDebugger.Send("Contents retrieved after writing"); + for (int i = 0; i < readLines.Length; i++) + { + mDebugger.Send(readLines[i]); + } + Assert.IsTrue(StringArrayAreEquals(contents, readLines), "Contents of test3.txt was written incorrectly!"); #if false // TODO maybe the more correct test is to implement ReadAllLines and then check that two arrays are equals var xContents = File.ReadAllText(@"0:\test3.txt");