Browse Source

#2850: swap try-catch and using statement so that exception handling shows the file being decompiled causing the IOException.

pull/2857/head
Siegfried Pammer 2 years ago
parent
commit
cedad6d5e8
  1. 4
      ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs

4
ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs

@ -259,10 +259,9 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
CancellationToken = cancellationToken CancellationToken = cancellationToken
}, },
delegate (IGrouping<string, TypeDefinitionHandle> file) { delegate (IGrouping<string, TypeDefinitionHandle> file) {
using (StreamWriter w = new StreamWriter(Path.Combine(TargetDirectory, file.Key)))
{
try try
{ {
using StreamWriter w = new StreamWriter(Path.Combine(TargetDirectory, file.Key));
CSharpDecompiler decompiler = CreateDecompiler(ts); CSharpDecompiler decompiler = CreateDecompiler(ts);
foreach (var partialType in partialTypes) foreach (var partialType in partialTypes)
@ -298,7 +297,6 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
{ {
throw new DecompilerException(module, $"Error decompiling for '{file.Key}'", innerException); throw new DecompilerException(module, $"Error decompiling for '{file.Key}'", innerException);
} }
}
progress.Status = file.Key; progress.Status = file.Key;
Interlocked.Increment(ref progress.UnitsCompleted); Interlocked.Increment(ref progress.UnitsCompleted);
progressReporter?.Report(progress); progressReporter?.Report(progress);

Loading…
Cancel
Save