From bf1a2c85219630fececf518cf7aaa73c11095154 Mon Sep 17 00:00:00 2001 From: Sergei Vorobev Date: Fri, 8 Apr 2016 19:35:07 -0700 Subject: [PATCH] Make Add-Type work without a flat folder structure - Get rid of the assumption that all framework assemlbies live in the same place - Enable build scenario (assemlbies are referenced directly from unpacked nuget packages) - Fix #766 - Re-enable Add-Type tests --- .../commands/utility/AddType.cs | 3 ++- test/powershell/Add-Type.Tests.ps1 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs index fc1fb2da4c..cea0a87317 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/AddType.cs @@ -1059,8 +1059,9 @@ namespace Microsoft.PowerShell.Commands private static PortableExecutableReference ObjectImplementationAssemblyReference = MetadataReference.CreateFromFile(typeof(object).GetTypeInfo().Assembly.Location); + // This assembly should be System.Runtime.dll private static PortableExecutableReference ObjectDeclaredAssemblyReference = - MetadataReference.CreateFromFile(System.IO.Path.Combine(FrameworkFolder, "System.Runtime.dll")); + MetadataReference.CreateFromFile(ClrFacade.GetAssemblies(typeof(object).FullName).First().Location); private static MetadataReference[] defaultAssemblies = new MetadataReference[] { diff --git a/test/powershell/Add-Type.Tests.ps1 b/test/powershell/Add-Type.Tests.ps1 index f0a4e7f972..142e7e0f5e 100644 --- a/test/powershell/Add-Type.Tests.ps1 +++ b/test/powershell/Add-Type.Tests.ps1 @@ -1,5 +1,5 @@ Describe "Add-Type" { - It "Should not throw given a simple class definition" -Skip { + It "Should not throw given a simple class definition" { { Add-Type -TypeDefinition "public static class foo { }" } | Should Not Throw } }