diff --git a/binary/release.2.5.1.net.40.zip b/binary/release.2.5.1.net.40.zip new file mode 100644 index 00000000..6656d37c Binary files /dev/null and b/binary/release.2.5.1.net.40.zip differ diff --git a/source/Samples/SlimSamples.cs b/source/Samples/SlimSamples.cs index f606acf9..11a800c2 100644 --- a/source/Samples/SlimSamples.cs +++ b/source/Samples/SlimSamples.cs @@ -268,5 +268,20 @@ public string FirstHash(Dictionary hash) { public Dictionary SomeDictionary() { return new Dictionary{{"name", "bob"}, {"address", "here"}}; } + + public string StringOf(int count) { + //var thread = new Thread(WriteStuff); + //thread.Start(); + var result = new string('*', count); + Console.WriteLine(result); + return result; + } + + static void WriteStuff() { + for (var i = 0; i < 1000; i++) { + Thread.Sleep(1); + Console.WriteLine("hey"); + } + } } } diff --git a/source/fitSharp/Machine/Engine/Trace.cs b/source/fitSharp/Machine/Engine/Trace.cs new file mode 100644 index 00000000..9e2a5a8d --- /dev/null +++ b/source/fitSharp/Machine/Engine/Trace.cs @@ -0,0 +1,33 @@ +// Copyright © 2016 Syterra Software Inc. All rights reserved. +// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php) +// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing +// to be bound by the terms of this license. You must not remove this notice, or any other, from this software. + +using System; +using System.IO; +using fitSharp.Machine.Model; + +namespace fitSharp.Machine.Engine { + public class Trace: Copyable { + + public Copyable Copy() { + return new Trace {writer = writer}; + } + + public void File(string fileName) { + writer = new StreamWriter(fileName); + } + + public void Stop() { + writer.Close(); + writer = StreamWriter.Null; + } + + public void Write(string label, string message) { + writer.WriteLine("{0:yyyy-MM-dd HH:mm:ss.fffff},{1},{2}", DateTime.Now, label, message); + writer.Flush(); + } + + StreamWriter writer = StreamWriter.Null; + } +} diff --git a/source/fitSharp/Slim/Service/ConsoleSession.cs b/source/fitSharp/Slim/Service/ConsoleSession.cs index 66ee175a..7e162fc2 100644 --- a/source/fitSharp/Slim/Service/ConsoleSession.cs +++ b/source/fitSharp/Slim/Service/ConsoleSession.cs @@ -7,10 +7,13 @@ using System.IO; using System.Text; using fitSharp.IO; +using fitSharp.Machine.Engine; namespace fitSharp.Slim.Service { public class ConsoleSession: Session { - public ConsoleSession() { + + public ConsoleSession(Memory memory) { + this.memory = memory; saveOut = Console.Out; saveError = Console.Error; CaptureConsole(); @@ -43,23 +46,29 @@ void WriteCaptured() { } void WriteEncoded(string prefix, StringWriter content) { - var encodedContent = prefix + content.ToString().Replace(Environment.NewLine, Environment.NewLine + prefix); + var contentString = content.ToString(); + if (string.IsNullOrEmpty(contentString)) return; + var encodedContent = prefix + contentString.Replace(Environment.NewLine, Environment.NewLine + prefix); if (encodedContent.EndsWith(prefix)) { encodedContent = encodedContent.Substring(0, encodedContent.Length - prefix.Length); } + memory.GetItem().Write("ConsoleErr", encodedContent); saveError.Write(encodedContent); } void WriteToConsole(string message) { + memory.GetItem().Write("ConsoleOut", message); saveOut.Write(message); } - static string ReadFromConsole(int length) { + string ReadFromConsole(int length) { var result = new StringBuilder(length); for (var i = 0; i < length; i++) { result.Append((char) Console.Read()); } - return result.ToString(); + var message = result.ToString(); + memory.GetItem().Write("ConsoleIn", message); + return message; } void CaptureConsole() { @@ -69,6 +78,7 @@ void CaptureConsole() { Console.SetError(captureError); } + readonly Memory memory; readonly TextWriter saveOut; readonly TextWriter saveError; StringWriter captureOut; diff --git a/source/fitSharp/Slim/Service/Messenger.cs b/source/fitSharp/Slim/Service/Messenger.cs index b30a765c..1fcfd6e8 100644 --- a/source/fitSharp/Slim/Service/Messenger.cs +++ b/source/fitSharp/Slim/Service/Messenger.cs @@ -6,15 +6,16 @@ using System.Net; using System.Net.Sockets; using fitSharp.IO; +using fitSharp.Machine.Engine; using fitSharp.Machine.Model; namespace fitSharp.Slim.Service { public class Messenger { public bool IsEnd { get; private set; } - public static Messenger Make(int port) { + public static Messenger Make(int port, Memory memory) { if (port == 1) { - return new Messenger(new ConsoleSession()); + return new Messenger(new ConsoleSession(memory)); } var listener = new TcpListener(IPAddress.Any, port); listener.Start(); diff --git a/source/fitSharp/Slim/Service/Runner.cs b/source/fitSharp/Slim/Service/Runner.cs index 9ae12b7e..2e53efc7 100644 --- a/source/fitSharp/Slim/Service/Runner.cs +++ b/source/fitSharp/Slim/Service/Runner.cs @@ -1,4 +1,4 @@ -// Copyright © 2011 Syterra Software Inc. All rights reserved. +// Copyright © 2016 Syterra Software Inc. All rights reserved. // The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php) // which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing // to be bound by the terms of this license. You must not remove this notice, or any other, from this software. @@ -16,13 +16,13 @@ public class Runner: Runnable { public int Run(IList commandLineArguments, Memory memory, ProgressReporter reporter) { service = new Service(memory); - ParseCommandLine(commandLineArguments); + ParseCommandLine(commandLineArguments, memory); new Interpreter(messenger, assemblyPaths, service).ProcessInstructions(); return 0; } - private void ParseCommandLine(IList commandLineArguments) { - messenger = Messenger.Make(int.Parse(commandLineArguments[commandLineArguments.Count - 1])); + private void ParseCommandLine(IList commandLineArguments, Memory memory) { + messenger = Messenger.Make(int.Parse(commandLineArguments[commandLineArguments.Count - 1]), memory); if (commandLineArguments.Count > 1) { assemblyPaths = commandLineArguments[0]; } diff --git a/source/fitSharp/Slim/Service/Service.cs b/source/fitSharp/Slim/Service/Service.cs index 0d500891..2c63f134 100644 --- a/source/fitSharp/Slim/Service/Service.cs +++ b/source/fitSharp/Slim/Service/Service.cs @@ -1,4 +1,4 @@ -// Copyright © 2011 Syterra Software Inc. All rights reserved. +// Copyright © 2016 Syterra Software Inc. All rights reserved. // The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php) // which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing // to be bound by the terms of this license. You must not remove this notice, or any other, from this software. @@ -24,6 +24,7 @@ public Service(Memory memory) : base(memory) { Memory.GetItem(); PushLibraryInstance(new TypedValue(new Actors(this))); + PushLibraryInstance(new TypedValue(new SlimFunctions(this))); } public void PushLibraryInstance(TypedValue instance) { @@ -64,5 +65,17 @@ public void PopFixture() { processor.Get().Save(actorInstanceName, actors.Pop()); } } + + class SlimFunctions { + public SlimFunctions(SlimProcessor processor) { + this.processor = processor; + } + + public void _Configure(string feature, string item, string value) { + processor.Memory.GetItem().File(value); + } + + readonly SlimProcessor processor; + } } } \ No newline at end of file diff --git a/source/fitSharp/fitSharp.csproj b/source/fitSharp/fitSharp.csproj index 24136f1d..52d79fee 100644 --- a/source/fitSharp/fitSharp.csproj +++ b/source/fitSharp/fitSharp.csproj @@ -106,6 +106,7 @@ + diff --git a/source/fitSharpTest/NUnit/Slim/ConsoleSessionTest.cs b/source/fitSharpTest/NUnit/Slim/ConsoleSessionTest.cs index 638bc10c..e46ff39a 100644 --- a/source/fitSharpTest/NUnit/Slim/ConsoleSessionTest.cs +++ b/source/fitSharpTest/NUnit/Slim/ConsoleSessionTest.cs @@ -5,6 +5,7 @@ using System; using System.IO; +using fitSharp.Machine.Engine; using fitSharp.Slim.Service; using NUnit.Framework; @@ -21,7 +22,7 @@ public void SetUp() { Console.SetOut(testOut); testError = new StringWriter(); Console.SetError(testError); - session = new ConsoleSession(); + session = new ConsoleSession(new TypeDictionary()); } [TearDown]