ICSharpCode.ILSpy.Language.DecompileAssembly C# (CSharp) Метод

DecompileAssembly() публичный Метод

public DecompileAssembly ( LoadedAssembly assembly, ITextOutput output, DecompilationOptions options ) : void
assembly LoadedAssembly
output ITextOutput
options DecompilationOptions
Результат void
		public virtual void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
		{
			WriteCommentLine(output, assembly.FileName);
			if (assembly.AssemblyDefinition != null) {
				var name = assembly.AssemblyDefinition.Name;
				if (name.IsWindowsRuntime) {
					WriteCommentLine(output, name.Name + " [WinRT]");
				} else {
					WriteCommentLine(output, name.FullName);
				}
			} else {
				WriteCommentLine(output, assembly.ModuleDefinition.Name);
			}
		}

Usage Example

Пример #1
0
        void WriteProject(LoadedAssembly loadedAssembly, Language language, string targetDirectory, CancellationToken ct)
        {
            targetDirectory = Path.Combine(targetDirectory, loadedAssembly.ShortName);
            string projectFileName = Path.Combine(targetDirectory, loadedAssembly.ShortName + language.ProjectFileExtension);

            if (!Directory.Exists(targetDirectory))
            {
                try
                {
                    Directory.CreateDirectory(targetDirectory);
                }
                catch (Exception e)
                {
                    statusOutput.Add($"Failed to create a directory '{targetDirectory}':{Environment.NewLine}{e}");
                    return;
                }
            }

            try
            {
                using (var projectFileWriter = new StreamWriter(projectFileName))
                {
                    var projectFileOutput = new PlainTextOutput(projectFileWriter);
                    var options           = new DecompilationOptions()
                    {
                        FullDecompilation      = true,
                        CancellationToken      = ct,
                        SaveAsProjectDirectory = targetDirectory
                    };

                    var projectInfo = language.DecompileAssembly(loadedAssembly, projectFileOutput, options);
                    if (projectInfo != null)
                    {
                        projects.Add(new ProjectItem(projectFileName, projectInfo.PlatformName, projectInfo.Guid, projectInfo.TypeGuid));
                    }
                }
            }
            catch (Exception e) when(!(e is OperationCanceledException))
            {
                statusOutput.Add($"Failed to decompile the assembly '{loadedAssembly.FileName}':{Environment.NewLine}{e}");
            }
        }
All Usage Examples Of ICSharpCode.ILSpy.Language::DecompileAssembly