Skip to content

Commit fb33c7f

Browse files
committed
Merge branch 'export-decompiled-code'
2 parents 6b7dc4d + a0a95e9 commit fb33c7f

13 files changed

Lines changed: 698 additions & 3 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2025 ICSharpCode
2+
// Licensed under the MIT license. See the LICENSE file in the project root for more information.
3+
4+
using ILSpyX.Backend.Decompiler;
5+
using ILSpyX.Backend.LSP.Protocol;
6+
using OmniSharp.Extensions.JsonRpc;
7+
using System.Threading;
8+
using System.Threading.Tasks;
9+
10+
namespace ILSpyX.Backend.LSP.Handlers;
11+
12+
[Serial, Method("ilspy/exportAssembly", Direction.ClientToServer)]
13+
public class ExportAssemblyHandler(DecompilerBackend decompilerBackend)
14+
: IJsonRpcRequestHandler<ExportAssemblyRequest, ExportAssemblyResponse>
15+
{
16+
public async Task<ExportAssemblyResponse> Handle(
17+
ExportAssemblyRequest request,
18+
CancellationToken cancellationToken)
19+
{
20+
(var result, bool shouldUpdateAssemblyList) =
21+
await decompilerBackend.DetectAutoLoadedAssemblies(() =>
22+
decompilerBackend.ExportAssemblyAsync(
23+
request.NodeMetadata,
24+
request.OutputLanguage,
25+
request.OutputDirectory,
26+
request.IncludeCompilerGenerated,
27+
cancellationToken));
28+
29+
return new ExportAssemblyResponse(
30+
result.Succeeded,
31+
result.OutputDirectory,
32+
result.FilesWritten,
33+
result.ErrorCount,
34+
result.ErrorMessage,
35+
shouldUpdateAssemblyList);
36+
}
37+
}

backend/ILSpyX.Backend.LSP/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static async Task Main(string[] args)
4141
.WithHandler<InitWithAssembliesHandler>()
4242
.WithHandler<AddAssemblyHandler>()
4343
.WithHandler<DecompileNodeHandler>()
44+
.WithHandler<ExportAssemblyHandler>()
4445
.WithHandler<GetNodesHandler>()
4546
.WithHandler<RemoveAssemblyHandler>()
4647
.WithHandler<SearchHandler>()

backend/ILSpyX.Backend.LSP/Protocol/Messages.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ public DecompileResponse(DecompileResult decompileResult, bool shouldUpdateAssem
6060

6161
#endregion
6262

63+
#region exportAssembly
64+
65+
[Serial, Method("ilspy/exportAssembly", Direction.ClientToServer)]
66+
public record ExportAssemblyRequest(
67+
NodeMetadata NodeMetadata,
68+
string OutputLanguage,
69+
string OutputDirectory,
70+
bool IncludeCompilerGenerated)
71+
: IRequest<ExportAssemblyResponse>;
72+
73+
public record ExportAssemblyResponse(
74+
bool Succeeded,
75+
string? OutputDirectory,
76+
int FilesWritten,
77+
int ErrorCount,
78+
string? ErrorMessage,
79+
bool ShouldUpdateAssemblyList);
80+
81+
#endregion
82+
6383
#region getNodes
6484

6585
[Serial, Method("ilspy/getNodes", Direction.ClientToServer)]

0 commit comments

Comments
 (0)