ProjectFile CreateTypeProjectFile(TypeDef type, FilenameCreator filenameCreator) { var bamlFile = TryGetBamlFile(type); if (bamlFile != null) { var filename = filenameCreator.Create(GetTypeExtension(type), type.FullName); TypeProjectFile newFile; var isAppType = DotNetUtils.IsSystemWindowsApplication(type); if (!options.Language.CanDecompile(DecompilationType.PartialType)) newFile = new TypeProjectFile(type, filename, options.DecompilationContext, options.Language); else newFile = new XamlTypeProjectFile(type, filename, options.DecompilationContext, options.Language); newFile.DependentUpon = bamlFile; if (isAppType && DotNetUtils.IsStartUpClass(type)) { bamlFile.IsAppDef = true; StartupObject = null; } if (isAppType) appTypeProjFile = newFile; return newFile; } const string DESIGNER = ".Designer"; var resxFile = TryGetResXFile(type); if (resxFile != null) { if (DotNetUtils.IsWinForm(type)) { var filename = filenameCreator.CreateFromNamespaceName(GetTypeExtension(type), type.ReflectionNamespace, Path.GetFileNameWithoutExtension(resxFile.Filename)); var newFile = new WinFormsProjectFile(type, filename, options.DecompilationContext, options.Language); resxFile.DependentUpon = newFile; var dname = filenameCreator.CreateFromNamespaceName(GetTypeExtension(type), type.ReflectionNamespace, Path.GetFileNameWithoutExtension(resxFile.Filename) + DESIGNER); var winFormsDesignerFile = new WinFormsDesignerProjectFile(newFile, dname); winFormsDesignerFile.DependentUpon = newFile; files.Add(winFormsDesignerFile); return newFile; } else { var filename = filenameCreator.CreateFromNamespaceName(GetTypeExtension(type), type.ReflectionNamespace, Path.GetFileNameWithoutExtension(resxFile.Filename) + DESIGNER); var newFile = new TypeProjectFile(type, filename, options.DecompilationContext, options.Language); newFile.DependentUpon = resxFile; newFile.AutoGen = true; newFile.DesignTime = true; resxFile.Generator = type.IsPublic ? "PublicResXFileCodeGenerator" : "ResXFileCodeGenerator"; resxFile.LastGenOutput = newFile; return newFile; } } var bt = type.BaseType; if (bt != null && bt.FullName == "System.Configuration.ApplicationSettingsBase") { var designerFilename = filenameCreator.Create(DESIGNER + GetTypeExtension(type), type.FullName); var settingsFilename = filenameCreator.Create(".settings", type.FullName); ProjectFile designerTypeFile; if (options.Language.CanDecompile(DecompilationType.PartialType)) { var typeFilename = filenameCreator.Create(GetTypeExtension(type), type.FullName); var settingsTypeFile = new SettingsTypeProjectFile(type, typeFilename, options.DecompilationContext, options.Language); designerTypeFile = new SettingsDesignerTypeProjectFile(settingsTypeFile, designerFilename); files.Add(settingsTypeFile); } else designerTypeFile = new TypeProjectFile(type, designerFilename, options.DecompilationContext, options.Language); var settingsFile = new SettingsProjectFile(type, settingsFilename); designerTypeFile.DependentUpon = settingsFile; designerTypeFile.AutoGen = true; designerTypeFile.DesignTimeSharedInput = true; settingsFile.Generator = type.IsPublic ? "PublicSettingsSingleFileGenerator" : "SettingsSingleFileGenerator"; settingsFile.LastGenOutput = designerTypeFile; files.Add(settingsFile); return designerTypeFile; } var newFilename = filenameCreator.Create(GetTypeExtension(type), type.FullName); return new TypeProjectFile(type, newFilename, options.DecompilationContext, options.Language); }
ProjectFile CreateTypeProjectFile(TypeDef type, FilenameCreator filenameCreator) { var bamlFile = TryGetBamlFile(type); if (bamlFile != null) { var filename = filenameCreator.Create(GetTypeExtension(type), type.FullName); TypeProjectFile newFile; var isAppType = DotNetUtils.IsSystemWindowsApplication(type); if (!Options.Language.CanDecompile(DecompilationType.PartialType)) { newFile = new TypeProjectFile(type, filename, Options.DecompilationContext, Options.Language, createDecompilerOutput); } else { newFile = new XamlTypeProjectFile(type, filename, Options.DecompilationContext, Options.Language, createDecompilerOutput); } newFile.DependentUpon = bamlFile; if (isAppType && DotNetUtils.IsStartUpClass(type)) { bamlFile.IsAppDef = true; StartupObject = null; } if (isAppType) { appTypeProjFile = newFile; } return(newFile); } const string DESIGNER = ".Designer"; var resxFile = TryGetResXFile(type); if (resxFile != null) { if (DotNetUtils.IsWinForm(type)) { var filename = filenameCreator.CreateFromNamespaceName(GetTypeExtension(type), type.ReflectionNamespace, Path.GetFileNameWithoutExtension(resxFile.Filename)); var newFile = new WinFormsProjectFile(type, filename, Options.DecompilationContext, Options.Language, createDecompilerOutput); resxFile.DependentUpon = newFile; var dname = filenameCreator.CreateFromNamespaceName(GetTypeExtension(type), type.ReflectionNamespace, Path.GetFileNameWithoutExtension(resxFile.Filename) + DESIGNER); var winFormsDesignerFile = new WinFormsDesignerProjectFile(newFile, dname, createDecompilerOutput); winFormsDesignerFile.DependentUpon = newFile; Files.Add(winFormsDesignerFile); return(newFile); } else { var filename = filenameCreator.CreateFromNamespaceName(GetTypeExtension(type), type.ReflectionNamespace, Path.GetFileNameWithoutExtension(resxFile.Filename) + DESIGNER); var newFile = new TypeProjectFile(type, filename, Options.DecompilationContext, Options.Language, createDecompilerOutput); newFile.DependentUpon = resxFile; newFile.AutoGen = true; newFile.DesignTime = true; resxFile.Generator = type.IsPublic ? "PublicResXFileCodeGenerator" : "ResXFileCodeGenerator"; resxFile.LastGenOutput = newFile; return(newFile); } } var bt = type.BaseType; if (bt != null && bt.FullName == "System.Configuration.ApplicationSettingsBase") { var designerFilename = filenameCreator.Create(DESIGNER + GetTypeExtension(type), type.FullName); var settingsFilename = filenameCreator.Create(".settings", type.FullName); ProjectFile designerTypeFile; if (Options.Language.CanDecompile(DecompilationType.PartialType)) { var typeFilename = filenameCreator.Create(GetTypeExtension(type), type.FullName); var settingsTypeFile = new SettingsTypeProjectFile(type, typeFilename, Options.DecompilationContext, Options.Language, createDecompilerOutput); designerTypeFile = new SettingsDesignerTypeProjectFile(settingsTypeFile, designerFilename, createDecompilerOutput); Files.Add(settingsTypeFile); } else { designerTypeFile = new TypeProjectFile(type, designerFilename, Options.DecompilationContext, Options.Language, createDecompilerOutput); } var settingsFile = new SettingsProjectFile(type, settingsFilename); designerTypeFile.DependentUpon = settingsFile; designerTypeFile.AutoGen = true; designerTypeFile.DesignTimeSharedInput = true; settingsFile.Generator = type.IsPublic ? "PublicSettingsSingleFileGenerator" : "SettingsSingleFileGenerator"; settingsFile.LastGenOutput = designerTypeFile; Files.Add(settingsFile); return(designerTypeFile); } var newFilename = filenameCreator.Create(GetTypeExtension(type), type.FullName); return(new TypeProjectFile(type, newFilename, Options.DecompilationContext, Options.Language, createDecompilerOutput)); }