|
|
|
@ -259,45 +259,43 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
@@ -259,45 +259,43 @@ namespace ICSharpCode.Decompiler.CSharp.ProjectDecompiler
|
|
|
|
|
CancellationToken = cancellationToken |
|
|
|
|
}, |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
foreach (var partialType in partialTypes) |
|
|
|
|
{ |
|
|
|
|
CSharpDecompiler decompiler = CreateDecompiler(ts); |
|
|
|
|
decompiler.AddPartialTypeDefinition(partialType); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach (var partialType in partialTypes) |
|
|
|
|
decompiler.CancellationToken = cancellationToken; |
|
|
|
|
var declaredTypes = file.ToArray(); |
|
|
|
|
var syntaxTree = decompiler.DecompileTypes(declaredTypes); |
|
|
|
|
|
|
|
|
|
foreach (var node in syntaxTree.Descendants) |
|
|
|
|
{ |
|
|
|
|
var td = (node.GetResolveResult() as TypeResolveResult)?.Type.GetDefinition(); |
|
|
|
|
if (td?.ParentModule != ts.MainModule) |
|
|
|
|
continue; |
|
|
|
|
while (td?.DeclaringTypeDefinition != null) |
|
|
|
|
{ |
|
|
|
|
decompiler.AddPartialTypeDefinition(partialType); |
|
|
|
|
td = td.DeclaringTypeDefinition; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
decompiler.CancellationToken = cancellationToken; |
|
|
|
|
var declaredTypes = file.ToArray(); |
|
|
|
|
var syntaxTree = decompiler.DecompileTypes(declaredTypes); |
|
|
|
|
|
|
|
|
|
foreach (var node in syntaxTree.Descendants) |
|
|
|
|
if (td != null && td.MetadataToken is { IsNil: false } token && !processedTypes.Contains((TypeDefinitionHandle)token)) |
|
|
|
|
{ |
|
|
|
|
var td = (node.GetResolveResult() as TypeResolveResult)?.Type.GetDefinition(); |
|
|
|
|
if (td?.ParentModule != ts.MainModule) |
|
|
|
|
continue; |
|
|
|
|
while (td?.DeclaringTypeDefinition != null) |
|
|
|
|
{ |
|
|
|
|
td = td.DeclaringTypeDefinition; |
|
|
|
|
} |
|
|
|
|
if (td != null && td.MetadataToken is { IsNil: false } token && !processedTypes.Contains((TypeDefinitionHandle)token)) |
|
|
|
|
lock (workList) |
|
|
|
|
{ |
|
|
|
|
lock (workList) |
|
|
|
|
{ |
|
|
|
|
workList.Add((TypeDefinitionHandle)token); |
|
|
|
|
} |
|
|
|
|
workList.Add((TypeDefinitionHandle)token); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
syntaxTree.AcceptVisitor(new CSharpOutputVisitor(w, Settings.CSharpFormattingOptions)); |
|
|
|
|
} |
|
|
|
|
catch (Exception innerException) when (!(innerException is OperationCanceledException || innerException is DecompilerException)) |
|
|
|
|
{ |
|
|
|
|
throw new DecompilerException(module, $"Error decompiling for '{file.Key}'", innerException); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
syntaxTree.AcceptVisitor(new CSharpOutputVisitor(w, Settings.CSharpFormattingOptions)); |
|
|
|
|
} |
|
|
|
|
catch (Exception innerException) when (!(innerException is OperationCanceledException || innerException is DecompilerException)) |
|
|
|
|
{ |
|
|
|
|
throw new DecompilerException(module, $"Error decompiling for '{file.Key}'", innerException); |
|
|
|
|
} |
|
|
|
|
progress.Status = file.Key; |
|
|
|
|
Interlocked.Increment(ref progress.UnitsCompleted); |
|
|
|
|