/// <summary>Initializes a new instance of the <see cref="AssemblyPropertiesInfo"/> class.</summary> /// <param name="assemblyPath">The assembly file path.</param> public AssemblyPropertiesInfo(string assemblyPath) : this() { if (string.IsNullOrEmpty(assemblyPath)) { throw new ArgumentNullException(nameof(assemblyPath), @"The file name cannot be null or empty."); } if (!File.Exists(assemblyPath)) { throw new FileNotFoundException(@"The assembly file name cannot be found!", assemblyPath); } if (!AsmUtil.IsAssembly(assemblyPath)) { throw new ArgumentNullException(nameof(assemblyPath), @"The file name is not an assembly file (*.DLL;*.EXE)."); } Location = assemblyPath; AssemblyDirectory = new DirectoryInfo(Path.GetDirectoryName(assemblyPath)); if (File.Exists(assemblyPath)) { // Update the assembly file version information. FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assemblyPath); ProductName = fileVersionInfo.ProductName; FileDescription = fileVersionInfo.FileDescription; CompanyName = fileVersionInfo.CompanyName; LegalCopyright = fileVersionInfo.LegalCopyright; LegalTrademarks = fileVersionInfo.LegalTrademarks; OriginalFileName = fileVersionInfo.OriginalFilename; ProductVersion = fileVersionInfo.ProductVersion; FileVersion = fileVersionInfo.FileVersion; } }
/// <summary>Initializes a new instance of the <see cref="AssemblyAnalyzer"/> class.</summary> /// <param name="assemblyPath">The assembly file path.</param> public AssemblyAnalyzer(string assemblyPath) : this() { // Validate the assembly path if (string.IsNullOrEmpty(assemblyPath)) { throw new ArgumentNullException(nameof(assemblyPath), @"The file name cannot be null or empty."); } if (!File.Exists(assemblyPath)) { throw new FileNotFoundException(@"The assembly file name cannot be found!", assemblyPath); } if (!AsmUtil.IsAssembly(assemblyPath)) { throw new ArgumentNullException(nameof(assemblyPath), @"The file name is not an assembly file (*.DLL;*.EXE)."); } // Initialize Location = assemblyPath; AssemblyPropertiesInfo = new AssemblyPropertiesInfo(assemblyPath); HierarchyTree = new HierarchyTree(assemblyPath); AssemblyReport = new MarkdownReport(AssemblyPropertiesInfo, HierarchyTree, Settings); Settings = new ReportSettings(AssemblyPropertiesInfo, HierarchyTree); }
/// <summary>Loads the assembly.</summary> /// <param name="assemblyLocation">The assembly location.</param> private void LoadAssembly(string assemblyLocation) { if (string.IsNullOrEmpty(assemblyLocation)) { throw new ArgumentNullException(nameof(assemblyLocation), @"The assembly location cannot be null or empty."); } if (!File.Exists(assemblyLocation)) { throw new FileNotFoundException(@"The assembly location cannot be found.", assemblyLocation); } if (!AsmUtil.IsAssembly(assemblyLocation)) { throw new ArgumentNullException(nameof(assemblyLocation), @"The assembly location doesn't link to a valid assembly file type."); } // BUG: Validate the assembly is same '.NET Framework' version or below and not a '.NET Core' or '.NET Standard'. To validate the input and provider better feedback. UpdateStatus(string.Format(Resources.Analyzer_Parsing, Path.GetFileNameWithoutExtension(Tb_Location.Text))); // Stop any currently loaded progress and restart. if (assemblyWorker.IsBusy) { assemblyWorker.CancelAsync(); } // Reset assembly explorer grids assemblyExplorer.ResetAssemblyExplorerPropertyGrid(); // Disable buttons Btn_Browse.Enabled = false; Btn_Build.Enabled = false; // Set the assembly location. Tb_Location.Text = assemblyLocation; // Show the status bar progress information. Tspb_ProgressBar.Visible = true; Tssl_ProgressPercent.Visible = true; Tssl_Separator0Divider.Visible = true; Tssl_Separator1Divider.Visible = true; Tssl_Elapsed.Visible = true; // Start counting the process duration from the start. duration.Reset(); duration.Start(); // Start the assembly loading process in separate thread. assemblyWorker.RunWorkerAsync(assemblyLocation); }
/// <summary>Resolves the specified input to a <see cref="Type"/>.</summary> /// <param name="assemblyPath">The assembly path.</param> /// <param name="namespacePath">The namespace path.</param> /// <param name="typeName">Name of the type.</param> /// <returns>The <see cref="Type"/>.</returns> public static Type ResolveType(string assemblyPath, string namespacePath, string typeName) { if (string.IsNullOrEmpty(assemblyPath)) { throw new ArgumentNullException(nameof(assemblyPath), @"The assembly path cannot be null or empty when resolving a Type."); } if (string.IsNullOrEmpty(typeName)) { throw new ArgumentNullException(nameof(typeName), @"The type name cannot be null or empty when resolving a Type."); } if (!AsmUtil.IsAssembly(assemblyPath)) { throw new ArgumentNullException(nameof(assemblyPath), @"The assembly path doesn't link to an Assembly executable type file path."); } return(ResolveType(Assembly.LoadFile(assemblyPath), namespacePath, typeName)); }