public static GetModuleWeaver ( string targetAssemblyFilename, System.Xml.Linq.XElement config ) : |
||
targetAssemblyFilename | string | |
config | System.Xml.Linq.XElement | |
return |
public static ModuleDefinition WeaveTestTarget( string targetAssemblyFilename, XElement config) { Contract.Requires(config != null); Contract.Ensures(Contract.Result <ModuleDefinition>() != null); var moduleWeaver = ModuleWeaverHelper.GetModuleWeaver(targetAssemblyFilename, config); moduleWeaver.Execute(); var tempProcessedAssemblyPath = Path.Combine(Path.GetDirectoryName(moduleWeaver.AssemblyFilePath), string.Format("{0}.dll", Path.GetRandomFileName())); try { moduleWeaver.ModuleDefinition.Write(tempProcessedAssemblyPath); } finally { if (File.Exists(tempProcessedAssemblyPath)) { try { File.Delete(tempProcessedAssemblyPath); } catch { /* Best-effort deletion only */ } } } return(moduleWeaver.ModuleDefinition); }
public static ModuleDefinition WeaveTestTarget( string targetAssemblyFilename, XElement config) { Contract.Requires(config != null); Contract.Ensures(Contract.Result <ModuleDefinition>() != null); var moduleWeaver = ModuleWeaverHelper.GetModuleWeaver(targetAssemblyFilename, config); bool isVerified; string verificationOutput; AssemblyVerifier.RunVerifyProcessAndCollectOutput(moduleWeaver.AssemblyFilePath, out isVerified, out verificationOutput); Assert.That(isVerified, string.Format("Unprocessed assembly could not be verified: \n{0}", verificationOutput)); moduleWeaver.Execute(); var tempProcessedAssemblyPath = Path.Combine(Path.GetDirectoryName(moduleWeaver.AssemblyFilePath), string.Format("{0}.dll", Path.GetRandomFileName())); try { moduleWeaver.ModuleDefinition.Write(tempProcessedAssemblyPath); AssemblyVerifier.RunVerifyProcessAndCollectOutput(tempProcessedAssemblyPath, out isVerified, out verificationOutput); Assert.That(isVerified, string.Format("Processed assembly could not be verified: \n{0}", verificationOutput)); } finally { if (File.Exists(tempProcessedAssemblyPath)) { try { File.Delete(tempProcessedAssemblyPath); } catch { /* Best-effort deletion only */ } } } return(moduleWeaver.ModuleDefinition); }