New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate mono support #80
Comments
Do we know if Roslyn will run on top of the Mono VM? I'm assuming that, if it is pure Managed Code as they say it is, we shouldn't see any issues, correct? If not, would the best course of action be to create a ScriptEngine/ScriptExecutor implementation that wraps around the Mono.CSharp or NRefactory APIs? I'll poke around at this when I can get back to my desk and get a *nix distro setup with MonoDevelop, because this interests me. |
Roslyn will not run on Mono, unfortunately. The classes will need to be reimplemented without Roslyn. |
Mono has had a C# REPL, and C# scripting support for some time. It shouldn't be too hard to get it running on Mono. Some relevant links: http://www.mono-project.com/CsharpRepl However, according to the docs it looks like the Mono C# Compiler Service has some limitations:
But after looking at the sample code from http://blog.davidebbo.com/2012/02/quick-fun-with-monos-csharp-compiler-as.html it looks like Mono has full support compling C# code: using System;
using System.IO;
using Mono.CSharp;
namespace MonoCompilerDemo
{
public interface IFoo { string Bar(string s); }
class Program
{
static void Main(string[] args)
{
var evaluator = new Evaluator(
new CompilerSettings(),
new Report(new ConsoleReportPrinter()));
// Make it reference our own assembly so it can use IFoo
evaluator.ReferenceAssembly(typeof(IFoo).Assembly);
// Feed it some code
evaluator.Compile(
@"
public class Foo : MonoCompilerDemo.IFoo
{
public string Bar(string s) { return s.ToUpper(); }
}");
for (; ; )
{
string line = Console.ReadLine();
if (line == null) break;
object result;
bool result_set;
evaluator.Evaluate(line, out result, out result_set);
if (result_set) Console.WriteLine(result);
}
}
}
} Adding Mono support would require isolating dependency on Roslyn. The Mono C# compiler is available as a NuGet package, and can be used as any .NET assembly, and do not require Mono. This makes it easier to test/work on Mono-support from standard .NET/VS environment: https://nuget.org/packages/Mono.CSharp |
I did a quick spike to test if I could get scriptcs running with Mono.CSharp as its back-end. I was able to compile/run simple scripts such as: using System;
Func<int, int, int> add = (int a, int b) => a + b;
Console.WriteLine("add({0}, {1}) = {2}", 1, 2, add(1, 2)); The main issue (as far as I can tell), is how Mono.CSharp has The commit for my experiment is available at follesoe@cfd648f in the mono-experiments branch. The branch is not intended for any PR etc, but I'll keep it around for reference if some one else want to further explore the possibility to use Mono.CSharp instead of Roslyn. |
Great work - when I have some time again I'll do another spike, based on the changes to the pluggable script enginge. Need to learn more about Mono.CSharp to understand what needs to be compiled vs evaluated. |
@follesoe Are you working on this outside of Windows? |
@dragan I was hoping you'd join us! Thanks! |
Welcome! On Wed, Mar 13, 2013 at 2:31 PM, Dale Ragan notifications@github.comwrote:
|
Okay, played enough with this branch, going to start a new branch with the latest changes that pulled Roslyn out. Too much changed between this branch and that being merged into dev. |
@dragan Yeah - I did a new experiment on the plane yesterday, using the new architecture with external enginges. The new architecture makes it dead simple to plug-in new compilers. As far as I can tell, the hard part will be to understand/use Mono.CSharp correctly. I.e. when to Compile/Run/Evaluate some code. In Roslyn its a simple call to Execute - while in Mono you need to compile classes/methods etc, but can evaluate expressions. Not sure if one would need to parse the passed in Code first, before passing it to the evaluator. |
Feel free to ping me as well. On Thu, Mar 14, 2013 at 9:52 AM, Nick Berardi notifications@github.comwrote:
|
@follesoe @dragan AFAIK the mono c# repls don't support classes/methods/members. Maybe use the monodevelop/sharpdevelop ast parser or something similar? EDIT: Giving it a bit more though it would be a lot easier to pull the eval part out and compile the rest as a whole. When talking to Marek I recall him saying that it supports being handed a file / class / function for compile. |
Currently blocked with the changes added for MEF recently. Issue #117 was created to replace MEF with Autofac so work can continue on Mono support. |
@glennblock Okay, as old Phil Robertson would say from Duck Dynasty, "Now we're cooking with peanut oil"! Everything is compiling under mono again. Time to start implementing and get the tests passing! You can watch my branch if interested. |
@dragan it's merged now too |
I love it when a plan comes together! |
@glennblock Mind bumping the Autofac version down to 2.6.3.862? I believe 3.0 was built with Client Profile and Mono doesn't support Client Profiles yet. We also need to talk about how you want to handle the registration based on runtime and etc. I also have another request to help with MonoDevelop loading the project files. It doesn't have support for common properties between projects. I've been dealing with it, but it's time to fix it. |
@dragan yes Autofac 3 is a PCL. We talked about that yesterday, and there is no real reason why we use 3.0 (just happens to be the latest) and we sure can go down a version (that was the whole point of going to Autofac - to facilitate Mono) |
@filipw Great, yeah I just wanted to make sure that he didn't use the latest for a specific feature. |
@dragan can you just do the change and submit it along with your PR? |
@glennblock Done, ignore the typo in the commit message. ;-) |
Still work to do, but I have ScriptCS working under Mono. Need to get the NuGet package for Mono.CSharp updated before I can check things in. You can execute a simple .csx file that contains interfaces, classes, methods, and expressions. :-D |
Great -----Original Message----- @glennblock Done, ignore the typo in the commit message. ;-) |
Awesome! What are you planning around script packs? -----Original Message----- Still work to do, but I have ScriptCS working under Mono. Need to get the NuGet package for Mono.CSharp updated before I can check things in. You can execute a simple .csx file that contains interfaces, classes, methods, and expressions. :-D |
Update here. We need to move this forward ;-). In order to help we've taken a few steps.
We hope that both of these steps will give more visibility to the state of mono support and make it easier for others to contribute, like @migueldeicaza;-) |
Thanks @glennblock! |
Allright all, Filip is moving the ball forward. He created a mono engine here (https://github.com/scriptcs-contrib/scriptcs-engine-mono) that has some basic functionality. There are still many challenges, for one thing we're really not happy with perf. Adding @migueldeicaza in hopes someone from the mono team can jump in :-) He needs your help! |
Refactored roslyn out of core to fix scriptcs#90 in preperation for scriptcs#80
# By Nick Berardi (8) and others # Via dschenkelman (6) and others * dev: Added error messages with line number when using -debug in console # Deleted DebugFilePreProcessor.cs. No longer needed with support for debugging in VS # Updated FilePreProcessor.cs, FileProcessorTests.cs and RoslynScriptDebuggerEngine.cs to add #line directives after #loads fixed bug with #r not loading, and set #load to only be available at the top scriptcs#105 scriptcs#98 scriptcs#21 removed IDisposable from ScriptPackSession Update ScriptCs.Engine.Roslyn.csproj Update ScriptCs.Engine.Roslyn.Tests.csproj Update ScriptCs.Engine.Roslyn.csproj moved ScriptHostFactory into Roslyn since the script host is Roslyn specific # Simplified code for IScriptEngine constructor convention. Thanks to @khellang for the code review. # Removed namespaces that are no longer used added [InheritedExport] back onto IScriptEngine refactored code to bring ScriptPackSession back into the core # Updated code base to get rid of MEF attributes and use RegistrationBuilder refactored roslyn out of core to fix scriptcs#90 in preperation for scriptcs#80
Can we close this? |
YES!!!!! |
This PR: #635 adds support for Mono to the core. Several other PRs follow which improve on the Mono support specifically dealing with multi-line and the REPL. |
we can delete the mono branch too now On 27 May 2014 09:31, Glenn Block notifications@github.com wrote:
|
@filipw look when opened this, March 2013! |
mono branch deleted (it was fully merged) |
I see this was merged to core, but see no references to linux or OS X in docs. Did I miss it somewhere? How to install and run under different platforms? |
@mika76 You didn't see this empty page? 😝 https://github.com/scriptcs/scriptcs/wiki/Installing-on-Mac-and-Linux |
@mika76 check out the following: https://github.com/scriptcs/scriptcs#building-from-source https://github.com/scriptcs/scriptcs/wiki/Building-on-Mac-and-Linux If you're a Mac / Homebrew (http://brew.sh/) user you can just |
@mika76 The easiest way to get it is probably by installing SVM and getting it from there: https://github.com/scriptcs-contrib/svm/wiki/Installing-svm. It has instructions on installing on OSX and Linux 😄 |
Cool, thanks guys. May I recommend you put a link or description of that wiki page on the main pages (github readme and the github site) since it's all very Windows based. (I'm talking about installing and running, not so much building) |
Figure out if we could get scriptcs working for mono. Roslyn allows you to pass host objects into the running script. Ideally this feature which script packs rely on will also work.
The text was updated successfully, but these errors were encountered: