@ -19,6 +19,7 @@
#if DEBUG
#if DEBUG
using System ;
using System ;
using System.Collections.Concurrent ;
using System.Diagnostics ;
using System.Diagnostics ;
using System.Linq ;
using System.Linq ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
@ -40,29 +41,32 @@ namespace ICSharpCode.ILSpy
{
{
Docking . DockWorkspace . Instance . RunWithCancellation ( ct = > Task < AvalonEditTextOutput > . Factory . StartNew ( ( ) = > {
Docking . DockWorkspace . Instance . RunWithCancellation ( ct = > Task < AvalonEditTextOutput > . Factory . StartNew ( ( ) = > {
AvalonEditTextOutput output = new AvalonEditTextOutput ( ) ;
AvalonEditTextOutput output = new AvalonEditTextOutput ( ) ;
Parallel . ForEach ( MainWindow . Instance . CurrentAssemblyList . GetAssemblies ( ) , new ParallelOptions { MaxDegreeOfParallelism = Environment . ProcessorCount , CancellationToken = ct } , delegate ( LoadedAssembly asm ) {
Parallel . ForEach (
if ( ! asm . HasLoadError ) {
Partitioner . Create ( MainWindow . Instance . CurrentAssemblyList . GetAssemblies ( ) , loadBalance : true ) ,
Stopwatch w = Stopwatch . StartNew ( ) ;
new ParallelOptions { MaxDegreeOfParallelism = Environment . ProcessorCount , CancellationToken = ct } ,
Exception exception = null ;
delegate ( LoadedAssembly asm ) {
using ( var writer = new System . IO . StreamWriter ( "c:\\temp\\decompiled\\" + asm . ShortName + ".cs" ) ) {
if ( ! asm . HasLoadError ) {
try {
Stopwatch w = Stopwatch . StartNew ( ) ;
new CSharpLanguage ( ) . DecompileAssembly ( asm , new Decompiler . PlainTextOutput ( writer ) , new DecompilationOptions ( ) { FullDecompilation = true , CancellationToken = ct } ) ;
Exception exception = null ;
using ( var writer = new System . IO . StreamWriter ( "c:\\temp\\decompiled\\" + asm . ShortName + ".cs" ) ) {
try {
new CSharpLanguage ( ) . DecompileAssembly ( asm , new Decompiler . PlainTextOutput ( writer ) , new DecompilationOptions ( ) { FullDecompilation = true , CancellationToken = ct } ) ;
}
catch ( Exception ex ) {
writer . WriteLine ( ex . ToString ( ) ) ;
exception = ex ;
}
}
}
catch ( Exception ex ) {
lock ( output ) {
writer . WriteLine ( ex . ToString ( ) ) ;
output . Write ( asm . ShortName + " - " + w . Elapsed ) ;
exception = ex ;
if ( exception ! = null ) {
output . Write ( " - " ) ;
output . Write ( exception . GetType ( ) . Name ) ;
}
output . WriteLine ( ) ;
}
}
}
}
lock ( output ) {
} ) ;
output . Write ( asm . ShortName + " - " + w . Elapsed ) ;
if ( exception ! = null ) {
output . Write ( " - " ) ;
output . Write ( exception . GetType ( ) . Name ) ;
}
output . WriteLine ( ) ;
}
}
} ) ;
return output ;
return output ;
} , ct ) ) . Then ( output = > Docking . DockWorkspace . Instance . ShowText ( output ) ) . HandleExceptions ( ) ;
} , ct ) ) . Then ( output = > Docking . DockWorkspace . Instance . ShowText ( output ) ) . HandleExceptions ( ) ;
}
}