Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions backend/ILSpyX.Backend.LSP/Handlers/ExportAssemblyHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2025 ICSharpCode
// Licensed under the MIT license. See the LICENSE file in the project root for more information.

using ILSpyX.Backend.Decompiler;
using ILSpyX.Backend.LSP.Protocol;
using OmniSharp.Extensions.JsonRpc;
using System.Threading;
using System.Threading.Tasks;

namespace ILSpyX.Backend.LSP.Handlers;

[Serial, Method("ilspy/exportAssembly", Direction.ClientToServer)]
public class ExportAssemblyHandler(DecompilerBackend decompilerBackend)
: IJsonRpcRequestHandler<ExportAssemblyRequest, ExportAssemblyResponse>
{
public async Task<ExportAssemblyResponse> Handle(
ExportAssemblyRequest request,
CancellationToken cancellationToken)
{
(var result, bool shouldUpdateAssemblyList) =
await decompilerBackend.DetectAutoLoadedAssemblies(() =>
decompilerBackend.ExportAssemblyAsync(
request.NodeMetadata,
request.OutputLanguage,
request.OutputDirectory,
request.IncludeCompilerGenerated,
cancellationToken));

return new ExportAssemblyResponse(
result.Succeeded,
result.OutputDirectory,
result.FilesWritten,
result.ErrorCount,
result.ErrorMessage,
shouldUpdateAssemblyList);
}
}
1 change: 1 addition & 0 deletions backend/ILSpyX.Backend.LSP/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static async Task Main(string[] args)
.WithHandler<InitWithAssembliesHandler>()
.WithHandler<AddAssemblyHandler>()
.WithHandler<DecompileNodeHandler>()
.WithHandler<ExportAssemblyHandler>()
.WithHandler<GetNodesHandler>()
.WithHandler<RemoveAssemblyHandler>()
.WithHandler<SearchHandler>()
Expand Down
20 changes: 20 additions & 0 deletions backend/ILSpyX.Backend.LSP/Protocol/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ public DecompileResponse(DecompileResult decompileResult, bool shouldUpdateAssem

#endregion

#region exportAssembly

[Serial, Method("ilspy/exportAssembly", Direction.ClientToServer)]
public record ExportAssemblyRequest(
NodeMetadata NodeMetadata,
string OutputLanguage,
string OutputDirectory,
bool IncludeCompilerGenerated)
: IRequest<ExportAssemblyResponse>;

public record ExportAssemblyResponse(
bool Succeeded,
string? OutputDirectory,
int FilesWritten,
int ErrorCount,
string? ErrorMessage,
bool ShouldUpdateAssemblyList);

#endregion

#region getNodes

[Serial, Method("ilspy/getNodes", Direction.ClientToServer)]
Expand Down
Loading
Loading