Skip to content

Making the mono module no-op unless the mono runtime is present #2

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

Merged
merged 4 commits into from
Apr 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ScriptCs.Engine.Mono/MonoModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

namespace ScriptCs.Engine.Mono
{
[Module("mono", Extensions = "csx")]
[Module(ModuleName)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly for my education, but why do we no longer need to set the extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want the REPL to just work so it needs to load the module all the time as there is no extension it can look for. We don't want people to have to specify the mono module, it should just work.

One thing you did make me realize (thanks) however is that the module should only register an engine IF one was not already registered.

I've added an conditional check for this module and the new Roslyn Module that will only register IF no other engine has already been provided. This way the F# module etc will still work and not be overridden. Order also doesn't matter, because let's say the F# module loads first, then it will register itself and not be overridden. If the Roslyn/Mono module is registered first then it will be overridden.

Make sense?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, makes sense.

public class MonoModule : IModule
{
public const string ModuleName = "mono";

public void Initialize(IModuleConfiguration config)
{
Console.WriteLine("Mono Engine initialized!");
config.ScriptEngine<MonoScriptEngine>();
if (!config.Overrides.ContainsKey(typeof(IScriptEngine)))
config.ScriptEngine<MonoScriptEngine>();
}
}
}