Skip to content

Commit a0a95e9

Browse files
committed
Enable project file generation when exporting decompiled assemblies, fix progress notification
1 parent 7e6ac9e commit a0a95e9

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

backend/ILSpyX.Backend/Decompiler/DecompilerBackend.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ private async Task<ExportAssemblyResult> ExportCSharpAsync(
564564
settings.UseNestedDirectoriesForNamespaces = true;
565565

566566
var resolver = loadedAssembly.GetAssemblyResolver(true);
567-
var projectDecompiler = new CodeOnlyProjectDecompiler(
567+
var projectDecompiler = new SimpleProjectDecompiler(
568568
settings,
569569
resolver,
570570
metadataFile,
@@ -785,15 +785,15 @@ private static string CreateUniqueDirectory(string baseDirectory, string folderN
785785
return candidate;
786786
}
787787

788-
private sealed class CodeOnlyProjectDecompiler : WholeProjectDecompiler
788+
private sealed class SimpleProjectDecompiler : WholeProjectDecompiler
789789
{
790790
private readonly bool includeCompilerGenerated;
791791
private readonly DecompilerTypeSystem? typeSystem;
792792
private int filesWritten;
793793

794794
public int FilesWritten => filesWritten;
795795

796-
public CodeOnlyProjectDecompiler(
796+
public SimpleProjectDecompiler(
797797
DecompilerSettings settings,
798798
IAssemblyResolver assemblyResolver,
799799
MetadataFile metadataFile,
@@ -835,11 +835,6 @@ protected override IEnumerable<ProjectItemInfo> WriteMiscellaneousFilesInProject
835835

836836
protected override TextWriter CreateFile(string path)
837837
{
838-
if (path.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase))
839-
{
840-
return TextWriter.Null;
841-
}
842-
843838
Interlocked.Increment(ref filesWritten);
844839
return base.CreateFile(path);
845840
}

vscode-extension/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ A description of the extension's features can be found in [Feature Tour](https:/
1111

1212
## Export decompiled code
1313

14-
To export all decompiled code of a loaded assembly (keeping the namespace directory structure), right-click the assembly node in the `ILSpy: Assemblies` view and run `Export Decompiled Code...`.
14+
To export all decompiled code of a loaded assembly, right-click the assembly node in the `ILSpy: Assemblies` view and run `Export Decompiled Code...`. This will generate a complete C# project including:
15+
- All decompiled source files organized by namespace
16+
- A .csproj project file for easy compilation
1517

1618
## Requirements
1719

vscode-extension/src/commands/exportDecompiledAssembly.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,25 @@ export function registerExportDecompiledAssemblyCommand(
8181
const fileCount = response.filesWritten ?? 0;
8282

8383
if (response.errorCount > 0) {
84-
const choice = await vscode.window.showWarningMessage(
84+
vscode.window.showWarningMessage(
8585
`Exported ${fileCount} files to ${outputDirectory} with ${response.errorCount} errors.`,
8686
"Reveal in File Explorer"
87-
);
88-
if (choice === "Reveal in File Explorer") {
89-
vscode.commands.executeCommand("revealFileInOS", outputUri);
90-
}
87+
).then((choice) => {
88+
if (choice === "Reveal in File Explorer") {
89+
vscode.commands.executeCommand("revealFileInOS", outputUri);
90+
}
91+
});
9192
return;
9293
}
9394

94-
const choice = await vscode.window.showInformationMessage(
95+
vscode.window.showInformationMessage(
9596
`Exported ${fileCount} files to ${outputDirectory}`,
9697
"Reveal in File Explorer"
97-
);
98-
if (choice === "Reveal in File Explorer") {
99-
vscode.commands.executeCommand("revealFileInOS", outputUri);
100-
}
98+
).then((choice) => {
99+
if (choice === "Reveal in File Explorer") {
100+
vscode.commands.executeCommand("revealFileInOS", outputUri);
101+
}
102+
});
101103
} catch (err) {
102104
if (token.isCancellationRequested) {
103105
return;

0 commit comments

Comments
 (0)