Skip to content

Conversation

@filipw
Copy link
Member

@filipw filipw commented Mar 21, 2015

Fixes #964 and unblocks 0.14 release

The fast path is only invoked if there is:

  • no explicit module provided AND
  • file extension is "csx" OR no extension (REPL mode)

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make the comparison with ".csx" case insensitive?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point

On 21 March 2015 at 21:48, Adam Ralph notifications@github.com wrote:

In src/ScriptCs.Hosting/ModuleLoader.cs
#980 (comment):

@@ -69,7 +71,8 @@ public ModuleLoader(IAssemblyResolver resolver, ILog logger, Action<Assembly, Ag
{
if (modulePackagesPaths == null) return;

  •        if (moduleNames.Length == 1 && DefaultCSharpModules.ContainsKey(moduleNames[0])) // only CSharp module needed
    
  •        // only CSharp module needed - use fast path
    
  •        if (moduleNames.Length == 1 && DefaultCSharpModules.ContainsKey(moduleNames[0]) && (extension == DefaultCSharpExtension || string.IsNullOrWhiteSpace(extension)))
    

Should we make the comparison with ".csx" case insensitive?


Reply to this email directly or view it on GitHub
https://github.com/scriptcs/scriptcs/pull/980/files#r26896677.

@adamralph
Copy link
Contributor

Whilst we're here, should we also instantiate DefaultCSharpModules as case insensitive? I.e.

internal static readonly Dictionary<string, string> DefaultCSharpModules =
    new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase)
    {
        {"roslyn", "ScriptCs.Engine.Roslyn.dll"},
        {"mono", "ScriptCs.Engine.Mono.dll"}
    };

Copy link
Contributor

Choose a reason for hiding this comment

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

This blows up with a NullReferenceException if extension is null (REPL). You'll have to use string.Equals(extension, DefaultCSharpExtension, StringComparison.OrdinalIgnoreCase)

Copy link
Contributor

Choose a reason for hiding this comment

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

Or you could swap the order of the conditions around the ||, but may as well just call the static on string.

@adamralph
Copy link
Contributor

The Travis build is still so flaky... IIRC I've seen the problem before. It's a race condition in xunit 1.0. I don't know why it only manifests in Linux though.

@adamralph
Copy link
Contributor

LGTM. The module name casing can be left for now, that's a wider problem which isn't catered for in ScriptServicesBuilder either (and is unlikely to be affecting anyone anyway).

adamralph added a commit that referenced this pull request Mar 21, 2015
Only use fast path when extension is CSX or none
@adamralph adamralph merged commit d238444 into scriptcs:dev Mar 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only scan for modules when -m is specified

2 participants