|
| 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 | +} |
0 commit comments