From b22e96dae4d0f3dd19803178e9b52e2e1b22b7a0 Mon Sep 17 00:00:00 2001 From: Glenn Block Date: Sat, 7 Feb 2015 01:57:35 -0800 Subject: [PATCH 1/3] Ensuring GAC dlls are loaded. Fix for #922 --- src/ScriptCs.Core/AssemblyUtility.cs | 8 +++++ .../AssemblyUtilityTests.cs | 33 +++++++++++++++++++ .../ScriptCs.Core.Tests.csproj | 1 + 3 files changed, 42 insertions(+) create mode 100644 test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs diff --git a/src/ScriptCs.Core/AssemblyUtility.cs b/src/ScriptCs.Core/AssemblyUtility.cs index b8776147..d24cd8e6 100644 --- a/src/ScriptCs.Core/AssemblyUtility.cs +++ b/src/ScriptCs.Core/AssemblyUtility.cs @@ -5,10 +5,18 @@ namespace ScriptCs { + using System.IO; + public class AssemblyUtility : IAssemblyUtility { public bool IsManagedAssembly(string path) { + if (!Path.IsPathRooted(path) && !(path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) || + path.EndsWith("*.exe", StringComparison.InvariantCultureIgnoreCase))) + { + return true; + } + try { AssemblyName.GetAssemblyName(path); diff --git a/test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs b/test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs new file mode 100644 index 00000000..593ee643 --- /dev/null +++ b/test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ScriptCs.Tests +{ + using System.IO; + using Contracts; + using Xunit; + using Should; + + public class AssemblyUtilityTests + { + public class TheIsManagedAssemblyMethod + { + private readonly IAssemblyUtility _assemblyUtility = new AssemblyUtility(); + + [Fact] + public void ShouldReturnTrueWhenThePathIsNotRootedAndDoesNotHaveADllExtension() + { + _assemblyUtility.IsManagedAssembly("System.Data").ShouldBeTrue(); + } + + [Fact] + public void ShouldReturnTrueWhenThePathPointsToAManagedAssembly() + { + _assemblyUtility.IsManagedAssembly(typeof(String).Assembly.Location).ShouldBeTrue(); + } + } + } +} diff --git a/test/ScriptCs.Core.Tests/ScriptCs.Core.Tests.csproj b/test/ScriptCs.Core.Tests/ScriptCs.Core.Tests.csproj index 3d4c3961..c461cf9e 100644 --- a/test/ScriptCs.Core.Tests/ScriptCs.Core.Tests.csproj +++ b/test/ScriptCs.Core.Tests/ScriptCs.Core.Tests.csproj @@ -48,6 +48,7 @@ + From d18f5161415389219d11eb8f322f54b0a1d66f26 Mon Sep 17 00:00:00 2001 From: Glenn Block Date: Sat, 7 Feb 2015 01:59:47 -0800 Subject: [PATCH 2/3] Renaming test --- test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs b/test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs index 593ee643..0e50c115 100644 --- a/test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs +++ b/test/ScriptCs.Core.Tests/AssemblyUtilityTests.cs @@ -18,7 +18,7 @@ public class TheIsManagedAssemblyMethod private readonly IAssemblyUtility _assemblyUtility = new AssemblyUtility(); [Fact] - public void ShouldReturnTrueWhenThePathIsNotRootedAndDoesNotHaveADllExtension() + public void ShouldReturnTrueWhenThePathIsNotRootedAndDoesNotHaveADllOrExeExtension() { _assemblyUtility.IsManagedAssembly("System.Data").ShouldBeTrue(); } From b725cd6bd5efd1a5102c1058a5087036adbb037f Mon Sep 17 00:00:00 2001 From: Glenn Block Date: Sat, 7 Feb 2015 02:01:09 -0800 Subject: [PATCH 3/3] Fixing to check for .exe not *.exe --- src/ScriptCs.Core/AssemblyUtility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScriptCs.Core/AssemblyUtility.cs b/src/ScriptCs.Core/AssemblyUtility.cs index d24cd8e6..f2357870 100644 --- a/src/ScriptCs.Core/AssemblyUtility.cs +++ b/src/ScriptCs.Core/AssemblyUtility.cs @@ -12,7 +12,7 @@ public class AssemblyUtility : IAssemblyUtility public bool IsManagedAssembly(string path) { if (!Path.IsPathRooted(path) && !(path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) || - path.EndsWith("*.exe", StringComparison.InvariantCultureIgnoreCase))) + path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase))) { return true; }