1 using System;
2 using System.Collections;
3 using System.Collections.Concurrent;
4 using System.Collections.Generic;
5 using System.IO;
6 using System.Runtime.Versioning;
7 using Microsoft.Build.Framework;
8 using Microsoft.Build.Shared;
9 using Microsoft.Build.Tasks;
10 using Microsoft.Build.Tasks.AssemblyDependency;
11 using Microsoft.Build.Utilities;
12 using Microsoft.Win32;
13 using FrameworkNameVersioning = System.Runtime.Versioning.FrameworkName;
14 using SystemProcessorArchitecture = System.Reflection.ProcessorArchitecture;
15 using Xunit;
16 
17 namespace Microsoft.Build.UnitTests.ResolveAssemblyReference_Tests
18 {
19     public class ResolveAssemblyReferenceTestFixture : IDisposable
20     {
21         // Create the mocks.
22         internal static Microsoft.Build.Shared.FileExists fileExists = new Microsoft.Build.Shared.FileExists(FileExists);
23         internal static Microsoft.Build.Shared.DirectoryExists directoryExists = new Microsoft.Build.Shared.DirectoryExists(DirectoryExists);
24         internal static Microsoft.Build.Tasks.GetDirectories getDirectories = new Microsoft.Build.Tasks.GetDirectories(GetDirectories);
25         internal static Microsoft.Build.Tasks.GetAssemblyName getAssemblyName = new Microsoft.Build.Tasks.GetAssemblyName(GetAssemblyName);
26         internal static Microsoft.Build.Tasks.GetAssemblyMetadata getAssemblyMetadata = new Microsoft.Build.Tasks.GetAssemblyMetadata(GetAssemblyMetadata);
27 #if FEATURE_WIN32_REGISTRY
28         internal static Microsoft.Build.Shared.GetRegistrySubKeyNames getRegistrySubKeyNames = new Microsoft.Build.Shared.GetRegistrySubKeyNames(GetRegistrySubKeyNames);
29         internal static Microsoft.Build.Shared.GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue = new Microsoft.Build.Shared.GetRegistrySubKeyDefaultValue(GetRegistrySubKeyDefaultValue);
30 #endif
31         internal static Microsoft.Build.Tasks.GetLastWriteTime getLastWriteTime = new Microsoft.Build.Tasks.GetLastWriteTime(GetLastWriteTime);
32         internal static Microsoft.Build.Tasks.GetAssemblyRuntimeVersion getRuntimeVersion = new Microsoft.Build.Tasks.GetAssemblyRuntimeVersion(GetRuntimeVersion);
33         internal static Microsoft.Build.Tasks.GetAssemblyPathInGac checkIfAssemblyIsInGac = new Microsoft.Build.Tasks.GetAssemblyPathInGac(GetPathForAssemblyInGac);
34 #if FEATURE_WIN32_REGISTRY
35         internal static Microsoft.Build.Shared.OpenBaseKey openBaseKey = new Microsoft.Build.Shared.OpenBaseKey(GetBaseKey);
36 #endif
37         internal Microsoft.Build.UnitTests.MockEngine.GetStringDelegate resourceDelegate = new Microsoft.Build.UnitTests.MockEngine.GetStringDelegate(AssemblyResources.GetString);
38         internal static Microsoft.Build.Tasks.IsWinMDFile isWinMDFile = new Microsoft.Build.Tasks.IsWinMDFile(IsWinMDFile);
39         internal static Microsoft.Build.Tasks.ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader = new Microsoft.Build.Tasks.ReadMachineTypeFromPEHeader(ReadMachineTypeFromPEHeader);
40 
41         // Performance checks.
42         internal static Dictionary<string, int> uniqueFileExists = null;
43         internal static Dictionary<string, int> uniqueGetAssemblyName = null;
44 
45         internal static bool useFrameworkFileExists = false;
46         internal const string REDISTLIST = @"<FileList  Redist=""Microsoft-Windows-CLRCoreComp.4.0"" Name="".NET Framework 4"" RuntimeVersion=""4.0"" ToolsVersion=""12.0"">
47   <File AssemblyName=""Accessibility"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
48   <File AssemblyName=""CustomMarshalers"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
49   <File AssemblyName=""ISymWrapper"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
50   <File AssemblyName=""Microsoft.Build"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
51   <File AssemblyName=""Microsoft.Build.Conversion.v4.0"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
52   <File AssemblyName=""Microsoft.Build.Engine"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
53   <File AssemblyName=""Microsoft.Build.Framework"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
54   <File AssemblyName=""Microsoft.Build.Tasks.v4.0"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
55   <File AssemblyName=""Microsoft.Build.Utilities.v4.0"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
56   <File AssemblyName=""Microsoft.CSharp"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
57   <File AssemblyName=""Microsoft.JScript"" Version=""10.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
58   <File AssemblyName=""Microsoft.VisualBasic"" Version=""10.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
59   <File AssemblyName=""Microsoft.VisualBasic.Compatibility"" Version=""10.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
60   <File AssemblyName=""Microsoft.VisualBasic.Compatibility.Data"" Version=""10.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
61   <File AssemblyName=""Microsoft.VisualC"" Version=""10.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
62   <File AssemblyName=""Microsoft.VisualC.STLCLR"" Version=""2.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
63   <File AssemblyName=""mscorlib"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
64   <File AssemblyName=""PresentationBuildTasks"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
65   <File AssemblyName=""PresentationCore"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
66   <File AssemblyName=""PresentationFramework.Aero"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
67   <File AssemblyName=""PresentationFramework.Classic"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
68   <File AssemblyName=""PresentationFramework"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
69   <File AssemblyName=""PresentationFramework.Luna"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
70   <File AssemblyName=""PresentationFramework.Royale"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
71   <File AssemblyName=""ReachFramework"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
72   <File AssemblyName=""sysglobl"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
73   <File AssemblyName=""System.Activities"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
74   <File AssemblyName=""System.Activities.Core.Presentation"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
75   <File AssemblyName=""System.Activities.DurableInstancing"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
76   <File AssemblyName=""System.Activities.Presentation"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
77   <File AssemblyName=""System.AddIn.Contract"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
78   <File AssemblyName=""System.AddIn"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
79   <File AssemblyName=""System.ComponentModel.Composition"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
80   <File AssemblyName=""System.ComponentModel.DataAnnotations"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
81   <File AssemblyName=""System.Configuration"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
82   <File AssemblyName=""System.Configuration.Install"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
83   <File AssemblyName=""System.Core"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
84   <File AssemblyName=""System.Data.DataSetExtensions"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
85   <File AssemblyName=""System.Data"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
86   <File AssemblyName=""System.Data.Entity.Design"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
87   <File AssemblyName=""System.Data.Entity"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
88   <File AssemblyName=""System.Data.Linq"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
89   <File AssemblyName=""System.Data.OracleClient"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
90   <File AssemblyName=""System.Data.Services.Client"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
91   <File AssemblyName=""System.Data.Services.Design"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
92   <File AssemblyName=""System.Data.Services"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
93   <File AssemblyName=""System.Data.SqlXml"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
94   <File AssemblyName=""System.Deployment"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
95   <File AssemblyName=""System.Design"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
96   <File AssemblyName=""System.Device"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
97   <File AssemblyName=""System.DirectoryServices.AccountManagement"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
98   <File AssemblyName=""System.DirectoryServices"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
99   <File AssemblyName=""System.DirectoryServices.Protocols"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
100   <File AssemblyName=""System"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
101   <File AssemblyName=""System.Drawing.Design"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
102   <File AssemblyName=""System.Drawing"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
103   <File AssemblyName=""System.Dynamic"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
104   <File AssemblyName=""System.EnterpriseServices"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
105   <File AssemblyName=""System.IdentityModel"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
106   <File AssemblyName=""System.IdentityModel.Selectors"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
107   <File AssemblyName=""System.IO.Log"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
108   <File AssemblyName=""System.Management"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
109   <File AssemblyName=""System.Management.Instrumentation"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
110   <File AssemblyName=""System.Messaging"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
111   <File AssemblyName=""System.Net"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
112   <File AssemblyName=""System.Numerics"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
113   <File AssemblyName=""System.Printing"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
114   <File AssemblyName=""System.Runtime.DurableInstancing"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
115   <File AssemblyName=""System.Runtime.Caching"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
116   <File AssemblyName=""System.Runtime.Remoting"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
117   <File AssemblyName=""System.Runtime.Serialization"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
118   <File AssemblyName=""System.Runtime.Serialization.Formatters.Soap"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
119   <File AssemblyName=""System.Security"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
120   <File AssemblyName=""System.ServiceModel.Activation"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
121   <File AssemblyName=""System.ServiceModel.Activities"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
122   <File AssemblyName=""System.ServiceModel.Channels"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
123   <File AssemblyName=""System.ServiceModel.Discovery"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
124   <File AssemblyName=""System.ServiceModel"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
125   <File AssemblyName=""System.ServiceModel.Routing"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
126   <File AssemblyName=""System.ServiceModel.Web"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
127   <File AssemblyName=""System.ServiceProcess"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
128   <File AssemblyName=""System.Speech"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
129   <File AssemblyName=""System.Transactions"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
130   <File AssemblyName=""System.Web.Abstractions"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
131   <File AssemblyName=""System.Web.ApplicationServices"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
132   <File AssemblyName=""System.Web"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
133   <File AssemblyName=""System.Web.DataVisualization.Design"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
134   <File AssemblyName=""System.Web.DataVisualization"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
135   <File AssemblyName=""System.Web.DynamicData.Design"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
136   <File AssemblyName=""System.Web.DynamicData"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
137   <File AssemblyName=""System.Web.Entity.Design"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
138   <File AssemblyName=""System.Web.Entity"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
139   <File AssemblyName=""System.Web.Extensions.Design"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
140   <File AssemblyName=""System.Web.Extensions"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
141   <File AssemblyName=""System.Web.Mobile"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
142   <File AssemblyName=""System.Web.RegularExpressions"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
143   <File AssemblyName=""System.Web.Routing"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
144   <File AssemblyName=""System.Web.Services"" Version=""4.0.0.0"" PublicKeyToken=""b03f5f7f11d50a3a"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
145   <File AssemblyName=""System.Windows.Forms.DataVisualization.Design"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
146   <File AssemblyName=""System.Windows.Forms.DataVisualization"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
147   <File AssemblyName=""System.Windows.Forms"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
148   <File AssemblyName=""System.Windows.Input.Manipulations"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
149   <File AssemblyName=""System.Windows.Presentation"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
150   <File AssemblyName=""System.Workflow.Activities"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
151   <File AssemblyName=""System.Workflow.ComponentModel"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
152   <File AssemblyName=""System.Workflow.Runtime"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
153   <File AssemblyName=""System.WorkflowServices"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
154   <File AssemblyName=""System.Xaml"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
155   <File AssemblyName=""System.Xml"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
156   <File AssemblyName=""System.Xml.Linq"" Version=""4.0.0.0"" PublicKeyToken=""b77a5c561934e089"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
157   <File AssemblyName=""UIAutomationClient"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
158   <File AssemblyName=""UIAutomationClientsideProviders"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
159   <File AssemblyName=""UIAutomationProvider"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
160   <File AssemblyName=""UIAutomationTypes"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
161   <File AssemblyName=""WindowsBase"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
162   <File AssemblyName=""WindowsFormsIntegration"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
163   <File AssemblyName=""XamlBuildTask"" Version=""4.0.0.0"" PublicKeyToken=""31bf3856ad364e35"" Culture=""neutral"" ProcessorArchitecture=""MSIL"" InGac=""true"" />
164 </FileList>"
165             ;
166 
ResolveAssemblyReferenceTestFixture()167         public ResolveAssemblyReferenceTestFixture()
168         {
169             Environment.SetEnvironmentVariable("MSBUILDDISABLEASSEMBLYFOLDERSEXCACHE", "1");
170         }
171 
Dispose()172         public void Dispose()
173         {
174             Environment.SetEnvironmentVariable("MSBUILDDISABLEASSEMBLYFOLDERSEXCACHE", null);
175         }
176 
177         protected static readonly string s_rootPathPrefix = NativeMethodsShared.IsWindows ? "C:\\" : Path.VolumeSeparatorChar.ToString();
178         protected static readonly string s_myProjectPath = Path.Combine(s_rootPathPrefix, "MyProject");
179 
180         protected static readonly string s_myVersion20Path = Path.Combine(s_rootPathPrefix, "WINNT", "Microsoft.NET", "Framework", "v2.0.MyVersion");
181         protected static readonly string s_myVersion40Path = Path.Combine(s_rootPathPrefix, "WINNT", "Microsoft.NET", "Framework", "v4.0.MyVersion");
182         protected static readonly string s_myVersion90Path = Path.Combine(s_rootPathPrefix, "WINNT", "Microsoft.NET", "Framework", "v9.0.MyVersion");
183 
184         protected static readonly string s_myVersionPocket20Path = s_myVersion20Path + ".PocketPC";
185 
186         protected static readonly string s_myMissingAssemblyAbsPath = Path.Combine(s_rootPathPrefix, "MyProject", "MyMissingAssembly.dll");
187         protected static readonly string s_myMissingAssemblyRelPath = Path.Combine("MyProject", "MyMissingAssembly.dll");
188         protected static readonly string s_myPrivateAssemblyRelPath = Path.Combine("MyProject", "MyPrivateAssembly.exe");
189 
190         protected static readonly string s_frameworksPath = Path.Combine(s_rootPathPrefix, "Frameworks");
191 
192         protected static readonly string s_myComponents2RootPath = Path.Combine(s_rootPathPrefix, "MyComponents2");
193         protected static readonly string s_myComponentsRootPath = Path.Combine(s_rootPathPrefix, "MyComponents");
194         protected static readonly string s_myComponents10Path = Path.Combine(s_myComponentsRootPath, "1.0");
195         protected static readonly string s_myComponents20Path = Path.Combine(s_myComponentsRootPath, "2.0");
196         protected static readonly string s_myComponentsMiscPath = Path.Combine(s_myComponentsRootPath, "misc");
197 
198         protected static readonly string s_myComponentsV05Path = Path.Combine(s_myComponentsRootPath, "v0.5");
199         protected static readonly string s_myComponentsV10Path = Path.Combine(s_myComponentsRootPath, "v1.0");
200         protected static readonly string s_myComponentsV20Path = Path.Combine(s_myComponentsRootPath, "v2.0");
201         protected static readonly string s_myComponentsV30Path = Path.Combine(s_myComponentsRootPath, "v3.0");
202 
203         protected static readonly string s_unifyMeDll_V05Path = Path.Combine(s_myComponentsV05Path, "UnifyMe.dll");
204         protected static readonly string s_unifyMeDll_V10Path = Path.Combine(s_myComponentsV10Path, "UnifyMe.dll");
205         protected static readonly string s_unifyMeDll_V20Path = Path.Combine(s_myComponentsV20Path, "UnifyMe.dll");
206         protected static readonly string s_unifyMeDll_V30Path = Path.Combine(s_myComponentsV30Path, "UnifyMe.dll");
207 
208         protected static readonly string s_myComponents40ComponentPath = Path.Combine(s_myComponentsRootPath, "4.0Component");
209         protected static readonly string s_40ComponentDependsOnOnlyv4AssembliesDllPath = Path.Combine(s_myComponents40ComponentPath, "DependsOnOnlyv4Assemblies.dll");
210 
211         protected static readonly string s_myLibrariesRootPath = Path.Combine(s_rootPathPrefix, "MyLibraries");
212         protected static readonly string s_myLibraries_V1Path = Path.Combine(s_myLibrariesRootPath, "v1");
213         protected static readonly string s_myLibraries_V2Path = Path.Combine(s_myLibrariesRootPath, "v2");
214         protected static readonly string s_myLibraries_V1_EPath = Path.Combine(s_myLibraries_V1Path, "E");
215 
216         protected static readonly string s_myLibraries_ADllPath = Path.Combine(s_myLibrariesRootPath, "A.dll");
217         protected static readonly string s_myLibraries_BDllPath = Path.Combine(s_myLibrariesRootPath, "B.dll");
218         protected static readonly string s_myLibraries_CDllPath = Path.Combine(s_myLibrariesRootPath, "C.dll");
219         protected static readonly string s_myLibraries_TDllPath = Path.Combine(s_myLibrariesRootPath, "T.dll");
220 
221         protected static readonly string s_myLibraries_V1_DDllPath = Path.Combine(s_myLibraries_V1Path, "D.dll");
222         protected static readonly string s_myLibraries_V1_E_EDllPath = Path.Combine(s_myLibraries_V1_EPath, "E.dll");
223         protected static readonly string s_myLibraries_V2_DDllPath = Path.Combine(s_myLibraries_V2Path, "D.dll");
224         protected static readonly string s_myLibraries_V1_GDllPath = Path.Combine(s_myLibraries_V1Path, "G.dll");
225         protected static readonly string s_myLibraries_V2_GDllPath = Path.Combine(s_myLibraries_V2Path, "G.dll");
226 
227         protected static readonly string s_regress454863_ADllPath = Path.Combine(s_rootPathPrefix, "Regress454863", "A.dll");
228         protected static readonly string s_regress454863_BDllPath = Path.Combine(s_rootPathPrefix, "Regress454863", "B.dll");
229 
230         protected static readonly string s_regress444809RootPath = Path.Combine(s_rootPathPrefix, "Regress444809");
231         protected static readonly string s_regress444809_ADllPath = Path.Combine(s_regress444809RootPath, "A.dll");
232         protected static readonly string s_regress444809_BDllPath = Path.Combine(s_regress444809RootPath, "B.dll");
233         protected static readonly string s_regress444809_CDllPath = Path.Combine(s_regress444809RootPath, "C.dll");
234         protected static readonly string s_regress444809_DDllPath = Path.Combine(s_regress444809RootPath, "D.dll");
235 
236         protected static readonly string s_regress444809_V2RootPath = Path.Combine(s_regress444809RootPath, "v2");
237         protected static readonly string s_regress444809_V2_ADllPath = Path.Combine(s_regress444809_V2RootPath, "A.dll");
238 
239         protected static readonly string s_regress442570_RootPath = Path.Combine(s_rootPathPrefix, "Regress442570");
240         protected static readonly string s_regress442570_ADllPath = Path.Combine(s_regress442570_RootPath, "A.dll");
241         protected static readonly string s_regress442570_BDllPath = Path.Combine(s_regress442570_RootPath, "B.dll");
242 
243         protected static readonly string s_myAppRootPath = Path.Combine(s_rootPathPrefix, "MyApp");
244         protected static readonly string s_myApp_V05Path = Path.Combine(s_myAppRootPath, "v0.5");
245         protected static readonly string s_myApp_V10Path = Path.Combine(s_myAppRootPath, "v1.0");
246         protected static readonly string s_myApp_V20Path = Path.Combine(s_myAppRootPath, "v2.0");
247         protected static readonly string s_myApp_V30Path = Path.Combine(s_myAppRootPath, "v3.0");
248 
249         protected static readonly string s_netstandardLibraryDllPath = Path.Combine(s_rootPathPrefix, "NetStandard", "netstandardlibrary.dll");
250         protected static readonly string s_netstandardDllPath = Path.Combine(s_rootPathPrefix, "NetStandard", "netstandard.dll");
251 
252         protected static readonly string s_portableDllPath = Path.Combine(s_rootPathPrefix, "SystemRuntime", "Portable.dll");
253         protected static readonly string s_systemRuntimeDllPath = Path.Combine(s_rootPathPrefix, "SystemRuntime", "System.Runtime.dll");
254 
255         protected static readonly string s_dependsOnNuGet_ADllPath = Path.Combine(s_rootPathPrefix, "DependsOnNuget", "A.dll");
256         protected static readonly string s_dependsOnNuGet_NDllPath = Path.Combine(s_rootPathPrefix, "DependsOnNuget", "N.dll");
257         protected static readonly string s_dependsOnNuGet_NExePath = Path.Combine(s_rootPathPrefix, "DependsOnNuget", "N.exe");
258         protected static readonly string s_dependsOnNuGet_NWinMdPath = Path.Combine(s_rootPathPrefix, "DependsOnNuget", "N.winmd");
259 
260         protected static readonly string s_nugetCache_N_Lib_NDllPath = Path.Combine(s_rootPathPrefix, "NugetCache", "N", "lib", "N.dll");
261 
262         protected static readonly string s_assemblyFolder_RootPath = Path.Combine(s_rootPathPrefix, "AssemblyFolder");
263         protected static readonly string s_assemblyFolder_SomeAssemblyDllPath = Path.Combine(s_assemblyFolder_RootPath, "SomeAssembly.dll");
264 
265         /// <summary>
266         /// Search paths to use.
267         /// </summary>
268         private static readonly string[] s_defaultPaths = new string[]
269         {
270             "{RawFileName}",
271             "{CandidateAssemblyFiles}",
272             s_myProjectPath,
273             s_myComponentsMiscPath,
274             s_myComponents10Path,
275             s_myComponents20Path,
276             s_myVersion20Path,
277             @"{Registry:Software\Microsoft\.NetFramework,v2.0,AssemblyFoldersEx}",
278             "{AssemblyFolders}",
279             "{HintPathFromItem}"
280         };
281 
282         /// <summary>
283         /// Return the default search paths.
284         /// </summary>
285         /// <value></value>
286         internal string[] DefaultPaths
287         {
288             get { return s_defaultPaths; }
289         }
290 
291         /// <summary>
292         /// Start monitoring IO calls.
293         /// </summary>
StartIOMonitoring()294         internal void StartIOMonitoring()
295         {
296             // If tables are present then the corresponding IO function will do some monitoring.
297             uniqueFileExists = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
298             uniqueGetAssemblyName = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
299         }
300 
301         /// <summary>
302         /// Stop monitoring IO calls and assert if any unnecessary IO was used.
303         /// </summary>
304         /// <param name="ioThreshold">Maximum number of file existence checks per file</param>
StopIOMonitoringAndAssert_Minimal_IOUse(int ioThreshold = 1)305         internal void StopIOMonitoringAndAssert_Minimal_IOUse(int ioThreshold = 1)
306         {
307             // Check for minimal IO in File.Exists.
308             foreach (var entry in uniqueFileExists)
309             {
310                 string path = (string)entry.Key;
311                 int count = (int)entry.Value;
312                 if (count > ioThreshold)
313                 {
314                     string message = String.Format("File.Exists() was called {0} times with path {1}.", count, path);
315                     Assert.True(false, message);
316                 }
317             }
318 
319 
320             uniqueFileExists = null;
321             uniqueGetAssemblyName = null;
322         }
323 
324         /// <summary>
325         /// Stop monitoring IO calls and assert if any IO was used.
326         /// </summary>
StopIOMonitoringAndAssert_Zero_IOUse()327         internal void StopIOMonitoringAndAssert_Zero_IOUse()
328         {
329             // Check for minimal IO in File.Exists.
330             foreach (var entry in uniqueFileExists)
331             {
332                 string path = (string)entry.Key;
333                 int count = (int)entry.Value;
334                 if (count > 0)
335                 {
336                     string message = String.Format("File.Exists() was called {0} times with path {1}.", count, path);
337                     Assert.True(false, message);
338                 }
339             }
340 
341 
342             // Check for zero IO in GetAssemblyName.
343             foreach (var entry in uniqueGetAssemblyName)
344             {
345                 string path = (string)entry.Key;
346                 int count = (int)entry.Value;
347                 if (count > 0)
348                 {
349                     string message = String.Format("GetAssemblyName() was called {0} times with path {1}.", count, path);
350                     Assert.True(false, message);
351                 }
352             }
353 
354             uniqueFileExists = null;
355             uniqueGetAssemblyName = null;
356         }
357 
StopIOMonitoring()358         internal void StopIOMonitoring()
359         {
360             uniqueFileExists = null;
361             uniqueGetAssemblyName = null;
362         }
363 
364         protected static List<string> s_existentFiles = new List<string>
365         {
366             Path.Combine(s_frameworksPath, "DependsOnFoo4Framework.dll"),
367             Path.Combine(s_frameworksPath, "DependsOnFoo45Framework.dll"),
368             Path.Combine(s_frameworksPath, "DependsOnFoo35Framework.dll"),
369             Path.Combine(s_frameworksPath, "IndirectDependsOnFoo45Framework.dll"),
370             Path.Combine(s_frameworksPath, "IndirectDependsOnFoo4Framework.dll"),
371             Path.Combine(s_frameworksPath, "IndirectDependsOnFoo35Framework.dll"),
372             Path.Combine(Path.GetTempPath(), @"RawFileNameRelative\System.Xml.dll"),
373             Path.Combine(Path.GetTempPath(), @"RelativeAssemblyFiles\System.Xml.dll"),
374             Path.Combine(s_myVersion20Path, "System.Data.dll"),
375             Path.Combine(s_myVersion20Path, "System.Xml.dll"),
376             Path.Combine(s_myVersion20Path, "System.Xml.pdb"),
377             Path.Combine(s_myVersion20Path, "System.Xml.xml"),
378             Path.Combine(s_myVersion20Path, "en", "System.Xml.resources.dll"),
379             Path.Combine(s_myVersion20Path, "en", "System.Xml.resources.pdb"),
380             Path.Combine(s_myVersion20Path, "en", "System.Xml.resources.config"),
381             Path.Combine(s_myVersion20Path, "xx", "System.Xml.resources.dll"),
382             Path.Combine(s_myVersion20Path, "en-GB", "System.Xml.resources.dll"),
383             Path.Combine(s_myVersion20Path, "en-GB", "System.Xml.resources.pdb"),
384             Path.Combine(s_myVersion20Path, "en-GB", "System.Xml.resources.config"),
385             Path.Combine(s_rootPathPrefix, s_myPrivateAssemblyRelPath),
386             Path.Combine(s_myProjectPath, "MyCopyLocalAssembly.dll"),
387             Path.Combine(s_myProjectPath, "MyDontCopyLocalAssembly.dll"),
388             Path.Combine(s_myVersion20Path, "BadImage.dll"),            // An assembly that will give a BadImageFormatException from GetAssemblyName
389             Path.Combine(s_myVersion20Path, "BadImage.pdb"),
390             Path.Combine(s_myVersion20Path, "MyGacAssembly.dll"),
391             Path.Combine(s_myVersion20Path, "MyGacAssembly.pdb"),
392             Path.Combine(s_myVersion20Path, "xx", "MyGacAssembly.resources.dll"),
393             Path.Combine(s_myVersion20Path, "System.dll"),
394             Path.Combine(s_myVersion40Path, "System.dll"),
395             Path.Combine(s_myVersion90Path, "System.dll"),
396             Path.Combine(s_myVersion20Path, "mscorlib.dll"),
397             Path.Combine(s_myVersionPocket20Path, "mscorlib.dll"),
398             @"C:\myassemblies\My.Assembly.dll",
399             Path.Combine(s_myProjectPath, "mscorlib.dll"),                           // This is an mscorlib.dll that has no metadata (i.e. GetAssemblyName returns null)
400             Path.Combine(s_myProjectPath, "System.Data.dll"),                        // This is a System.Data.dll that has the wrong pkt, it shouldn't be matched.
401             Path.Combine(s_myComponentsRootPath, "MyGrid.dll"),                      // A vendor component that we should find in the registry.
402             @"C:\MyComponentsA\CustomComponent.dll",                                           // A vendor component that we should find in the registry.
403             @"C:\MyComponentsB\CustomComponent.dll",                                           // A vendor component that we should find in the registry.
404             @"C:\MyWinMDComponents7\MyGridWinMD.winmd",
405             @"C:\MyWinMDComponents9\MyGridWinMD.winmd",
406             @"C:\MyWinMDComponents\MyGridWinMD.winmd",
407             @"C:\MyWinMDComponents2\MyGridWinMD.winmd",
408             @"C:\MyWinMDComponentsA\CustomComponentWinMD.winmd",
409             @"C:\MyWinMDComponentsB\CustomComponentWinMD.winmd",
410             @"C:\MyWinMDComponentsVv1\MyGridWinMD2.winmd",
411             @"C:\MyWinMDComponentsV1\MyGridWinMD3.winmd",
412             @"C:\MyRawDropControls\MyRawDropControl.dll",                             // A control installed by VSREG under v2.0.x86chk
413             @"C:\MyComponents\HKLM Components\MyHKLMControl.dll",                    // A vendor component that is installed under HKLM but not HKCU.
414             @"C:\MyComponents\HKCU Components\MyHKLMandHKCUControl.dll",             // A vendor component that is installed under HKLM and HKCU.
415             @"C:\MyComponents\HKLM Components\MyHKLMandHKCUControl.dll",             // A vendor component that is installed under HKLM and HKCU.
416             @"C:\MyWinMDComponents\HKLM Components\MyHKLMControlWinMD.winmd",                    // A vendor component that is installed under HKLM but not HKCU.
417             @"C:\MyWinMDComponents\HKCU Components\MyHKLMandHKCUControlWinMD.winmd",             // A vendor component that is installed under HKLM and HKCU.
418             @"C:\MyWinMDComponents\HKLM Components\MyHKLMandHKCUControlWinMD.winmd",             // A vendor component that is installed under HKLM and HKCU.
419             Path.Combine(s_myComponentsV30Path, "MyControlWithFutureTargetNDPVersion.dll"),         // The future version of a component.
420             Path.Combine(s_myComponentsV20Path, "MyControlWithFutureTargetNDPVersion.dll"),         // The current version of a component.
421             Path.Combine(s_myComponentsV10Path, "MyNDP1Control.dll"),                               // A control that only has an NDP 1.0 version
422             Path.Combine(s_myComponentsV20Path, "MyControlWithPastTargetNDPVersion.dll"),           // The current version of a component.
423             Path.Combine(s_myComponentsV10Path, "MyControlWithPastTargetNDPVersion.dll"),           // The past version of a component.
424             @"C:\MyComponentServicePack\MyControlWithServicePack.dll",               // The service pack 1 version of the control
425             @"C:\MyComponentBase\MyControlWithServicePack.dll",                      // The non-service pack version of the control.
426             @"C:\MyComponentServicePack2\MyControlWithServicePack.dll",              // The service pack 1 version of the control
427             Path.Combine(s_myVersionPocket20Path, "mscorlib.dll"),  // A devices mscorlib.
428             s_myLibraries_ADllPath,
429             @"c:\MyExecutableLibraries\A.exe",
430             s_myLibraries_BDllPath,
431             s_myLibraries_CDllPath,
432             s_myLibraries_V1_DDllPath,
433             s_myLibraries_V1_E_EDllPath,
434             @"c:\RogueLibraries\v1\D.dll",
435             s_myLibraries_V2_DDllPath,
436             s_myLibraries_V1_GDllPath,
437             s_myLibraries_V2_GDllPath,
438             @"c:\MyStronglyNamed\A.dll",
439             @"c:\MyWeaklyNamed\A.dll",
440             @"c:\MyInaccessible\A.dll",
441             @"c:\MyNameMismatch\Foo.dll",
442             @"c:\MyEscapedName\=A=.dll",
443             @"c:\MyEscapedName\__'ASP'dw0024ry.dll",
444             Path.Combine(s_myAppRootPath, "DependsOnSimpleA.dll"),
445             @"C:\Regress312873\a.dll",
446             @"C:\Regress312873\b.dll",
447             @"C:\Regress312873-2\a.dll",
448             @"C:\Regress275161\a.dll",
449             @"C:\Regress317975\a.dll",
450             @"C:\Regress317975\b.dll",
451             @"C:\Regress317975\v2\b.dll",
452             @"c:\Regress313086\mscorlib.dll",
453             @"c:\V1Control\MyDeviceControlAssembly.dll",
454             @"c:\V1ControlSP1\MyDeviceControlAssembly.dll",
455             @"C:\Regress339786\FolderA\a.dll",
456             @"C:\Regress339786\FolderA\c.dll", // v1 of c
457             @"C:\Regress339786\FolderB\b.dll",
458             @"C:\Regress339786\FolderB\c.dll", // v2 of c
459             @"c:\OldClrBug\MyFileLoadExceptionAssembly.dll",
460             @"c:\OldClrBug\DependsMyFileLoadExceptionAssembly.dll",
461             @"c:\Regress563286\DependsOnBadImage.dll",
462             @"C:\Regress407623\CrystalReportsAssembly.dll",
463             @"C:\Regress435487\microsoft.build.engine.dll",
464             @"C:\Regress313747\Microsoft.Office.Interop.Excel.dll",
465             @"C:\Regress313747\MS.Internal.Test.Automation.Office.Excel.dll",
466             s_regress442570_ADllPath,
467             s_regress442570_BDllPath,
468             s_regress454863_ADllPath,
469             s_regress454863_BDllPath,
470             @"C:\Regress393931\A.metadata_dll",
471             @"c:\Regress387218\A.dll",
472             @"c:\Regress387218\B.dll",
473             @"c:\Regress387218\v1\D.dll",
474             @"c:\Regress387218\v2\D.dll",
475             @"c:\Regress390219\A.dll",
476             @"c:\Regress390219\B.dll",
477             @"c:\Regress390219\v1\D.dll",
478             @"c:\Regress390219\v2\D.dll",
479             @"c:\Regress315619\A\MyAssembly.dll",
480             @"c:\Regress315619\B\MyAssembly.dll",
481             @"c:\SGenDependeicies\mycomponent.dll",
482             @"c:\SGenDependeicies\mycomponent.XmlSerializers.dll",
483             @"c:\SGenDependeicies\mycomponent2.dll",
484             @"c:\SGenDependeicies\mycomponent2.XmlSerializers.dll",
485             @"c:\Regress315619\A\MyAssembly.dll",
486             @"c:\Regress315619\B\MyAssembly.dll",
487             @"c:\MyRedist\MyRedistRootAssembly.dll",
488             @"c:\MyRedist\MyOtherAssembly.dll",
489             @"c:\MyRedist\MyThirdAssembly.dll",
490             // ==[Related File Extensions Testing]================================================================================================
491             s_assemblyFolder_SomeAssemblyDllPath,
492             Path.Combine(s_assemblyFolder_RootPath, "SomeAssembly.pdb"),
493             Path.Combine(s_assemblyFolder_RootPath, "SomeAssembly.xml"),
494             Path.Combine(s_assemblyFolder_RootPath, "SomeAssembly.pri"),
495             Path.Combine(s_assemblyFolder_RootPath, "SomeAssembly.licenses"),
496             Path.Combine(s_assemblyFolder_RootPath, "SomeAssembly.config"),
497             // ==[Related File Extensions Testing]================================================================================================
498 
499             // ==[Unification Testing]============================================================================================================
500             //@"C:\MyComponents\v0.5\UnifyMe.dll",                                 // For unification testing, a version that doesn't exist.
501             s_unifyMeDll_V10Path,
502             s_unifyMeDll_V20Path,
503             s_unifyMeDll_V30Path,
504             //@"C:\MyComponents\v4.0\UnifyMe.dll",
505             Path.Combine(s_myApp_V05Path, "DependsOnUnified.dll"),
506             Path.Combine(s_myApp_V10Path, "DependsOnUnified.dll"),
507             Path.Combine(s_myApp_V20Path, "DependsOnUnified.dll"),
508             Path.Combine(s_myApp_V30Path, "DependsOnUnified.dll"),
509             Path.Combine(s_myAppRootPath, "DependsOnWeaklyNamedUnified.dll"),
510             Path.Combine(s_myApp_V10Path, "DependsOnEverettSystem.dll"),
511             @"C:\Framework\Everett\System.dll",
512             @"C:\Framework\Whidbey\System.dll",
513             // ==[Unification Testing]============================================================================================================
514 
515             // ==[Test assemblies reference higher versions than the current target framework=====================================================
516             Path.Combine(s_myComponentsMiscPath, "DependsOnOnlyv4Assemblies.dll"),  // Only depends on 4.0.0 assemblies
517             Path.Combine(s_myComponentsMiscPath, "ReferenceVersion9.dll"), //Is in redist list and is a 9.0 assembly
518             Path.Combine(s_myComponentsMiscPath, "DependsOn9.dll"), //Depends on 9.0 assemblies
519             Path.Combine(s_myComponentsMiscPath, "DependsOn9Also.dll"), // Depends on 9.0 assemblies
520             Path.Combine(s_myComponents10Path, "DependsOn9.dll"), // Depends on 9.0 assemblies
521             Path.Combine(s_myComponents20Path, "DependsOn9.dll"), // Depends on 9.0 assemblies
522             s_regress444809_ADllPath,
523             s_regress444809_V2_ADllPath,
524             s_regress444809_BDllPath,
525             s_regress444809_CDllPath,
526             s_regress444809_DDllPath,
527             s_40ComponentDependsOnOnlyv4AssembliesDllPath,
528             @"C:\Regress714052\MSIL\a.dll",
529             @"C:\Regress714052\X86\a.dll",
530             @"C:\Regress714052\NONE\a.dll",
531             @"C:\Regress714052\Mix\a.dll",
532             @"C:\Regress714052\Mix\a.winmd",
533             @"C:\Regress714052\MSIL\b.dll",
534             @"C:\Regress714052\X86\b.dll",
535             @"C:\Regress714052\NONE\b.dll",
536             @"C:\Regress714052\Mix\b.dll",
537             @"C:\Regress714052\Mix\b.winmd",
538 
539             Path.Combine(s_myComponentsRootPath, "V.dll"),
540             Path.Combine(s_myComponents2RootPath, "W.dll"),
541             Path.Combine(s_myComponentsRootPath, "X.dll"),
542             Path.Combine(s_myComponentsRootPath, "Y.dll"),
543             Path.Combine(s_myComponentsRootPath, "Z.dll"),
544 
545             Path.Combine(s_myComponentsRootPath, "Microsoft.Build.dll"),
546             Path.Combine(s_myComponentsRootPath, "DependsOnMSBuild12.dll"),
547 
548             // WinMD sample files
549             @"C:\WinMD\v4\mscorlib.dll",  // Fake 4.0 mscorlib so we can actually resolve it for one of the tests. With a version of 4
550             @"C:\WinMD\v255\mscorlib.dll",  // Fake 4.0 mscorlib so we can actually resolve it for one of the tests. With a version of 255
551             @"C:\WinMD\DotNetAssemblyDependsOnWinMD.dll",
552             @"C:\WinMD\DotNetAssemblyDependsOn255WinMD.dll",
553             @"C:\WinMD\SampleWindowsRuntimeAndCLR.Winmd",
554             @"C:\WinMD\SampleWindowsRuntimeAndCLR.dll",
555             @"C:\WinMD\SampleWindowsRuntimeAndOther.Winmd",
556             @"C:\WinMD\SampleWindowsRuntimeOnly.Winmd",
557             @"C:\WinMD\SampleWindowsRuntimeOnly.dll",
558             @"C:\WinMD\SampleWindowsRuntimeOnly.pri",
559             @"C:\WinMD\SampleWindowsRuntimeOnly2.Winmd",
560             @"C:\WinMD\SampleWindowsRuntimeOnly3.Winmd",
561             @"C:\WinMD\SampleWindowsRuntimeOnly4.Winmd",
562             @"C:\WinMD\SampleWindowsRuntimeReferencingSystem.Winmd",
563             @"C:\WinMD\SampleWindowsRuntimeReferencingSystemDNE.Winmd",
564             @"C:\WinMD\SampleClrOnly.Winmd",
565             @"C:\WinMD\SampleBadWindowsRuntime.Winmd",
566             @"C:\WinMD\WinMDWithVersion255.Winmd",
567             @"C:\WinMDArchVerification\DependsOnInvalidPeHeader.Winmd",
568             @"C:\WinMDArchVerification\DependsOnInvalidPeHeader.dll",
569             @"C:\WinMDArchVerification\DependsOnAmd64.Winmd",
570             @"C:\WinMDArchVerification\DependsOnAmd64.dll",
571             @"C:\WinMDArchVerification\DependsOnArm.Winmd",
572             @"C:\WinMDArchVerification\DependsOnArm.dll",
573             @"C:\WinMDArchVerification\DependsOnArmv7.Winmd",
574             @"C:\WinMDArchVerification\DependsOnArmv7.dll",
575             @"C:\WinMDArchVerification\DependsOnX86.Winmd",
576             @"C:\WinMDArchVerification\DependsOnX86.dll",
577             @"C:\WinMDArchVerification\DependsOnAnyCPUUnknown.Winmd",
578             @"C:\WinMDArchVerification\DependsOnAnyCPUUnknown.dll",
579             @"C:\WinMDArchVerification\DependsOnIA64.Winmd",
580             @"C:\WinMDArchVerification\DependsOnIA64.dll",
581             @"C:\WinMDArchVerification\DependsOnUnknown.Winmd",
582             @"C:\WinMDArchVerification\DependsOnUnknown.dll",
583             @"C:\FakeSDK\References\Debug\X86\DebugX86SDKWinMD.Winmd",
584             @"C:\FakeSDK\References\Debug\Neutral\DebugNeutralSDKWinMD.Winmd",
585             @"C:\FakeSDK\References\CommonConfiguration\x86\x86SDKWinMD.Winmd",
586             @"C:\FakeSDK\References\CommonConfiguration\Neutral\NeutralSDKWinMD.Winmd",
587             @"C:\FakeSDK\References\Debug\X86\DebugX86SDKRA.dll",
588             @"C:\FakeSDK\References\Debug\Neutral\DebugNeutralSDKRA.dll",
589             @"C:\FakeSDK\References\CommonConfiguration\x86\x86SDKRA.dll",
590             @"C:\FakeSDK\References\CommonConfiguration\Neutral\NeutralSDKRA.dll",
591             @"C:\FakeSDK\References\Debug\X86\SDKReference.dll",
592             @"C:\DirectoryContainsOnlyDll\a.dll",
593             @"C:\DirectoryContainsdllAndWinmd\b.dll",
594             @"C:\DirectoryContainsdllAndWinmd\c.winmd",
595             @"C:\DirectoryContainstwoWinmd\a.winmd",
596             @"C:\DirectoryContainstwoWinmd\c.winmd",
597             s_systemRuntimeDllPath,
598             s_portableDllPath,
599             s_netstandardLibraryDllPath,
600             s_netstandardDllPath,
601             @"C:\SystemRuntime\Regular.dll",
602             s_dependsOnNuGet_ADllPath,
603             s_nugetCache_N_Lib_NDllPath
604         };
605 
606         /// <summary>
607         /// Mocked up GetFiles.
608         /// </summary>
609         /// <param name="path"></param>
610         /// <param name="pattern"></param>
611         /// <returns></returns>
GetFiles(string path, string pattern)612         internal static string[] GetFiles(string path, string pattern)
613         {
614             if (path.Length > 240)
615             {
616                 throw new PathTooLongException();
617             }
618 
619             string extension = null;
620             if (pattern == "*.xml")
621             {
622                 extension = ".xml";
623             }
624             else if (pattern == "*.pdb")
625             {
626                 extension = ".pdb";
627             }
628             else
629             {
630                 Assert.True(false, "Unsupported GetFiles pattern " + pattern);
631             }
632 
633             ArrayList matches = new ArrayList();
634             foreach (string file in s_existentFiles)
635             {
636                 string baseDir = Path.GetDirectoryName(file);
637 
638                 if (0 == String.Compare(baseDir, path, StringComparison.OrdinalIgnoreCase))
639                 {
640                     string fileExtension = Path.GetExtension(file);
641 
642                     if (0 == String.Compare(fileExtension, extension, StringComparison.OrdinalIgnoreCase))
643                     {
644                         matches.Add(file);
645                     }
646                 }
647             }
648 
649             return (string[])matches.ToArray(typeof(string));
650         }
651 
652         /// <summary>
653         /// Reads the machine type out of the PEHeader of the native dll
654         /// </summary>
ReadMachineTypeFromPEHeader(string dllPath)655         private static UInt16 ReadMachineTypeFromPEHeader(string dllPath)
656         {
657             if (@"C:\WinMDArchVerification\DependsOnInvalidPeHeader.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
658             {
659                 return NativeMethods.IMAGE_FILE_MACHINE_INVALID;
660             }
661             else if (@"C:\WinMDArchVerification\DependsOnAmd64.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
662             {
663                 return NativeMethods.IMAGE_FILE_MACHINE_AMD64;
664             }
665             else if (@"C:\WinMDArchVerification\DependsOnX86.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
666             {
667                 return NativeMethods.IMAGE_FILE_MACHINE_I386;
668             }
669             else if (@"C:\WinMDArchVerification\DependsOnArm.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
670             {
671                 return NativeMethods.IMAGE_FILE_MACHINE_ARM;
672             }
673             else if (@"C:\WinMDArchVerification\DependsOnArmV7.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
674             {
675                 return NativeMethods.IMAGE_FILE_MACHINE_ARMV7;
676             }
677             else if (@"C:\WinMDArchVerification\DependsOnIA64.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
678             {
679                 return NativeMethods.IMAGE_FILE_MACHINE_IA64;
680             }
681             else if (@"C:\WinMDArchVerification\DependsOnUnknown.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
682             {
683                 return NativeMethods.IMAGE_FILE_MACHINE_R4000;
684             }
685             else if (@"C:\WinMDArchVerification\DependsOnAnyCPUUnknown.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
686             {
687                 return NativeMethods.IMAGE_FILE_MACHINE_UNKNOWN;
688             }
689             else if (@"C:\WinMD\SampleWindowsRuntimeOnly.dll".Equals(dllPath, StringComparison.OrdinalIgnoreCase))
690             {
691                 return NativeMethods.IMAGE_FILE_MACHINE_I386;
692             }
693 
694             return NativeMethods.IMAGE_FILE_MACHINE_INVALID;
695         }
696 
697         /// <summary>
698         ///  Checks to see if the file is a winmd file.
699         /// </summary>
IsWinMDFile(string fullPath, GetAssemblyRuntimeVersion getAssemblyRuntimeVersion, FileExists fileExists, out string imageRuntimeVersion, out bool isManagedWinMD)700         private static bool IsWinMDFile(string fullPath, GetAssemblyRuntimeVersion getAssemblyRuntimeVersion, FileExists fileExists, out string imageRuntimeVersion, out bool isManagedWinMD)
701         {
702             imageRuntimeVersion = getAssemblyRuntimeVersion(fullPath);
703             isManagedWinMD = false;
704 
705             if (String.Compare(fullPath, @"C:\WinMD\SampleWindowsRuntimeOnly.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
706             {
707                 return true;
708             }
709             else if (String.Compare(fullPath, @"C:\WinMD\SampleWindowsRuntimeAndCLR.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
710             {
711                 isManagedWinMD = true;
712                 return true;
713             }
714             else if (String.Compare(fullPath, @"C:\WinMD\WinMDWithVersion255.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
715             {
716                 return true;
717             }
718             else if (String.Compare(fullPath, @"C:\WinMD\SampleWindowsRuntimeOnly2.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
719             {
720                 return true;
721             }
722             else if (String.Compare(fullPath, @"C:\WinMD\SampleWindowsRuntimeOnly3.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
723             {
724                 return true;
725             }
726             else if (String.Compare(fullPath, @"C:\WinMD\SampleWindowsRuntimeOnly4.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
727             {
728                 return true;
729             }
730             else if (String.Compare(fullPath, @"C:\WinMD\SampleWindowsRuntimeReferencingSystem.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
731             {
732                 return true;
733             }
734             else if (String.Compare(fullPath, @"C:\WinMD\SampleWindowsRuntimeReferencingSystemDNE.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
735             {
736                 return true;
737             }
738             else if (fullPath.StartsWith(@"C:\MyWinMDComponents", StringComparison.OrdinalIgnoreCase))
739             {
740                 return true;
741             }
742             else if (String.Compare(fullPath, @"C:\FakeSDK\WindowsMetadata\SDKWinMD2.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
743             {
744                 return true;
745             }
746             else if (fullPath.StartsWith(@"C:\DirectoryContains", StringComparison.OrdinalIgnoreCase) && Path.GetExtension(fullPath).Equals(".winmd", StringComparison.OrdinalIgnoreCase))
747             {
748                 return true;
749             }
750             else if (fullPath.StartsWith(@"C:\WinMDArchVerification", StringComparison.OrdinalIgnoreCase) && Path.GetExtension(fullPath).Equals(".winmd", StringComparison.OrdinalIgnoreCase))
751             {
752                 return true;
753             }
754             else if (String.Compare(fullPath, @"C:\FakeSDK\WindowsMetadata\SDKWinMD.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
755             {
756                 return true;
757             }
758 
759             return false;
760         }
761 
762         /// <summary>
763         ///  Checks to see if the assemblyName passed in is in the GAC.
764         /// </summary>
GetPathForAssemblyInGac(AssemblyNameExtension assemblyName, SystemProcessorArchitecture targetProcessorArchitecture, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, FileExists fileExists, bool fullFusionName, bool specificVersion)765         private static string GetPathForAssemblyInGac(AssemblyNameExtension assemblyName, SystemProcessorArchitecture targetProcessorArchitecture, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVersion, FileExists fileExists, bool fullFusionName, bool specificVersion)
766         {
767             if (assemblyName.Equals(new AssemblyNameExtension("V, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
768             {
769                 return null;
770             }
771             else if (assemblyName.Equals(new AssemblyNameExtension("W, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
772             {
773                 return @"C:\MyComponents2\W.dll";
774             }
775             else if (assemblyName.Equals(new AssemblyNameExtension("Z, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
776             {
777                 return null;
778             }
779             else if (assemblyName.Equals(new AssemblyNameExtension("X, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
780             {
781                 return @"C:\MyComponents\X.dll";
782             }
783             else if (assemblyName.Equals(new AssemblyNameExtension("Y, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")))
784             {
785                 return null;
786             }
787             else
788             {
789                 string gacLocation = null;
790                 if (assemblyName.Version != null)
791                 {
792                     gacLocation = GlobalAssemblyCache.GetLocation(assemblyName, targetProcessorArchitecture, getRuntimeVersion, targetedRuntimeVersion, fullFusionName, fileExists, null, null, specificVersion /* this value does not matter if we are passing a full fusion name*/);
793                 }
794                 return gacLocation;
795             }
796         }
797 
798         /// <summary>
799         /// Mock the File.Exists method.
800         /// </summary>
801         /// <param name="path">The path to check.</param>
802         /// <returns>'true' if the file is supposed to exist</returns>
FileExists(string path)803         internal static bool FileExists(string path)
804         {
805             // For very long paths, File.Exists just returns false
806             if (path.Length > 240)
807             {
808                 return false;
809             }
810 
811             // Do a real File.Exists to make it throw exceptions for illegal paths.
812             if (File.Exists(path) && useFrameworkFileExists)
813             {
814                 return true;
815             }
816 
817             // Do IO monitoring if needed.
818             if (uniqueFileExists != null)
819             {
820                 string lowerPath = path.ToLower();
821 
822                 if (!uniqueFileExists.ContainsKey(lowerPath))
823                 {
824                     uniqueFileExists[lowerPath] = 0;
825                 }
826 
827                 uniqueFileExists[lowerPath] = uniqueFileExists[lowerPath] + 1;
828             }
829 
830 
831             // First, MyMissingAssembly doesn't exist anywhere.
832             if (path.IndexOf("MyMissingAssembly") != -1)
833             {
834                 return false;
835             }
836 
837             if (!Path.IsPathRooted(path))
838             {
839                 path = Path.GetFullPath(path);
840             }
841 
842 
843             foreach (string file in s_existentFiles)
844             {
845                 if (0 == String.Compare(path, file, StringComparison.OrdinalIgnoreCase))
846                 {
847                     return true;
848                 }
849             }
850 
851 
852             // Everything else doesn't exist.
853             return false;
854         }
855 
856         /// <summary>
857         /// Mock the Directory.Exists method.
858         /// </summary>
859         /// <param name="path">The path to check.</param>
860         /// <returns>'true' if the directory is supposed to exist</returns>
DirectoryExists(string path)861         internal static bool DirectoryExists(string path)
862         {
863             // Now specify the remaining files.
864             string[] existentDirs = new string[]
865             {
866                 s_myVersion20Path,
867                 @"c:\SGenDependeicies",
868                 Path.GetTempPath()
869             };
870 
871             foreach (string dir in existentDirs)
872             {
873                 if (0 == String.Compare(path, dir, StringComparison.OrdinalIgnoreCase))
874                 {
875                     return true;
876                 }
877             }
878 
879             // Everything else doesn't exist.
880             return false;
881         }
882 
883         /// <summary>
884         /// A mock delegate for Directory.GetDirectories.
885         /// </summary>
886         /// <param name="file">The file path.</param>
887         /// <param name="file">The file pattern.</param>
888         /// <returns>A set of subdirectories</returns>
GetDirectories(string path, string pattern)889         internal static string[] GetDirectories(string path, string pattern)
890         {
891             if (path.EndsWith(s_myVersion20Path))
892             {
893                 string[] paths = new string[] {
894                     Path.Combine(path, "en"), Path.Combine(path, "en-GB"), Path.Combine(path, "xx")
895                 };
896 
897                 return paths;
898             }
899             else if (String.Compare(path, @".", StringComparison.OrdinalIgnoreCase) == 0)
900             {
901                 // Pretend the current directory has a few subfolders.
902                 return new string[] {
903                     Path.Combine(path, "en"), Path.Combine(path, "en-GB"), Path.Combine(path, "xx")
904                 };
905             }
906 
907             return new string[0];
908         }
909 
910         /// <summary>
911         /// Given a path return the corosponding CLR runtime version
912         /// </summary>
913         /// <param name="path">Path to the file</param>
914         /// <returns>Image runtime version</returns>
GetRuntimeVersion(string path)915         internal static string GetRuntimeVersion(string path)
916         {
917             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeAndCLR.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
918             {
919                 return "WindowsRuntime 1.0, CLR V2.0.50727";
920             }
921             else if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
922             {
923                 // Simulate a strongly named assembly.
924                 return "WindowsRuntime 1.0";
925             }
926             else if (String.Compare(path, @"C:\WinMD\WinMDWithVersion255.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
927             {
928                 // Simulate a strongly named assembly.
929                 return "WindowsRuntime 1.0";
930             }
931             else if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly2.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
932             {
933                 // Simulate a strongly named assembly.
934                 return "WindowsRuntime 1.0";
935             }
936             else if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly3.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
937             {
938                 // Simulate a strongly named assembly.
939                 return "WindowsRuntime 1.0";
940             }
941             else if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly4.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
942             {
943                 // Simulate a strongly named assembly.
944                 return "WindowsRuntime 1.0";
945             }
946             else if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeReferencingSystem.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
947             {
948                 // Simulate a strongly named assembly.
949                 return "WindowsRuntime 1.0";
950             }
951             else if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeReferencingSystemDNE.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
952             {
953                 // Simulate a strongly named assembly.
954                 return "WindowsRuntime 1.0";
955             }
956             else if (String.Compare(path, @"C:\WinMD\SampleClrOnly.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
957             {
958                 return "CLR V2.0.50727";
959             }
960             else if (String.Compare(path, @"C:\WinMD\SampleBadWindowsRuntime.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
961             {
962                 return "Windows Runtime";
963             }
964             else if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeAndOther.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
965             {
966                 return "WindowsRuntime 1.0, Other V2.0.50727";
967             }
968 
969             else if (String.Compare(path, @"C:\DirectoryContainsOnlyDll\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
970             {
971                 return "V2.0.50727";
972             }
973             else if (String.Compare(path, @"C:\DirectoryContainsdllAndWinmd\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
974             {
975                 return "V2.0.50727";
976             }
977             else if (String.Compare(path, @"C:\DirectoryContainsdllAndWinmd\c.winmd", StringComparison.OrdinalIgnoreCase) == 0)
978             {
979                 return "WindowsRuntime 1.0";
980             }
981             else if (String.Compare(path, @"C:\DirectoryContainstwoWinmd\a.winmd", StringComparison.OrdinalIgnoreCase) == 0)
982             {
983                 return "WindowsRuntime 1.0";
984             }
985             else if (String.Compare(path, @"C:\DirectoryContainstwoWinmd\c.winmd", StringComparison.OrdinalIgnoreCase) == 0)
986             {
987                 return "WindowsRuntime 1.0";
988             }
989             else if (path.StartsWith(@"C:\MyWinMDComponents", StringComparison.OrdinalIgnoreCase))
990             {
991                 return "Windows Runtime";
992             }
993             else if (path.StartsWith(@"C:\WinMDArchVerification", StringComparison.OrdinalIgnoreCase) && path.EndsWith(".winmd"))
994             {
995                 return "WindowsRuntime 1.0";
996             }
997             else if (path.EndsWith(".dll") || path.EndsWith(".exe") || path.EndsWith(".winmd"))
998             {
999                 return "v2.0.50727";
1000             }
1001             else
1002             {
1003                 return "";
1004             }
1005         }
1006 
1007         /// <summary>
1008         /// Given a path, return the corresponding AssemblyName
1009         /// </summary>
1010         /// <param name="path">Path to the assembly.</param>
1011         /// <returns>The assemblyname.</returns>
GetAssemblyName(string path)1012         internal static AssemblyNameExtension GetAssemblyName(string path)
1013         {
1014             // Do IO monitoring if needed.
1015             if (uniqueGetAssemblyName != null)
1016             {
1017                 string lowerPath = path.ToLower();
1018                 if (!uniqueGetAssemblyName.ContainsKey(lowerPath))
1019                 {
1020                     uniqueGetAssemblyName[lowerPath] = 0;
1021                 }
1022                 else
1023                 {
1024                     uniqueGetAssemblyName[lowerPath] = (int)uniqueGetAssemblyName[lowerPath] + 1;
1025                 }
1026             }
1027 
1028             // For very long paths, GetAssemblyName throws an exception.
1029             if (path.Length > 240)
1030             {
1031                 throw new FileNotFoundException(path);
1032             }
1033 
1034             if (!Path.IsPathRooted(path))
1035             {
1036                 path = Path.GetFullPath(path);
1037             }
1038 
1039             if
1040             (
1041                 String.Compare(path, @"c:\OldClrBug\MyFileLoadExceptionAssembly.dll", StringComparison.OrdinalIgnoreCase) == 0
1042             )
1043             {
1044                 // An older LKG of the CLR could throw a FileLoadException if it doesn't recognize
1045                 // the assembly. We need to support this for dogfooding purposes.
1046                 throw new FileLoadException("Could not load " + path);
1047             }
1048 
1049             if
1050             (
1051                 String.Compare(path, @"c:\Regress313086\mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0
1052             )
1053             {
1054                 // This is an mscorlib that returns null for its assembly name.
1055                 return null;
1056             }
1057 
1058             if
1059             (
1060                 String.Compare(path, Path.Combine(s_myVersion20Path, "BadImage.dll"), StringComparison.OrdinalIgnoreCase) == 0
1061             )
1062             {
1063                 throw new System.BadImageFormatException(@"The format of the file '" + Path.Combine(s_myVersion20Path, "BadImage.dll") + "' is invalid");
1064             }
1065 
1066             if
1067             (
1068                 String.Compare(path, Path.Combine(s_myProjectPath, "mscorlib.dll"), StringComparison.OrdinalIgnoreCase) == 0
1069                 || String.Compare(path, Path.Combine(s_myVersion20Path, "mscorlib.dll"), StringComparison.OrdinalIgnoreCase) == 0
1070                 || String.Compare(path, Path.Combine(s_myVersionPocket20Path, "mscorlib.dll"), StringComparison.OrdinalIgnoreCase) == 0
1071             )
1072             {
1073                 // This is an mscorlib.dll with no metadata.
1074                 return null;
1075             }
1076 
1077             if
1078             (
1079                 String.Compare(path, Path.Combine(s_myVersion20Path, "mscorlib.dll"), StringComparison.OrdinalIgnoreCase) == 0
1080                 || String.Compare(path, Path.Combine(s_myVersionPocket20Path, "mscorlib.dll"), StringComparison.OrdinalIgnoreCase) == 0
1081             )
1082             {
1083                 // This is an mscorlib.dll with no metadata.
1084                 return null;
1085             }
1086 
1087             if (path.Contains("MyMissingAssembly"))
1088             {
1089                 throw new FileNotFoundException(path);
1090             }
1091 
1092             if (String.Compare(path, Path.Combine(s_frameworksPath, "DependsOnFoo45Framework.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1093             {
1094                 return new AssemblyNameExtension("DependsOnFoo45Framework, Version=4.5.0.0, PublicKeyToken=null, Culture=Neutral");
1095             }
1096 
1097             if (String.Compare(path, Path.Combine(s_frameworksPath, "DependsOnFoo4Framework.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1098             {
1099                 return new AssemblyNameExtension("DependsOnFoo4Framework, Version=4.0.0.0, PublicKeyToken=null, Culture=Neutral");
1100             }
1101 
1102             if (String.Compare(path, Path.Combine(s_frameworksPath, "DependsOnFoo35Framework.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1103             {
1104                 return new AssemblyNameExtension("DependsOnFoo35Framework, Version=3.5.0.0, PublicKeyToken=null, Culture=Neutral");
1105             }
1106 
1107             if (String.Compare(path, @"c:\Regress315619\A\MyAssembly.dll", StringComparison.OrdinalIgnoreCase) == 0)
1108             {
1109                 // Simulate a strongly named assembly.
1110                 return new AssemblyNameExtension("MyAssembly, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1111             }
1112 
1113             if (String.Compare(path, @"c:\Regress315619\B\MyAssembly.dll", StringComparison.OrdinalIgnoreCase) == 0)
1114             {
1115                 // Simulate a strongly named assembly.
1116                 return new AssemblyNameExtension("MyAssembly, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=null");
1117             }
1118 
1119             if (String.Compare(path, s_regress442570_ADllPath, StringComparison.OrdinalIgnoreCase) == 0)
1120             {
1121                 // Simulate a strongly named assembly.
1122                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
1123             }
1124             if (String.Compare(path, @"c:\Regress387218\v1\D.dll", StringComparison.OrdinalIgnoreCase) == 0)
1125             {
1126                 // Simulate a strongly named assembly.
1127                 return new AssemblyNameExtension("D, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1128             }
1129 
1130             if (String.Compare(path, s_regress442570_BDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1131             {
1132                 // Simulate a strongly named assembly.
1133                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
1134             }
1135 
1136             if (String.Compare(path, @"c:\Regress387218\v2\D.dll", StringComparison.OrdinalIgnoreCase) == 0)
1137             {
1138                 // Simulate a strongly named assembly.
1139                 return new AssemblyNameExtension("D, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=null");
1140             }
1141 
1142             if (String.Compare(path, @"c:\Regress390219\v1\D.dll", StringComparison.OrdinalIgnoreCase) == 0)
1143             {
1144                 // Simulate a strongly named assembly.
1145                 return new AssemblyNameExtension("D, Version=1.0.0.0, Culture=fr, PublicKeyToken=b77a5c561934e089");
1146             }
1147 
1148             if (String.Compare(path, @"c:\Regress390219\v2\D.dll", StringComparison.OrdinalIgnoreCase) == 0)
1149             {
1150                 // Simulate a strongly named assembly.
1151                 return new AssemblyNameExtension("D, Version=2.0.0.0, Culture=en, PublicKeyToken=b77a5c561934e089");
1152             }
1153 
1154             if (String.Compare(path, s_regress442570_BDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1155             {
1156                 // Simulate a strongly named assembly.
1157                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
1158             }
1159 
1160             if (String.Compare(path, @"c:\MyStronglyNamed\A.dll", StringComparison.OrdinalIgnoreCase) == 0)
1161             {
1162                 // Simulate a strongly named assembly.
1163                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=neUtral, PublicKeyToken=b77a5c561934e089");
1164             }
1165 
1166             if (String.Compare(path, @"c:\MyNameMismatch\Foo.dll", StringComparison.OrdinalIgnoreCase) == 0)
1167             {
1168                 // Notice the metadata assembly name does not match the base file name.
1169                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=neUtral, PublicKeyToken=b77a5c561934e089");
1170             }
1171 
1172             if (String.Compare(path, @"c:\MyEscapedName\=A=.dll", StringComparison.OrdinalIgnoreCase) == 0)
1173             {
1174                 // Notice the metadata assembly name does not match the base file name.
1175                 return new AssemblyNameExtension("\\=A\\=, Version=2.0.0.0, Culture=neUtral, PublicKeyToken=b77a5c561934e089", true);
1176             }
1177 
1178             if (String.Compare(path, @"c:\MyEscapedName\__'ASP'dw0024ry.dll", StringComparison.OrdinalIgnoreCase) == 0)
1179             {
1180                 // Notice the metadata assembly name does not match the base file name.
1181                 return new AssemblyNameExtension("__\\'ASP\\'dw0024ry", true);
1182             }
1183 
1184             if (String.Compare(path, @"c:\MyInaccessible\A.dll", StringComparison.OrdinalIgnoreCase) == 0)
1185             {
1186                 // Simulate an assembly that throws an UnauthorizedAccessException upon access.
1187                 throw new UnauthorizedAccessException();
1188             }
1189 
1190             if (String.Compare(path, Path.Combine(Path.GetTempPath(), @"RawFileNameRelative\System.Xml.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1191             {
1192                 return new AssemblyNameExtension(AssemblyRef.SystemXml);
1193             }
1194 
1195             if (String.Compare(path, Path.Combine(Path.GetTempPath(), @"RelativeAssemblyFiles\System.Xml.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1196             {
1197                 return new AssemblyNameExtension(AssemblyRef.SystemXml);
1198             }
1199 
1200             if (String.Compare(path, Path.Combine(s_myVersion20Path, "System.XML.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1201             {
1202                 // Simulate a strongly named assembly.
1203                 return new AssemblyNameExtension(AssemblyRef.SystemXml);
1204             }
1205 
1206             // This is an assembly with an earlier version.
1207             if (String.Compare(path, Path.Combine(s_myProjectPath, "System.Xml.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1208             {
1209                 // Simulate a strongly named assembly.
1210                 return new AssemblyNameExtension(AssemblyRef.SystemXml);
1211             }
1212 
1213             // This is an assembly with an incorrect PKT.
1214             if (String.Compare(path, Path.Combine(s_myProjectPath, "System.Data.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1215             {
1216                 // Simulate a strongly named assembly.
1217                 return new AssemblyNameExtension("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=A77a5c561934e089");
1218             }
1219 
1220             if (path.EndsWith(Path.Combine(s_myVersion20Path, "MyGacAssembly.dll")))
1221             {
1222                 // Simulate a strongly named assembly.
1223                 return new AssemblyNameExtension("MyGacAssembly, Version=9.2.3401.1, Culture=neutral, PublicKeyToken=a6694b450823df78");
1224             }
1225 
1226             if (String.Compare(path, Path.Combine(s_myVersion20Path, "System.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1227             {
1228                 // Simulate a strongly named assembly.
1229                 return new AssemblyNameExtension("System, VeRSion=2.0.0.0, Culture=neutRAl, PublicKeyToken=b77a5c561934e089");
1230             }
1231 
1232             if (String.Compare(path, Path.Combine(s_myVersion40Path, "System.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1233             {
1234                 // Simulate a strongly named assembly.
1235                 return new AssemblyNameExtension("System, VeRSion=4.0.0.0, Culture=neutRAl, PublicKeyToken=b77a5c561934e089");
1236             }
1237 
1238             if (String.Compare(path, Path.Combine(s_myVersion90Path, "System.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1239             {
1240                 // Simulate a strongly named assembly.
1241                 return new AssemblyNameExtension("System, VeRSion=9.0.0.0, Culture=neutRAl, PublicKeyToken=b77a5c561934e089");
1242             }
1243 
1244             if
1245             (
1246                 String.Compare(path, Path.Combine(s_myVersion20Path, "System.Data.dll"), StringComparison.OrdinalIgnoreCase) == 0
1247             )
1248             {
1249                 // Simulate a strongly named assembly.
1250                 return new AssemblyNameExtension(AssemblyRef.SystemData);
1251             }
1252 
1253             if (path.EndsWith(s_myLibraries_V1_DDllPath))
1254             {
1255                 // Version 1 of D
1256                 return new AssemblyNameExtension("D, Version=1.0.0.0, CulTUre=neutral, PublicKeyToken=aaaaaaaaaaaaaaaa");
1257             }
1258 
1259             if (path.EndsWith(@"c:\RogueLibraries\v1\D.dll"))
1260             {
1261                 // Version 1 of D, but with a different PKT
1262                 return new AssemblyNameExtension("D, VERsion=1.0.0.0, Culture=neutral, PublicKeyToken=bbbbbbbbbbbbbbbb");
1263             }
1264 
1265             if (path.EndsWith(s_myLibraries_V1_E_EDllPath))
1266             {
1267                 return new AssemblyNameExtension("E, Version=0.0.0.0, Culture=neutral, PUBlicKeyToken=null");
1268             }
1269 
1270 
1271             if (String.Compare(path, s_unifyMeDll_V05Path, StringComparison.OrdinalIgnoreCase) == 0)
1272             {
1273                 throw new FileNotFoundException();
1274             }
1275 
1276             if (String.Compare(path, s_unifyMeDll_V10Path, StringComparison.OrdinalIgnoreCase) == 0)
1277             {
1278                 return new AssemblyNameExtension("UnifyMe, Version=1.0.0.0, Culture=nEUtral, PublicKeyToken=b77a5c561934e089, ProcessorArchitecture=MSIL");
1279             }
1280 
1281             if (String.Compare(path, @"C:\Framework\Everett\System.dll", StringComparison.OrdinalIgnoreCase) == 0)
1282             {
1283                 return new AssemblyNameExtension("System, Version=1.0.5000.0, Culture=neutral, PublICKeyToken=" + AssemblyRef.EcmaPublicKey);
1284             }
1285 
1286             if (String.Compare(path, @"C:\Framework\Whidbey\System.dll", StringComparison.OrdinalIgnoreCase) == 0)
1287             {
1288                 return new AssemblyNameExtension("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.EcmaPublicKey);
1289             }
1290 
1291 
1292             if (String.Compare(path, Path.Combine(s_myApp_V10Path, "DependsOnEverettSystem.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1293             {
1294                 return new AssemblyNameExtension("DependsOnEverettSystem, VersION=1.0.5000.0, Culture=neutral, PublicKeyToken=feedbeadbadcadbe");
1295             }
1296 
1297             if (String.Compare(path, Path.Combine(s_myApp_V05Path, "DependsOnUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1298             {
1299                 return new AssemblyNameExtension("DependsOnUnified, Version=0.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
1300             }
1301 
1302             if (String.Compare(path, @"C:\Regress339786\FolderA\C.dll", StringComparison.OrdinalIgnoreCase) == 0)
1303             {
1304                 return new AssemblyNameExtension("C, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1305             }
1306 
1307             if (String.Compare(path, @"C:\Regress339786\FolderB\C.dll", StringComparison.OrdinalIgnoreCase) == 0)
1308             {
1309                 return new AssemblyNameExtension("C, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
1310             }
1311 
1312             if (String.Compare(path, Path.Combine(s_myApp_V10Path, "DependsOnUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1313             {
1314                 return new AssemblyNameExtension("DependsOnUnified, VERSion=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
1315             }
1316 
1317             if (String.Compare(path, Path.Combine(s_myApp_V20Path, "DependsOnUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1318             {
1319                 return new AssemblyNameExtension("DependsOnUnified, VeRSIon=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
1320             }
1321 
1322             if (String.Compare(path, Path.Combine(s_myApp_V30Path, "DependsOnUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1323             {
1324                 return new AssemblyNameExtension("DependsOnUnified, Version=3.0.0.0, Culture=neutral, PublicKEYToken=b77a5c561934e089");
1325             }
1326 
1327             if (String.Compare(path, s_unifyMeDll_V20Path, StringComparison.OrdinalIgnoreCase) == 0)
1328             {
1329                 return new AssemblyNameExtension("UnifyMe, Version=2.0.0.0, Culture=neutral, PublicKeyTOKEn=b77a5c561934e089");
1330             }
1331 
1332             if (String.Compare(path, s_unifyMeDll_V30Path, StringComparison.OrdinalIgnoreCase) == 0)
1333             {
1334                 return new AssemblyNameExtension("UnifyMe, Version=3.0.0.0, Culture=neutral, PublICkeyToken=b77a5c561934e089");
1335             }
1336 
1337             if (path.EndsWith(s_myLibraries_V2_DDllPath))
1338             {
1339                 return new AssemblyNameExtension("D, VErsion=2.0.0.0, CulturE=neutral, PublicKEyToken=aaaaaaaaaaaaaaaa");
1340             }
1341 
1342             if (path.EndsWith(s_myLibraries_V1_GDllPath))
1343             {
1344                 return new AssemblyNameExtension("G, Version=1.0.0.0, Culture=neutral, PublicKEyToken=aaaaaaaaaaaaaaaa");
1345             }
1346 
1347             if (path.EndsWith(s_myLibraries_V2_GDllPath))
1348             {
1349                 return new AssemblyNameExtension("G, Version=2.0.0.0, Culture=neutral, PublicKEyToken=aaaaaaaaaaaaaaaa");
1350             }
1351 
1352             if (String.Compare(path, @"C:\Regress317975\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
1353             {
1354                 return new AssemblyNameExtension("A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
1355             }
1356             if (String.Compare(path, @"C:\Regress317975\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
1357             {
1358                 return new AssemblyNameExtension("B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
1359             }
1360             if (String.Compare(path, @"C:\Regress317975\v2\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
1361             {
1362                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1363             }
1364 
1365             // Set up assembly names for testing target framework version checks
1366             // Is version 4 and will only depends on 4.0 assemblies
1367             if (String.Compare(path, s_40ComponentDependsOnOnlyv4AssembliesDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1368             {
1369                 return new AssemblyNameExtension("DependsOnOnlyv4Assemblies, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
1370             }
1371 
1372             // Is version 9 and will not have any dependencies, will be in the redist list
1373             if (String.Compare(path, Path.Combine(s_myComponentsMiscPath, "ReferenceVersion9.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1374             {
1375                 return new AssemblyNameExtension("ReferenceVersion9, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
1376             }
1377 
1378             // Is a third party assembly which depends on a version 9 assembly
1379             if (String.Compare(path, Path.Combine(s_myComponentsMiscPath, "DependsOn9.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1380             {
1381                 return new AssemblyNameExtension("DependsOn9, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
1382             }
1383 
1384             //A second assembly which depends on version 9 framework assemblies.
1385             if (String.Compare(path, Path.Combine(s_myComponentsMiscPath, "DependsOn9Also.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1386             {
1387                 return new AssemblyNameExtension("DependsOn9Also, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
1388             }
1389 
1390             if (String.Compare(path, Path.Combine(s_myComponents10Path, "DependsOn9.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1391             {
1392                 return new AssemblyNameExtension("DependsOn9, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
1393             }
1394 
1395             if (String.Compare(path, Path.Combine(s_myComponents20Path, "DependsOn9.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1396             {
1397                 return new AssemblyNameExtension("DependsOn9, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089");
1398             }
1399 
1400             if (String.Compare(path, s_regress444809_ADllPath, StringComparison.OrdinalIgnoreCase) == 0)
1401             {
1402                 // Simulate a strongly named assembly.
1403                 return new AssemblyNameExtension("A, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1404             }
1405 
1406             if (String.Compare(path, s_regress444809_V2_ADllPath, StringComparison.OrdinalIgnoreCase) == 0)
1407             {
1408                 // Simulate a strongly named assembly.
1409                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=null");
1410             }
1411 
1412             if (String.Compare(path, s_regress444809_BDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1413             {
1414                 // Simulate a strongly named assembly.
1415                 return new AssemblyNameExtension("B, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1416             }
1417 
1418             if (String.Compare(path, s_regress444809_CDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1419             {
1420                 // Simulate a strongly named assembly.
1421                 return new AssemblyNameExtension("C, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1422             }
1423 
1424             if (String.Compare(path, s_regress444809_DDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1425             {
1426                 // Simulate a strongly named assembly.
1427                 return new AssemblyNameExtension("D, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1428             }
1429 
1430             if (String.Compare(path, @"C:\Regress714052\X86\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
1431             {
1432                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=X86");
1433             }
1434             if (String.Compare(path, @"C:\Regress714052\Mix\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
1435             {
1436                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=X86");
1437             }
1438             if (String.Compare(path, @"C:\Regress714052\Mix\a.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1439             {
1440                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=MSIL");
1441             }
1442 
1443             if (String.Compare(path, @"C:\Regress714052\MSIL\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
1444             {
1445                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=MSIL");
1446             }
1447 
1448             if (String.Compare(path, @"C:\Regress714052\None\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
1449             {
1450                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1451             }
1452             if (String.Compare(path, @"C:\Regress714052\X86\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
1453             {
1454                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=X86");
1455             }
1456             if (String.Compare(path, @"C:\Regress714052\Mix\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
1457             {
1458                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=X86");
1459             }
1460             if (String.Compare(path, @"C:\Regress714052\Mix\b.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1461             {
1462                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=MSIL");
1463             }
1464             if (String.Compare(path, @"C:\Regress714052\MSIL\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
1465             {
1466                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=MSIL");
1467             }
1468             if (String.Compare(path, @"C:\Regress714052\None\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
1469             {
1470                 return new AssemblyNameExtension("B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1471             }
1472             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "V.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1473             {
1474                 return new AssemblyNameExtension("V, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1475             }
1476             if (String.Compare(path, Path.Combine(s_myComponents2RootPath, "W.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1477             {
1478                 return new AssemblyNameExtension("W, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1479             }
1480             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "X.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1481             {
1482                 return new AssemblyNameExtension("X, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1483             }
1484 
1485             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "Z.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1486             {
1487                 return new AssemblyNameExtension("Z, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1488             }
1489 
1490             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "Y.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1491             {
1492                 return new AssemblyNameExtension("Y, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1493             }
1494 
1495             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "Microsoft.Build.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1496             {
1497                 return new AssemblyNameExtension("Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
1498             }
1499 
1500             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "DependsOnMSBuild12.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1501             {
1502                 return new AssemblyNameExtension("DependsOnMSBuild12, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1503             }
1504 
1505             if (String.Compare(path, @"C:\WinMD\v4\MsCorlib.dll", StringComparison.OrdinalIgnoreCase) == 0)
1506             {
1507                 // Simulate a strongly named assembly.
1508                 return new AssemblyNameExtension("mscorlib, Version=4.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
1509             }
1510 
1511             if (String.Compare(path, @"C:\WinMD\v255\MsCorlib.dll", StringComparison.OrdinalIgnoreCase) == 0)
1512             {
1513                 // Simulate a strongly named assembly.
1514                 return new AssemblyNameExtension("mscorlib, Version=255.255.255.255, Culture=Neutral, PublicKeyToken=b77a5c561934e089");
1515             }
1516 
1517             if (String.Compare(path, @"C:\WinMD\DotNetAssemblyDependsOnWinMD.dll", StringComparison.OrdinalIgnoreCase) == 0)
1518             {
1519                 // Simulate a strongly named assembly.
1520                 return new AssemblyNameExtension("DotNetAssemblyDependsOnWinMD, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1521             }
1522 
1523             if (String.Compare(path, @"C:\WinMD\DotNetAssemblyDependsOn255WinMD.dll", StringComparison.OrdinalIgnoreCase) == 0)
1524             {
1525                 // Simulate a strongly named assembly.
1526                 return new AssemblyNameExtension("DotNetAssemblyDependsOn255WinMD, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1527             }
1528 
1529             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1530             {
1531                 // Simulate a strongly named assembly.
1532                 return new AssemblyNameExtension("SampleWindowsRuntimeOnly, Version=1.0.0.0");
1533             }
1534 
1535             if (String.Compare(path, @"C:\WinMDArchVerification\DependsOnInvalidPeHeader.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1536             {
1537                 // Simulate a strongly named assembly.
1538                 return new AssemblyNameExtension("DependsOnInvalidPeHeader, Version=1.0.0.0");
1539             }
1540             if (String.Compare(path, @"C:\WinMDArchVerification\DependsOnAmd64.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1541             {
1542                 // Simulate a strongly named assembly.
1543                 return new AssemblyNameExtension("DependsOnAmd64, Version=1.0.0.0");
1544             }
1545             if (String.Compare(path, @"C:\WinMDArchVerification\DependsOnArm.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1546             {
1547                 // Simulate a strongly named assembly.
1548                 return new AssemblyNameExtension("DependsOnArm, Version=1.0.0.0");
1549             }
1550             if (String.Compare(path, @"C:\WinMDArchVerification\DependsOnIA64.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1551             {
1552                 // Simulate a strongly named assembly.
1553                 return new AssemblyNameExtension("DependsOnIA64, Version=1.0.0.0");
1554             }
1555             if (String.Compare(path, @"C:\WinMDArchVerification\DependsOnArmv7.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1556             {
1557                 // Simulate a strongly named assembly.
1558                 return new AssemblyNameExtension("DependsOnArmv7, Version=1.0.0.0");
1559             }
1560             if (String.Compare(path, @"C:\WinMDArchVerification\DependsOnX86.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1561             {
1562                 // Simulate a strongly named assembly.
1563                 return new AssemblyNameExtension("DependsOnX86, Version=1.0.0.0");
1564             }
1565             if (String.Compare(path, @"C:\WinMDArchVerification\DependsOnUnknown.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1566             {
1567                 // Simulate a strongly named assembly.
1568                 return new AssemblyNameExtension("DependsOnUnknown, Version=1.0.0.0");
1569             }
1570             if (String.Compare(path, @"C:\WinMDArchVerification\DependsOnAnyCPUUnknown.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1571             {
1572                 // Simulate a strongly named assembly.
1573                 return new AssemblyNameExtension("DependsOnAnyCPUUnknown, Version=1.0.0.0");
1574             }
1575             if (String.Compare(path, @"C:\WinMD\WinMDWithVersion255.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1576             {
1577                 // Simulate a strongly named assembly.
1578                 return new AssemblyNameExtension("WinMDWithVersion255, Version=255.255.255.255");
1579             }
1580 
1581             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly2.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1582             {
1583                 // Simulate a strongly named assembly.
1584                 return new AssemblyNameExtension("SampleWindowsRuntimeOnly2, Version=1.0.0.0");
1585             }
1586 
1587             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly3.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1588             {
1589                 // Simulate a strongly named assembly.
1590                 return new AssemblyNameExtension("SampleWindowsRuntimeOnly3, Version=1.0.0.0");
1591             }
1592 
1593             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly4.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1594             {
1595                 // Simulate a strongly named assembly.
1596                 return new AssemblyNameExtension("SampleWindowsRuntimeOnly4, Version=1.0.0.0");
1597             }
1598 
1599             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeReferencingSystem.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1600             {
1601                 // Simulate a strongly named assembly.
1602                 return new AssemblyNameExtension("SampleWindowsRuntimeReferencingSystem, Version=1.0.0.0");
1603             }
1604 
1605             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeReferencingSystemDNE.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1606             {
1607                 // Simulate a strongly named assembly.
1608                 return new AssemblyNameExtension("SampleWindowsRuntimeReferencingSystemDNE, Version=1.0.0.0");
1609             }
1610 
1611             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeAndCLR.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1612             {
1613                 // Simulate a strongly named assembly.
1614                 return new AssemblyNameExtension("SampleWindowsRuntimeAndCLR, Version=1.0.0.0");
1615             }
1616 
1617             if (String.Compare(path, @"C:\MyWinMDComponents\MyGridWinMD.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1618             {
1619                 // Simulate a strongly named assembly.
1620                 return new AssemblyNameExtension("MyGridWinMD, Version=1.0.0.0");
1621             }
1622 
1623             if (String.Compare(path, @"C:\MyWinMDComponents2\MyGridWinMD.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1624             {
1625                 // Simulate a strongly named assembly.
1626                 return new AssemblyNameExtension("MyGridWinMD, Version=2.0.0.0");
1627             }
1628 
1629             if (String.Compare(path, @"C:\MyWinMDComponent7s\MyGridWinMD.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1630             {
1631                 // Simulate a strongly named assembly.
1632                 return new AssemblyNameExtension("MyGridWinMD, Version=1.0.0.0");
1633             }
1634 
1635             if (String.Compare(path, @"C:\MyWinMDComponents9\MyGridWinMD.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1636             {
1637                 // Simulate a strongly named assembly.
1638                 return new AssemblyNameExtension("MyGridWinMD, Version=1.0.0.0");
1639             }
1640 
1641             if (String.Compare(path, @"C:\MyWinMDComponentsVv1\MyGridWinMD2.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1642             {
1643                 // Simulate a strongly named assembly.
1644                 return new AssemblyNameExtension("MyGridWinMD2, Version=1.0.0.0");
1645             }
1646 
1647             if (String.Compare(path, @"C:\MyWinMDComponentsV1\MyGridWinMD3.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1648             {
1649                 // Simulate a strongly named assembly.
1650                 return new AssemblyNameExtension("MyGridWinMD3, Version=1.0.0.0");
1651             }
1652 
1653             if (String.Compare(path, @"C:\FakeSDK\References\Debug\X86\DebugX86SDKWinMD.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1654             {
1655                 // Simulate a strongly named assembly.
1656                 return new AssemblyNameExtension("DebugX86SDKWinMD, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1657             }
1658 
1659             if (String.Compare(path, @"C:\FakeSDK\References\Debug\Neutral\DebugNeutralSDKWinMD.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1660             {
1661                 // Simulate a strongly named assembly.
1662                 return new AssemblyNameExtension("DebugNeutralSDKWinMD, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1663             }
1664 
1665             if (String.Compare(path, @"C:\FakeSDK\References\CommonConfiguration\x86\x86SDKWinMD.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1666             {
1667                 // Simulate a strongly named assembly.
1668                 return new AssemblyNameExtension("X86SDKWinMD, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1669             }
1670 
1671             if (String.Compare(path, @"C:\FakeSDK\References\CommonConfiguration\Neutral\NeutralSDKWinMD.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
1672             {
1673                 // Simulate a strongly named assembly.
1674                 return new AssemblyNameExtension("NeutralSDKWINMD, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1675             }
1676 
1677             if (String.Compare(path, @"C:\FakeSDK\References\Debug\X86\DebugX86SDKRA.dll", StringComparison.OrdinalIgnoreCase) == 0)
1678             {
1679                 // Simulate a strongly named assembly.
1680                 return new AssemblyNameExtension("Debugx86SDKRA, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1681             }
1682 
1683             if (String.Compare(path, @"C:\FakeSDK\References\Debug\Neutral\DebugNeutralSDKRA.dll", StringComparison.OrdinalIgnoreCase) == 0)
1684             {
1685                 // Simulate a strongly named assembly.
1686                 return new AssemblyNameExtension("DebugNeutralSDKRA, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1687             }
1688 
1689             if (String.Compare(path, @"C:\FakeSDK\References\CommonConfiguration\x86\x86SDKRA.dll", StringComparison.OrdinalIgnoreCase) == 0)
1690             {
1691                 // Simulate a strongly named assembly.
1692                 return new AssemblyNameExtension("X86SDKRA, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1693             }
1694 
1695             if (String.Compare(path, @"C:\FakeSDK\References\CommonConfiguration\Neutral\NeutralSDKRA.dll", StringComparison.OrdinalIgnoreCase) == 0)
1696             {
1697                 // Simulate a strongly named assembly.
1698                 return new AssemblyNameExtension("NeutralSDKRA, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1699             }
1700 
1701             if (String.Compare(path, @"C:\FakeSDK\References\Debug\X86\SDKReference.dll", StringComparison.OrdinalIgnoreCase) == 0)
1702             {
1703                 // Simulate a strongly named assembly.
1704                 return new AssemblyNameExtension("SDKReference, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1705             }
1706 
1707             if (String.Compare(path, @"C:\DirectoryContainsOnlyDll\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
1708             {
1709                 // Simulate a strongly named assembly.
1710                 return new AssemblyNameExtension("A, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1711             }
1712 
1713             if (String.Compare(path, @"C:\DirectoryContainsdllAndWinmd\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
1714             {
1715                 // Simulate a strongly named assembly.
1716                 return new AssemblyNameExtension("b, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1717             }
1718 
1719             if (String.Compare(path, @"C:\DirectoryContainsdllAndWinmd\c.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1720             {
1721                 // Simulate a strongly named assembly.
1722                 return new AssemblyNameExtension("C, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1723             }
1724 
1725             if (String.Compare(path, @"C:\DirectoryContainstwoWinmd\a.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1726             {
1727                 // Simulate a strongly named assembly.
1728                 return new AssemblyNameExtension("A, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1729             }
1730 
1731             if (String.Compare(path, @"C:\DirectoryContainstwoWinmd\c.winmd", StringComparison.OrdinalIgnoreCase) == 0)
1732             {
1733                 // Simulate a strongly named assembly.
1734                 return new AssemblyNameExtension("C, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null");
1735             }
1736 
1737             if (string.Compare(path, @"c:\assemblyfromconfig\folder_x64\assemblyfromconfig_common.dll", StringComparison.OrdinalIgnoreCase) == 0)
1738             {
1739                 return new AssemblyNameExtension("assemblyfromconfig_common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=AMD64");
1740             }
1741 
1742             if (string.Compare(path, @"c:\assemblyfromconfig\folder_x86\assemblyfromconfig_common.dll", StringComparison.OrdinalIgnoreCase) == 0)
1743             {
1744                 return new AssemblyNameExtension("assemblyfromconfig_common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=X86");
1745             }
1746 
1747             if (string.Compare(path, @"c:\assemblyfromconfig\folder5010x64\v5assembly.dll", StringComparison.OrdinalIgnoreCase) == 0)
1748             {
1749                 return new AssemblyNameExtension("v5assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=AMD64");
1750             }
1751 
1752             if (string.Compare(path, @"c:\assemblyfromconfig\folder501000x86\v5assembly.dll", StringComparison.OrdinalIgnoreCase) == 0)
1753             {
1754                 return new AssemblyNameExtension("v5assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null, ProcessorArchitecture=X86");
1755             }
1756 
1757             if (string.Compare(path, s_dependsOnNuGet_ADllPath, StringComparison.OrdinalIgnoreCase) == 0)
1758             {
1759                 return new AssemblyNameExtension("A, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1760             }
1761 
1762             if (string.Compare(path, s_nugetCache_N_Lib_NDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1763             {
1764                 return new AssemblyNameExtension("N, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null");
1765             }
1766 
1767             string defaultName = String.Format("{0}, Version=0.0.0.0, PublicKeyToken=null, Culture=Neutral", Path.GetFileNameWithoutExtension(path));
1768             return new AssemblyNameExtension(defaultName);
1769         }
1770 
1771 
1772         /// <summary>
1773         /// Cached implementation. Given an assembly name, crack it open and retrieve the list of dependent
1774         /// assemblies and  the list of scatter files.
1775         /// </summary>
1776         /// <param name="path">Path to the assembly.</param>
1777         /// <param name="assemblyMetadataCache">Ignored.</param>
1778         /// <param name="dependencies">Receives the list of dependencies.</param>
1779         /// <param name="scatterFiles">Receives the list of associated scatter files.</param>
1780         /// <param name="frameworkName">Receives the assembly framework name.</param>
GetAssemblyMetadata( string path, ConcurrentDictionary<string, AssemblyMetadata> assemblyMetadataCache, out AssemblyNameExtension[] dependencies, out string[] scatterFiles, out FrameworkNameVersioning frameworkName )1781         internal static void GetAssemblyMetadata
1782         (
1783             string path,
1784             ConcurrentDictionary<string, AssemblyMetadata> assemblyMetadataCache,
1785             out AssemblyNameExtension[] dependencies,
1786             out string[] scatterFiles,
1787             out FrameworkNameVersioning frameworkName
1788         )
1789         {
1790             dependencies = GetDependencies(path);
1791             scatterFiles = null;
1792             frameworkName = GetTargetFrameworkAttribute(path);
1793 
1794             if (@"C:\Regress275161\a.dll" == path)
1795             {
1796                 scatterFiles = new string[]
1797                 {
1798                     @"m1.netmodule",
1799                     @"m2.netmodule"
1800                 };
1801             }
1802         }
1803 
1804         /// <summary>
1805         /// Cached implementation. Given an assembly name, crack it open and retrieve the TargetFrameworkAttribute
1806         /// </summary>
GetTargetFrameworkAttribute( string path )1807         internal static FrameworkNameVersioning GetTargetFrameworkAttribute
1808         (
1809             string path
1810         )
1811         {
1812             FrameworkNameVersioning frameworkName = null;
1813 
1814             if (String.Equals(path, Path.Combine(s_frameworksPath, "DependsOnFoo4Framework.dll"), StringComparison.OrdinalIgnoreCase))
1815             {
1816                 frameworkName = new FrameworkNameVersioning("FoO, Version=v4.0");
1817             }
1818             else if (String.Equals(path, Path.Combine(s_frameworksPath, "DependsOnFoo45Framework.dll"), StringComparison.OrdinalIgnoreCase))
1819             {
1820                 frameworkName = new FrameworkNameVersioning("FoO, Version=v4.5");
1821             }
1822             else if (String.Equals(path, Path.Combine(s_frameworksPath, "DependsOnFoo35Framework.dll"), StringComparison.OrdinalIgnoreCase))
1823             {
1824                 frameworkName = new FrameworkNameVersioning("FoO, Version=v3.5");
1825             }
1826             else if (String.Equals(path, Path.Combine(s_frameworksPath, "IndirectDependsOnFoo4Framework.dll"), StringComparison.OrdinalIgnoreCase))
1827             {
1828                 frameworkName = new FrameworkNameVersioning("FoO, Version=v4.0");
1829             }
1830             else if (String.Equals(path, Path.Combine(s_frameworksPath, "IndirectDependsOnFoo45Framework.dll"), StringComparison.OrdinalIgnoreCase))
1831             {
1832                 frameworkName = new FrameworkNameVersioning("FoO, Version=v4.0");
1833             }
1834             else if (String.Equals(path, Path.Combine(s_frameworksPath, "IndirectDependsOnFoo35Framework.dll"), StringComparison.OrdinalIgnoreCase))
1835             {
1836                 frameworkName = new FrameworkNameVersioning("FoO, Version=v4.0");
1837             }
1838 
1839             return frameworkName;
1840         }
1841 
1842         /// <summary>
1843         /// Given an assembly, with optional assemblyName return all of the dependent assemblies.
1844         /// </summary>
1845         /// <param name="path">The full path to the parent assembly</param>
1846         /// <returns>The array of dependent assembly names.</returns>
GetDependencies(string path)1847         internal static AssemblyNameExtension[] GetDependencies(string path)
1848         {
1849             if (String.Compare(path, Path.Combine(s_frameworksPath, "IndirectDependsOnFoo4Framework.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1850             {
1851                 return new AssemblyNameExtension[]
1852                 {
1853                     new AssemblyNameExtension("DependsOnFoo4Framework, Version=4.0.0.0, PublicKeyToken=null, Culture=Neutral")
1854                 };
1855             }
1856 
1857             if (String.Compare(path, Path.Combine(s_frameworksPath, "IndirectDependsOnFoo45Framework.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1858             {
1859                 return new AssemblyNameExtension[]
1860                 {
1861                     new AssemblyNameExtension("DependsOnFoo45Framework, Version=4.5.0.0, PublicKeyToken=null, Culture=Neutral")
1862                 };
1863             }
1864 
1865             if (String.Compare(path, Path.Combine(s_frameworksPath, "IndirectDependsOnFoo35Framework.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1866             {
1867                 return new AssemblyNameExtension[]
1868                 {
1869                     new AssemblyNameExtension("DependsOnFoo35Framework, Version=3.5.0.0, PublicKeyToken=null, Culture=Neutral")
1870                 };
1871             }
1872 
1873             if (String.Compare(path, s_regress454863_ADllPath, StringComparison.OrdinalIgnoreCase) == 0)
1874             {
1875                 return new AssemblyNameExtension[]
1876                 {
1877                     new AssemblyNameExtension("B, Version=0.0.0.0, PublicKeyToken=null, Culture=Neutral")
1878                 };
1879             }
1880 
1881             if (String.Compare(path, s_regress442570_BDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1882             {
1883                 return new AssemblyNameExtension[]
1884                 {
1885                     new AssemblyNameExtension(" A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
1886                 };
1887             }
1888 
1889             if (String.Compare(path, @"C:\Regress313747\Microsoft.Office.Interop.Excel.dll", StringComparison.OrdinalIgnoreCase) == 0)
1890             {
1891                 return new AssemblyNameExtension[]
1892                 {
1893                     new AssemblyNameExtension(" Office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
1894                 };
1895             }
1896 
1897             if (String.Compare(path, @"C:\Regress313747\MS.Internal.Test.Automation.Office.Excel.dll", StringComparison.OrdinalIgnoreCase) == 0)
1898             {
1899                 return new AssemblyNameExtension[]
1900                 {
1901                     new AssemblyNameExtension(" Office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5")
1902                 };
1903             }
1904 
1905             if (String.Compare(path, @"c:\Regress387218\A.dll", StringComparison.OrdinalIgnoreCase) == 0)
1906             {
1907                 return new AssemblyNameExtension[]
1908                 {
1909                     new AssemblyNameExtension("D, Version=1.0.0.0, PublicKeyToken=null, Culture=Neutral")
1910                 };
1911             }
1912 
1913             if (String.Compare(path, @"c:\Regress387218\B.dll", StringComparison.OrdinalIgnoreCase) == 0)
1914             {
1915                 return new AssemblyNameExtension[]
1916                 {
1917                     new AssemblyNameExtension("D, Version=2.0.0.0, PublicKeyToken=null, Culture=Neutral")
1918                 };
1919             }
1920 
1921             if (String.Compare(path, @"c:\Regress390219\A.dll", StringComparison.OrdinalIgnoreCase) == 0)
1922             {
1923                 return new AssemblyNameExtension[]
1924                 {
1925                     new AssemblyNameExtension("D, Version=1.0.0.0, PublicKeyToken=b77a5c561934e089, Culture=fr")
1926                 };
1927             }
1928 
1929             if (String.Compare(path, @"c:\Regress390219\B.dll", StringComparison.OrdinalIgnoreCase) == 0)
1930             {
1931                 return new AssemblyNameExtension[]
1932                 {
1933                     new AssemblyNameExtension("D, Version=2.0.0.0,  PublicKeyToken=b77a5c561934e089, Culture=en")
1934                 };
1935             }
1936 
1937             if (String.Compare(path, s_regress442570_BDllPath, StringComparison.OrdinalIgnoreCase) == 0)
1938             {
1939                 return new AssemblyNameExtension[]
1940                 {
1941                     new AssemblyNameExtension(" A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
1942                 };
1943             }
1944 
1945             if (String.Compare(path, @"C:\Regress313747\Microsoft.Office.Interop.Excel.dll", StringComparison.OrdinalIgnoreCase) == 0)
1946             {
1947                 return new AssemblyNameExtension[]
1948                 {
1949                     new AssemblyNameExtension(" Office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
1950                 };
1951             }
1952 
1953             if (String.Compare(path, @"C:\Regress313747\MS.Internal.Test.Automation.Office.Excel.dll", StringComparison.OrdinalIgnoreCase) == 0)
1954             {
1955                 return new AssemblyNameExtension[]
1956                 {
1957                     new AssemblyNameExtension(" Office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=94de0004b6e3fcc5")
1958                 };
1959             }
1960 
1961             if (String.Compare(path, @"c:\OldClrBug\DependsMyFileLoadExceptionAssembly.dll", StringComparison.OrdinalIgnoreCase) == 0)
1962             {
1963                 return new AssemblyNameExtension[]
1964                 {
1965                     new AssemblyNameExtension("MyFileLoadExceptionAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
1966                 };
1967             }
1968 
1969             if (String.Compare(path, @"c:\Regress563286\DependsOnBadImage.dll", StringComparison.OrdinalIgnoreCase) == 0)
1970             {
1971                 return new AssemblyNameExtension[]
1972                 {
1973                     new AssemblyNameExtension("BadImage, Version=0.0.0.0, PublicKeyToken=null, Culture=Neutral")
1974                 };
1975             }
1976 
1977             if (String.Compare(path, @"c:\MyInaccessible\A.dll", StringComparison.OrdinalIgnoreCase) == 0)
1978             {
1979                 throw new UnauthorizedAccessException();
1980             }
1981 
1982             if (String.Compare(path, @"c:\Regress313086\mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0)
1983             {
1984                 return new AssemblyNameExtension[] { };
1985             }
1986 
1987             if (String.Compare(path, Path.Combine(s_myVersion20Path, "System.dll"), StringComparison.OrdinalIgnoreCase) == 0)
1988             {
1989                 return new AssemblyNameExtension[]
1990                 {
1991                     new AssemblyNameExtension("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
1992                 };
1993             }
1994 
1995             if (String.Compare(path, @"C:\WinMD\DotNetAssemblyDependsOnWinMD.dll", StringComparison.OrdinalIgnoreCase) == 0)
1996             {
1997                 return new AssemblyNameExtension[]
1998                 {
1999                     new AssemblyNameExtension("SampleWindowsRuntimeOnly, Version=1.0.0.0")
2000                 };
2001             }
2002 
2003             if (String.Compare(path, @"C:\WinMD\DotNetAssemblyDependsOn255WinMD.dll", StringComparison.OrdinalIgnoreCase) == 0)
2004             {
2005                 return new AssemblyNameExtension[]
2006                 {
2007                     new AssemblyNameExtension("WinMDWithVersion255, Version=255.255.255.255")
2008                 };
2009             }
2010 
2011             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeAndClr.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
2012             {
2013                 return new AssemblyNameExtension[]
2014                  {
2015                     new AssemblyNameExtension("mscorlib, Version=4.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089")
2016                  };
2017             }
2018 
2019             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
2020             {
2021                 return new AssemblyNameExtension[]
2022                  {
2023                     new AssemblyNameExtension("mscorlib, Version=255.255.255.255, Culture=neutral, PublicKeyToken=b77a5c561934e089")
2024                  };
2025             }
2026 
2027             if (String.Compare(path, @"C:\WinMD\WinMDWithVersion255.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
2028             {
2029                 return new AssemblyNameExtension[]
2030                 {
2031                     new AssemblyNameExtension("mscorlib, Version=255.255.255.255, Culture=neutral, PublicKeyToken=b77a5c561934e089")
2032                 };
2033             }
2034 
2035             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly2.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
2036             {
2037                 return new AssemblyNameExtension[]
2038                 {
2039                     new AssemblyNameExtension("SampleWindowsRuntimeOnly, Version=1.0.0.0")
2040                 };
2041             }
2042 
2043             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly3.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
2044             {
2045                 return new AssemblyNameExtension[]
2046                 {
2047                     new AssemblyNameExtension("mscorlib, Version=255.255.255.255, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
2048                     new AssemblyNameExtension("SampleWindowsRuntimeOnly, Version=1.0.0.0"),
2049                     new AssemblyNameExtension("SampleWindowsRuntimeReferencingSystem, Version=1.0.0.0"),
2050                     new AssemblyNameExtension("WinMDWithVersion255, Version=255.255.255.255")
2051                 };
2052             }
2053 
2054             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeOnly4.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
2055             {
2056                 return new AssemblyNameExtension[]
2057                 {
2058                     new AssemblyNameExtension("mscorlib, Version=255.255.255.255, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
2059                     new AssemblyNameExtension("SampleWindowsRuntimeReferencingSystemDNE, Version=1.0.0.0"),
2060                 };
2061             }
2062 
2063             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeReferencingSystem.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
2064             {
2065                 return new AssemblyNameExtension[]
2066                 {
2067                     new AssemblyNameExtension("mscorlib, Version=255.255.255.255, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
2068                     new AssemblyNameExtension("System, Version=255.255.255.255, Culture=Neutral, PublicKeyToken=b77a5c561934e089")
2069                 };
2070             }
2071 
2072             if (String.Compare(path, @"C:\WinMD\SampleWindowsRuntimeReferencingSystemDNE.Winmd", StringComparison.OrdinalIgnoreCase) == 0)
2073             {
2074                 return new AssemblyNameExtension[]
2075                 {
2076                     new AssemblyNameExtension("mscorlib, Version=255.255.255.255, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
2077                     new AssemblyNameExtension("System.DoesNotExist, Version=255.255.255.255")
2078                 };
2079             }
2080 
2081             if
2082             (
2083                 String.Compare(path, Path.Combine(s_myVersion20Path, "mscorlib.dll"), StringComparison.OrdinalIgnoreCase) == 0
2084                 || String.Compare(path, Path.Combine(s_myVersionPocket20Path, "mscorlib.dll"), StringComparison.OrdinalIgnoreCase) == 0
2085             )
2086             {
2087                 return new AssemblyNameExtension[]
2088                 {
2089                 };
2090             }
2091 
2092             if (String.Compare(path, @"MyRelativeAssembly.dll", StringComparison.OrdinalIgnoreCase) == 0)
2093             {
2094                 return new AssemblyNameExtension[]
2095                 {
2096                 };
2097             }
2098 
2099             if (String.Compare(path, Path.Combine(s_myAppRootPath, "DependsOnSimpleA.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2100             {
2101                 return new AssemblyNameExtension[]
2102                 {
2103                     new AssemblyNameExtension("A, Version=0.0.0.0, PublicKeyToken=null, Culture=Neutral")
2104                 };
2105             }
2106 
2107             if (String.Compare(path, @"C:\Regress312873\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
2108             {
2109                 return new AssemblyNameExtension[]
2110                 {
2111                     new AssemblyNameExtension("A, Version=0.0.0.0, PublickEyToken=null, Culture=Neutral")
2112                 };
2113             }
2114 
2115             if (String.Compare(path, @"C:\Regress339786\FolderA\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
2116             {
2117                 return new AssemblyNameExtension[]
2118                 {
2119                     new AssemblyNameExtension("C, Version=1.0.0.0, PublickEyToken=null, Culture=Neutral")
2120                 };
2121             }
2122 
2123             if (String.Compare(path, @"C:\Regress339786\FolderB\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
2124             {
2125                 return new AssemblyNameExtension[]
2126                 {
2127                     new AssemblyNameExtension("C, Version=2.0.0.0, PublickEyToken=null, Culture=Neutral")
2128                 };
2129             }
2130 
2131             if (String.Compare(path, @"C:\Regress317975\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
2132             {
2133                 return new AssemblyNameExtension[]
2134                 {
2135                     new AssemblyNameExtension("B, Version=1.0.0.0, PublickEyToken=null, Culture=Neutral")
2136                 };
2137             }
2138 
2139             if (String.Compare(path, @"C:\myassemblies\My.Assembly.dll", StringComparison.OrdinalIgnoreCase) == 0)
2140             {
2141                 return new AssemblyNameExtension[]
2142                 {
2143                     new AssemblyNameExtension("mscorlib, Version=2.0.0.0, Culture=NEUtraL, PublicKeyToken=b77a5c561934e089")
2144                 };
2145             }
2146 
2147             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "MyGrid.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2148             {
2149                 return new AssemblyNameExtension[]
2150                 {
2151                     new AssemblyNameExtension("mscorlib, VeRsIon=2.0.0.0, Culture=neuTRal, PublicKeyToken=b77a5c561934e089")
2152                 };
2153             }
2154 
2155             if (String.Compare(path, @"C:\MyRawDropControls\MyRawDropControl.dll", StringComparison.OrdinalIgnoreCase) == 0)
2156             {
2157                 return new AssemblyNameExtension[]
2158                 {
2159                     new AssemblyNameExtension("mscorlib, VeRsIon=2.0.0.0, Culture=neuTRal, PublicKeyToken=b77a5c561934e089")
2160                 };
2161             }
2162 
2163 
2164             if (String.Compare(path, s_myLibraries_ADllPath, StringComparison.OrdinalIgnoreCase) == 0)
2165             {
2166                 return new AssemblyNameExtension[]
2167                 {
2168                     new AssemblyNameExtension("D, Version=1.0.0.0, CuLtUrE=neutral, PublicKeyToken=aaaaaaaaaaaaaaaa")
2169                 };
2170             }
2171 
2172             if (String.Compare(path, s_myLibraries_TDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2173             {
2174                 return new AssemblyNameExtension[]
2175                 {
2176                     new AssemblyNameExtension("D, VeRsIon=1.0.0.0, Culture=neutral, PublicKeyToken=bbbbbbbbbbbbbbbb")
2177                 };
2178             }
2179 
2180             if (String.Compare(path, s_myLibraries_BDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2181             {
2182                 return new AssemblyNameExtension[]
2183                 {
2184                     new AssemblyNameExtension("D, Version=2.0.0.0, Culture=neutral, PuBlIcKeYToken=aaaaaaaaaaaaaaaa"),
2185                     new AssemblyNameExtension("G, Version=2.0.0.0, Culture=neutral, PuBlIcKeYToken=aaaaaaaaaaaaaaaa")
2186                 };
2187             }
2188 
2189             if (String.Compare(path, s_myLibraries_V1_DDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2190             {
2191                 return new AssemblyNameExtension[]
2192                 {
2193                     new AssemblyNameExtension("E, VERSIOn=0.0.0.0, Culture=neutral, PublicKeyToken=null")
2194                 };
2195             }
2196 
2197             if (String.Compare(path, s_myLibraries_V2_DDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2198             {
2199                 return new AssemblyNameExtension[]
2200                 {
2201                     new AssemblyNameExtension("E, Version=0.0.0.0, Culture=neutRAL, PUblicKeyToken=null")
2202                 };
2203             }
2204 
2205             if (String.Compare(path, s_myLibraries_V1_E_EDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2206             {
2207                 return new AssemblyNameExtension[]
2208                 {
2209                 };
2210             }
2211 
2212             if (String.Compare(path, Path.Combine(s_myApp_V05Path, "DependsOnWeaklyNamedUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2213             {
2214                 return new AssemblyNameExtension[]
2215                 {
2216                     new AssemblyNameExtension("UnifyMe, Version=0.0.0.0, PUBLICKeyToken=null, CuLTURE=Neutral")
2217                 };
2218             }
2219 
2220             if (String.Compare(path, Path.Combine(s_myApp_V10Path, "DependsOnEverettSystem.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2221             {
2222                 return new AssemblyNameExtension[]
2223                 {
2224                     new AssemblyNameExtension("System, VeRsiON=1.0.5000.0, Culture=neutral, PublicKeyToken="+AssemblyRef.EcmaPublicKey)
2225                 };
2226             }
2227 
2228             if (String.Compare(path, Path.Combine(s_myApp_V05Path, "DependsOnUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2229             {
2230                 return new AssemblyNameExtension[]
2231                 {
2232                     new AssemblyNameExtension("UnifyMe, Version=0.5.0.0, CuLTUre=neUTral, PubLICKeyToken=b77a5c561934e089")
2233                 };
2234             }
2235 
2236             if (String.Compare(path, Path.Combine(s_myApp_V10Path, "DependsOnUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2237             {
2238                 return new AssemblyNameExtension[]
2239                 {
2240                     new AssemblyNameExtension("UNIFyMe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
2241                 };
2242             }
2243 
2244             if (String.Compare(path, Path.Combine(s_myApp_V20Path, "DependsOnUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2245             {
2246                 return new AssemblyNameExtension[]
2247                 {
2248                     new AssemblyNameExtension("UniFYme, Version=2.0.0.0, Culture=NeutraL, PublicKeyToken=b77a5c561934e089")
2249                 };
2250             }
2251 
2252             if (String.Compare(path, Path.Combine(s_myApp_V30Path, "DependsOnUnified.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2253             {
2254                 return new AssemblyNameExtension[]
2255                 {
2256                     new AssemblyNameExtension("UnIfyMe, Version=3.0.0.0, Culture=nEutral, PublicKEyToken=b77a5c561934e089")
2257                 };
2258             }
2259 
2260             if (String.Compare(path, s_myMissingAssemblyAbsPath, StringComparison.OrdinalIgnoreCase) == 0)
2261             {
2262                 throw new FileNotFoundException(path);
2263             }
2264 
2265             // Set up assembly names for testing target framework version checks
2266             // Is version 4 and will only depends on 4.0 assemblies
2267             if (String.Compare(path, s_40ComponentDependsOnOnlyv4AssembliesDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2268             {
2269                 return new AssemblyNameExtension[]
2270                 {
2271                     new AssemblyNameExtension("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
2272                 };
2273             }
2274 
2275             // Is version 9 and will not have any dependencies, will be in the redist list
2276             if (String.Compare(path, Path.Combine(s_myComponentsMiscPath, "ReferenceVersion9.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2277             {
2278                 return new AssemblyNameExtension[]
2279                 {
2280                     new AssemblyNameExtension("mscorlib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
2281                     new AssemblyNameExtension("RandomAssembly, Version=9.0.0.0, Culture=neutral, PublicKeyToken=c77a5c561934e089")
2282                 };
2283             }
2284 
2285             // Is a third party assembly which depends on a version 9 assembly
2286             if (String.Compare(path, Path.Combine(s_myComponentsMiscPath, "DependsOn9.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2287             {
2288                 return new AssemblyNameExtension[]
2289                 {
2290                     new AssemblyNameExtension("System, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
2291                     new AssemblyNameExtension("System.Data, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
2292                 };
2293             }
2294 
2295             //A second assembly which depends on version 9 framework assemblies.
2296             if (String.Compare(path, Path.Combine(s_myComponentsMiscPath, "DependsOn9Also.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2297             {
2298                 return new AssemblyNameExtension[]
2299                 {
2300                     new AssemblyNameExtension("System, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
2301                 };
2302             }
2303 
2304             if (String.Compare(path, Path.Combine(s_myComponents10Path, "DependsOn9.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2305             {
2306                 return new AssemblyNameExtension[]
2307                 {
2308                     new AssemblyNameExtension("System, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
2309                 };
2310             }
2311 
2312             if (String.Compare(path, Path.Combine(s_myComponents20Path, "DependsOn9.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2313             {
2314                 return new AssemblyNameExtension[]
2315                 {
2316                     new AssemblyNameExtension("System, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
2317                 };
2318             }
2319 
2320             if (String.Compare(path, s_regress444809_CDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2321             {
2322                 return new AssemblyNameExtension[]
2323                 {
2324                     new AssemblyNameExtension("B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"),
2325                     new AssemblyNameExtension("A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
2326                 };
2327             }
2328 
2329             if (String.Compare(path, s_regress444809_BDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2330             {
2331                 return new AssemblyNameExtension[]
2332                 {
2333                     new AssemblyNameExtension("A, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")
2334                 };
2335             }
2336 
2337             if (String.Compare(path, s_regress444809_DDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2338             {
2339                 return new AssemblyNameExtension[]
2340                 {
2341                     new AssemblyNameExtension("A, Version=20.0.0.0, Culture=neutral, PublicKeyToken=null")
2342                 };
2343             }
2344 
2345             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "V.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2346             {
2347                 return new AssemblyNameExtension[]
2348                 {
2349                     new AssemblyNameExtension("W, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")
2350                 };
2351             }
2352 
2353             if (String.Compare(path, Path.Combine(s_myComponents2RootPath, "W.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2354             {
2355                 return new AssemblyNameExtension[] { };
2356             }
2357 
2358             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "X.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2359             {
2360                 return new AssemblyNameExtension[]
2361                 {
2362                     new AssemblyNameExtension("Z, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")
2363                 };
2364             }
2365 
2366             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "Z.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2367             {
2368                 return new AssemblyNameExtension[] { };
2369             }
2370 
2371             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "Y.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2372             {
2373                 return new AssemblyNameExtension[]
2374                 {
2375                     new AssemblyNameExtension("Z, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null")
2376                 };
2377             }
2378 
2379             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "Microsoft.Build.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2380             {
2381                 return new AssemblyNameExtension[] { };
2382             }
2383 
2384             if (String.Compare(path, Path.Combine(s_myComponentsRootPath, "DependsOnMSBuild12.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2385             {
2386                 return new AssemblyNameExtension[]
2387                 {
2388                     new AssemblyNameExtension("Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
2389                 };
2390             }
2391 
2392             if (String.Compare(path, Path.Combine(s_myVersion20Path, "System.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2393             {
2394                 // Simulate a strongly named assembly.
2395                 return new AssemblyNameExtension[]
2396                 {
2397                      new AssemblyNameExtension("msCORlib, Version=2.0.0.0, Culture=NEutral, PublicKeyToken=b77a5c561934e089")
2398                 };
2399             }
2400 
2401             if (String.Compare(path, Path.Combine(s_myVersion40Path, "System.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2402             {
2403                 // Simulate a strongly named assembly.
2404                 return new AssemblyNameExtension[]
2405                 {
2406                      new AssemblyNameExtension("msCORlib, Version=2.0.0.0, Culture=NEutral, PublicKeyToken=b77a5c561934e089")
2407                 };
2408             }
2409 
2410             if (String.Compare(path, Path.Combine(s_myVersion90Path, "System.dll"), StringComparison.OrdinalIgnoreCase) == 0)
2411             {
2412                 // Simulate a strongly named assembly.
2413                 return new AssemblyNameExtension[]
2414                 {
2415                      new AssemblyNameExtension("msCORlib, Version=2.0.0.0, Culture=NEutral, PublicKeyToken=b77a5c561934e089")
2416                 };
2417             }
2418 
2419             if (String.Compare(path, @"C:\DirectoryContainsOnlyDll\a.dll", StringComparison.OrdinalIgnoreCase) == 0)
2420             {
2421                 // Simulate a strongly named assembly.
2422                 return new AssemblyNameExtension[]
2423                 {
2424                      new AssemblyNameExtension("C, Version=1.0.0.0, PublickEyToken=null, Culture=Neutral")
2425                 };
2426             }
2427 
2428             if (String.Compare(path, @"C:\DirectoryContainsdllAndWinmd\b.dll", StringComparison.OrdinalIgnoreCase) == 0)
2429             {
2430                 // Simulate a strongly named assembly.
2431                 return new AssemblyNameExtension[]
2432                 {
2433                      new AssemblyNameExtension("C, Version=1.0.0.0, PublickEyToken=null, Culture=Neutral")
2434                 };
2435             }
2436 
2437             if (String.Compare(path, @"C:\DirectoryContainsdllAndWinmd\c.winmd", StringComparison.OrdinalIgnoreCase) == 0)
2438             {
2439                 // Simulate a strongly named assembly.
2440                 return new AssemblyNameExtension[0];
2441             }
2442 
2443             if (String.Compare(path, @"C:\DirectoryContainstwoWinmd\a.winmd", StringComparison.OrdinalIgnoreCase) == 0)
2444             {
2445                 // Simulate a strongly named assembly.
2446                 return new AssemblyNameExtension[]
2447                 {
2448                      new AssemblyNameExtension("C, Version=1.0.0.0, PublickEyToken=null, Culture=Neutral")
2449                 };
2450             }
2451 
2452             if (String.Compare(path, @"C:\DirectoryContainstwoWinmd\c.winmd", StringComparison.OrdinalIgnoreCase) == 0)
2453             {
2454                 return new AssemblyNameExtension[0];
2455             }
2456 
2457             if (path.StartsWith(@"C:\FakeSDK\", StringComparison.OrdinalIgnoreCase))
2458             {
2459                 return new AssemblyNameExtension[0];
2460             }
2461 
2462             if (String.Compare(path, s_portableDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2463             {
2464                 // Simulate a portable assembly with a reference to System.Runtime
2465                 return new AssemblyNameExtension[]
2466                 {
2467                     GetAssemblyName(s_systemRuntimeDllPath)
2468                 };
2469             }
2470 
2471             if (String.Compare(path, s_netstandardLibraryDllPath, StringComparison.OrdinalIgnoreCase) == 0)
2472             {
2473                 // Simulate a .NET Standard assembly
2474                 return new AssemblyNameExtension[]
2475                 {
2476                     GetAssemblyName(s_netstandardDllPath)
2477                 };
2478             }
2479 
2480             if (String.Compare(path, s_dependsOnNuGet_ADllPath, StringComparison.OrdinalIgnoreCase) == 0)
2481             {
2482                 return new AssemblyNameExtension[]
2483                 {
2484                     new AssemblyNameExtension("N, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
2485                 };
2486             }
2487 
2488             // Use a default list.
2489             return new AssemblyNameExtension[]
2490             {
2491                 new AssemblyNameExtension("SysTem, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77A5c561934e089"),
2492                 new AssemblyNameExtension("msCORlib, Version=2.0.0.0, Culture=NEutral, PublicKeyToken=b77a5c561934e089")
2493             };
2494         }
2495 
2496         /// <summary>
2497         /// Registry access delegate. Given a hive and a view, return the registry base key.
2498         /// </summary>
GetBaseKey(RegistryHive hive, RegistryView view)2499         private static RegistryKey GetBaseKey(RegistryHive hive, RegistryView view)
2500         {
2501             if (hive == RegistryHive.CurrentUser)
2502             {
2503                 return Registry.CurrentUser;
2504             }
2505             else if (hive == RegistryHive.LocalMachine)
2506             {
2507                 return Registry.LocalMachine;
2508             }
2509 
2510             return null;
2511         }
2512 
2513         /// <summary>
2514         /// Simplified registry access delegate. Given a baseKey and a subKey, get all of the subkey
2515         /// names.
2516         /// </summary>
2517         /// <param name="baseKey">The base registry key.</param>
2518         /// <param name="subKey">The subkey</param>
2519         /// <returns>An enumeration of strings.</returns>
GetRegistrySubKeyNames(RegistryKey baseKey, string subKey)2520         private static IEnumerable<string> GetRegistrySubKeyNames(RegistryKey baseKey, string subKey)
2521         {
2522             if (baseKey == Registry.CurrentUser)
2523             {
2524                 if (String.Compare(subKey, @"Software\Regress714052", StringComparison.OrdinalIgnoreCase) == 0)
2525                 {
2526                     return new string[] { };
2527                 }
2528 
2529                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2530                 {
2531                     return new string[] { };
2532                 }
2533 
2534                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\X86", StringComparison.OrdinalIgnoreCase) == 0)
2535                 {
2536                     return new string[] { };
2537                 }
2538 
2539                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\MSIL", StringComparison.OrdinalIgnoreCase) == 0)
2540                 {
2541                     return new string[] { };
2542                 }
2543                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\Mix", StringComparison.OrdinalIgnoreCase) == 0)
2544                 {
2545                     return new string[] { };
2546                 }
2547                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\Mix\Mix", StringComparison.OrdinalIgnoreCase) == 0)
2548                 {
2549                     return new string[] { };
2550                 }
2551                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\None", StringComparison.OrdinalIgnoreCase) == 0)
2552                 {
2553                     return new string[] { };
2554                 }
2555 
2556                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\X86\X86", StringComparison.OrdinalIgnoreCase) == 0)
2557                 {
2558                     return new string[] { };
2559                 }
2560 
2561                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\MSIL\MSIL", StringComparison.OrdinalIgnoreCase) == 0)
2562                 {
2563                     return new string[] { };
2564                 }
2565 
2566                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\None\None", StringComparison.OrdinalIgnoreCase) == 0)
2567                 {
2568                     return new string[] { };
2569                 }
2570 
2571                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework", StringComparison.OrdinalIgnoreCase) == 0)
2572                 {
2573                     return new string[] { "", "vBogusVersion", "v1.a.2.3", "v1.0", "v3.0", "v2.0.50727", "v2.0.x86chk", "RandomJunk" };
2574                 }
2575 
2576                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2577                 {
2578                     return new string[] { "ZControlA", "ZControlB", "Infragistics.GridControl.1.0", "Infragistics.MyHKLMControl.1.0", "Infragistics.MyControlWithFutureTargetNDPVersion.1.0", "Infragistics.MyControlWithPastTargetNDPVersion.1.0", "Infragistics.MyControlWithServicePack.1.0" };
2579                 }
2580                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.x86chk\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2581                 {
2582                     return new string[] { "RawDropControls" };
2583                 }
2584 
2585                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v3.0\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2586                 {
2587                     return new string[] { "Infragistics.MyControlWithFutureTargetNDPVersion.1.0" };
2588                 }
2589 
2590                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v1.0\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2591                 {
2592                     return new string[] { "Infragistics.MyNDP1Control.1.0", "Infragistics.MyControlWithPastTargetNDPVersion.1.0" };
2593                 }
2594 
2595                 if
2596                 (
2597                     String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.GridControl.1.0", StringComparison.OrdinalIgnoreCase) == 0
2598                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithFutureTargetNDPVersion.1.0", StringComparison.OrdinalIgnoreCase) == 0
2599                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyHKLMControl.1.0", StringComparison.OrdinalIgnoreCase) == 0
2600                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v3.0\AssemblyFoldersEx\Infragistics.MyControlWithFutureTargetNDPVersion.1.0", StringComparison.OrdinalIgnoreCase) == 0
2601                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v1.0\AssemblyFoldersEx\Infragistics.MyNDP1Control.1.0", StringComparison.OrdinalIgnoreCase) == 0
2602                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithPastTargetNDPVersion.1.0", StringComparison.OrdinalIgnoreCase) == 0
2603                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v1.0\AssemblyFoldersEx\Infragistics.MyControlWithPastTargetNDPVersion.1.0", StringComparison.OrdinalIgnoreCase) == 0
2604                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.x86chk\AssemblyFoldersEx\RawDropControls", StringComparison.OrdinalIgnoreCase) == 0
2605                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\ZControlA", StringComparison.OrdinalIgnoreCase) == 0
2606                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\ZControlB", StringComparison.OrdinalIgnoreCase) == 0
2607                 )
2608                 {
2609                     return new string[] { };
2610                 }
2611 
2612                 if
2613                 (
2614                     String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithServicePack.1.0", StringComparison.OrdinalIgnoreCase) == 0
2615                 )
2616                 {
2617                     // This control has a service pack
2618                     return new string[] { "sp1", "sp2" };
2619                 }
2620 
2621                 if (String.Compare(subKey, @"Software\Microsoft\.NETCompactFramework", StringComparison.OrdinalIgnoreCase) == 0)
2622                 {
2623                     return new string[] { "v2.0.3600" };
2624                 }
2625 
2626                 if (String.Compare(subKey, @"Software\Microsoft\.NETCompactFramework\v2.0.3600", StringComparison.OrdinalIgnoreCase) == 0)
2627                 {
2628                     return new string[] { "PocketPC" };
2629                 }
2630 
2631                 if (String.Compare(subKey, @"Software\Microsoft\.NETCompactFramework\v2.0.3600\PocketPC\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2632                 {
2633                     return new string[] { "AFETestDeviceControl" };
2634                 }
2635 
2636                 if (String.Compare(subKey, @"Software\Microsoft\.NETCompactFramework\v2.0.3600\PocketPC\AssemblyFoldersEx\AFETestDeviceControl", StringComparison.OrdinalIgnoreCase) == 0)
2637                 {
2638                     return new string[] { "1234" };
2639                 }
2640 
2641                 if (String.Compare(subKey, @"Software\Microsoft\Microsoft SDKs", StringComparison.OrdinalIgnoreCase) == 0)
2642                 {
2643                     return new string[] { "Windows" };
2644                 }
2645 
2646                 if (String.Compare(subKey, @"Software\Microsoft\Microsoft SDKs\Windows", StringComparison.OrdinalIgnoreCase) == 0)
2647                 {
2648                     return new string[] { "7.0", "8.0", "v8.0", "9.0" };
2649                 }
2650             }
2651 
2652             if (baseKey == Registry.LocalMachine)
2653             {
2654                 if (String.Compare(subKey, @"Software\Regress714052", StringComparison.OrdinalIgnoreCase) == 0)
2655                 {
2656                     return new string[] { "v2.0.0" };
2657                 }
2658 
2659                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2660                 {
2661                     return new string[] { "A", "B" };
2662                 }
2663 
2664                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\AssemblyFoldersEx\A", StringComparison.OrdinalIgnoreCase) == 0)
2665                 {
2666                     return new string[] { };
2667                 }
2668 
2669                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\AssemblyFoldersEx\B", StringComparison.OrdinalIgnoreCase) == 0)
2670                 {
2671                     return new string[] { };
2672                 }
2673                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\X86", StringComparison.OrdinalIgnoreCase) == 0)
2674                 {
2675                     return new string[] { "X86" };
2676                 }
2677 
2678                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\MSIL", StringComparison.OrdinalIgnoreCase) == 0)
2679                 {
2680                     return new string[] { "MSIL" };
2681                 }
2682 
2683                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\None", StringComparison.OrdinalIgnoreCase) == 0)
2684                 {
2685                     return new string[] { "None" };
2686                 }
2687 
2688                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\Mix", StringComparison.OrdinalIgnoreCase) == 0)
2689                 {
2690                     return new string[] { "Mix" };
2691                 }
2692 
2693                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\Mix\Mix", StringComparison.OrdinalIgnoreCase) == 0)
2694                 {
2695                     return new string[] { };
2696                 }
2697                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\X86\X86", StringComparison.OrdinalIgnoreCase) == 0)
2698                 {
2699                     return new string[] { };
2700                 }
2701 
2702                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\MSIL\MSIL", StringComparison.OrdinalIgnoreCase) == 0)
2703                 {
2704                     return new string[] { };
2705                 }
2706 
2707                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\None\None", StringComparison.OrdinalIgnoreCase) == 0)
2708                 {
2709                     return new string[] { };
2710                 }
2711 
2712                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework", StringComparison.OrdinalIgnoreCase) == 0)
2713                 {
2714                     return new string[] { "vBogusVersion", "v2.0.50727" };
2715                 }
2716 
2717                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2718                 {
2719                     return new string[] { "Infragistics.FancyControl.1.0", "Infragistics.MyHKLMControl.1.0" };
2720                 }
2721 
2722                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.FancyControl.1.0", StringComparison.OrdinalIgnoreCase) == 0)
2723                 {
2724                     return new string[] { };
2725                 }
2726 
2727                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyHKLMControl.1.0", StringComparison.OrdinalIgnoreCase) == 0)
2728                 {
2729                     return new string[] { };
2730                 }
2731 
2732                 if (String.Compare(subKey, @"Software\Microsoft\.NETCompactFramework", StringComparison.OrdinalIgnoreCase) == 0)
2733                 {
2734                     return new string[] { "v2.0.3600" };
2735                 }
2736 
2737                 if (String.Compare(subKey, @"Software\Microsoft\.NETCompactFramework\v2.0.3600", StringComparison.OrdinalIgnoreCase) == 0)
2738                 {
2739                     return new string[] { "PocketPC" };
2740                 }
2741 
2742                 if (String.Compare(subKey, @"Software\Microsoft\.NETCompactFramework\v2.0.3600\PocketPC\AssemblyFoldersEx", StringComparison.OrdinalIgnoreCase) == 0)
2743                 {
2744                     return new string[] { };
2745                 }
2746 
2747                 if (String.Compare(subKey, @"Software\Microsoft\.NETCompactFramework\v2.0.3600\PocketPC\AssemblyFoldersEx\AFETestDeviceControl", StringComparison.OrdinalIgnoreCase) == 0)
2748                 {
2749                     return new string[] { };
2750                 }
2751 
2752                 if (String.Compare(subKey, @"Software\Microsoft\Microsoft SDKs\Windows", StringComparison.OrdinalIgnoreCase) == 0)
2753                 {
2754                     return new string[] { "8.0" };
2755                 }
2756             }
2757 
2758             Console.WriteLine("subKey={0}", subKey);
2759             Assert.True(false, "New GetRegistrySubKeyNames parameters encountered, need to add unittesting support");
2760             return null;
2761         }
2762 
2763         /// <summary>
2764         /// Simplified registry access delegate. Given a baseKey and subKey, get the default value
2765         /// of the subKey.
2766         /// </summary>
2767         /// <param name="baseKey">The base registry key.</param>
2768         /// <param name="subKey">The subkey</param>
2769         /// <returns>A string containing the default value.</returns>
GetRegistrySubKeyDefaultValue(RegistryKey baseKey, string subKey)2770         private static string GetRegistrySubKeyDefaultValue(RegistryKey baseKey, string subKey)
2771         {
2772             if (baseKey == Registry.CurrentUser)
2773             {
2774                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\ZControlA", StringComparison.OrdinalIgnoreCase) == 0)
2775                 {
2776                     return @"C:\MyComponentsA";
2777                 }
2778 
2779                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\ZControlB", StringComparison.OrdinalIgnoreCase) == 0)
2780                 {
2781                     return @"C:\MyComponentsB";
2782                 }
2783 
2784                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.GridControl.1.0", StringComparison.OrdinalIgnoreCase) == 0)
2785                 {
2786                     return @"C:\MyComponents";
2787                 }
2788 
2789                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.x86chk\AssemblyFoldersEx\RawDropControls", StringComparison.OrdinalIgnoreCase) == 0)
2790                 {
2791                     return @"C:\MyRawDropControls";
2792                 }
2793 
2794                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyHKLMControl.1.0", StringComparison.OrdinalIgnoreCase) == 0)
2795                 {
2796                     return @"C:\MyComponents\HKCU Components";
2797                 }
2798 
2799                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v3.0\AssemblyFoldersEx\Infragistics.MyControlWithFutureTargetNDPVersion.1.0", StringComparison.OrdinalIgnoreCase) == 0)
2800                 {
2801                     return s_myComponentsV30Path;
2802                 }
2803 
2804                 if
2805                 (
2806                     String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithFutureTargetNDPVersion.1.0", StringComparison.OrdinalIgnoreCase) == 0
2807                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithPastTargetNDPVersion.1.0", StringComparison.OrdinalIgnoreCase) == 0
2808                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithServicePack.1.0", StringComparison.OrdinalIgnoreCase) == 0
2809                 )
2810                 {
2811                     return s_myComponentsV20Path;
2812                 }
2813 
2814                 if
2815                 (
2816                     String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithServicePack.1.0", StringComparison.OrdinalIgnoreCase) == 0
2817                 )
2818                 {
2819                     return @"C:\MyComponentBase";
2820                 }
2821 
2822                 if
2823                 (
2824                     String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithServicePack.1.0\sp1", StringComparison.OrdinalIgnoreCase) == 0
2825                 )
2826                 {
2827                     return @"C:\MyComponentServicePack1";
2828                 }
2829 
2830                 if
2831                 (
2832                     String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyControlWithServicePack.1.0\sp2", StringComparison.OrdinalIgnoreCase) == 0
2833                 )
2834                 {
2835                     return @"C:\MyComponentServicePack2";
2836                 }
2837 
2838                 if
2839                 (
2840                     String.Compare(subKey, @"Software\Microsoft\.NetFramework\v1.0\AssemblyFoldersEx\Infragistics.MyNDP1Control.1.0", StringComparison.OrdinalIgnoreCase) == 0
2841                     || String.Compare(subKey, @"Software\Microsoft\.NetFramework\v1.0\AssemblyFoldersEx\Infragistics.MyControlWithPastTargetNDPVersion.1.0", StringComparison.OrdinalIgnoreCase) == 0
2842                 )
2843                 {
2844                     return s_myComponentsV10Path;
2845                 }
2846 
2847                 if (String.Compare(subKey, @"SOFTWARE\Microsoft\.NETCompactFramework\v2.0.3600\PocketPC\AssemblyFoldersEx\AFETestDeviceControl", StringComparison.OrdinalIgnoreCase) == 0)
2848                 {
2849                     return @"C:\V1Control";
2850                 }
2851                 if (String.Compare(subKey, @"SOFTWARE\Microsoft\.NETCompactFramework\v2.0.3600\PocketPC\AssemblyFoldersEx\AFETestDeviceControl\1234", StringComparison.OrdinalIgnoreCase) == 0)
2852                 {
2853                     return @"C:\V1ControlSP1";
2854                 }
2855             }
2856 
2857             if (baseKey == Registry.LocalMachine)
2858             {
2859                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.FancyControl.1.0", StringComparison.OrdinalIgnoreCase) == 0)
2860                 {
2861                     return @"C:\MyComponents\HKLM Components";
2862                 }
2863 
2864                 if (String.Compare(subKey, @"Software\Microsoft\.NetFramework\v2.0.50727\AssemblyFoldersEx\Infragistics.MyHKLMControl.1.0", StringComparison.OrdinalIgnoreCase) == 0)
2865                 {
2866                     return @"C:\MyComponents\HKLM Components";
2867                 }
2868 
2869                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\AssemblyFoldersEx\B", StringComparison.OrdinalIgnoreCase) == 0)
2870                 {
2871                     return @"C:\Regress714052\X86";
2872                 }
2873                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\AssemblyFoldersEx\A", StringComparison.OrdinalIgnoreCase) == 0)
2874                 {
2875                     return @"C:\Regress714052\MSIL";
2876                 }
2877 
2878                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\X86\X86", StringComparison.OrdinalIgnoreCase) == 0)
2879                 {
2880                     return @"C:\Regress714052\X86";
2881                 }
2882                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\Mix\Mix", StringComparison.OrdinalIgnoreCase) == 0)
2883                 {
2884                     return @"C:\Regress714052\Mix";
2885                 }
2886                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\MSIL\MSIL", StringComparison.OrdinalIgnoreCase) == 0)
2887                 {
2888                     return @"C:\Regress714052\MSIL";
2889                 }
2890 
2891                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\MSIL\MSIL", StringComparison.OrdinalIgnoreCase) == 0)
2892                 {
2893                     return @"C:\Regress714052\MSIL";
2894                 }
2895 
2896                 if (String.Compare(subKey, @"Software\Regress714052\v2.0.0\None\None", StringComparison.OrdinalIgnoreCase) == 0)
2897                 {
2898                     return @"C:\Regress714052\None";
2899                 }
2900             }
2901 
2902             Console.WriteLine("subKey={0}", subKey);
2903             Assert.True(false, "New GetRegistrySubKeyDefaultValue parameters encountered, need to add unittesting support");
2904             return null;
2905         }
2906 
2907         /// <summary>
2908         /// Delegate for System.IO.File.GetLastWriteTime
2909         /// </summary>
2910         /// <param name="path">The file name</param>
2911         /// <returns>The last write time.</returns>
GetLastWriteTime(string path)2912         private static DateTime GetLastWriteTime(string path)
2913         {
2914             return DateTime.FromOADate(0.0);
2915         }
2916 
2917         /// <summary>
2918         /// Assert that two strings are equal without regard to case.
2919         /// </summary>
2920         /// <param name="expected">The expected string.</param>
2921         /// <param name="actual">The actual string.</param>
AssertNoCase(string expected, string actual)2922         internal protected static void AssertNoCase(string expected, string actual)
2923         {
2924             if (0 != String.Compare(expected, actual, StringComparison.OrdinalIgnoreCase))
2925             {
2926                 string message = String.Format("Expected value '{0}' but received '{1}'", expected, actual);
2927                 Console.WriteLine(message);
2928                 Assert.True(false, message);
2929             }
2930         }
2931 
2932         /// <summary>
2933         /// Assert that two strings are equal without regard to case.
2934         /// </summary>
2935         /// <param name="expected">The expected string.</param>
2936         /// <param name="actual">The actual string.</param>
AssertNoCase(string message, string expected, string actual)2937         internal protected static void AssertNoCase(string message, string expected, string actual)
2938         {
2939             if (0 != String.Compare(expected, actual, StringComparison.OrdinalIgnoreCase))
2940             {
2941                 Console.WriteLine(message);
2942                 Assert.True(false, message);
2943             }
2944         }
2945 
2946         /// <summary>
2947         /// Write out an appConfig file.
2948         /// Return the filename that was written.
2949         /// </summary>
2950         /// <param name="appConfigFile"></param>
2951         /// <param name="redirects"></param>
WriteAppConfig(string redirects)2952         protected static string WriteAppConfig(string redirects)
2953         {
2954             string appConfigContents =
2955             "<configuration>\n" +
2956             "    <runtime>\n" +
2957             redirects +
2958             "    </runtime>\n" +
2959             "</configuration>";
2960 
2961             string appConfigFile = FileUtilities.GetTemporaryFile();
2962             File.WriteAllText(appConfigFile, appConfigContents);
2963             return appConfigFile;
2964         }
2965 
2966         /// <summary>
2967         /// Determines whether the given item array has an item with the given spec.
2968         /// </summary>
2969         /// <param name="items">The item array.</param>
2970         /// <param name="spec">The spec to search for.</param>
2971         /// <returns>True if the spec was found.</returns>
ContainsItem(ITaskItem[] items, string spec)2972         protected static bool ContainsItem(ITaskItem[] items, string spec)
2973         {
2974             foreach (ITaskItem item in items)
2975             {
2976                 if (0 == String.Compare(item.ItemSpec, spec, StringComparison.OrdinalIgnoreCase))
2977                 {
2978                     return true;
2979                 }
2980             }
2981             return false;
2982         }
2983 
2984         /// <summary>
2985         /// Execute the task.
2986         /// </summary>
2987         /// <remarks>
2988         /// NOTE! This test is not in fact completely isolated from its environment: it is reading the real redist lists.
2989         /// </remarks>
Execute(ResolveAssemblyReference t, RARSimulationMode RARSimulationMode = RARSimulationMode.LoadAndBuildProject)2990         protected static bool Execute(ResolveAssemblyReference t, RARSimulationMode RARSimulationMode = RARSimulationMode.LoadAndBuildProject)
2991         {
2992             return Execute(t, true, RARSimulationMode);
2993         }
2994 
2995         [Flags]
2996         public enum RARSimulationMode
2997         {
2998             LoadProject = 1,
2999             BuildProject = 2,
3000             LoadAndBuildProject = LoadProject | BuildProject
3001         }
3002 
3003         /// <summary>
3004         /// Execute the task. Without confirming that the number of files resolved with and without find dependencies is identical.
3005         /// This is because profiles could cause the number of primary references to be different.
3006         /// </summary>
Execute(ResolveAssemblyReference t, bool buildConsistencyCheck, RARSimulationMode rarSimulationMode = RARSimulationMode.LoadAndBuildProject)3007         protected static bool Execute(ResolveAssemblyReference t, bool buildConsistencyCheck, RARSimulationMode rarSimulationMode = RARSimulationMode.LoadAndBuildProject)
3008         {
3009             string tempPath = Path.GetTempPath();
3010             string redistListPath = Path.Combine(tempPath, Guid.NewGuid() + ".xml");
3011             string rarCacheFile = Path.Combine(tempPath, Guid.NewGuid() + ".RarCache");
3012             s_existentFiles.Add(rarCacheFile);
3013 
3014             bool succeeded = false;
3015 
3016             try
3017             {
3018                 // Set the InstalledAssemblyTables parameter.
3019                 if (t.InstalledAssemblyTables.Length == 0)
3020                 {
3021                     File.WriteAllText(redistListPath, REDISTLIST);
3022                     t.InstalledAssemblyTables = new ITaskItem[] { new TaskItem(redistListPath) };
3023                 }
3024 
3025                 // First, run it in loading-a-project mode.
3026 
3027                 if (rarSimulationMode.HasFlag(RARSimulationMode.LoadProject))
3028                 {
3029                     t.Silent = true;
3030                     t.FindDependencies = false;
3031                     t.FindSatellites = false;
3032                     t.FindSerializationAssemblies = false;
3033                     t.FindRelatedFiles = false;
3034                     t.StateFile = null;
3035 	                t.Execute
3036 	                (
3037 	                    fileExists,
3038 	                    directoryExists,
3039 	                    getDirectories,
3040 	                    getAssemblyName,
3041 	                    getAssemblyMetadata,
3042 	#if FEATURE_WIN32_REGISTRY
3043 	                    getRegistrySubKeyNames,
3044 	                    getRegistrySubKeyDefaultValue,
3045 	#endif
3046 	                    getLastWriteTime,
3047 	                    getRuntimeVersion,
3048 	#if FEATURE_WIN32_REGISTRY
3049 	                    openBaseKey,
3050 	#endif
3051 	                    checkIfAssemblyIsInGac,
3052 	                    isWinMDFile,
3053 	                    readMachineTypeFromPEHeader
3054 	                );
3055 
3056                     // A few checks. These should always be true or it may be a perf issue for project load.
3057                     ITaskItem[] loadModeResolvedFiles = new TaskItem[0];
3058                     if (t.ResolvedFiles != null)
3059                     {
3060                         loadModeResolvedFiles = (ITaskItem[])t.ResolvedFiles.Clone();
3061                     }
3062                     Assert.Equal(0, t.ResolvedDependencyFiles.Length);
3063                     Assert.Equal(0, t.SatelliteFiles.Length);
3064                     Assert.Equal(0, t.RelatedFiles.Length);
3065                     Assert.Equal(0, t.SuggestedRedirects.Length);
3066                     Assert.Equal(0, t.FilesWritten.Length);
3067 
3068                     if (buildConsistencyCheck)
3069                     {
3070                         // Some consistency checks between load mode and build mode.
3071                         Assert.Equal(loadModeResolvedFiles.Length, t.ResolvedFiles.Length);
3072                         for (int i = 0; i < loadModeResolvedFiles.Length; i++)
3073                         {
3074                             Assert.Equal(loadModeResolvedFiles[i].ItemSpec, t.ResolvedFiles[i].ItemSpec);
3075                             Assert.Equal(loadModeResolvedFiles[i].GetMetadata("CopyLocal"), t.ResolvedFiles[i].GetMetadata("CopyLocal"));
3076                             Assert.Equal(loadModeResolvedFiles[i].GetMetadata("ResolvedFrom"), t.ResolvedFiles[i].GetMetadata("ResolvedFrom"));
3077                         }
3078                     }
3079                 }
3080 
3081                 // Now, run it in building-a-project mode.
3082                 if (rarSimulationMode.HasFlag(RARSimulationMode.BuildProject))
3083                 {
3084                     MockEngine e = (MockEngine)t.BuildEngine;
3085                     e.Warnings = 0;
3086                     e.Errors = 0;
3087                     e.Log = "";
3088                     t.Silent = false;
3089                     t.FindDependencies = true;
3090                     t.FindSatellites = true;
3091                     t.FindSerializationAssemblies = true;
3092                     t.FindRelatedFiles = true;
3093                     string cache = rarCacheFile;
3094                     t.StateFile = cache;
3095                     File.Delete(t.StateFile);
3096 	                succeeded =
3097 	                    t.Execute
3098 	                    (
3099 	                        fileExists,
3100 	                        directoryExists,
3101 	                        getDirectories,
3102 	                        getAssemblyName,
3103 	                        getAssemblyMetadata,
3104 	#if FEATURE_WIN32_REGISTRY
3105 	                        getRegistrySubKeyNames,
3106 	                        getRegistrySubKeyDefaultValue,
3107 	#endif
3108 	                        getLastWriteTime,
3109 	                        getRuntimeVersion,
3110 	#if FEATURE_WIN32_REGISTRY
3111 	                        openBaseKey,
3112 	#endif
3113 	                        checkIfAssemblyIsInGac,
3114 	                        isWinMDFile,
3115 	                        readMachineTypeFromPEHeader
3116 	                    );
3117                     if (FileUtilities.FileExistsNoThrow(t.StateFile))
3118                     {
3119                         Assert.Equal(1, t.FilesWritten.Length);
3120                         Assert.True(t.FilesWritten[0].ItemSpec.Equals(cache, StringComparison.OrdinalIgnoreCase));
3121                     }
3122 
3123                     File.Delete(t.StateFile);
3124 
3125                     // Check attributes on resolve files.
3126                     for (int i = 0; i < t.ResolvedFiles.Length; i++)
3127                     {
3128                         // OriginalItemSpec attribute on resolved items is to support VS in figuring out which
3129                         // project file reference caused a particular resolved file.
3130                         string originalItemSpec = t.ResolvedFiles[i].GetMetadata("OriginalItemSpec");
3131                         Assert.True(ContainsItem(t.Assemblies, originalItemSpec) || ContainsItem(t.AssemblyFiles, originalItemSpec)); //                         "Expected to find OriginalItemSpec in Assemblies or AssemblyFiles task parameters"
3132                     }
3133                 }
3134             }
3135             finally
3136             {
3137                 s_existentFiles.Remove(rarCacheFile);
3138                 if (File.Exists(redistListPath))
3139                 {
3140                     FileUtilities.DeleteNoThrow(redistListPath);
3141                 }
3142 
3143                 if (File.Exists(rarCacheFile))
3144                 {
3145                     FileUtilities.DeleteNoThrow(rarCacheFile);
3146                 }
3147             }
3148             return succeeded;
3149         }
3150 
3151         /// <summary>
3152         /// Helper method which allows tests to specify additional assembly search paths.
3153         /// </summary>
3154         /// <param name="e"></param>
ExecuteRAROnItemsAndRedist(ResolveAssemblyReference t, MockEngine e, ITaskItem[] items, string redistString, bool consistencyCheck)3155         internal void ExecuteRAROnItemsAndRedist(ResolveAssemblyReference t, MockEngine e, ITaskItem[] items, string redistString, bool consistencyCheck)
3156         {
3157             ExecuteRAROnItemsAndRedist(t, e, items, redistString, consistencyCheck, null);
3158         }
3159 
3160         /// <summary>
3161         /// Helper method to get rid of some of the code duplication
3162         /// </summary>
ExecuteRAROnItemsAndRedist(ResolveAssemblyReference t, MockEngine e, ITaskItem[] items, string redistString, bool consistencyCheck, List<string> additionalSearchPaths)3163         internal void ExecuteRAROnItemsAndRedist(ResolveAssemblyReference t, MockEngine e, ITaskItem[] items, string redistString, bool consistencyCheck, List<string> additionalSearchPaths)
3164         {
3165             t.BuildEngine = e;
3166             List<string> searchPaths = new List<string>(DefaultPaths);
3167 
3168             if (additionalSearchPaths != null)
3169             {
3170                 searchPaths.AddRange(additionalSearchPaths);
3171             }
3172 
3173             t.Assemblies = items;
3174             t.SearchPaths = searchPaths.ToArray();
3175             string redistFile = FileUtilities.GetTemporaryFile();
3176             try
3177             {
3178                 File.Delete(redistFile);
3179                 File.WriteAllText
3180                 (
3181                     redistFile,
3182                     redistString
3183                 );
3184 
3185                 t.InstalledAssemblyTables = new TaskItem[] { new TaskItem(redistFile) };
3186 
3187                 Execute(t, consistencyCheck);
3188             }
3189             finally
3190             {
3191                 File.Delete(redistFile);
3192             }
3193         }
3194     }
3195 }
3196