internal AssemblyBuilder(CompilationSection compConfig, ICollection referencedAssemblies, CompilerType compilerType, string outputAssemblyName) { this._compConfig = compConfig; this._outputAssemblyName = outputAssemblyName; this._initialReferencedAssemblies = AssemblySet.Create(referencedAssemblies); this._compilerType = compilerType.Clone(); if (BuildManager.PrecompilingWithDebugInfo) { this._compilerType.CompilerParameters.IncludeDebugInformation = true; } else if (BuildManager.PrecompilingForDeployment) { this._compilerType.CompilerParameters.IncludeDebugInformation = false; } else if (DeploymentSection.RetailInternal) { this._compilerType.CompilerParameters.IncludeDebugInformation = false; } else if (this._compConfig.AssemblyPostProcessorTypeInternal != null) { this._compilerType.CompilerParameters.IncludeDebugInformation = true; } this._tempFiles.KeepFiles = this._compilerType.CompilerParameters.IncludeDebugInformation; this._codeProvider = CompilationUtil.CreateCodeDomProviderNonPublic(this._compilerType.CodeDomProviderType); this._maxBatchSize = this._compConfig.MaxBatchSize; this._maxBatchGeneratedFileSize = this._compConfig.MaxBatchGeneratedFileSize * 0x400; }
public void AddAssemblyReference(Assembly a) { if (this._additionalReferencedAssemblies == null) { this._additionalReferencedAssemblies = new AssemblySet(); } this._additionalReferencedAssemblies.Add(a); }
private void AddAssemblyDependency(Assembly assembly) { if (_linkedAssemblies == null) { _linkedAssemblies = new AssemblySet(); } _linkedAssemblies.Add(assembly); }
public MainForm() { InitializeComponent(); var set = new AssemblySet(); set.Name = ".Net v4.0"; _assemblySets.Add(set); RefreshSets(); }
private void Populate(AssemblySet set) { _nodesTreeView.Nodes.Clear(); foreach (var asm in set) { var node = new TreeNode(asm.Name); node.Tag = asm.Load(); node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); _nodesTreeView.Nodes.Add(node); } }
private void newSetToolStripMenuItem_Click(object sender, EventArgs e) { using (var name = new AssemblySetNameForm()) { if (name.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var set = new AssemblySet(); set.Name = name.SelectedName; _assemblySets.Add(set); RefreshSets(); } } }
internal static AssemblySet GetReferencedAssemblies(Assembly a) { AssemblySet set = new AssemblySet(); foreach (AssemblyName name in a.GetReferencedAssemblies()) { Assembly o = Assembly.Load(name); if (!(o == typeof(string).Assembly)) { set.Add(o); } } return(set); }
private void GetAppStateByParsingGlobalAsax() { using (new ApplicationImpersonationContext()) { if (FileUtil.FileExists(this._appFilename)) { ApplicationFileParser parser = new ApplicationFileParser(); AssemblySet referencedAssemblies = Util.GetReferencedAssemblies(this._theApplicationType.Assembly); referencedAssemblies.Add(typeof(string).Assembly); VirtualPath virtualPath = HttpRuntime.AppDomainAppVirtualPathObject.SimpleCombine("global.asax"); parser.Parse(referencedAssemblies, virtualPath); this._state = new HttpApplicationState(parser.ApplicationObjects, parser.SessionObjects); } } }
private void GetAppStateByParsingGlobalAsax() { using (new ApplicationImpersonationContext()) { // It may not exist if the app is precompiled if (FileUtil.FileExists(_appFilename)) { ApplicationFileParser parser; parser = new ApplicationFileParser(); AssemblySet referencedAssemblies = System.Web.UI.Util.GetReferencedAssemblies( _theApplicationType.Assembly); referencedAssemblies.Add(typeof(string).Assembly); VirtualPath virtualPath = HttpRuntime.AppDomainAppVirtualPathObject.SimpleCombine( applicationFileName); parser.Parse(referencedAssemblies, virtualPath); // Create app state _state = new HttpApplicationState(parser.ApplicationObjects, parser.SessionObjects); } } }
public void Load() { var file = Path.Combine(DataFolder, "preferences.xml"); if (!File.Exists(file)) { DefaultSettings(); } else { var doc = XDocument.Load(file); foreach (var setElement in doc.Elements("preferences").Elements("assemblySets").Elements("set")) { var set = new AssemblySet((string)setElement.Attribute("name")); foreach (var asmElement in setElement.Elements("assembly")) { var asm = new AssemblyData(asmElement.Value); set.Add(asm); } AssemblySets.Add(set); } } }
private void DefaultSettings() { var set = new AssemblySet(); set.Name = string.Format(".Net v{0}", new AssemblyName(typeof(string).Assembly.FullName).Version.ToString()); set.Add(new AssemblyData(typeof(string).Assembly)); set.Add(new AssemblyData(typeof(System.Xml.XmlElement).Assembly)); AssemblySets.Add(set); }
private ParamContext InitContext <T>(string methodXml, int fxIndex, bool forceAlignment = false, string ns1 = "mdoc.Test", string ns2 = "mdoc.Test2") { Func <int, bool> indexCheck = fi => fi < 2; if (typeof(T) == typeof(MyClass2)) { indexCheck = fi => fi != 1; } bool useFirst = forceAlignment || indexCheck(fxIndex); var doc = new XmlDocument(); //doc.PreserveWhitespace = true; doc.LoadXml(methodXml); var beforeXML = doc.OuterXml; XmlElement root = doc.SelectSingleNode("//Docs") as XmlElement; // Docs TypeDefinition type = GetDefinition <T> (ns1); var method = type.Methods.First(m => m.Name == "Meth") as MethodReference; var parameters = method.Parameters.ToList(); TypeDefinition type2 = GetDefinition <T> (ns2); var method2 = type2.Methods.First(m => m.Name == "Meth") as MethodReference; var parameters2 = method2.Parameters.ToList(); // updater var updater = new MDocUpdater(); var fx = new FrameworkIndex("", 3, null); fx.Frameworks.Add(new FrameworkEntry(fx.Frameworks, fx.Frameworks) { Id = "One", Name = "One", Replace = ns2, With = ns1 }); fx.Frameworks.Add(new FrameworkEntry(fx.Frameworks, fx.Frameworks) { Id = "Three", Name = "Three", Replace = ns2, With = ns1 }); fx.Frameworks.Add(new FrameworkEntry(fx.Frameworks, fx.Frameworks) { Id = "Two", Name = "Two", Replace = ns2, With = ns1 }); var i = 0; foreach (var f in fx.Frameworks) { if (indexCheck(i) || forceAlignment) { var t = f.ProcessType(type, type.Module.Assembly); t.ProcessMember(method); var aset = new AssemblySet(new[] { "one.dll" }); f.AddAssemblySet(aset); } else { var t = f.ProcessType(type2, type2.Module.Assembly); t.ProcessMember(method2); } i++; } updater.InitializeFrameworksCache(fx); return(new ParamContext() { doc = doc, beforeXML = beforeXML, method = useFirst ? method : method2, parameters = useFirst ? parameters : parameters2, fx = fx, updater = updater }); }
/// <summary> /// Instanciate information about AspMvc Application. /// </summary> /// <param name="appAspNetPath"></param> /// <param name="typeSet"></param> /// <param name="isAspNetCoreWindows"></param> public AspMvcInfo(string appAspNetPath, AssemblySet typeSet, bool isAspNetCoreWindows = false) : this(appAspNetPath, new AssemblySet[] { typeSet }, isAspNetCoreWindows) { }
public DiffConfiguration(AssemblySet left, AssemblySet right, DiffConfigurationOptions options) { Left = left; Right = right; Options = options; }
/// <summary> /// Initializes a new instance of the <see cref="AssemblySetBrowser"/> class. /// </summary> public AssemblySetBrowser(AssemblySet set) : this() { _assemblySet = set; this.ComposeParts(); }
public AssemblySelector(AssemblySet assemblySet) : this() { _assemblySet = assemblySet; this.ComposeParts(); }
public bool LoadReferences(ICollection<string> references, IErrorHandler errorHandler) { bool hasLoadErrors = false; AssemblySet assemblySet = new AssemblySet(); foreach (string referencePath in references) { string assemblyFilePath = Path.GetFullPath(referencePath); if (File.Exists(assemblyFilePath) == false) { errorHandler.ReportMissingAssemblyReferenceError(referencePath); hasLoadErrors = true; continue; } string referenceName = Path.GetFileNameWithoutExtension(assemblyFilePath); if (assemblySet.IsReferenced(referenceName)) { errorHandler.ReportDuplicateAssemblyReferenceError(referenceName, referencePath); hasLoadErrors = true; continue; } try { AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(assemblyFilePath); if (assembly == null) { errorHandler.ReportAssemblyLoadError(referenceName, referencePath); hasLoadErrors = true; continue; } if (referenceName.Equals(CoreAssemblyName, StringComparison.OrdinalIgnoreCase)) { if (CoreAssemblyPath != null) { errorHandler.ReportDuplicateAssemblyReferenceError(referenceName, referencePath); hasLoadErrors = true; } else { CoreAssemblyPath = assemblyFilePath; CoreAssemblyMetadata = assembly; } } else { assemblySet.AddAssembly(assemblyFilePath, referenceName, assembly); } } catch (Exception e) { Debug.Fail(e.ToString()); errorHandler.ReportAssemblyLoadError(referenceName, referencePath); hasLoadErrors = true; } } if (CoreAssemblyMetadata == null) { errorHandler.ReportMissingAssemblyReferenceError(CoreAssemblyName); hasLoadErrors = true; } assemblyMap = assemblySet.Assemblies; assemblyPaths = assemblySet.GetAssemblyPaths(); return hasLoadErrors; }
/// <summary> /// Constructs an instance of the <c>GacUninstallTask</c>. /// </summary> public GacUninstallTask() { _assemblies = new AssemblySet(); }
public bool LoadReferences(ICollection<string> references, IErrorHandler errorHandler) { bool hasLoadErrors = false; AssemblySet assemblySet = new AssemblySet(); foreach (string referencePath in references) { string assemblyFilePath = Path.GetFullPath(referencePath); if (File.Exists(assemblyFilePath) == false) { errorHandler.ReportError("The referenced assembly '" + referencePath + "' could not be located.", String.Empty); hasLoadErrors = true; continue; } string referenceName = Path.GetFileNameWithoutExtension(assemblyFilePath); if (assemblySet.IsReferenced(referenceName)) { errorHandler.ReportError("The referenced assembly '" + referencePath + "' is a duplicate reference.", String.Empty); hasLoadErrors = true; continue; } try { AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(assemblyFilePath); if (assembly == null) { errorHandler.ReportError("The referenced assembly '" + referencePath + "' could not be loaded as an assembly.", String.Empty); hasLoadErrors = true; continue; } if (referenceName.Equals(CoreAssemblyName, StringComparison.OrdinalIgnoreCase)) { if (_coreAssemblyPath != null) { errorHandler.ReportError("The core runtime assembly, mscorlib.dll must be referenced only once.", String.Empty); hasLoadErrors = true; continue; } else { _coreAssemblyPath = assemblyFilePath; _coreAssembly = assembly; } } else { assemblySet.AddAssembly(assemblyFilePath, referenceName, assembly); } } catch (Exception e) { Debug.Fail(e.ToString()); errorHandler.ReportError("The referenced assembly '" + referencePath + "' could not be loaded as an assembly.", String.Empty); hasLoadErrors = true; } } if (_coreAssembly == null) { errorHandler.ReportError("The 'mscorlib' assembly must be referenced.", String.Empty); hasLoadErrors = true; } else { if (VerifyScriptAssembly(_coreAssembly) == false) { errorHandler.ReportError("The assembly '" + _coreAssemblyPath + "' is not a valid script assembly.", String.Empty); hasLoadErrors = true; } } foreach (KeyValuePair<string, AssemblyDefinition> assemblyReference in assemblySet.Assemblies) { if (VerifyScriptAssembly(assemblyReference.Value) == false) { errorHandler.ReportError("The assembly '" + assemblyReference.Key + "' is not a valid script assembly.", String.Empty); hasLoadErrors = true; } } _assemblyMap = assemblySet.Assemblies; _assemblyPaths = assemblySet.GetAssemblyPaths(); return hasLoadErrors; }
public bool LoadReferences(ICollection <string> references, IErrorHandler errorHandler) { bool hasLoadErrors = false; AssemblySet assemblySet = new AssemblySet(); foreach (string referencePath in references) { string assemblyFilePath = Path.GetFullPath(referencePath); if (File.Exists(assemblyFilePath) == false) { errorHandler.ReportError("The referenced assembly '" + referencePath + "' could not be located.", String.Empty); hasLoadErrors = true; continue; } string referenceName = Path.GetFileNameWithoutExtension(assemblyFilePath); if (assemblySet.IsReferenced(referenceName)) { errorHandler.ReportError("The referenced assembly '" + referencePath + "' is a duplicate reference.", String.Empty); hasLoadErrors = true; continue; } try { AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(assemblyFilePath); if (assembly == null) { errorHandler.ReportError("The referenced assembly '" + referencePath + "' could not be loaded as an assembly.", String.Empty); hasLoadErrors = true; continue; } if (referenceName.Equals(CoreAssemblyName, StringComparison.OrdinalIgnoreCase)) { if (_coreAssemblyPath != null) { errorHandler.ReportError("The core runtime assembly, mscorlib.dll must be referenced only once.", String.Empty); hasLoadErrors = true; continue; } else { _coreAssemblyPath = assemblyFilePath; _coreAssembly = assembly; } } else { assemblySet.AddAssembly(assemblyFilePath, referenceName, assembly); } } catch (Exception e) { Debug.Fail(e.ToString()); errorHandler.ReportError("The referenced assembly '" + referencePath + "' could not be loaded as an assembly.", String.Empty); hasLoadErrors = true; } } if (_coreAssembly == null) { errorHandler.ReportError("The 'mscorlib' assembly must be referenced.", String.Empty); hasLoadErrors = true; } else { if (VerifyScriptAssembly(_coreAssembly) == false) { errorHandler.ReportError("The assembly '" + _coreAssemblyPath + "' is not a valid script assembly.", String.Empty); hasLoadErrors = true; } } foreach (KeyValuePair <string, AssemblyDefinition> assemblyReference in assemblySet.Assemblies) { if (VerifyScriptAssembly(assemblyReference.Value) == false) { errorHandler.ReportError("The assembly '" + assemblyReference.Key + "' is not a valid script assembly.", String.Empty); hasLoadErrors = true; } } _assemblyMap = assemblySet.Assemblies; _assemblyPaths = assemblySet.GetAssemblyPaths(); return(hasLoadErrors); }