@@ -52,17 +52,7 @@ public void Execute(TextViewContext context)
5252 if ( selectedNodes == null || selectedNodes . Length == 0 )
5353 return ;
5454
55- if ( selectedNodes . Length == 1 )
56- {
57- var assembly = selectedNodes . First ( ) . LoadedAssembly ;
58- if ( assembly == null )
59- return ;
60- GeneratePdbForAssembly ( assembly , languageService , dockWorkspace ) ;
61- }
62- else
63- {
64- GeneratePdbForAssemblies ( selectedNodes . Select ( n => n . LoadedAssembly ) , languageService , dockWorkspace ) ;
65- }
55+ GeneratePdbForAssemblies ( selectedNodes . Select ( n => n . LoadedAssembly ) , languageService , dockWorkspace ) ;
6656 }
6757
6858 public bool IsEnabled ( TextViewContext context ) => true ;
@@ -74,50 +64,6 @@ public bool IsVisible(TextViewContext context)
7464 && selectedNodes . All ( n => n is AssemblyTreeNode asm && asm . LoadedAssembly . IsLoadedAsValidAssembly ) ;
7565 }
7666
77- internal static void GeneratePdbForAssembly ( LoadedAssembly assembly , LanguageService languageService , DockWorkspace dockWorkspace )
78- {
79- var file = assembly . GetMetadataFileOrNull ( ) as PEFile ;
80- if ( ! PortablePdbWriter . HasCodeViewDebugDirectoryEntry ( file ) )
81- {
82- MessageBox . Show ( string . Format ( Resources . CannotCreatePDBFile , Path . GetFileName ( assembly . FileName ) ) ) ;
83- return ;
84- }
85- SaveFileDialog dlg = new SaveFileDialog ( ) ;
86- dlg . FileName = WholeProjectDecompiler . CleanUpFileName ( assembly . ShortName , ".pdb" ) ;
87- dlg . Filter = Resources . PortablePDBPdbAllFiles ;
88- dlg . InitialDirectory = Path . GetDirectoryName ( assembly . FileName ) ;
89- if ( dlg . ShowDialog ( ) != true )
90- return ;
91- DecompilationOptions options = dockWorkspace . ActiveTabPage . CreateDecompilationOptions ( ) ;
92- string fileName = dlg . FileName ;
93- dockWorkspace . RunWithCancellation ( ct => Task < AvalonEditTextOutput > . Factory . StartNew ( ( ) => {
94- AvalonEditTextOutput output = new AvalonEditTextOutput ( ) ;
95- Stopwatch stopwatch = Stopwatch . StartNew ( ) ;
96- options . CancellationToken = ct ;
97- using ( FileStream stream = new FileStream ( fileName , FileMode . Create , FileAccess . Write ) )
98- {
99- try
100- {
101- var decompiler = new CSharpDecompiler ( file , assembly . GetAssemblyResolver ( options . DecompilerSettings . AutoLoadAssemblyReferences ) , options . DecompilerSettings ) ;
102- decompiler . CancellationToken = ct ;
103- PortablePdbWriter . WritePdb ( file , decompiler , options . DecompilerSettings , stream , progress : options . Progress , currentProgressTitle : string . Format ( Resources . GeneratingPortablePDB , Path . GetFileName ( assembly . FileName ) ) ) ;
104- }
105- catch ( OperationCanceledException )
106- {
107- output . WriteLine ( ) ;
108- output . WriteLine ( Resources . GenerationWasCancelled ) ;
109- throw ;
110- }
111- }
112- stopwatch . Stop ( ) ;
113- output . WriteLine ( Resources . GenerationCompleteInSeconds , stopwatch . Elapsed . TotalSeconds . ToString ( "F1" ) ) ;
114- output . WriteLine ( ) ;
115- output . AddButton ( null , Resources . OpenExplorer , delegate { ShellHelper . OpenFolderAndSelectItem ( fileName ) ; } ) ;
116- output . WriteLine ( ) ;
117- return output ;
118- } , ct ) ) . Then ( dockWorkspace . ShowText ) . HandleExceptions ( ) ;
119- }
120-
12167 internal static void GeneratePdbForAssemblies ( IEnumerable < LoadedAssembly > assemblies , LanguageService languageService , DockWorkspace dockWorkspace )
12268 {
12369 var assemblyArray = assemblies ? . Where ( a => a != null ) . ToArray ( ) ?? [ ] ;
@@ -258,17 +204,7 @@ public override void Execute(object parameter)
258204 if ( selectedNodes == null || selectedNodes . Length == 0 )
259205 return ;
260206
261- if ( selectedNodes . Length == 1 )
262- {
263- var assembly = selectedNodes . First ( ) . LoadedAssembly ;
264- if ( assembly == null )
265- return ;
266- GeneratePdbContextMenuEntry . GeneratePdbForAssembly ( assembly , languageService , dockWorkspace ) ;
267- }
268- else
269- {
270- GeneratePdbContextMenuEntry . GeneratePdbForAssemblies ( selectedNodes . Select ( n => n . LoadedAssembly ) , languageService , dockWorkspace ) ;
271- }
207+ GeneratePdbContextMenuEntry . GeneratePdbForAssemblies ( selectedNodes . Select ( n => n . LoadedAssembly ) , languageService , dockWorkspace ) ;
272208 }
273209 }
274210}
0 commit comments