List <ResXDataNode> ReadResourceEntries(DecompileContext ctx) { var list = new List <ResXDataNode>(); try { using (var reader = new ResourceReader(embeddedResource.GetResourceStream())) { var iter = reader.GetEnumerator(); while (iter.MoveNext()) { ctx.CancellationToken.ThrowIfCancellationRequested(); string key = null; try { key = iter.Key as string; if (key == null) { continue; } //TODO: Some resources, like images, should be saved as separate files. Use ResXFileRef. // Don't do it if it's a satellite assembly. list.Add(new ResXDataNode(key, iter.Value, TypeNameConverter)); } catch (Exception ex) { ctx.Logger.Error(string.Format("Could not add resource '{0}', Message: {1}", key, ex.Message)); } } } } catch (Exception ex) { ctx.Logger.Error(string.Format("Could not read resources from {0}, Message: {1}", embeddedResource.Name, ex.Message)); } return(list); }
public override void Create(DecompileContext ctx) { using (var writer = new StreamWriter(Filename, false, Encoding.UTF8)) { var output = new PlainTextOutput(writer); language.Decompile(DecompilationType.AssemblyInfo, new DecompileAssemblyInfo(module, output, decompilationContext)); } }
List<ResXDataNode> ReadResourceEntries(DecompileContext ctx) { var list = new List<ResXDataNode>(); try { using (var reader = new ResourceReader(embeddedResource.GetResourceStream())) { var iter = reader.GetEnumerator(); while (iter.MoveNext()) { ctx.CancellationToken.ThrowIfCancellationRequested(); string key = null; try { key = iter.Key as string; if (key == null) continue; //TODO: Some resources, like images, should be saved as separate files. Use ResXFileRef. // Don't do it if it's a satellite assembly. list.Add(new ResXDataNode(key, iter.Value, TypeNameConverter)); } catch (Exception ex) { ctx.Logger.Error(string.Format("Could not add resource '{0}', Message: {1}", key, ex.Message)); } } } } catch (Exception ex) { ctx.Logger.Error(string.Format("Could not read resources from {0}, Message: {1}", embeddedResource.Name, ex.Message)); } return list; }
public override void Create(DecompileContext ctx) { using (var writer = new StreamWriter(Filename, false, Encoding.UTF8)) { var output = new PlainTextOutput(writer); Decompile(ctx, output); } }
public override void Create(DecompileContext ctx) { using (var stream = File.Create(Filename)) { var data = embeddedResource.GetResourceData(); stream.Write(data, 0, data.Length); } }
public override void Create(DecompileContext ctx) { var settings = new XmlWriterSettings { Encoding = Encoding.UTF8, Indent = true, }; using (var writer = XmlWriter.Create(filename, settings)) { writer.WriteProcessingInstruction("xml", "version='1.0' encoding='utf-8'"); writer.WriteStartElement("SettingsFile", "http://schemas.microsoft.com/VisualStudio/2004/01/settings"); writer.WriteAttributeString("CurrentProfile", DEFAULT_PROFILE); writer.WriteAttributeString("GeneratedClassNamespace", type.ReflectionNamespace); writer.WriteAttributeString("GeneratedClassName", type.ReflectionName); writer.WriteStartElement("Profiles"); writer.WriteEndElement(); writer.WriteStartElement("Settings"); foreach (var setting in FindSettings()) { writer.WriteStartElement("Setting"); writer.WriteAttributeString("Name", setting.Name); if (!string.IsNullOrEmpty(setting.Description)) { writer.WriteAttributeString("Description", setting.Description); } if (!string.IsNullOrEmpty(setting.Provider)) { writer.WriteAttributeString("Provider", setting.Provider); } if (setting.Roaming) { writer.WriteAttributeString("Roaming", "true"); } if (!setting.GenerateDefaultValueInCode) { writer.WriteAttributeString("GenerateDefaultValueInCode", "false"); } writer.WriteAttributeString("Type", setting.Type); writer.WriteAttributeString("Scope", setting.Scope); if (setting.DesignTimeValue != null) { writer.WriteStartElement("DesignTimeValue"); writer.WriteAttributeString("Profile", setting.DesignTimeValue.Profile); writer.WriteString(setting.DesignTimeValue.Text); writer.WriteEndElement(); } writer.WriteStartElement("Value"); writer.WriteAttributeString("Profile", setting.Value.Profile); writer.WriteString(setting.Value.Text); writer.WriteEndElement(); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); } }
public override void Create(DecompileContext ctx) { InitializeIsEmpty(); if (!isEmpty) { base.Create(ctx); } }
protected override void Decompile(DecompileContext ctx, ITextOutput output) { var opts = new DecompilePartialType(type, output, decompilationContext); foreach (var d in GetDefsToRemove()) opts.Definitions.Add(d); opts.InterfacesToRemove.Add(new TypeRefUser(type.Module, "System.Windows.Markup", "IComponentConnector", new AssemblyNameInfo("WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35").ToAssemblyRef())); opts.InterfacesToRemove.Add(new TypeRefUser(type.Module, "System.Windows.Markup", "IComponentConnector", new AssemblyNameInfo("System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089").ToAssemblyRef())); language.Decompile(DecompilationType.PartialType, opts); }
protected override void Decompile(DecompileContext ctx, ITextOutput output) { var opts = new DecompilePartialType(type, output, decompilationContext); foreach (var d in GetDefsToRemove()) { opts.Definitions.Add(d); } language.Decompile(DecompilationType.PartialType, opts); }
public override void Create(DecompileContext ctx) { var list = ReadResourceEntries(ctx); using (var writer = new ResXResourceWriter(Filename, TypeNameConverter)) { foreach (var t in list) { ctx.CancellationToken.ThrowIfCancellationRequested(); writer.AddResource(t); } } }
protected override void Decompile(DecompileContext ctx, ITextOutput output) { if (!language.CanDecompile(DecompilationType.PartialType)) base.Decompile(ctx, output); else { var opts = new DecompilePartialType(type, output, decompilationContext); foreach (var d in GetDefsToRemove()) opts.Definitions.Add(d); language.Decompile(DecompilationType.PartialType, opts); } }
public override void Create(DecompileContext ctx) { IList<string> refs; using (var stream = File.Create(Filename)) refs = decompileBaml(bamlData, stream); foreach (var asmRef in refs) { var a = new AssemblyNameInfo(asmRef); if (!UTF8String.IsNullOrEmpty(a.Name)) asmRefs.Add(a); } }
protected override void Decompile(DecompileContext ctx, ITextOutput output) { var opts = new DecompilePartialType(type, output, decompilationContext); foreach (var d in GetDefsToRemove()) { opts.Definitions.Add(d); } opts.InterfacesToRemove.Add(new TypeRefUser(type.Module, "System.Windows.Markup", "IComponentConnector", new AssemblyNameInfo("WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35").ToAssemblyRef())); opts.InterfacesToRemove.Add(new TypeRefUser(type.Module, "System.Windows.Markup", "IComponentConnector", new AssemblyNameInfo("System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089").ToAssemblyRef())); language.Decompile(DecompilationType.PartialType, opts); }
public override void Create(DecompileContext ctx) { IList <string> refs; using (var stream = File.Create(Filename)) refs = decompileBaml(bamlData, stream); foreach (var asmRef in refs) { var a = new AssemblyNameInfo(asmRef); if (!UTF8String.IsNullOrEmpty(a.Name)) { asmRefs.Add(a); } } }
public override void Create(DecompileContext ctx) { using (var writer = new StreamWriter(Filename, false, Encoding.UTF8)) { if (typeFile.Language.CanDecompile(DecompilationType.PartialType)) { var output = new PlainTextOutput(writer); var opts = new DecompilePartialType(typeFile.Type, output, typeFile.DecompilationContext); foreach (var d in typeFile.GetDefsToRemove()) { opts.Definitions.Add(d); } opts.ShowDefinitions = true; typeFile.Language.Decompile(DecompilationType.PartialType, opts); } } }
protected override void Decompile(DecompileContext ctx, IDecompilerOutput output) { if (!language.CanDecompile(DecompilationType.PartialType)) { base.Decompile(ctx, output); } else { var opts = new DecompilePartialType(output, decompilationContext, Type); foreach (var d in GetDefsToRemove()) { opts.Definitions.Add(d); } language.Decompile(DecompilationType.PartialType, opts); } }
public override void Create(DecompileContext ctx) { var settings = new XmlWriterSettings { Encoding = Encoding.UTF8, Indent = true, }; using (var writer = XmlWriter.Create(filename, settings)) { writer.WriteProcessingInstruction("xml", "version='1.0' encoding='utf-8'"); writer.WriteStartElement("SettingsFile", "http://schemas.microsoft.com/VisualStudio/2004/01/settings"); writer.WriteAttributeString("CurrentProfile", DEFAULT_PROFILE); writer.WriteAttributeString("GeneratedClassNamespace", type.ReflectionNamespace); writer.WriteAttributeString("GeneratedClassName", type.ReflectionName); writer.WriteStartElement("Profiles"); writer.WriteEndElement(); writer.WriteStartElement("Settings"); foreach (var setting in FindSettings()) { writer.WriteStartElement("Setting"); writer.WriteAttributeString("Name", setting.Name); if (!string.IsNullOrEmpty(setting.Description)) writer.WriteAttributeString("Description", setting.Description); if (!string.IsNullOrEmpty(setting.Provider)) writer.WriteAttributeString("Provider", setting.Provider); if (setting.Roaming) writer.WriteAttributeString("Roaming", "true"); if (!setting.GenerateDefaultValueInCode) writer.WriteAttributeString("GenerateDefaultValueInCode", "false"); writer.WriteAttributeString("Type", setting.Type); writer.WriteAttributeString("Scope", setting.Scope); if (setting.DesignTimeValue != null) { writer.WriteStartElement("DesignTimeValue"); writer.WriteAttributeString("Profile", setting.DesignTimeValue.Profile); writer.WriteString(setting.DesignTimeValue.Text); writer.WriteEndElement(); } writer.WriteStartElement("Value"); writer.WriteAttributeString("Profile", setting.Value.Profile); writer.WriteString(setting.Value.Text); writer.WriteEndElement(); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndDocument(); } }
public override void Create(DecompileContext ctx) { using (var writer = new StreamWriter(Filename, false, Encoding.UTF8)) { if (winFormsFile.Language.CanDecompile(DecompilationType.PartialType)) { var output = createDecompilerOutput(writer); var opts = new DecompilePartialType(output, winFormsFile.DecompilationContext, winFormsFile.Type); foreach (var d in winFormsFile.GetDefsToRemove()) { opts.Definitions.Add(d); } opts.ShowDefinitions = true; opts.UseUsingDeclarations = false; winFormsFile.Language.Decompile(DecompilationType.PartialType, opts); } } }
public override void Create(DecompileContext ctx) { var settings = new XmlWriterSettings { Encoding = Encoding.UTF8, Indent = true, OmitXmlDeclaration = true, }; using (var writer = XmlWriter.Create(Filename, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("Application", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"); writer.WriteAttributeString("x", "Class", "http://schemas.microsoft.com/winfx/2006/xaml", type.ReflectionFullName); if (type.IsNotPublic) { var opts = BamlDecompilerOptions.Create(language); writer.WriteAttributeString("x", "ClassModifier", "http://schemas.microsoft.com/winfx/2006/xaml", opts.InternalClassModifier); } var body = GetInitializeComponentBody(); Debug.Assert(body != null); if (body != null) { var startupUri = GetStartupUri(body); if (startupUri != null) { writer.WriteAttributeString("StartupUri", startupUri); } foreach (var info in GetEvents(body)) { writer.WriteAttributeString(info.Item1, info.Item2); } } writer.WriteElementString("Application.Resources", "\r\n"); writer.WriteEndElement(); writer.WriteEndDocument(); } }
public void Create(DecompileContext ctx) { using (var stream = File.Create(Filename)) stream.Write(data, 0, data.Length); }
protected virtual void Decompile(DecompileContext ctx, IDecompilerOutput output) => language.Decompile(Type, output, decompilationContext);
public void Create() { SatelliteAssemblyFinder satelliteAssemblyFinder = null; try { var opts = new ParallelOptions { CancellationToken = options.CancellationToken, MaxDegreeOfParallelism = options.NumberOfThreads <= 0 ? Environment.ProcessorCount : options.NumberOfThreads, }; var filenameCreator = new FilenameCreator(options.Directory); var ctx = new DecompileContext(options.CancellationToken, logger); satelliteAssemblyFinder = new SatelliteAssemblyFinder(); Parallel.ForEach(options.ProjectModules, opts, modOpts => { options.CancellationToken.ThrowIfCancellationRequested(); string name; lock (filenameCreator) name = filenameCreator.Create(modOpts.Module); var p = new Project(modOpts, name, satelliteAssemblyFinder, options.CreateDecompilerOutput); lock (projects) projects.Add(p); p.CreateProjectFiles(ctx); }); var jobs = GetJobs().ToArray(); bool writeSolutionFile = !string.IsNullOrEmpty(options.SolutionFilename); int maxProgress = jobs.Length + projects.Count; if (writeSolutionFile) { maxProgress++; } progressListener.SetMaxProgress(maxProgress); Parallel.ForEach(GetJobs(), opts, job => { options.CancellationToken.ThrowIfCancellationRequested(); try { job.Create(ctx); } catch (OperationCanceledException) { throw; } catch (Exception ex) { var fjob = job as IFileJob; if (fjob != null) { logger.Error(string.Format(dnSpy_Languages_Resources.MSBuild_FileCreationFailed3, fjob.Filename, job.Description, ex.Message)); } else { logger.Error(string.Format(dnSpy_Languages_Resources.MSBuild_FileCreationFailed2, job.Description, ex.Message)); } } progressListener.SetProgress(Interlocked.Increment(ref totalProgress)); }); Parallel.ForEach(projects, opts, p => { options.CancellationToken.ThrowIfCancellationRequested(); try { var writer = new ProjectWriter(p, p.Options.ProjectVersion ?? options.ProjectVersion, projects, options.UserGACPaths); writer.Write(); } catch (OperationCanceledException) { throw; } catch (Exception ex) { logger.Error(string.Format(dnSpy_Languages_Resources.MSBuild_FailedToCreateProjectFile, p.Filename, ex.Message)); } progressListener.SetProgress(Interlocked.Increment(ref totalProgress)); }); if (writeSolutionFile) { options.CancellationToken.ThrowIfCancellationRequested(); try { var writer = new SolutionWriter(options.ProjectVersion, projects, SolutionFilename); writer.Write(); } catch (OperationCanceledException) { throw; } catch (Exception ex) { logger.Error(string.Format(dnSpy_Languages_Resources.MSBuild_FailedToCreateSolutionFile, SolutionFilename, ex.Message)); } progressListener.SetProgress(Interlocked.Increment(ref totalProgress)); } Debug.Assert(totalProgress == maxProgress); progressListener.SetProgress(maxProgress); } finally { if (satelliteAssemblyFinder != null) { satelliteAssemblyFinder.Dispose(); } } }
public override void Create(DecompileContext ctx) { using (var writer = new StreamWriter(Filename, false, Encoding.UTF8)) { if (winFormsFile.Language.CanDecompile(DecompilationType.PartialType)) { var output = new PlainTextOutput(writer); var opts = new DecompilePartialType(winFormsFile.Type, output, winFormsFile.DecompilationContext); foreach (var d in winFormsFile.GetDefsToRemove()) opts.Definitions.Add(d); opts.ShowDefinitions = true; opts.UseUsingDeclarations = false; winFormsFile.Language.Decompile(DecompilationType.PartialType, opts); } } }
public override void Create(DecompileContext ctx) { // ApplicationManifest writes the file }
public void CreateProjectFiles(DecompileContext ctx) { var filenameCreator = new FilenameCreator(Directory, DefaultNamespace); var resourceNameCreator = new ResourceNameCreator(Options.Module, filenameCreator); AllowUnsafeBlocks = DotNetUtils.IsUnsafe(Options.Module); InitializeSplashScreen(); if (Options.Language.CanDecompile(DecompilationType.AssemblyInfo)) { var filename = filenameCreator.CreateFromRelativePath(Path.Combine(PropertiesFolder, "AssemblyInfo"), Options.Language.FileExtension); Files.Add(new AssemblyInfoProjectFile(Options.Module, filename, Options.DecompilationContext, Options.Language, createDecompilerOutput)); } var ep = Options.Module.EntryPoint; if (ep != null && ep.DeclaringType != null) { StartupObject = ep.DeclaringType.ReflectionFullName; } applicationManifest = ApplicationManifest.TryCreate(Options.Module.Win32Resources, filenameCreator); if (ApplicationManifest != null) { Files.Add(new ApplicationManifestProjectFile(ApplicationManifest.Filename)); } foreach (var rsrc in Options.Module.Resources) { ctx.CancellationToken.ThrowIfCancellationRequested(); switch (rsrc.ResourceType) { case ResourceType.Embedded: foreach (var file in CreateEmbeddedResourceFiles(Options.Module, resourceNameCreator, (EmbeddedResource)rsrc)) { Files.Add(file); Files.AddRange(CreateSatelliteFiles(rsrc.Name, filenameCreator, file)); } break; case ResourceType.AssemblyLinked: //TODO: What should be created here? break; case ResourceType.Linked: //TODO: What should be created here? break; default: break; } } InitializeXaml(); InitializeResX(); foreach (var type in Options.Module.Types) { ctx.CancellationToken.ThrowIfCancellationRequested(); if (!DecompileType(type)) { continue; } Files.Add(CreateTypeProjectFile(type, filenameCreator)); } CreateEmptyAppXamlFile(); var existingAppConfig = Options.Module.Location + ".config"; if (File.Exists(existingAppConfig)) { Files.Add(new AppConfigProjectFile(filenameCreator.CreateName("App.config"), existingAppConfig)); } applicationIcon = ApplicationIcon.TryCreate(Options.Module.Win32Resources, Path.GetFileName(Directory), filenameCreator); var dirs = new HashSet <string>(Files.Select(a => GetDirectoryName(a.Filename)).Where(a => a != null), StringComparer.OrdinalIgnoreCase); int errors = 0; foreach (var dir in dirs) { ctx.CancellationToken.ThrowIfCancellationRequested(); try { System.IO.Directory.CreateDirectory(dir); } catch (Exception ex) { if (errors++ < 20) { ctx.Logger.Error(string.Format(dnSpy_Languages_Resources.MSBuild_CouldNotCreateDirectory2, dir, ex.Message)); } } } }
public override void Create(DecompileContext ctx) { var settings = new XmlWriterSettings { Encoding = Encoding.UTF8, Indent = true, OmitXmlDeclaration = true, }; using (var writer = XmlWriter.Create(Filename, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("Application", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"); writer.WriteAttributeString("x", "Class", "http://schemas.microsoft.com/winfx/2006/xaml", type.ReflectionFullName); if (type.IsNotPublic) { var opts = BamlDecompilerOptions.Create(language); writer.WriteAttributeString("x", "ClassModifier", "http://schemas.microsoft.com/winfx/2006/xaml", opts.InternalClassModifier); } var body = GetInitializeComponentBody(); Debug.Assert(body != null); if (body != null) { var startupUri = GetStartupUri(body); if (startupUri != null) writer.WriteAttributeString("StartupUri", startupUri); foreach (var info in GetEvents(body)) writer.WriteAttributeString(info.Item1, info.Item2); } writer.WriteElementString("Application.Resources", "\r\n"); writer.WriteEndElement(); writer.WriteEndDocument(); } }
public void Create() { SatelliteAssemblyFinder satelliteAssemblyFinder = null; try { var opts = new ParallelOptions { CancellationToken = options.CancellationToken, MaxDegreeOfParallelism = options.NumberOfThreads <= 0 ? Environment.ProcessorCount : options.NumberOfThreads, }; var filenameCreator = new FilenameCreator(options.Directory); var ctx = new DecompileContext(options.CancellationToken, logger); satelliteAssemblyFinder = new SatelliteAssemblyFinder(); Parallel.ForEach(options.ProjectModules, opts, modOpts => { AppCulture.InitializeCulture(); options.CancellationToken.ThrowIfCancellationRequested(); string name; lock (filenameCreator) name = filenameCreator.Create(modOpts.Module); var p = new Project(modOpts, name, satelliteAssemblyFinder); lock (projects) projects.Add(p); p.CreateProjectFiles(ctx); }); var jobs = GetJobs().ToArray(); bool writeSolutionFile = !string.IsNullOrEmpty(options.SolutionFilename); int maxProgress = jobs.Length + projects.Count; if (writeSolutionFile) maxProgress++; progressListener.SetMaxProgress(maxProgress); Parallel.ForEach(GetJobs(), opts, job => { AppCulture.InitializeCulture(); options.CancellationToken.ThrowIfCancellationRequested(); try { job.Create(ctx); } catch (OperationCanceledException) { throw; } catch (Exception ex) { var fjob = job as IFileJob; if (fjob != null) logger.Error(string.Format(Languages_Resources.MSBuild_FileCreationFailed3, fjob.Filename, job.Description, ex.Message)); else logger.Error(string.Format(Languages_Resources.MSBuild_FileCreationFailed2, job.Description, ex.Message)); } progressListener.SetProgress(Interlocked.Increment(ref totalProgress)); }); Parallel.ForEach(projects, opts, p => { AppCulture.InitializeCulture(); options.CancellationToken.ThrowIfCancellationRequested(); try { var writer = new ProjectWriter(p, p.Options.ProjectVersion ?? options.ProjectVersion, projects, options.UserGACPaths); writer.Write(); } catch (OperationCanceledException) { throw; } catch (Exception ex) { logger.Error(string.Format(Languages_Resources.MSBuild_FailedToCreateProjectFile, p.Filename, ex.Message)); } progressListener.SetProgress(Interlocked.Increment(ref totalProgress)); }); if (writeSolutionFile) { options.CancellationToken.ThrowIfCancellationRequested(); try { var writer = new SolutionWriter(options.ProjectVersion, projects, SolutionFilename); writer.Write(); } catch (OperationCanceledException) { throw; } catch (Exception ex) { logger.Error(string.Format(Languages_Resources.MSBuild_FailedToCreateSolutionFile, SolutionFilename, ex.Message)); } progressListener.SetProgress(Interlocked.Increment(ref totalProgress)); } Debug.Assert(totalProgress == maxProgress); progressListener.SetProgress(maxProgress); } finally { if (satelliteAssemblyFinder != null) satelliteAssemblyFinder.Dispose(); } }
public override void Create(DecompileContext ctx) { File.Copy(existingName, Filename, true); }
protected virtual void Decompile(DecompileContext ctx, ITextOutput output) { language.Decompile(type, output, decompilationContext); }
public override void Create(DecompileContext ctx) { InitializeIsEmpty(); if (!isEmpty) base.Create(ctx); }
public void CreateProjectFiles(DecompileContext ctx) { var filenameCreator = new FilenameCreator(projDir, defaultNamespace); var resourceNameCreator = new ResourceNameCreator(options.Module, filenameCreator); AllowUnsafeBlocks = DotNetUtils.IsUnsafe(options.Module); InitializeSplashScreen(); if (options.Language.CanDecompile(DecompilationType.AssemblyInfo)) { var filename = filenameCreator.CreateFromRelativePath(Path.Combine(PropertiesFolder, "AssemblyInfo"), options.Language.FileExtension); files.Add(new AssemblyInfoProjectFile(options.Module, filename, options.DecompilationContext, options.Language)); } var ep = options.Module.EntryPoint; if (ep != null && ep.DeclaringType != null) StartupObject = ep.DeclaringType.ReflectionFullName; applicationManifest = ApplicationManifest.TryCreate(options.Module.Win32Resources, filenameCreator); if (applicationManifest != null) files.Add(new ApplicationManifestProjectFile(applicationManifest.Filename)); foreach (var rsrc in options.Module.Resources) { ctx.CancellationToken.ThrowIfCancellationRequested(); switch (rsrc.ResourceType) { case ResourceType.Embedded: foreach (var file in CreateEmbeddedResourceFiles(options.Module, resourceNameCreator, (EmbeddedResource)rsrc)) { files.Add(file); files.AddRange(CreateSatelliteFiles(rsrc.Name, filenameCreator, file)); } break; case ResourceType.AssemblyLinked: //TODO: What should be created here? break; case ResourceType.Linked: //TODO: What should be created here? break; default: break; } } InitializeXaml(); InitializeResX(); foreach (var type in options.Module.Types) { ctx.CancellationToken.ThrowIfCancellationRequested(); if (!DecompileType(type)) continue; files.Add(CreateTypeProjectFile(type, filenameCreator)); } CreateEmptyAppXamlFile(); var existingAppConfig = options.Module.Location + ".config"; if (File.Exists(existingAppConfig)) files.Add(new AppConfigProjectFile(filenameCreator.CreateName("App.config"), existingAppConfig)); applicationIcon = ApplicationIcon.TryCreate(options.Module.Win32Resources, Path.GetFileName(Directory), filenameCreator); var dirs = new HashSet<string>(files.Select(a => Path.GetDirectoryName(a.Filename)), StringComparer.OrdinalIgnoreCase); foreach (var dir in dirs) { ctx.CancellationToken.ThrowIfCancellationRequested(); try { System.IO.Directory.CreateDirectory(dir); } catch (Exception ex) { ctx.Logger.Error(string.Format(Languages_Resources.MSBuild_CouldNotCreateDirectory2, dir, ex.Message)); } } }
public override void Create(DecompileContext ctx) { using (var stream = File.Create(Filename)) stream.Write(data, 0, data.Length); }