diff --git a/Capture.PNG b/Capture.PNG new file mode 100644 index 0000000..6a4686c Binary files /dev/null and b/Capture.PNG differ diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..d206b1b --- /dev/null +++ b/Readme.md @@ -0,0 +1,3 @@ +This is a simple c# repl powered by roslyn + +![](Capture.PNG) \ No newline at end of file diff --git a/SharpRepl.sln b/SharpRepl.sln index f9bc048..49effc0 100644 --- a/SharpRepl.sln +++ b/SharpRepl.sln @@ -5,6 +5,11 @@ VisualStudioVersion = 15.0.27130.2010 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRepl", "SharpRepl\SharpRepl.csproj", "{F240A133-A353-4FF2-9E5F-18CDC650085A}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4DF85585-54FB-48A9-BE73-FF42D0F42783}" + ProjectSection(SolutionItems) = preProject + Readme.md = Readme.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/SharpRepl/Banner.txt b/SharpRepl/Banner.txt new file mode 100644 index 0000000..f927134 --- /dev/null +++ b/SharpRepl/Banner.txt @@ -0,0 +1,11 @@ + $$$$$$\ $$\ $$$$$$$\ $$\ +$$ __$$\ $$ | $$ __$$\ $$ | +$$ / \__|$$$$$$$\ $$$$$$\ $$$$$$\ $$$$$$\ $$ | $$ | $$$$$$\ $$$$$$\ $$ | +\$$$$$$\ $$ __$$\ \____$$\ $$ __$$\ $$ __$$\ $$$$$$$ |$$ __$$\ $$ __$$\ $$ | + \____$$\ $$ | $$ | $$$$$$$ |$$ | \__|$$ / $$ |$$ __$$< $$$$$$$$ |$$ / $$ |$$ | +$$\ $$ |$$ | $$ |$$ __$$ |$$ | $$ | $$ |$$ | $$ |$$ ____|$$ | $$ |$$ | +\$$$$$$ |$$ | $$ |\$$$$$$$ |$$ | $$$$$$$ |$$ | $$ |\$$$$$$$\ $$$$$$$ |$$ | + \______/ \__| \__| \_______|\__| $$ ____/ \__| \__| \_______|$$ ____/ \__| + $$ | $$ | + $$ | $$ | + \__| \__| \ No newline at end of file diff --git a/SharpRepl/Program.cs b/SharpRepl/Program.cs index 3b43637..c6ae912 100644 --- a/SharpRepl/Program.cs +++ b/SharpRepl/Program.cs @@ -1,4 +1,8 @@ -using System; +using Microsoft.CodeAnalysis.CSharp.Scripting; +using Microsoft.CodeAnalysis.Scripting; +using System; +using System.IO; +using System.Reflection; namespace SharpRepl { @@ -6,7 +10,31 @@ namespace SharpRepl { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + foreach(var line in banner) + { + Console.WriteLine(line); + } + Console.WriteLine(); + var state = CSharpScript.RunAsync("2+2").Result; //prime the engine + while (true) + { + try + { + Console.Write('>'); + var input = Console.ReadLine(); + state = state.ContinueWithAsync(input).Result; + if (state.ReturnValue != null && !string.IsNullOrWhiteSpace(state.ReturnValue.ToString())) + { + Console.WriteLine(state.ReturnValue); + } + + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } } + public static string[] banner = File.ReadAllLines(Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName, "Banner.txt")); } } diff --git a/SharpRepl/SharpRepl.csproj b/SharpRepl/SharpRepl.csproj index ce1697a..12a22e7 100644 --- a/SharpRepl/SharpRepl.csproj +++ b/SharpRepl/SharpRepl.csproj @@ -5,4 +5,18 @@ netcoreapp2.0 + + + + + + + Always + + + + + + +