From 7a398438c7d3ddb88576fe4c5954cf0eafecaad0 Mon Sep 17 00:00:00 2001 From: Alexej Kowalew <616b2f@gmail.com> Date: Fri, 21 Nov 2025 18:44:41 +0100 Subject: [PATCH 1/3] feat: separate client --- dotnet-bsp.sln | 7 + src/bsp-client/BspConnectionDetails.cs | 15 ++ .../bsp-client}/BuildServerClient.cs | 8 +- .../bsp-client/BuildServerClientExtensions.cs | 19 +-- src/bsp-client/BuildServerFactory.cs | 90 +++++++++++ src/bsp-client/IServerCallbacks.cs | 28 ++++ src/bsp-client/ProcessExtensions.cs | 17 +++ .../Protocol/BuildClientCapabilities.cs | 16 ++ .../Protocol/BuildServerCapabilities.cs | 126 ++++++++++++++++ src/bsp-client/Protocol/BuildTarget.cs | 81 ++++++++++ .../Protocol/BuildTargetCapabilities.cs | 28 ++++ .../Protocol/BuildTargetDataKind.cs | 30 ++++ .../Protocol/BuildTargetIdentifier.cs | 15 ++ src/bsp-client/Protocol/BuildTargetTag.cs | 50 +++++++ src/bsp-client/Protocol/CleanCacheParams.cs | 11 ++ src/bsp-client/Protocol/CleanCacheResult.cs | 17 +++ src/bsp-client/Protocol/CompileParams.cs | 23 +++ src/bsp-client/Protocol/CompileProvider.cs | 10 ++ src/bsp-client/Protocol/CompileReport.cs | 28 ++++ src/bsp-client/Protocol/CompileResult.cs | 26 ++++ src/bsp-client/Protocol/CompileTask.cs | 10 ++ src/bsp-client/Protocol/DebugProvider.cs | 10 ++ .../Protocol/DebugSessionAddress.cs | 13 ++ src/bsp-client/Protocol/DebugSessionParams.cs | 27 ++++ src/bsp-client/Protocol/Diagnostic.cs | 47 ++++++ src/bsp-client/Protocol/DiagnosticSeverity.cs | 16 ++ .../Protocol/DotnetTestParamsData.cs | 14 ++ .../Protocol/InitializeBuildParams.cs | 61 ++++++++ .../Protocol/InitializeBuildResult.cs | 55 +++++++ .../Protocol/InitializedBuildParams.cs | 9 ++ src/bsp-client/Protocol/LanguageId.cs | 6 + src/bsp-client/Protocol/Location.cs | 13 ++ src/bsp-client/Protocol/LogMessageParams.cs | 36 +++++ src/bsp-client/Protocol/MessageType.cs | 24 +++ src/bsp-client/Protocol/Methods.cs | 39 +++++ src/bsp-client/Protocol/Position.cs | 19 +++ src/bsp-client/Protocol/PrintParams.cs | 25 ++++ .../Protocol/PublishDiagnosticsParams.cs | 35 +++++ src/bsp-client/Protocol/Range.cs | 13 ++ src/bsp-client/Protocol/ReadParams.cs | 19 +++ src/bsp-client/Protocol/RunParams.cs | 46 ++++++ src/bsp-client/Protocol/RunProvider.cs | 11 ++ src/bsp-client/Protocol/RunResult.cs | 17 +++ src/bsp-client/Protocol/SourceItem.cs | 36 +++++ src/bsp-client/Protocol/SourcesItem.cs | 24 +++ src/bsp-client/Protocol/SourcesParams.cs | 11 ++ src/bsp-client/Protocol/SourcesResult.cs | 10 ++ src/bsp-client/Protocol/StatusCode.cs | 14 ++ src/bsp-client/Protocol/TaskFinishDataKind.cs | 9 ++ src/bsp-client/Protocol/TaskFinishParams.cs | 46 ++++++ src/bsp-client/Protocol/TaskId.cs | 25 ++++ .../Protocol/TaskProgressDataKind.cs | 7 + src/bsp-client/Protocol/TaskProgressParams.cs | 57 +++++++ src/bsp-client/Protocol/TaskStartData.cs | 15 ++ src/bsp-client/Protocol/TaskStartDataKind.cs | 9 ++ src/bsp-client/Protocol/TaskStartParams.cs | 42 ++++++ .../Protocol/TestCaseDiscoveredData.cs | 28 ++++ .../Protocol/TestCaseDiscoveryParams.cs | 18 +++ .../Protocol/TestCaseDiscoveryProvider.cs | 10 ++ .../Protocol/TestCaseDiscoveryResult.cs | 17 +++ src/bsp-client/Protocol/TestFinishData.cs | 41 +++++ src/bsp-client/Protocol/TestParams.cs | 46 ++++++ .../Protocol/TestParamsDataKinds.cs | 7 + src/bsp-client/Protocol/TestProvider.cs | 11 ++ src/bsp-client/Protocol/TestReportData.cs | 37 +++++ src/bsp-client/Protocol/TestResult.cs | 27 ++++ src/bsp-client/Protocol/TestStatus.cs | 19 +++ src/bsp-client/Protocol/TestTaskData.cs | 11 ++ .../Protocol/TextDocumentIdentifier.cs | 10 ++ .../Protocol/WorkspaceBuildTargetsResult.cs | 14 ++ src/bsp-client/bsp-client.csproj | 7 + src/bsp-client/packages.lock.json | 141 ++++++++++++++++++ src/bsp-server/Logging/MSBuildLogger.cs | 8 +- .../Protocol/BuildClientCapabilities.cs | 2 +- test/BuildServerProtocolTests.cs | 7 +- test/InitializeAndInitializedTests.cs | 7 +- test/ShutdownAndExitTests.cs | 7 +- test/TestHelpers/BuildServerFactory.cs | 4 +- test/TestHelpers/ServerCallbacks.cs | 3 +- test/TestHelpers/TestProjectPath.cs | 22 ++- test/TestsRelatedEndpointsTests.cs | 7 +- test/bsp-server.tests.csproj | 57 +++---- test/packages.lock.json | 6 + 83 files changed, 2026 insertions(+), 63 deletions(-) create mode 100644 src/bsp-client/BspConnectionDetails.cs rename {test/TestHelpers => src/bsp-client}/BuildServerClient.cs (86%) rename test/TestHelpers/BuildServerClientTestExtensions.cs => src/bsp-client/BuildServerClientExtensions.cs (78%) create mode 100644 src/bsp-client/BuildServerFactory.cs create mode 100644 src/bsp-client/IServerCallbacks.cs create mode 100644 src/bsp-client/ProcessExtensions.cs create mode 100644 src/bsp-client/Protocol/BuildClientCapabilities.cs create mode 100644 src/bsp-client/Protocol/BuildServerCapabilities.cs create mode 100644 src/bsp-client/Protocol/BuildTarget.cs create mode 100644 src/bsp-client/Protocol/BuildTargetCapabilities.cs create mode 100644 src/bsp-client/Protocol/BuildTargetDataKind.cs create mode 100644 src/bsp-client/Protocol/BuildTargetIdentifier.cs create mode 100644 src/bsp-client/Protocol/BuildTargetTag.cs create mode 100644 src/bsp-client/Protocol/CleanCacheParams.cs create mode 100644 src/bsp-client/Protocol/CleanCacheResult.cs create mode 100644 src/bsp-client/Protocol/CompileParams.cs create mode 100644 src/bsp-client/Protocol/CompileProvider.cs create mode 100644 src/bsp-client/Protocol/CompileReport.cs create mode 100644 src/bsp-client/Protocol/CompileResult.cs create mode 100644 src/bsp-client/Protocol/CompileTask.cs create mode 100644 src/bsp-client/Protocol/DebugProvider.cs create mode 100644 src/bsp-client/Protocol/DebugSessionAddress.cs create mode 100644 src/bsp-client/Protocol/DebugSessionParams.cs create mode 100644 src/bsp-client/Protocol/Diagnostic.cs create mode 100644 src/bsp-client/Protocol/DiagnosticSeverity.cs create mode 100644 src/bsp-client/Protocol/DotnetTestParamsData.cs create mode 100644 src/bsp-client/Protocol/InitializeBuildParams.cs create mode 100644 src/bsp-client/Protocol/InitializeBuildResult.cs create mode 100644 src/bsp-client/Protocol/InitializedBuildParams.cs create mode 100644 src/bsp-client/Protocol/LanguageId.cs create mode 100644 src/bsp-client/Protocol/Location.cs create mode 100644 src/bsp-client/Protocol/LogMessageParams.cs create mode 100644 src/bsp-client/Protocol/MessageType.cs create mode 100644 src/bsp-client/Protocol/Methods.cs create mode 100644 src/bsp-client/Protocol/Position.cs create mode 100644 src/bsp-client/Protocol/PrintParams.cs create mode 100644 src/bsp-client/Protocol/PublishDiagnosticsParams.cs create mode 100644 src/bsp-client/Protocol/Range.cs create mode 100644 src/bsp-client/Protocol/ReadParams.cs create mode 100644 src/bsp-client/Protocol/RunParams.cs create mode 100644 src/bsp-client/Protocol/RunProvider.cs create mode 100644 src/bsp-client/Protocol/RunResult.cs create mode 100644 src/bsp-client/Protocol/SourceItem.cs create mode 100644 src/bsp-client/Protocol/SourcesItem.cs create mode 100644 src/bsp-client/Protocol/SourcesParams.cs create mode 100644 src/bsp-client/Protocol/SourcesResult.cs create mode 100644 src/bsp-client/Protocol/StatusCode.cs create mode 100644 src/bsp-client/Protocol/TaskFinishDataKind.cs create mode 100644 src/bsp-client/Protocol/TaskFinishParams.cs create mode 100644 src/bsp-client/Protocol/TaskId.cs create mode 100644 src/bsp-client/Protocol/TaskProgressDataKind.cs create mode 100644 src/bsp-client/Protocol/TaskProgressParams.cs create mode 100644 src/bsp-client/Protocol/TaskStartData.cs create mode 100644 src/bsp-client/Protocol/TaskStartDataKind.cs create mode 100644 src/bsp-client/Protocol/TaskStartParams.cs create mode 100644 src/bsp-client/Protocol/TestCaseDiscoveredData.cs create mode 100644 src/bsp-client/Protocol/TestCaseDiscoveryParams.cs create mode 100644 src/bsp-client/Protocol/TestCaseDiscoveryProvider.cs create mode 100644 src/bsp-client/Protocol/TestCaseDiscoveryResult.cs create mode 100644 src/bsp-client/Protocol/TestFinishData.cs create mode 100644 src/bsp-client/Protocol/TestParams.cs create mode 100644 src/bsp-client/Protocol/TestParamsDataKinds.cs create mode 100644 src/bsp-client/Protocol/TestProvider.cs create mode 100644 src/bsp-client/Protocol/TestReportData.cs create mode 100644 src/bsp-client/Protocol/TestResult.cs create mode 100644 src/bsp-client/Protocol/TestStatus.cs create mode 100644 src/bsp-client/Protocol/TestTaskData.cs create mode 100644 src/bsp-client/Protocol/TextDocumentIdentifier.cs create mode 100644 src/bsp-client/Protocol/WorkspaceBuildTargetsResult.cs create mode 100644 src/bsp-client/bsp-client.csproj create mode 100644 src/bsp-client/packages.lock.json diff --git a/dotnet-bsp.sln b/dotnet-bsp.sln index 65d19cd..b4eb515 100644 --- a/dotnet-bsp.sln +++ b/dotnet-bsp.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-bsp", "src\bsp-serve EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsp-server.tests", "test\bsp-server.tests.csproj", "{4EE3A425-382F-42ED-934E-6A9676533962}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsp-client", "src\bsp-client\bsp-client.csproj", "{7F8753C3-6598-4773-96EA-6EB3463A3849}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,10 +40,15 @@ Global {4EE3A425-382F-42ED-934E-6A9676533962}.Debug|Any CPU.Build.0 = Debug|Any CPU {4EE3A425-382F-42ED-934E-6A9676533962}.Release|Any CPU.ActiveCfg = Release|Any CPU {4EE3A425-382F-42ED-934E-6A9676533962}.Release|Any CPU.Build.0 = Release|Any CPU + {7F8753C3-6598-4773-96EA-6EB3463A3849}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F8753C3-6598-4773-96EA-6EB3463A3849}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F8753C3-6598-4773-96EA-6EB3463A3849}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F8753C3-6598-4773-96EA-6EB3463A3849}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {4C290E5D-5CAD-42D7-B776-E581695D4E4A} = {992A1911-5B82-4DF3-9880-83E07F114A2D} {CC0B3E75-9BE0-466E-9723-CEBA3D4A79C6} = {992A1911-5B82-4DF3-9880-83E07F114A2D} {A88E3B50-D12B-4925-9522-E57878D2AB54} = {992A1911-5B82-4DF3-9880-83E07F114A2D} + {7F8753C3-6598-4773-96EA-6EB3463A3849} = {992A1911-5B82-4DF3-9880-83E07F114A2D} EndGlobalSection EndGlobal diff --git a/src/bsp-client/BspConnectionDetails.cs b/src/bsp-client/BspConnectionDetails.cs new file mode 100644 index 0000000..463afa2 --- /dev/null +++ b/src/bsp-client/BspConnectionDetails.cs @@ -0,0 +1,15 @@ +namespace bsp_client; + +public record BspConnectionDetails +{ + /** The name of the build tool. */ + public required string Name { get; init; } + /** The version of the build tool. */ + public required string Version { get; init; } + /** The bsp version of the build tool. */ + public required string BspVersion { get; init; } + /** A collection of languages supported by this BSP server. */ + public required string[] Languages { get; init; } + /** Command arguments runnable via system processes to start a BSP server */ + public required string[] Argv { get; init; } +} \ No newline at end of file diff --git a/test/TestHelpers/BuildServerClient.cs b/src/bsp-client/BuildServerClient.cs similarity index 86% rename from test/TestHelpers/BuildServerClient.cs rename to src/bsp-client/BuildServerClient.cs index 81cea3c..9e5318d 100644 --- a/test/TestHelpers/BuildServerClient.cs +++ b/src/bsp-client/BuildServerClient.cs @@ -1,13 +1,17 @@ using StreamJsonRpc; +using System; using System.Diagnostics; +using System.IO; +using System.Threading; +using System.Threading.Tasks; -namespace test; +namespace bsp_client; public sealed class BuildServerClient : IDisposable { private readonly JsonRpc _jsonRpc; - public BuildServerClient(Stream sendingStream, Stream receivingStream, ServerCallbacks serverCallbacks, TraceListener? traceListener = null) + public BuildServerClient(Stream sendingStream, Stream receivingStream, IServerCallbacks serverCallbacks, TraceListener? traceListener = null) { _jsonRpc = new JsonRpc(sendingStream, receivingStream); _jsonRpc.AddLocalRpcTarget(serverCallbacks); diff --git a/test/TestHelpers/BuildServerClientTestExtensions.cs b/src/bsp-client/BuildServerClientExtensions.cs similarity index 78% rename from test/TestHelpers/BuildServerClientTestExtensions.cs rename to src/bsp-client/BuildServerClientExtensions.cs index a513c06..ead398e 100644 --- a/test/TestHelpers/BuildServerClientTestExtensions.cs +++ b/src/bsp-client/BuildServerClientExtensions.cs @@ -1,22 +1,13 @@ +using System.Threading; +using System.Threading.Tasks; using bsp4csharp.Protocol; -using dotnet_bsp; -namespace test; +namespace bsp_client; public static class BuildServerClientExtensions { - public static Task BuildInitializeAsync(this BuildServerClient client, string workspaceRootPath, CancellationToken cancellationToken) - { - var initParams = new InitializeBuildParams - { - DisplayName = "TestClient", - Version = "1.0.0", - BspVersion = "2.1.1", - RootUri = UriFixer.WithFileSchema(workspaceRootPath), - Capabilities = new BuildClientCapabilities() - }; - initParams.Capabilities.LanguageIds.Add("csharp"); - + public static Task BuildInitializeAsync(this BuildServerClient client, InitializeBuildParams initParams, CancellationToken cancellationToken) + { return client.SendRequestAsync(Methods.BuildInitialize, initParams, cancellationToken); } diff --git a/src/bsp-client/BuildServerFactory.cs b/src/bsp-client/BuildServerFactory.cs new file mode 100644 index 0000000..230b1fe --- /dev/null +++ b/src/bsp-client/BuildServerFactory.cs @@ -0,0 +1,90 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; + +namespace bsp_client; + +public class BuildServerFactory +{ + private BuildServerFactory() + { + } + + public static BuildServer CreateServer(BspConnectionDetails connectionDetails, ILogger logger) + { + return new BuildServer(connectionDetails, logger); + } +} + +public sealed class BuildServer : IDisposable +{ + private readonly Stream _serverStdin; + private readonly Stream _serverStdout; + private readonly Process _process; + private readonly ILogger _logger; + + public BuildServer(BspConnectionDetails connectionDetails, ILogger logger) + { + var command = connectionDetails.Argv[0]; + var args = connectionDetails.Argv[1..]; + _process = new Process + { + StartInfo = new ProcessStartInfo(command, args) + { + CreateNoWindow = true, + RedirectStandardInput = true, + RedirectStandardOutput = true, + // RedirectStandardError = true, + } + }; + + _process.Start(); + + _serverStdin = _process.StandardInput.BaseStream; + _serverStdout = _process.StandardOutput.BaseStream; + _process.ErrorDataReceived += ErrorDataReceived; + _logger = logger; + } + + private void ErrorDataReceived(object sender, DataReceivedEventArgs e) + { + _logger.LogError(e.Data); + } + + public BuildServerClient CreateClient( + IServerCallbacks serverCallbacks, + TraceListener? traceListener = null) + { + return new BuildServerClient(_serverStdin, _serverStdout, serverCallbacks, traceListener); + } + + public Task WaitForExitAsync(CancellationToken cancellationToken) + { + return _process.WaitForExitAsync(cancellationToken); + } + + public int ExitCode => _process.ExitCode; + + public void Dispose() + { + // var errors = _process.StandardError.ReadToEnd(); + // _logger.LogError(errors); + if (!_process.HasExited) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + _process.Kill(); + } + else + { + _process.Kill(ProcessExtensions.SIGINT); + } + } + + _process.Dispose(); + } +} \ No newline at end of file diff --git a/src/bsp-client/IServerCallbacks.cs b/src/bsp-client/IServerCallbacks.cs new file mode 100644 index 0000000..9c0ac5b --- /dev/null +++ b/src/bsp-client/IServerCallbacks.cs @@ -0,0 +1,28 @@ +using bsp4csharp.Protocol; +using StreamJsonRpc; +using System.Threading.Tasks; + +namespace bsp_client; + +public interface IServerCallbacks +{ + [JsonRpcMethod(Methods.BuildPublishDiagnostics, UseSingleObjectParameterDeserialization = true)] + public Task BuildPublishDiagnosticsRecievedAsync(PublishDiagnosticsParams publishDiagnosticsParams); + + [JsonRpcMethod(Methods.BuildLogMessage, UseSingleObjectParameterDeserialization = true)] + public void BuildLogMessage(LogMessageParams logMessageParams); + + [JsonRpcMethod(Methods.BuildTaskStart, UseSingleObjectParameterDeserialization = true)] + public Task BuildTaskStartAsync(TaskStartParams taskStartParams); + + [JsonRpcMethod(Methods.BuildTaskProgress, UseSingleObjectParameterDeserialization = true)] + public Task BuildTaskProgressAsync(TaskProgressParams taskProgressParams); + + [JsonRpcMethod(Methods.BuildTaskFinish, UseSingleObjectParameterDeserialization = true)] + public Task BuildTaskFinishAsync(TaskFinishParams taskFinishParams); + + // public const string BuildShowMessage = "build/showMessage"; + // public const string BuildTargetDidChange = "buildTarget/didChange"; + // public const string RunPrintStdout = "run/printStdout"; + // public const string RunPrintStderr = "run/printStderr"; +} \ No newline at end of file diff --git a/src/bsp-client/ProcessExtensions.cs b/src/bsp-client/ProcessExtensions.cs new file mode 100644 index 0000000..963b5a8 --- /dev/null +++ b/src/bsp-client/ProcessExtensions.cs @@ -0,0 +1,17 @@ +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace bsp_client; + +public static class ProcessExtensions +{ + [DllImport ("libc", SetLastError=true, EntryPoint="kill")] + private static extern int sys_kill (int pid, int sig); + + public static int SIGINT = 2; + + public static void Kill(this Process process, int sig) + { + sys_kill(process.Id, sig); + } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildClientCapabilities.cs b/src/bsp-client/Protocol/BuildClientCapabilities.cs new file mode 100644 index 0000000..8518d05 --- /dev/null +++ b/src/bsp-client/Protocol/BuildClientCapabilities.cs @@ -0,0 +1,16 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class BuildClientCapabilities +{ + /// + /// The languages that this client supports. + /// The ID strings for each language is defined in the LSP. + /// The server must never respond with build targets for other + /// languages than those that appear in this list. + /// + [DataMember(Name = "languageIds")] + public ICollection LanguageIds { get; init; } = new List(); +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildServerCapabilities.cs b/src/bsp-client/Protocol/BuildServerCapabilities.cs new file mode 100644 index 0000000..4f3493a --- /dev/null +++ b/src/bsp-client/Protocol/BuildServerCapabilities.cs @@ -0,0 +1,126 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +/// +/// Class which represents server capabilities. +/// +/// See the Build Server Protocol specification for additional information. +/// +[DataContract] +public class BuildServerCapabilities +{ + /// + /// The languages the server supports compilation via method buildTarget/compile. + /// + [DataMember(Name = "compileProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompileProvider? CompileProvider { get; set; } + + /// + /// The languages the server supports test execution via method buildTarget/test. + /// + [DataMember(Name = "testProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public TestProvider? TestProvider { get; set; } + + /// + /// The languages the server supports test case discovery via method buildTarget/testCaseDiscovery. + /// + [DataMember(Name = "testCaseDiscoveryProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public TestCaseDiscoveryProvider? TestCaseDiscoveryProvider { get; set; } + + /// + /// The languages the server supports run via method buildTarget/run. + /// + [DataMember(Name = "runProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public RunProvider? RunProvider { get; set; } + + /// + /// The languages the server supports debugging via method debugSession/start. + /// + [DataMember(Name = "debugProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DebugProvider? DebugProvider { get; set; } + + /// + /// Theserver can provide a list of targets that contain a + /// single text document via the method buildTarget/inverseSources + /// + [DataMember(Name = "inverseSourcesProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? InverseSourcesProvider { get; set; } + + /// + /// The server provides sources for library dependencies + /// via method buildTarget/dependencySources + /// + [DataMember(Name = "dependencySourcesProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? DependencySourcesProvider { get; set; } + + /// + /// The server can provide a list of dependency modules (libraries with meta information) + /// via method buildTarget/dependencyModules + /// + [DataMember(Name = "dependencyModulesProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? DependencyModulesProvider { get; set; } + + /// + /// The server provides all the resource dependencies + /// via method buildTarget/resources + /// + [DataMember(Name = "resourcesProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? ResourcesProvider { get; set; } + + /// + /// The server provides all output paths + /// via method buildTarget/outputPaths + /// + [DataMember(Name = "outputPathsProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? OutputPathsProvider { get; set; } + + /// + /// The server sends notifications to the client on build + /// target change events via buildTarget/didChange + /// + [DataMember(Name = "buildTargetChangedProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? BuildTargetChangedProvider { get; set; } + + /// + /// Reloading the build state through workspace/reload is supported + /// + [DataMember(Name = "canReload")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? CanReload { get; set; } + + /// + /// The server can respond to `buildTarget/jvmRunEnvironment` requests with the + /// necessary information required to launch a Java process to run a main class. + /// + [DataMember(Name = "jvmRunEnvironmentProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? JvmRunEnvironmentProvider { get; set; } + + /*/// The server can respond to `buildTarget/jvmTestEnvironment` requests with the + /// necessary information required to launch a Java process for testing or + /// debugging. */ + [DataMember(Name = "jvmTestEnvironmentProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? JvmTestEnvironmentProvider { get; set; } + + /// + /// The server can respond to `workspace/cargoFeaturesState` and + /// `setCargoFeatures` requests. In other words, supports Cargo Features extension. + /// + [DataMember(Name = "cargoFeaturesProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool? CargoFeaturesProvider { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTarget.cs b/src/bsp-client/Protocol/BuildTarget.cs new file mode 100644 index 0000000..e4d06c4 --- /dev/null +++ b/src/bsp-client/Protocol/BuildTarget.cs @@ -0,0 +1,81 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record BuildTarget +{ + /// + /// The target’s unique identifier + /// + [DataMember(Name = "id")] + public required BuildTargetIdentifier Id { get; set; } + + /// + /// A human readable name for this target. + /// May be presented in the user interface. + /// Should be unique if possible. + /// The id.uri is used if None. + /// + [DataMember(Name = "displayName")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DisplayName { get; set; } + + /// + /// The directory where this target belongs to. Multiple build targets are allowed to map + /// to the same base directory, and a build target is not required to have a base directory. + /// A base directory does not determine the sources of a target, see buildTarget/sources. + /// + [DataMember(Name = "baseDirectory")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Uri? BaseDirectory { get; set; } + + /// + /// Free-form string tags to categorize or label this build target. + /// For example, can be used by the client to: + /// - customize how the target should be translated into the client's project model. + /// - group together different but related targets in the user interface. + /// - display icons or colors in the user interface. + /// Pre-defined tags are listed in `BuildTargetTag` but clients and servers + /// are free to define new tags for custom purposes. + /// + [DataMember(Name = "tags")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IReadOnlyCollection Tags { get; set; } = []; + + /// + /// The set of languages that this target contains. + /// The ID string for each language is defined in the LSP. + /// + [DataMember(Name = "languageIds")] + public IReadOnlyCollection LanguageIds { get; set; } = []; + + /// + /// The direct upstream build target dependencies of this build target + /// + [DataMember(Name = "dependencies")] + public IReadOnlyCollection Dependencies { get; set; } = []; + + /// + /// The capabilities of this build target. + /// + [DataMember(Name = "capabilities")] + public required BuildTargetCapabilities Capabilities { get; set; } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, + /// the kind of data is not specified. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public BuildTargetDataKind? DataKind { get; set; } + + /// + /// Language-specific metadata about this target. + /// See ScalaBuildTarget as an example. + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTargetCapabilities.cs b/src/bsp-client/Protocol/BuildTargetCapabilities.cs new file mode 100644 index 0000000..4c2f232 --- /dev/null +++ b/src/bsp-client/Protocol/BuildTargetCapabilities.cs @@ -0,0 +1,28 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class BuildTargetCapabilities +{ + /** This target can be compiled by the BSP server. */ + [DataMember(Name="canCompile")] + [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] + public bool? CanCompile { get; set; } + + /** This target can be tested by the BSP server. */ + [DataMember(Name="canTest")] + [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] + public bool? CanTest { get; set; } + + /** This target can be run by the BSP server. */ + [DataMember(Name="canRun")] + [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] + public bool? CanRun { get; set; } + + /** This target can be debugged by the BSP server. */ + [DataMember(Name="canDebug")] + [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] + public bool? CanDebug { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTargetDataKind.cs b/src/bsp-client/Protocol/BuildTargetDataKind.cs new file mode 100644 index 0000000..caa71eb --- /dev/null +++ b/src/bsp-client/Protocol/BuildTargetDataKind.cs @@ -0,0 +1,30 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +public enum BuildTargetDataKind +{ + /** `data` field must contain a CargoBuildTarget object. */ + [EnumMember(Value="cargo")] + Cargo, + + /** `data` field must contain a CppBuildTarget object. */ + [EnumMember(Value="cpp")] + Cpp, + + /** `data` field must contain a JvmBuildTarget object. */ + [EnumMember(Value="jvm")] + Jvm, + + /** `data` field must contain a PythonBuildTarget object. */ + [EnumMember(Value="python")] + Python, + + /** `data` field must contain a SbtBuildTarget object. */ + [EnumMember(Value="sbt")] + Sbt, + + /** `data` field must contain a ScalaBuildTarget object. */ + [EnumMember(Value="scala")] + Scala, +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTargetIdentifier.cs b/src/bsp-client/Protocol/BuildTargetIdentifier.cs new file mode 100644 index 0000000..625a7f8 --- /dev/null +++ b/src/bsp-client/Protocol/BuildTargetIdentifier.cs @@ -0,0 +1,15 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record BuildTargetIdentifier +{ + [DataMember(Name="uri")] + public required Uri Uri { get; set; } + + public override string ToString() + { + return Uri.LocalPath.ToString(); + } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTargetTag.cs b/src/bsp-client/Protocol/BuildTargetTag.cs new file mode 100644 index 0000000..0bfb97e --- /dev/null +++ b/src/bsp-client/Protocol/BuildTargetTag.cs @@ -0,0 +1,50 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace bsp4csharp.Protocol; + +[JsonConverter(typeof(StringEnumConverter))] +public enum BuildTargetTag +{ + /** Target contains source code for producing any kind of application, may have + * but does not require the `canRun` capability. */ + [EnumMember(Value="application")] + Application, + + /** Target contains source code to measure performance of a program, may have + * but does not require the `canRun` build target capability. */ + [EnumMember(Value="benchmark")] + Benchmark, + + /** Target contains source code for integration testing purposes, may have + * but does not require the `canTest` capability. + * The difference between "test" and "integration-test" is that + * integration tests traditionally run slower compared to normal tests + * and require more computing resources to execute. */ + [EnumMember(Value="integration-test")] + IntegrationTest, + + /** Target contains re-usable functionality for downstream targets. May have any + * combination of capabilities. */ + [EnumMember(Value="library")] + Library, + + /** Actions on the target such as build and test should only be invoked manually + * and explicitly. For example, triggering a build on all targets in the workspace + * should by default not include this target. + * The original motivation to add the "manual" tag comes from a similar functionality + * that exists in Bazel, where targets with this tag have to be specified explicitly + * on the command line. */ + [EnumMember(Value="manual")] + Manual, + + /** Target should be ignored by IDEs. */ + [EnumMember(Value="no-ide")] + NoIde, + + /** Target contains source code for testing purposes, may have but does not + * require the `canTest` capability. */ + [EnumMember(Value="test")] + Test, +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CleanCacheParams.cs b/src/bsp-client/Protocol/CleanCacheParams.cs new file mode 100644 index 0000000..1dc9e0f --- /dev/null +++ b/src/bsp-client/Protocol/CleanCacheParams.cs @@ -0,0 +1,11 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class CleanCacheParams +{ + /** A sequence of build targets to clean. */ + [DataMember(Name="targets")] + public BuildTargetIdentifier[] Targets { get; set; } = []; +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CleanCacheResult.cs b/src/bsp-client/Protocol/CleanCacheResult.cs new file mode 100644 index 0000000..e27410b --- /dev/null +++ b/src/bsp-client/Protocol/CleanCacheResult.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class CleanCacheResult +{ + /** Optional message to display to the user. */ + [DataMember(Name = "message")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Message { get; set; } + + /** Indicates whether the clean cache request was performed or not. */ + [DataMember(Name = "cleaned")] + public bool Cleaned { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileParams.cs b/src/bsp-client/Protocol/CompileParams.cs new file mode 100644 index 0000000..fefa078 --- /dev/null +++ b/src/bsp-client/Protocol/CompileParams.cs @@ -0,0 +1,23 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class CompileParams +{ + /** A sequence of build targets to compile. */ + [DataMember(Name="targets")] + public BuildTargetIdentifier[] Targets { get; set; } = []; + + /** A unique identifier generated by the client to identify this request. + * The server may include this id in triggered notifications or responses. */ + [DataMember(Name="originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** Optional arguments to the compilation process. */ + [DataMember(Name="arguments")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? Arguments { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileProvider.cs b/src/bsp-client/Protocol/CompileProvider.cs new file mode 100644 index 0000000..8016d95 --- /dev/null +++ b/src/bsp-client/Protocol/CompileProvider.cs @@ -0,0 +1,10 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class CompileProvider +{ + [DataMember(Name="languageIds")] + public ICollection LanguageIds { get; } = new List(); +} diff --git a/src/bsp-client/Protocol/CompileReport.cs b/src/bsp-client/Protocol/CompileReport.cs new file mode 100644 index 0000000..788bcb5 --- /dev/null +++ b/src/bsp-client/Protocol/CompileReport.cs @@ -0,0 +1,28 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Identifier = string; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record CompileReport +{ + [DataMember(Name = "target")] + public required BuildTargetIdentifier Target { get; set; } + + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Identifier? OriginId { get; set; } + + [DataMember(Name = "errors")] + public int Errors { get; set; } + + [DataMember(Name = "warnings")] + public int Warnings { get; set; } + + [DataMember(Name = "time")] + public long? Time { get; set; } + + [DataMember(Name = "noOp")] + public bool? NoOp { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileResult.cs b/src/bsp-client/Protocol/CompileResult.cs new file mode 100644 index 0000000..6b3a2f7 --- /dev/null +++ b/src/bsp-client/Protocol/CompileResult.cs @@ -0,0 +1,26 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class CompileResult +{ + /** An optional request id to know the origin of this report. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** A status code for the execution. */ + [DataMember(Name = "statusCode")] + public StatusCode StatusCode { get; set; } + + /** Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. */ + [DataMember(Name = "dataKind")] + public string? DataKind { get; set; } + + /** A field containing language-specific information, like products + * of compilation or compiler-specific metadata the client needs to know. */ + [DataMember(Name = "data")] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileTask.cs b/src/bsp-client/Protocol/CompileTask.cs new file mode 100644 index 0000000..db22cdf --- /dev/null +++ b/src/bsp-client/Protocol/CompileTask.cs @@ -0,0 +1,10 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record CompileTask +{ + [DataMember(Name = "target")] + public required BuildTargetIdentifier Target { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/DebugProvider.cs b/src/bsp-client/Protocol/DebugProvider.cs new file mode 100644 index 0000000..9182a3a --- /dev/null +++ b/src/bsp-client/Protocol/DebugProvider.cs @@ -0,0 +1,10 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class DebugProvider +{ + [DataMember(Name="languageIds")] + public ICollection LanguageIds { get; } = new List(); +} diff --git a/src/bsp-client/Protocol/DebugSessionAddress.cs b/src/bsp-client/Protocol/DebugSessionAddress.cs new file mode 100644 index 0000000..da453cb --- /dev/null +++ b/src/bsp-client/Protocol/DebugSessionAddress.cs @@ -0,0 +1,13 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class DebugSessionAddress +{ + /// + /// The Debug Adapter Protocol server's connection uri + /// + [DataMember(Name = "uri")] + public required Uri Uri { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/DebugSessionParams.cs b/src/bsp-client/Protocol/DebugSessionParams.cs new file mode 100644 index 0000000..b1f4cbf --- /dev/null +++ b/src/bsp-client/Protocol/DebugSessionParams.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class DebugSessionParams +{ + /** A sequence of build targets to run. */ + [DataMember(Name="targets")] + public required BuildTargetIdentifier[] Targets { get; set; } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } + + /// + /// Language-specific metadata for this execution. + /// See ScalaMainClass as an example. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DataKind { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Diagnostic.cs b/src/bsp-client/Protocol/Diagnostic.cs new file mode 100644 index 0000000..9f333b9 --- /dev/null +++ b/src/bsp-client/Protocol/Diagnostic.cs @@ -0,0 +1,47 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class Diagnostic +{ + /** The range at which the message applies. */ + [DataMember(Name = "range")] + public required Range Range { get; set; } + + /** The diagnostic's severity. Can be omitted. If omitted it is up to the + * client to interpret diagnostics as error, warning, info or hint. */ + [DataMember(Name = "severity")] + public DiagnosticSeverity? Severity { get; set; } + + /** The diagnostic's code, which might appear in the user interface. */ + [DataMember(Name = "code")] + public string? Code { get; set; } + + /** An optional property to describe the error code. */ + // public CodeDescription? CodeDescription { get; set; } + + /** A human-readable string describing the source of this + * diagnostic, e.g. 'typescript' or 'super lint'. */ + [DataMember(Name = "source")] + public string? Source { get; set; } + + /** The diagnostic's message. */ + [DataMember(Name = "message")] + public required string Message { get; set; } + + // /** Additional metadata about the diagnostic. */ + // public DiagnosticTag[]? Tags { get; set; } + // + // /** An array of related diagnostic information, e.g. when symbol-names within + // * a scope collide all definitions can be marked via this property. */ + // public DiagnosticRelatedInformation[]? RelatedInformation { get; set; } + // + // /** Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. */ + // public DiagnosticDataKind? DataKind { get; set; } + // + // /** A data entry field that is preserved between a + // * `textDocument/publishDiagnostics` notification and + // * `textDocument/codeAction` request. */ + // public DiagnosticData? Data { get; set; } +} diff --git a/src/bsp-client/Protocol/DiagnosticSeverity.cs b/src/bsp-client/Protocol/DiagnosticSeverity.cs new file mode 100644 index 0000000..a207c49 --- /dev/null +++ b/src/bsp-client/Protocol/DiagnosticSeverity.cs @@ -0,0 +1,16 @@ +namespace bsp4csharp.Protocol; + +public enum DiagnosticSeverity +{ + /** Reports an error. */ + Error = 1, + + /** Reports a warning. */ + Warning = 2, + + /** Reports an information. */ + Information = 3, + + /** Reports a hint. */ + Hint = 4, +} diff --git a/src/bsp-client/Protocol/DotnetTestParamsData.cs b/src/bsp-client/Protocol/DotnetTestParamsData.cs new file mode 100644 index 0000000..9b650cc --- /dev/null +++ b/src/bsp-client/Protocol/DotnetTestParamsData.cs @@ -0,0 +1,14 @@ +using System.Runtime.Serialization; + +namespace dotnet_bsp.Handlers +{ + [DataContract] + public class DotnetTestParamsData + { + [DataMember(Name = "filter")] + public required string Filter { get; set; } + + [DataMember(Name = "runSettings")] + public string? RunSettings { get; set; } + } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/InitializeBuildParams.cs b/src/bsp-client/Protocol/InitializeBuildParams.cs new file mode 100644 index 0000000..5a91ec0 --- /dev/null +++ b/src/bsp-client/Protocol/InitializeBuildParams.cs @@ -0,0 +1,61 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +/// +/// Class which represents the parameter sent with an initialize method request. +/// +/// See the Build Server Protocol specification for additional information. +/// +[DataContract] +public class InitializeBuildParams +{ + /// + /// Name of the client + /// + [DataMember(Name = "displayName")] + public required string DisplayName { get; set; } + + /// + /// The version of the client + /// + [DataMember(Name = "version")] + public required string Version { get; set; } + + /// + /// The BSP version that the client speaks + /// + [DataMember(Name = "bspVersion")] + public required string BspVersion { get; set; } + + /// + /// Gets or sets the capabilities supported by the client. + /// + [DataMember(Name = "capabilities")] + public required BuildClientCapabilities Capabilities + { + get; + set; + } + + /// + /// The rootUri of the workspace + /// + [DataMember(Name = "rootUri")] + public required Uri RootUri { get; set; } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DataKind { get; set; } + + /// + /// Additional metadata about the client + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/InitializeBuildResult.cs b/src/bsp-client/Protocol/InitializeBuildResult.cs new file mode 100644 index 0000000..96494a7 --- /dev/null +++ b/src/bsp-client/Protocol/InitializeBuildResult.cs @@ -0,0 +1,55 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +/// +/// Class which represents the result returned by the initialize request. +/// +/// See the Build Server Protocol specification for additional information. +/// +[DataContract] +public class InitializeBuildResult +{ + /// + /// Name of the server + /// + [DataMember(Name = "displayName")] + public required string DisplayName { get; set; } + + /// + /// The version of the server + /// + [DataMember(Name = "version")] + public required string Version { get; set; } + + /// + /// The BSP version that the server speaks + /// + [DataMember(Name = "bspVersion")] + public required string BspVersion { get; set; } + + /// + /// Gets or sets the server capabilities. + /// + [DataMember(Name = "capabilities")] + public required BuildServerCapabilities Capabilities + { + get; + set; + } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DataKind { get; set; } + + /// + /// Additional metadata about the server + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } +} diff --git a/src/bsp-client/Protocol/InitializedBuildParams.cs b/src/bsp-client/Protocol/InitializedBuildParams.cs new file mode 100644 index 0000000..1c6601b --- /dev/null +++ b/src/bsp-client/Protocol/InitializedBuildParams.cs @@ -0,0 +1,9 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class InitializedBuildParams +{ +} + diff --git a/src/bsp-client/Protocol/LanguageId.cs b/src/bsp-client/Protocol/LanguageId.cs new file mode 100644 index 0000000..9208f4c --- /dev/null +++ b/src/bsp-client/Protocol/LanguageId.cs @@ -0,0 +1,6 @@ +namespace bsp4csharp.Protocol; + +public static class LanguageId +{ + public const string Csharp = "csharp"; +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Location.cs b/src/bsp-client/Protocol/Location.cs new file mode 100644 index 0000000..03f5e78 --- /dev/null +++ b/src/bsp-client/Protocol/Location.cs @@ -0,0 +1,13 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record Location +{ + [DataMember(Name = "uri")] + public required Uri Uri { get; set; } + + [DataMember(Name = "range")] + public required Range Range { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/LogMessageParams.cs b/src/bsp-client/Protocol/LogMessageParams.cs new file mode 100644 index 0000000..5282290 --- /dev/null +++ b/src/bsp-client/Protocol/LogMessageParams.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using System.Runtime.Serialization; +using Identifier = string; + +namespace bsp4csharp.Protocol; + +/// +/// Class which represents parameter sent with window/logMessage requests. +/// +/// See the Base Protocol specification for additional information. +/// +[DataContract] +public class LogMessageParams +{ + /// + /// Gets or sets the type of message. + /// + [DataMember(Name = "type")] + public MessageType MessageType { get; set; } + + /// + /// Gets or sets the message. + /// + [DataMember(Name = "message")] + public required string Message { get; set; } + + /** Unique id of the task with optional reference to parent task id */ + [DataMember(Name = "taskId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public TaskId? TaskId { get; set; } + + /** A unique identifier generated by the client to identify this request. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Identifier? OriginId { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/MessageType.cs b/src/bsp-client/Protocol/MessageType.cs new file mode 100644 index 0000000..0c9129c --- /dev/null +++ b/src/bsp-client/Protocol/MessageType.cs @@ -0,0 +1,24 @@ +namespace bsp4csharp.Protocol; + +public enum MessageType +{ + /// + /// Error message. + /// + Error = 1, + + /// + /// Warning message. + /// + Warning = 2, + + /// + /// Info message. + /// + Info = 3, + + /// + /// Log message. + /// + Log = 4, +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Methods.cs b/src/bsp-client/Protocol/Methods.cs new file mode 100644 index 0000000..31537f7 --- /dev/null +++ b/src/bsp-client/Protocol/Methods.cs @@ -0,0 +1,39 @@ +namespace bsp4csharp.Protocol; + +/// +/// Class which contains the string values for all common build server protocol methods. +/// +public static class Methods +{ + // server methods + public const string BuildInitialize = "build/initialize"; + public const string BuildInitialized = "build/initialized"; + public const string BuildShutdown = "build/shutdown"; + public const string BuildExit = "build/exit"; + public const string WorkspaceBuildTargets = "workspace/buildTargets"; + public const string WorkspaceReload = "workspace/reload"; + public const string BuildTargetSources = "buildTarget/sources"; + public const string BuildTargetInverseSources = "buildTarget/inverseSources"; + public const string BuildTargetDependencySources = "buildTarget/dependencySources"; + public const string BuildTargetDependencyModules = "buildTarget/dependencyModules"; + public const string BuildTargetResources = "buildTarget/resources"; + public const string BuildTargetOutputPaths = "buildTarget/outputPaths"; + public const string BuildTargetCompile = "buildTarget/compile"; + public const string BuildTargetRun = "buildTarget/run"; + public const string BuildTargetTest = "buildTarget/test"; + public const string BuildTargetTestCaseDiscovery = "buildTarget/testCaseDiscovery"; + public const string BuildTargetCleanCache = "buildTarget/cleanCache"; + public const string DebugSessionStart = "debugSession/start"; + public const string RunReadStdin = "run/readStdin"; + + // client methods + public const string BuildShowMessage = "build/showMessage"; + public const string BuildLogMessage = "build/logMessage"; + public const string BuildPublishDiagnostics = "build/publishDiagnostics"; + public const string BuildTargetDidChange = "buildTarget/didChange"; + public const string BuildTaskStart = "build/taskStart"; + public const string BuildTaskProgress = "build/taskProgress"; + public const string BuildTaskFinish = "build/taskFinish"; + public const string RunPrintStdout = "run/printStdout"; + public const string RunPrintStderr = "run/printStderr"; +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Position.cs b/src/bsp-client/Protocol/Position.cs new file mode 100644 index 0000000..00b0a71 --- /dev/null +++ b/src/bsp-client/Protocol/Position.cs @@ -0,0 +1,19 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record Position +{ + /** Line position in a document (zero-based). */ + [DataMember(Name = "line")] + public int Line { get; set; } + + /** Character offset on a line in a document (zero-based) + * + * If the character value is greater than the line length it defaults back + * to the line length. */ + [DataMember(Name = "character")] + public int Character { get; set; } +} + diff --git a/src/bsp-client/Protocol/PrintParams.cs b/src/bsp-client/Protocol/PrintParams.cs new file mode 100644 index 0000000..cd65429 --- /dev/null +++ b/src/bsp-client/Protocol/PrintParams.cs @@ -0,0 +1,25 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class PrintParams +{ + /** An optional request id to know the origin of this report. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** Relevant only for test tasks. + * Allows to tell the client from which task the output is coming from. + **/ + [DataMember(Name = "taskId")] + public TaskId? TaskId { get; set; } + + /** Message content can contain arbitrary bytes. + * They should be escaped as per [javascript encoding](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#using_special_characters_in_strings) + **/ + [DataMember(Name = "message")] + public required string Message { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/PublishDiagnosticsParams.cs b/src/bsp-client/Protocol/PublishDiagnosticsParams.cs new file mode 100644 index 0000000..93434be --- /dev/null +++ b/src/bsp-client/Protocol/PublishDiagnosticsParams.cs @@ -0,0 +1,35 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class PublishDiagnosticsParams +{ + /// + /// The document where the diagnostics are published. + /// + [DataMember(Name = "textDocument")] + public required TextDocumentIdentifier TextDocument { get; set; } + + /** The build target where the diagnostics origin. + * It is valid for one text document to belong to multiple + * build targets, for example sources that are compiled against multiple + * platforms (JVM, JavaScript). */ + [DataMember(Name = "buildTarget")] + public required BuildTargetIdentifier BuildTarget { get; set; } + + /** The request id that originated this notification. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** The diagnostics to be published by the client. */ + [DataMember(Name = "diagnostics")] + public ICollection Diagnostics { get; } = new List(); + + /** Whether the client should clear the previous diagnostics + * mapped to the same `textDocument` and `buildTarget`. */ + [DataMember(Name = "reset")] + public bool Reset { get; set; } +} diff --git a/src/bsp-client/Protocol/Range.cs b/src/bsp-client/Protocol/Range.cs new file mode 100644 index 0000000..7f6ecfa --- /dev/null +++ b/src/bsp-client/Protocol/Range.cs @@ -0,0 +1,13 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record Range +{ + [DataMember(Name = "start")] + public required Position Start { get; set; } + [DataMember(Name = "end")] + public required Position End { get; set; } +} + diff --git a/src/bsp-client/Protocol/ReadParams.cs b/src/bsp-client/Protocol/ReadParams.cs new file mode 100644 index 0000000..c48bb89 --- /dev/null +++ b/src/bsp-client/Protocol/ReadParams.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class ReadParams +{ + // Id of the request + [DataMember(Name="originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + [DataMember(Name = "task")] + public TaskId? TaskId { get; set; } + + [DataMember(Name = "message")] + public required string Message { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/RunParams.cs b/src/bsp-client/Protocol/RunParams.cs new file mode 100644 index 0000000..ddeb1e7 --- /dev/null +++ b/src/bsp-client/Protocol/RunParams.cs @@ -0,0 +1,46 @@ +using Newtonsoft.Json; +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class RunParams +{ + /** A sequence of build targets to run. */ + [DataMember(Name="target")] + public required BuildTargetIdentifier Target { get; set; } + + /** A unique identifier generated by the client to identify this request. + * The server may include this id in triggered notifications or responses. */ + [DataMember(Name="originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** Optional arguments to the compilation process. */ + [DataMember(Name="arguments")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? Arguments { get; set; } + + /** Optional environment variables to set before running the tests. */ + [DataMember(Name="environmentVariables")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Dictionary EnvironmentVariables { get; set; } = []; + + /** Optional working directory */ + [DataMember(Name="workingDirectory")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Uri? WorkingDirectory { get; set; } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DataKind { get; set; } + + /** Optional metadata about the task. + * Objects for specific tasks like compile, test, etc are specified in the protocol. */ + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/RunProvider.cs b/src/bsp-client/Protocol/RunProvider.cs new file mode 100644 index 0000000..202749d --- /dev/null +++ b/src/bsp-client/Protocol/RunProvider.cs @@ -0,0 +1,11 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class RunProvider +{ + [DataMember(Name="languageIds")] + public ICollection LanguageIds { get; } = new List(); +} + diff --git a/src/bsp-client/Protocol/RunResult.cs b/src/bsp-client/Protocol/RunResult.cs new file mode 100644 index 0000000..a4587cd --- /dev/null +++ b/src/bsp-client/Protocol/RunResult.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class RunResult +{ + /** An optional request id to know the origin of this report. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** A status code for the execution. */ + [DataMember(Name = "statusCode")] + public StatusCode StatusCode { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/SourceItem.cs b/src/bsp-client/Protocol/SourceItem.cs new file mode 100644 index 0000000..42dc3e0 --- /dev/null +++ b/src/bsp-client/Protocol/SourceItem.cs @@ -0,0 +1,36 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record SourceItem +{ + /** + * Either a text document or a directory. A directory entry must end with a forward + * slash "/" and a directory entry implies that every nested text document within the + * directory belongs to this source item. + * + **/ + [DataMember(Name = "uri")] + public required Uri Uri { get; init; } + + /** + * Type of file of the source item, such as whether it is file or directory. + * + **/ + [DataMember(Name = "kind")] + public required SourceItemKind Kind { get; init; } + + /** + * Indicates if this source is automatically generated by the build and is not + * intended to be manually edited by the user. + * + **/ + public bool Generated { get; init; } +} + +public enum SourceItemKind +{ + File = 1, + Directory = 2, +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/SourcesItem.cs b/src/bsp-client/Protocol/SourcesItem.cs new file mode 100644 index 0000000..ddc7500 --- /dev/null +++ b/src/bsp-client/Protocol/SourcesItem.cs @@ -0,0 +1,24 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record SourcesItem +{ + [DataMember(Name = "target")] + public required BuildTargetIdentifier Target { get; init; } + + // + // The text documents or and directories that belong to this build target. + // + [DataMember(Name = "sources")] + public required SourceItem[] Sources { get; init; } + + + // + // The root directories from where source files should be relativized. + // Example: ["file://Users/name/dev/metals/src/main/scala"] + // + [DataMember(Name = "roots")] + public Uri[]? Roots { get; init; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/SourcesParams.cs b/src/bsp-client/Protocol/SourcesParams.cs new file mode 100644 index 0000000..6aea8a0 --- /dev/null +++ b/src/bsp-client/Protocol/SourcesParams.cs @@ -0,0 +1,11 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record SourcesParams +{ + + [DataMember(Name = "targets")] + public required BuildTargetIdentifier[] Targets { get; init; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/SourcesResult.cs b/src/bsp-client/Protocol/SourcesResult.cs new file mode 100644 index 0000000..b5f6b90 --- /dev/null +++ b/src/bsp-client/Protocol/SourcesResult.cs @@ -0,0 +1,10 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record SourcesResult +{ + [DataMember(Name = "items")] + public required SourcesItem[] Items { get; init; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/StatusCode.cs b/src/bsp-client/Protocol/StatusCode.cs new file mode 100644 index 0000000..3a78220 --- /dev/null +++ b/src/bsp-client/Protocol/StatusCode.cs @@ -0,0 +1,14 @@ +namespace bsp4csharp.Protocol; + +public enum StatusCode +{ + /** Execution was successful. */ + Ok = 1, + + /** Execution failed. */ + Error = 2, + + /** Execution was cancelled. */ + Cancelled = 3, +} + diff --git a/src/bsp-client/Protocol/TaskFinishDataKind.cs b/src/bsp-client/Protocol/TaskFinishDataKind.cs new file mode 100644 index 0000000..38a9733 --- /dev/null +++ b/src/bsp-client/Protocol/TaskFinishDataKind.cs @@ -0,0 +1,9 @@ +namespace bsp4csharp.Protocol; + +public static class TaskFinishDataKind +{ + public static string CompileReport = "compile-report"; + public static string TestFinish = "test-finish"; + public static string TestReport = "test-report"; + public static string TestCaseDiscoveryFinish = "test-case-discovery-finish"; +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskFinishParams.cs b/src/bsp-client/Protocol/TaskFinishParams.cs new file mode 100644 index 0000000..136a166 --- /dev/null +++ b/src/bsp-client/Protocol/TaskFinishParams.cs @@ -0,0 +1,46 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Identifier = string; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TaskFinishParams +{ + /** Unique id of the task with optional reference to parent task id */ + [DataMember(Name = "taskId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public required TaskId TaskId { get; set; } + + /** A unique identifier generated by the client to identify this request. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Identifier? OriginId { get; set; } + + /** Timestamp of when the event started in milliseconds since Epoch. */ + [DataMember(Name = "eventTime")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public long? EventTime { get; set; } + + /** Message describing the task. */ + [DataMember(Name = "message")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Message { get; set; } + + /** Task completion status. */ + [DataMember(Name = "status")] + public StatusCode Status { get; set; } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DataKind { get; set; } + + /** Optional metadata about the task. + * Objects for specific tasks like compile, test, etc are specified in the protocol. */ + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskId.cs b/src/bsp-client/Protocol/TaskId.cs new file mode 100644 index 0000000..99fece7 --- /dev/null +++ b/src/bsp-client/Protocol/TaskId.cs @@ -0,0 +1,25 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Identifier = string; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class TaskId +{ + /** A unique identifier */ + [DataMember(Name = "id")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public required Identifier Id { get; set; } + + /** The parent task ids, if any. A non-empty parents field means + * this task is a sub-task of every parent task id. The child-parent + * relationship of tasks makes it possible to render tasks in + * a tree-like user interface or inspect what caused a certain task + * execution. + * OriginId should not be included in the parents field, there is a separate + * field for that. */ + [DataMember(Name = "parents")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Identifier[]? Parents { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskProgressDataKind.cs b/src/bsp-client/Protocol/TaskProgressDataKind.cs new file mode 100644 index 0000000..7ceba25 --- /dev/null +++ b/src/bsp-client/Protocol/TaskProgressDataKind.cs @@ -0,0 +1,7 @@ +namespace bsp4csharp.Protocol; + +public static class TaskProgressDataKind +{ + public static string TestCaseDiscovered = "test-case-discovered"; + public static string TestResult = "test-result"; +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskProgressParams.cs b/src/bsp-client/Protocol/TaskProgressParams.cs new file mode 100644 index 0000000..7882160 --- /dev/null +++ b/src/bsp-client/Protocol/TaskProgressParams.cs @@ -0,0 +1,57 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Identifier = string; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TaskProgressParams +{ + /** Unique id of the task with optional reference to parent task id */ + [DataMember(Name = "taskId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public required TaskId TaskId { get; set; } + + /** A unique identifier generated by the client to identify this request. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Identifier? OriginId { get; set; } + + /** Timestamp of when the event started in milliseconds since Epoch. */ + [DataMember(Name = "eventTime")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public long? EventTime { get; set; } + + /** Message describing the task. */ + [DataMember(Name = "message")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Message { get; set; } + + /** If known, total amount of work units in this task. */ + [DataMember(Name = "total")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public long? Total { get; set; } + + /** If known, completed amount of work units in this task. */ + [DataMember(Name = "progress")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public long? Progress { get; set; } + + /** Name of a work unit. For example, "files" or "tests". May be empty. */ + [DataMember(Name = "unit")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Unit { get; set; } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DataKind { get; set; } + + /** Optional metadata about the task. + * Objects for specific tasks like compile, test, etc are specified in the protocol. */ + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskStartData.cs b/src/bsp-client/Protocol/TaskStartData.cs new file mode 100644 index 0000000..79c42af --- /dev/null +++ b/src/bsp-client/Protocol/TaskStartData.cs @@ -0,0 +1,15 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TaskStartData +{ + /** Display name of the test **/ + [DataMember(Name = "displayName")] + public required string DisplayName { get; set; } + + /** Source location of the test, as LSP location. **/ + [DataMember(Name = "location")] + public Location? Location { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskStartDataKind.cs b/src/bsp-client/Protocol/TaskStartDataKind.cs new file mode 100644 index 0000000..ffc0690 --- /dev/null +++ b/src/bsp-client/Protocol/TaskStartDataKind.cs @@ -0,0 +1,9 @@ +namespace bsp4csharp.Protocol; + +public static class TaskStartDataKind +{ + public static string CompileTask = "compile-task"; + public static string TestStart = "test-start"; + public static string TestTask = "test-task"; + public static string TestCaseDiscoveryTask = "test-case-discovery-task"; +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskStartParams.cs b/src/bsp-client/Protocol/TaskStartParams.cs new file mode 100644 index 0000000..b3875f0 --- /dev/null +++ b/src/bsp-client/Protocol/TaskStartParams.cs @@ -0,0 +1,42 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Identifier = string; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TaskStartParams +{ + /** Unique id of the task with optional reference to parent task id */ + [DataMember(Name = "taskId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public required TaskId TaskId { get; set; } + + /** A unique identifier generated by the client to identify this request. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Identifier? OriginId { get; set; } + + /** Timestamp of when the event started in milliseconds since Epoch. */ + [DataMember(Name = "eventTime")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public long? EventTime { get; set; } + + /** Message describing the task. */ + [DataMember(Name = "message")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Message { get; set; } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DataKind { get; set; } + + /** Optional metadata about the task. + * Objects for specific tasks like compile, test, etc are specified in the protocol. */ + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestCaseDiscoveredData.cs b/src/bsp-client/Protocol/TestCaseDiscoveredData.cs new file mode 100644 index 0000000..002f012 --- /dev/null +++ b/src/bsp-client/Protocol/TestCaseDiscoveredData.cs @@ -0,0 +1,28 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TestCaseDiscoveredData +{ + [DataMember(Name = "id")] + public required string Id { get; set; } + + [DataMember(Name = "displayName")] + public required string DisplayName { get; set; } + + [DataMember(Name = "fullyQualifiedName")] + public required string FullyQualifiedName { get; set; } + + [DataMember(Name = "source")] + public required string Source { get; set; } + + [DataMember(Name = "line")] + public int Line { get; set; } + + [DataMember(Name = "filePath")] + public required string FilePath { get; set; } + + [DataMember(Name = "buildTarget")] + public required BuildTargetIdentifier BuildTarget { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestCaseDiscoveryParams.cs b/src/bsp-client/Protocol/TestCaseDiscoveryParams.cs new file mode 100644 index 0000000..ba9bfac --- /dev/null +++ b/src/bsp-client/Protocol/TestCaseDiscoveryParams.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class TestCaseDiscoveryParams +{ + /** A sequence of build targets to compile. */ + [DataMember(Name="targets")] + public BuildTargetIdentifier[] Targets { get; set; } = []; + + /** A unique identifier generated by the client to identify this request. + * The server may include this id in triggered notifications or responses. */ + [DataMember(Name="originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestCaseDiscoveryProvider.cs b/src/bsp-client/Protocol/TestCaseDiscoveryProvider.cs new file mode 100644 index 0000000..3047dc4 --- /dev/null +++ b/src/bsp-client/Protocol/TestCaseDiscoveryProvider.cs @@ -0,0 +1,10 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class TestCaseDiscoveryProvider +{ + [DataMember(Name="languageIds")] + public ICollection LanguageIds { get; } = new List(); +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestCaseDiscoveryResult.cs b/src/bsp-client/Protocol/TestCaseDiscoveryResult.cs new file mode 100644 index 0000000..82f12a4 --- /dev/null +++ b/src/bsp-client/Protocol/TestCaseDiscoveryResult.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class TestCaseDiscoveryResult +{ + /** An optional request id to know the origin of this report. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** A status code for the execution. */ + [DataMember(Name = "statusCode")] + public StatusCode StatusCode { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestFinishData.cs b/src/bsp-client/Protocol/TestFinishData.cs new file mode 100644 index 0000000..a12125c --- /dev/null +++ b/src/bsp-client/Protocol/TestFinishData.cs @@ -0,0 +1,41 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TestFinishData +{ + [DataMember(Name = "id")] + public required string Id { get; set; } + + [DataMember(Name = "buildTarget")] + public required BuildTargetIdentifier BuildTarget { get; set; } + + [DataMember(Name = "fullyQualifiedName")] + public required string FullyQualifiedName { get; set; } + + /** Name or description of the test. */ + [DataMember(Name = "displayName")] + public required string DisplayName { get; set; } + + /** Information about completion of the test, for example an error message. */ + [DataMember(Name = "message")] + public string? Message { get; set; } + + /** Completion status of the test. */ + [DataMember(Name = "status")] + public TestStatus Status { get; set; } + + /** Source location of the test, as LSP location. */ + [DataMember(Name = "location")] + public Location? Location { get; set; } + + /** Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. */ + [DataMember(Name = "dataKind")] + public string? DataKind { get; set; } + + /** Optionally, structured metadata about the test completion. + * For example: stack traces, expected/actual values. */ + [DataMember(Name = "data")] + public TestFinishData? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestParams.cs b/src/bsp-client/Protocol/TestParams.cs new file mode 100644 index 0000000..9b7035e --- /dev/null +++ b/src/bsp-client/Protocol/TestParams.cs @@ -0,0 +1,46 @@ +using Newtonsoft.Json; +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class TestParams +{ + /** A sequence of build targets to compile. */ + [DataMember(Name="targets")] + public BuildTargetIdentifier[] Targets { get; set; } = []; + + /** A unique identifier generated by the client to identify this request. + * The server may include this id in triggered notifications or responses. */ + [DataMember(Name="originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** Optional arguments to the compilation process. */ + [DataMember(Name="arguments")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? Arguments { get; set; } + + /** Optional environment variables to set before running the tests. */ + [DataMember(Name="environmentVariables")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Dictionary EnvironmentVariables { get; set; } = []; + + /** Optional working directory */ + [DataMember(Name="workingDirectory")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Uri? WorkingDirectory { get; set; } + + /// + /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. + /// + [DataMember(Name = "dataKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DataKind { get; set; } + + /** Optional metadata about the task. + * Objects for specific tasks like compile, test, etc are specified in the protocol. */ + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestParamsDataKinds.cs b/src/bsp-client/Protocol/TestParamsDataKinds.cs new file mode 100644 index 0000000..bbe723b --- /dev/null +++ b/src/bsp-client/Protocol/TestParamsDataKinds.cs @@ -0,0 +1,7 @@ +namespace dotnet_bsp.Handlers +{ + public class TestParamsDataKinds + { + public static readonly string DotnetTest = "dotnet-test"; + } +} diff --git a/src/bsp-client/Protocol/TestProvider.cs b/src/bsp-client/Protocol/TestProvider.cs new file mode 100644 index 0000000..bf58788 --- /dev/null +++ b/src/bsp-client/Protocol/TestProvider.cs @@ -0,0 +1,11 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class TestProvider +{ + [DataMember(Name="languageIds")] + public ICollection LanguageIds { get; } = new List(); +} + diff --git a/src/bsp-client/Protocol/TestReportData.cs b/src/bsp-client/Protocol/TestReportData.cs new file mode 100644 index 0000000..3184b90 --- /dev/null +++ b/src/bsp-client/Protocol/TestReportData.cs @@ -0,0 +1,37 @@ +using Newtonsoft.Json; +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TestReportData +{ + /** The build target that was compiled. */ + [DataMember(Name = "target")] + public required BuildTargetIdentifier Target { get; set; } + + /** The total number of milliseconds tests take to run (e.g. doesn't include compile times). */ + [DataMember(Name = "time")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public long? Time { get; set; } + + /** The total number of successful tests. */ + [DataMember(Name = "passed")] + public int Passed { get; set; } + + /** The total number of failed tests. */ + [DataMember(Name = "failed")] + public int Failed { get; set; } + + /** The total number of cancelled tests. */ + [DataMember(Name = "cancelled")] + public int Cancelled { get; set; } + + /** The total number of ignored tests. */ + [DataMember(Name = "ignored")] + public int Ignored { get; set; } + + /** The total number of skipped tests. */ + [DataMember(Name = "skipped")] + public int Skipped { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestResult.cs b/src/bsp-client/Protocol/TestResult.cs new file mode 100644 index 0000000..ecb57f3 --- /dev/null +++ b/src/bsp-client/Protocol/TestResult.cs @@ -0,0 +1,27 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class TestResult +{ + /** An optional request id to know the origin of this report. */ + [DataMember(Name = "originId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? OriginId { get; set; } + + /** A status code for the execution. */ + [DataMember(Name = "statusCode")] + public StatusCode StatusCode { get; set; } + + /** Kind of data to expect in the `data` field. + * If this field is not set, the kind of data is not specified. */ + [DataMember(Name = "dataKind")] + public string? DataKind { get; set; } + + /** Language-specific metadata about the test result. + * See ScalaTestParams as an example. */ + [DataMember(Name = "data")] + public object? Data { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestStatus.cs b/src/bsp-client/Protocol/TestStatus.cs new file mode 100644 index 0000000..3a338b5 --- /dev/null +++ b/src/bsp-client/Protocol/TestStatus.cs @@ -0,0 +1,19 @@ +namespace bsp4csharp.Protocol; + +public enum TestStatus +{ + /** The test passed successfully. */ + Passed = 1, + + /** The test failed. */ + Failed = 2, + + /** The test was marked as ignored. */ + Ignored = 3, + + /** The test execution was cancelled. */ + Cancelled = 4, + + /** The was not included in execution. */ + Skipped = 5, +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestTaskData.cs b/src/bsp-client/Protocol/TestTaskData.cs new file mode 100644 index 0000000..bf7d8d8 --- /dev/null +++ b/src/bsp-client/Protocol/TestTaskData.cs @@ -0,0 +1,11 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TestTaskData +{ + /** The build target that was compiled. */ + [DataMember(Name = "target")] + public required BuildTargetIdentifier Target { get; set; } +} diff --git a/src/bsp-client/Protocol/TextDocumentIdentifier.cs b/src/bsp-client/Protocol/TextDocumentIdentifier.cs new file mode 100644 index 0000000..d9e66b0 --- /dev/null +++ b/src/bsp-client/Protocol/TextDocumentIdentifier.cs @@ -0,0 +1,10 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public record TextDocumentIdentifier +{ + [DataMember(Name="uri")] + public required Uri Uri { get; set; } +} \ No newline at end of file diff --git a/src/bsp-client/Protocol/WorkspaceBuildTargetsResult.cs b/src/bsp-client/Protocol/WorkspaceBuildTargetsResult.cs new file mode 100644 index 0000000..c6945d7 --- /dev/null +++ b/src/bsp-client/Protocol/WorkspaceBuildTargetsResult.cs @@ -0,0 +1,14 @@ +using System.Runtime.Serialization; + +namespace bsp4csharp.Protocol; + +[DataContract] +public class WorkspaceBuildTargetsResult +{ + /// + /// The build targets in this workspace that + /// contain sources with the given language ids. + /// + [DataMember(Name = "targets")] + public IReadOnlyCollection Targets { get; set; } = []; +} \ No newline at end of file diff --git a/src/bsp-client/bsp-client.csproj b/src/bsp-client/bsp-client.csproj new file mode 100644 index 0000000..2a7f669 --- /dev/null +++ b/src/bsp-client/bsp-client.csproj @@ -0,0 +1,7 @@ + + + + bsp_client + + + diff --git a/src/bsp-client/packages.lock.json b/src/bsp-client/packages.lock.json new file mode 100644 index 0000000..75ac79e --- /dev/null +++ b/src/bsp-client/packages.lock.json @@ -0,0 +1,141 @@ +{ + "version": 2, + "dependencies": { + "net8.0": { + "MessagePack": { + "type": "Transitive", + "resolved": "2.5.192", + "contentHash": "Jtle5MaFeIFkdXtxQeL9Tu2Y3HsAQGoSntOzrn6Br/jrl6c8QmG22GEioT5HBtZJR0zw0s46OnKU8ei2M3QifA==", + "dependencies": { + "MessagePack.Annotations": "2.5.192", + "Microsoft.NET.StringTools": "17.6.3" + } + }, + "MessagePack.Annotations": { + "type": "Transitive", + "resolved": "2.5.192", + "contentHash": "jaJuwcgovWIZ8Zysdyf3b7b34/BrADw4v82GaEZymUhDd3ScMPrYd/cttekeDteJJPXseJxp04yTIcxiVUjTWg==" + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "9.0.10", + "contentHash": "r9waLiOPe9ZF1PvzUT+RDoHvpMmY8MW+lb4lqjYGObwKpnyPMLI3odVvlmshwuZcdoHynsGWOrCPA0hxZ63lIA==" + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "9.0.10", + "contentHash": "zMNABt8eBv0B0XrWjFy9nZNgddavaOeq3ZdaD5IlHhRH65MrU7HM+Hd8GjWE3e2VDGFPZFfSAc6XVXC17f9fOA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.10", + "Microsoft.Extensions.Primitives": "9.0.10" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "9.0.10", + "contentHash": "3pl8D1O5ZwMpDkZAT2uXrhQ6NipkwEgDLMFuURiHTf72TvkoMP61QYH3Vk1yrzVHnHBdNZk3cQACz8Zc7YGNhQ==" + }, + "Microsoft.NET.StringTools": { + "type": "Transitive", + "resolved": "17.6.3", + "contentHash": "N0ZIanl1QCgvUumEL1laasU0a7sOE5ZwLZVTn0pAePnfhq8P7SvTjF8Axq+CnavuQkmdQpGNXQ1efZtu5kDFbA==" + }, + "Microsoft.VisualStudio.Threading.Only": { + "type": "Transitive", + "resolved": "17.13.61", + "contentHash": "vl5a2URJYCO5m+aZZtNlAXAMz28e2pUotRuoHD7RnCWOCeoyd8hWp5ZBaLNYq4iEj2oeJx5ZxiSboAjVmB20Qg==", + "dependencies": { + "Microsoft.VisualStudio.Validation": "17.8.8" + } + }, + "Microsoft.VisualStudio.Validation": { + "type": "Transitive", + "resolved": "17.8.8", + "contentHash": "rWXThIpyQd4YIXghNkiv2+VLvzS+MCMKVRDR0GAMlflsdo+YcAN2g2r5U1Ah98OFjQMRexTFtXQQ2LkajxZi3g==" + }, + "Nerdbank.Streams": { + "type": "Transitive", + "resolved": "2.12.87", + "contentHash": "oDKOeKZ865I5X8qmU3IXMyrAnssYEiYWTobPGdrqubN3RtTzEHIv+D6fwhdcfrdhPJzHjCkK/ORztR/IsnmA6g==", + "dependencies": { + "Microsoft.VisualStudio.Threading.Only": "17.13.61", + "Microsoft.VisualStudio.Validation": "17.8.8", + "System.IO.Pipelines": "8.0.0" + } + }, + "Newtonsoft.Json": { + "type": "Transitive", + "resolved": "13.0.3", + "contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==" + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "9.0.10", + "contentHash": "uIpKiKp7EWlYZBK71jYP+maGYjDY9YTi/FxBlZoqDzM1ZHZB7gLqUm4jHvRFwaKfR1/Lrt2rQih9LGPIKyNEow==" + }, + "System.IO.Pipelines": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "FHNOatmUq0sqJOkTx+UF/9YK1f180cnW5FVqnQMvYUN0elp6wFzbtPSiqbo1/ru8ICp43JM1i7kKkk6GsNGHlA==" + }, + "bp": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.DependencyInjection": "[9.0.10, )", + "Microsoft.Extensions.Logging": "[9.0.10, )", + "StreamJsonRpc": "[2.22.23, )" + } + }, + "bsp4csharp": { + "type": "Project", + "dependencies": { + "bp": "[1.0.0, )" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "CentralTransitive", + "requested": "[9.0.10, )", + "resolved": "9.0.10", + "contentHash": "iEtXCkNd5XhjNJAOb/wO4IhDRdLIE2CsPxZggZQWJ/q2+sa8dmEPC393nnsiqdH8/4KV8Xn25IzgKPR1UEQ0og==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.10" + } + }, + "Microsoft.Extensions.Logging": { + "type": "CentralTransitive", + "requested": "[9.0.10, )", + "resolved": "9.0.10", + "contentHash": "UBXHqE9vyptVhaFnT1R7YJKCve7TqVI10yjjUZBNGMlW2lZ4c031Slt9hxsOzWCzlpPxxIFyf1Yk4a6Iubxx7w==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection": "9.0.10", + "Microsoft.Extensions.Logging.Abstractions": "9.0.10", + "Microsoft.Extensions.Options": "9.0.10" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[9.0.10, )", + "resolved": "9.0.10", + "contentHash": "MFUPv/nN1rAQ19w43smm6bbf0JDYN/1HEPHoiMYY50pvDMFpglzWAuoTavByDmZq7UuhjaxwrET3joU69ZHoHQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.10", + "System.Diagnostics.DiagnosticSource": "9.0.10" + } + }, + "StreamJsonRpc": { + "type": "CentralTransitive", + "requested": "[2.22.23, )", + "resolved": "2.22.23", + "contentHash": "Ahq6uUFPnU9alny5h4agyX74th3PRq3NQCRNaDOqWcx20WT06mH/wENSk5IbHDc8BmfreQVEIBx5IXLBbsLFIA==", + "dependencies": { + "MessagePack": "2.5.192", + "Microsoft.VisualStudio.Threading.Only": "17.13.61", + "Microsoft.VisualStudio.Validation": "17.8.8", + "Nerdbank.Streams": "2.12.87", + "Newtonsoft.Json": "13.0.3", + "System.IO.Pipelines": "8.0.0" + } + } + } + } +} \ No newline at end of file diff --git a/src/bsp-server/Logging/MSBuildLogger.cs b/src/bsp-server/Logging/MSBuildLogger.cs index b22b793..a28bfbc 100644 --- a/src/bsp-server/Logging/MSBuildLogger.cs +++ b/src/bsp-server/Logging/MSBuildLogger.cs @@ -1,7 +1,6 @@ using BaseProtocol; using bsp4csharp.Protocol; using Microsoft.Build.Framework; -using Newtonsoft.Json; using Methods = bsp4csharp.Protocol.Methods; namespace dotnet_bsp.Logging; @@ -24,7 +23,7 @@ internal class MSBuildLogger(IBaseProtocolClientManager baseProtocolClientManage public LoggerVerbosity Verbosity { get; set; } = LoggerVerbosity.Normal; - public string Parameters { get; set; } = string.Empty; + public string? Parameters { get; set; } = string.Empty; public void Initialize(IEventSource eventSource) { @@ -41,10 +40,7 @@ public void Initialize(IEventSource eventSource) private void TargetStarted(object sender, TargetStartedEventArgs e) { - if (_buildStartTimestamp == null) - { - _buildStartTimestamp = _timeProvider.GetUtcNow(); - } + _buildStartTimestamp = _timeProvider.GetUtcNow(); if (_targetsOfInterest.Contains(e.TargetName, StringComparer.InvariantCultureIgnoreCase)) { diff --git a/src/bsp4csharp/Protocol/BuildClientCapabilities.cs b/src/bsp4csharp/Protocol/BuildClientCapabilities.cs index ac346e1..8518d05 100644 --- a/src/bsp4csharp/Protocol/BuildClientCapabilities.cs +++ b/src/bsp4csharp/Protocol/BuildClientCapabilities.cs @@ -12,5 +12,5 @@ public class BuildClientCapabilities /// languages than those that appear in this list. /// [DataMember(Name = "languageIds")] - public ICollection LanguageIds { get; } = new List(); + public ICollection LanguageIds { get; init; } = new List(); } \ No newline at end of file diff --git a/test/BuildServerProtocolTests.cs b/test/BuildServerProtocolTests.cs index d5261c2..f689d80 100644 --- a/test/BuildServerProtocolTests.cs +++ b/test/BuildServerProtocolTests.cs @@ -1,6 +1,7 @@ using bsp4csharp.Protocol; using dotnet_bsp; using Xunit.Abstractions; +using bsp_client; namespace test; @@ -32,7 +33,8 @@ public Task InitializeAsync() public async Task RequestWorkspaceBuildTargets_AfterInitialize_Success() { // Arrange - _ = await _client.BuildInitializeAsync(TestProjectPath.AspnetWithoutErrors, _cancellationToken); + var initParams = TestData.GetInitParams(TestProjectPath.AspnetWithoutErrors); + _ = await _client.BuildInitializeAsync(initParams, _cancellationToken); await _client.BuildInitializedAsync(); // Act @@ -68,7 +70,8 @@ public async Task RequestWorkspaceBuildTargets_AfterInitialize_Success() public async Task RequestBuildTargetCompile_ForProjectWithErrors_Success(string testProjectName, string expectedDiagnosticCode, string expectedDiagnosticMessage, int expectedDiagnosticsCount) { // Arrange - _ = await _client.BuildInitializeAsync(TestProjectPath.GetFullPathFor(testProjectName), _cancellationToken); + var initParams = TestData.GetInitParams(TestProjectPath.GetFullPathFor(testProjectName)); + _ = await _client.BuildInitializeAsync(initParams, _cancellationToken); await _client.BuildInitializedAsync(); var buildTargets = await _client.WorkspaceBuildTargetsAsync(_cancellationToken); diff --git a/test/InitializeAndInitializedTests.cs b/test/InitializeAndInitializedTests.cs index 05f93c5..061afc2 100644 --- a/test/InitializeAndInitializedTests.cs +++ b/test/InitializeAndInitializedTests.cs @@ -1,5 +1,6 @@ using StreamJsonRpc; using Xunit.Abstractions; +using bsp_client; namespace test; @@ -32,7 +33,8 @@ public async Task RequestInitializeBuild_Success() // Arrange // Act - var initResult = await _client.BuildInitializeAsync(TestProjectPath.AspnetWithoutErrors, _cancellationToken); + var initParams = TestData.GetInitParams(TestProjectPath.AspnetWithoutErrors); + var initResult = await _client.BuildInitializeAsync(initParams, _cancellationToken); // Assert Assert.Equal("dotnet-bsp", initResult.DisplayName); @@ -69,7 +71,8 @@ public async Task Requests_BeforeInitializeBuildRequest_ShouldFail() public async Task Requests_BeforeInitializedBuildNotification_ShouldFail() { // Arrange - _ = await _client.BuildInitializeAsync(TestProjectPath.AspnetWithoutErrors, _cancellationToken); + var initParams = TestData.GetInitParams(TestProjectPath.AspnetWithoutErrors); + _ = await _client.BuildInitializeAsync(initParams, _cancellationToken); // Act var act = () => _client.WorkspaceBuildTargetsAsync(_cancellationToken); diff --git a/test/ShutdownAndExitTests.cs b/test/ShutdownAndExitTests.cs index b6a9915..a1f560d 100644 --- a/test/ShutdownAndExitTests.cs +++ b/test/ShutdownAndExitTests.cs @@ -1,4 +1,5 @@ using Xunit.Abstractions; +using bsp_client; namespace test; @@ -18,7 +19,8 @@ public async Task RequestToExit_WithShutdownRequestedBefore_SuccessWithExitCodeZ cancellationTokenSource.CancelAfter(TimeSpan.FromSeconds(3)); var cancellationToken = cancellationTokenSource.Token; - _ = await client.BuildInitializeAsync(TestProjectPath.AspnetWithoutErrors, cancellationToken); + var initParams = TestData.GetInitParams(TestProjectPath.AspnetWithoutErrors); + _ = await client.BuildInitializeAsync(initParams, cancellationToken); await client.BuildInitializedAsync(); await client.ShutdownAsync(); @@ -44,7 +46,8 @@ public async Task RequestToExit_WithoutShutdownFirst_FailWithExitCodeOne() cancellationTokenSource.CancelAfter(TimeSpan.FromSeconds(3)); var cancellationToken = cancellationTokenSource.Token; - _ = await client.BuildInitializeAsync(TestProjectPath.AspnetWithoutErrors, cancellationToken); + var initParams = TestData.GetInitParams(TestProjectPath.AspnetWithoutErrors); + _ = await client.BuildInitializeAsync(initParams, cancellationToken); await client.BuildInitializedAsync(); // Act diff --git a/test/TestHelpers/BuildServerFactory.cs b/test/TestHelpers/BuildServerFactory.cs index f6dd9a4..44e8591 100644 --- a/test/TestHelpers/BuildServerFactory.cs +++ b/test/TestHelpers/BuildServerFactory.cs @@ -1,7 +1,7 @@ -using dotnet_bsp; using Microsoft.Extensions.Logging; using System.Diagnostics; using System.Runtime.InteropServices; +using bsp_client; namespace test; @@ -58,7 +58,7 @@ private void ErrorDataReceived(object sender, DataReceivedEventArgs e) _logger.LogError(e.Data); } - public BuildServerClient CreateClient(ServerCallbacks serverCallbacks, TraceListener? traceListener = null) + public BuildServerClient CreateClient(IServerCallbacks serverCallbacks, TraceListener? traceListener = null) { return new BuildServerClient(_serverStdin, _serverStdout, serverCallbacks, traceListener); } diff --git a/test/TestHelpers/ServerCallbacks.cs b/test/TestHelpers/ServerCallbacks.cs index 9eff0d0..f715d28 100644 --- a/test/TestHelpers/ServerCallbacks.cs +++ b/test/TestHelpers/ServerCallbacks.cs @@ -2,10 +2,11 @@ using StreamJsonRpc; using Xunit.Abstractions; using Microsoft.Extensions.Logging; +using bsp_client; namespace test; -public class ServerCallbacks(ITestOutputHelper testOutputHelper, LogLevel logLevel = LogLevel.Warning) +public class ServerCallbacks(ITestOutputHelper testOutputHelper, LogLevel logLevel = LogLevel.Warning) : IServerCallbacks { private readonly List _diagnosticsCollection = []; public IReadOnlyCollection Diagnostics => _diagnosticsCollection.AsReadOnly(); diff --git a/test/TestHelpers/TestProjectPath.cs b/test/TestHelpers/TestProjectPath.cs index 18d4fed..cb5ac8e 100644 --- a/test/TestHelpers/TestProjectPath.cs +++ b/test/TestHelpers/TestProjectPath.cs @@ -1,5 +1,7 @@ -namespace test; +using bsp4csharp.Protocol; +using dotnet_bsp; +namespace test; public static class TestProject { @@ -12,6 +14,24 @@ public static class TestProject public const string MsTestSlnTests = "mstest-sln-tests"; } +internal static class TestData +{ + internal static InitializeBuildParams GetInitParams(string workspaceRootPath) + { + return new InitializeBuildParams + { + DisplayName = "TestClient", + Version = "1.0.0", + BspVersion = "2.1.1", + RootUri = UriFixer.WithFileSchema(workspaceRootPath), + Capabilities = new BuildClientCapabilities + { + LanguageIds = ["csharp"] + } + }; + } +} + internal static class TestProjectPath { private static readonly string TestProjectDir = Path.GetFullPath(AppContext.BaseDirectory + "../../../../test-projects"); diff --git a/test/TestsRelatedEndpointsTests.cs b/test/TestsRelatedEndpointsTests.cs index 2c1f245..fe4d3de 100644 --- a/test/TestsRelatedEndpointsTests.cs +++ b/test/TestsRelatedEndpointsTests.cs @@ -3,6 +3,7 @@ using dotnet_bsp.Handlers; using Newtonsoft.Json.Linq; using Xunit.Abstractions; +using bsp_client; namespace test; @@ -149,7 +150,8 @@ public async Task RequestBuildTargetTestCaseDiscovery_ForFramework_Success(strin CleanupOutputDirectories(testProjectPath); - _ = await _client.BuildInitializeAsync(testProjectPath, _cancellationToken); + var initParams = TestData.GetInitParams(testProjectPath); + _ = await _client.BuildInitializeAsync(initParams, _cancellationToken); await _client.BuildInitializedAsync(); var buildTargets = await _client.WorkspaceBuildTargetsAsync(_cancellationToken); @@ -356,7 +358,8 @@ public async Task RequestBuildTargetTest_ForTestableBuildTarget_Success( CleanupOutputDirectories(testProjectPath); - _ = await _client.BuildInitializeAsync(testProjectPath, _cancellationToken); + var initParams = TestData.GetInitParams(testProjectPath); + _ = await _client.BuildInitializeAsync(initParams, _cancellationToken); await _client.BuildInitializedAsync(); // Act diff --git a/test/bsp-server.tests.csproj b/test/bsp-server.tests.csproj index 6c83509..0bc1705 100644 --- a/test/bsp-server.tests.csproj +++ b/test/bsp-server.tests.csproj @@ -1,28 +1,29 @@ - - - - enable - enable - false - true - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - + + + + enable + enable + false + true + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/test/packages.lock.json b/test/packages.lock.json index bc2781f..d019176 100644 --- a/test/packages.lock.json +++ b/test/packages.lock.json @@ -266,6 +266,12 @@ "StreamJsonRpc": "[2.22.23, )" } }, + "bsp-client": { + "type": "Project", + "dependencies": { + "bsp4csharp": "[1.0.0, )" + } + }, "bsp4csharp": { "type": "Project", "dependencies": { From b95f7eb79056b84e8fbc5055173a3327df70f50b Mon Sep 17 00:00:00 2001 From: Alexej Kowalew <616b2f@gmail.com> Date: Sat, 22 Nov 2025 12:44:36 +0100 Subject: [PATCH 2/3] refactor: remove duplicated files --- .../Protocol/BuildClientCapabilities.cs | 17 --- .../Protocol/BuildServerCapabilities.cs | 126 ------------------ src/bsp-client/Protocol/BuildTarget.cs | 83 ------------ .../Protocol/BuildTargetCapabilities.cs | 28 ---- .../Protocol/BuildTargetDataKind.cs | 30 ----- .../Protocol/BuildTargetIdentifier.cs | 16 --- src/bsp-client/Protocol/BuildTargetTag.cs | 50 ------- src/bsp-client/Protocol/CleanCacheParams.cs | 11 -- src/bsp-client/Protocol/CleanCacheResult.cs | 17 --- src/bsp-client/Protocol/CompileParams.cs | 23 ---- src/bsp-client/Protocol/CompileProvider.cs | 11 -- src/bsp-client/Protocol/CompileReport.cs | 28 ---- src/bsp-client/Protocol/CompileResult.cs | 26 ---- src/bsp-client/Protocol/CompileTask.cs | 10 -- src/bsp-client/Protocol/DebugProvider.cs | 11 -- .../Protocol/DebugSessionAddress.cs | 14 -- src/bsp-client/Protocol/DebugSessionParams.cs | 27 ---- src/bsp-client/Protocol/Diagnostic.cs | 47 ------- src/bsp-client/Protocol/DiagnosticSeverity.cs | 16 --- .../Protocol/DotnetTestParamsData.cs | 14 -- .../Protocol/InitializeBuildParams.cs | 62 --------- .../Protocol/InitializeBuildResult.cs | 55 -------- .../Protocol/InitializedBuildParams.cs | 9 -- src/bsp-client/Protocol/LanguageId.cs | 6 - src/bsp-client/Protocol/Location.cs | 14 -- src/bsp-client/Protocol/LogMessageParams.cs | 36 ----- src/bsp-client/Protocol/MessageType.cs | 24 ---- src/bsp-client/Protocol/Methods.cs | 39 ------ src/bsp-client/Protocol/Position.cs | 19 --- src/bsp-client/Protocol/PrintParams.cs | 25 ---- .../Protocol/PublishDiagnosticsParams.cs | 36 ----- src/bsp-client/Protocol/Range.cs | 13 -- src/bsp-client/Protocol/ReadParams.cs | 19 --- src/bsp-client/Protocol/RunParams.cs | 48 ------- src/bsp-client/Protocol/RunProvider.cs | 11 -- src/bsp-client/Protocol/RunResult.cs | 17 --- src/bsp-client/Protocol/SourceItem.cs | 37 ----- src/bsp-client/Protocol/SourcesItem.cs | 25 ---- src/bsp-client/Protocol/SourcesParams.cs | 11 -- src/bsp-client/Protocol/SourcesResult.cs | 10 -- src/bsp-client/Protocol/StatusCode.cs | 14 -- src/bsp-client/Protocol/TaskFinishDataKind.cs | 9 -- src/bsp-client/Protocol/TaskFinishParams.cs | 46 ------- src/bsp-client/Protocol/TaskId.cs | 25 ---- .../Protocol/TaskProgressDataKind.cs | 7 - src/bsp-client/Protocol/TaskProgressParams.cs | 57 -------- src/bsp-client/Protocol/TaskStartData.cs | 15 --- src/bsp-client/Protocol/TaskStartDataKind.cs | 9 -- src/bsp-client/Protocol/TaskStartParams.cs | 42 ------ .../Protocol/TestCaseDiscoveredData.cs | 28 ---- .../Protocol/TestCaseDiscoveryParams.cs | 18 --- .../Protocol/TestCaseDiscoveryProvider.cs | 11 -- .../Protocol/TestCaseDiscoveryResult.cs | 17 --- src/bsp-client/Protocol/TestFinishData.cs | 41 ------ src/bsp-client/Protocol/TestParams.cs | 48 ------- .../Protocol/TestParamsDataKinds.cs | 7 - src/bsp-client/Protocol/TestProvider.cs | 11 -- src/bsp-client/Protocol/TestReportData.cs | 37 ----- src/bsp-client/Protocol/TestResult.cs | 27 ---- src/bsp-client/Protocol/TestStatus.cs | 19 --- src/bsp-client/Protocol/TestTaskData.cs | 11 -- .../Protocol/TextDocumentIdentifier.cs | 11 -- .../Protocol/WorkspaceBuildTargetsResult.cs | 15 --- src/bsp-client/bsp-client.csproj | 4 + src/bsp-client/packages.lock.json | 14 ++ test/bsp-server.tests.csproj | 2 +- test/packages.lock.json | 3 +- 67 files changed, 21 insertions(+), 1648 deletions(-) delete mode 100644 src/bsp-client/Protocol/BuildClientCapabilities.cs delete mode 100644 src/bsp-client/Protocol/BuildServerCapabilities.cs delete mode 100644 src/bsp-client/Protocol/BuildTarget.cs delete mode 100644 src/bsp-client/Protocol/BuildTargetCapabilities.cs delete mode 100644 src/bsp-client/Protocol/BuildTargetDataKind.cs delete mode 100644 src/bsp-client/Protocol/BuildTargetIdentifier.cs delete mode 100644 src/bsp-client/Protocol/BuildTargetTag.cs delete mode 100644 src/bsp-client/Protocol/CleanCacheParams.cs delete mode 100644 src/bsp-client/Protocol/CleanCacheResult.cs delete mode 100644 src/bsp-client/Protocol/CompileParams.cs delete mode 100644 src/bsp-client/Protocol/CompileProvider.cs delete mode 100644 src/bsp-client/Protocol/CompileReport.cs delete mode 100644 src/bsp-client/Protocol/CompileResult.cs delete mode 100644 src/bsp-client/Protocol/CompileTask.cs delete mode 100644 src/bsp-client/Protocol/DebugProvider.cs delete mode 100644 src/bsp-client/Protocol/DebugSessionAddress.cs delete mode 100644 src/bsp-client/Protocol/DebugSessionParams.cs delete mode 100644 src/bsp-client/Protocol/Diagnostic.cs delete mode 100644 src/bsp-client/Protocol/DiagnosticSeverity.cs delete mode 100644 src/bsp-client/Protocol/DotnetTestParamsData.cs delete mode 100644 src/bsp-client/Protocol/InitializeBuildParams.cs delete mode 100644 src/bsp-client/Protocol/InitializeBuildResult.cs delete mode 100644 src/bsp-client/Protocol/InitializedBuildParams.cs delete mode 100644 src/bsp-client/Protocol/LanguageId.cs delete mode 100644 src/bsp-client/Protocol/Location.cs delete mode 100644 src/bsp-client/Protocol/LogMessageParams.cs delete mode 100644 src/bsp-client/Protocol/MessageType.cs delete mode 100644 src/bsp-client/Protocol/Methods.cs delete mode 100644 src/bsp-client/Protocol/Position.cs delete mode 100644 src/bsp-client/Protocol/PrintParams.cs delete mode 100644 src/bsp-client/Protocol/PublishDiagnosticsParams.cs delete mode 100644 src/bsp-client/Protocol/Range.cs delete mode 100644 src/bsp-client/Protocol/ReadParams.cs delete mode 100644 src/bsp-client/Protocol/RunParams.cs delete mode 100644 src/bsp-client/Protocol/RunProvider.cs delete mode 100644 src/bsp-client/Protocol/RunResult.cs delete mode 100644 src/bsp-client/Protocol/SourceItem.cs delete mode 100644 src/bsp-client/Protocol/SourcesItem.cs delete mode 100644 src/bsp-client/Protocol/SourcesParams.cs delete mode 100644 src/bsp-client/Protocol/SourcesResult.cs delete mode 100644 src/bsp-client/Protocol/StatusCode.cs delete mode 100644 src/bsp-client/Protocol/TaskFinishDataKind.cs delete mode 100644 src/bsp-client/Protocol/TaskFinishParams.cs delete mode 100644 src/bsp-client/Protocol/TaskId.cs delete mode 100644 src/bsp-client/Protocol/TaskProgressDataKind.cs delete mode 100644 src/bsp-client/Protocol/TaskProgressParams.cs delete mode 100644 src/bsp-client/Protocol/TaskStartData.cs delete mode 100644 src/bsp-client/Protocol/TaskStartDataKind.cs delete mode 100644 src/bsp-client/Protocol/TaskStartParams.cs delete mode 100644 src/bsp-client/Protocol/TestCaseDiscoveredData.cs delete mode 100644 src/bsp-client/Protocol/TestCaseDiscoveryParams.cs delete mode 100644 src/bsp-client/Protocol/TestCaseDiscoveryProvider.cs delete mode 100644 src/bsp-client/Protocol/TestCaseDiscoveryResult.cs delete mode 100644 src/bsp-client/Protocol/TestFinishData.cs delete mode 100644 src/bsp-client/Protocol/TestParams.cs delete mode 100644 src/bsp-client/Protocol/TestParamsDataKinds.cs delete mode 100644 src/bsp-client/Protocol/TestProvider.cs delete mode 100644 src/bsp-client/Protocol/TestReportData.cs delete mode 100644 src/bsp-client/Protocol/TestResult.cs delete mode 100644 src/bsp-client/Protocol/TestStatus.cs delete mode 100644 src/bsp-client/Protocol/TestTaskData.cs delete mode 100644 src/bsp-client/Protocol/TextDocumentIdentifier.cs delete mode 100644 src/bsp-client/Protocol/WorkspaceBuildTargetsResult.cs diff --git a/src/bsp-client/Protocol/BuildClientCapabilities.cs b/src/bsp-client/Protocol/BuildClientCapabilities.cs deleted file mode 100644 index 9bc5428..0000000 --- a/src/bsp-client/Protocol/BuildClientCapabilities.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class BuildClientCapabilities -{ - /// - /// The languages that this client supports. - /// The ID strings for each language is defined in the LSP. - /// The server must never respond with build targets for other - /// languages than those that appear in this list. - /// - [DataMember(Name = "languageIds")] - public ICollection LanguageIds { get; init; } = new List(); -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildServerCapabilities.cs b/src/bsp-client/Protocol/BuildServerCapabilities.cs deleted file mode 100644 index 4f3493a..0000000 --- a/src/bsp-client/Protocol/BuildServerCapabilities.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -/// -/// Class which represents server capabilities. -/// -/// See the Build Server Protocol specification for additional information. -/// -[DataContract] -public class BuildServerCapabilities -{ - /// - /// The languages the server supports compilation via method buildTarget/compile. - /// - [DataMember(Name = "compileProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public CompileProvider? CompileProvider { get; set; } - - /// - /// The languages the server supports test execution via method buildTarget/test. - /// - [DataMember(Name = "testProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public TestProvider? TestProvider { get; set; } - - /// - /// The languages the server supports test case discovery via method buildTarget/testCaseDiscovery. - /// - [DataMember(Name = "testCaseDiscoveryProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public TestCaseDiscoveryProvider? TestCaseDiscoveryProvider { get; set; } - - /// - /// The languages the server supports run via method buildTarget/run. - /// - [DataMember(Name = "runProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public RunProvider? RunProvider { get; set; } - - /// - /// The languages the server supports debugging via method debugSession/start. - /// - [DataMember(Name = "debugProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public DebugProvider? DebugProvider { get; set; } - - /// - /// Theserver can provide a list of targets that contain a - /// single text document via the method buildTarget/inverseSources - /// - [DataMember(Name = "inverseSourcesProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? InverseSourcesProvider { get; set; } - - /// - /// The server provides sources for library dependencies - /// via method buildTarget/dependencySources - /// - [DataMember(Name = "dependencySourcesProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? DependencySourcesProvider { get; set; } - - /// - /// The server can provide a list of dependency modules (libraries with meta information) - /// via method buildTarget/dependencyModules - /// - [DataMember(Name = "dependencyModulesProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? DependencyModulesProvider { get; set; } - - /// - /// The server provides all the resource dependencies - /// via method buildTarget/resources - /// - [DataMember(Name = "resourcesProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? ResourcesProvider { get; set; } - - /// - /// The server provides all output paths - /// via method buildTarget/outputPaths - /// - [DataMember(Name = "outputPathsProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? OutputPathsProvider { get; set; } - - /// - /// The server sends notifications to the client on build - /// target change events via buildTarget/didChange - /// - [DataMember(Name = "buildTargetChangedProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? BuildTargetChangedProvider { get; set; } - - /// - /// Reloading the build state through workspace/reload is supported - /// - [DataMember(Name = "canReload")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? CanReload { get; set; } - - /// - /// The server can respond to `buildTarget/jvmRunEnvironment` requests with the - /// necessary information required to launch a Java process to run a main class. - /// - [DataMember(Name = "jvmRunEnvironmentProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? JvmRunEnvironmentProvider { get; set; } - - /*/// The server can respond to `buildTarget/jvmTestEnvironment` requests with the - /// necessary information required to launch a Java process for testing or - /// debugging. */ - [DataMember(Name = "jvmTestEnvironmentProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? JvmTestEnvironmentProvider { get; set; } - - /// - /// The server can respond to `workspace/cargoFeaturesState` and - /// `setCargoFeatures` requests. In other words, supports Cargo Features extension. - /// - [DataMember(Name = "cargoFeaturesProvider")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public bool? CargoFeaturesProvider { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTarget.cs b/src/bsp-client/Protocol/BuildTarget.cs deleted file mode 100644 index d064aab..0000000 --- a/src/bsp-client/Protocol/BuildTarget.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record BuildTarget -{ - /// - /// The target’s unique identifier - /// - [DataMember(Name = "id")] - public required BuildTargetIdentifier Id { get; set; } - - /// - /// A human readable name for this target. - /// May be presented in the user interface. - /// Should be unique if possible. - /// The id.uri is used if None. - /// - [DataMember(Name = "displayName")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DisplayName { get; set; } - - /// - /// The directory where this target belongs to. Multiple build targets are allowed to map - /// to the same base directory, and a build target is not required to have a base directory. - /// A base directory does not determine the sources of a target, see buildTarget/sources. - /// - [DataMember(Name = "baseDirectory")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Uri? BaseDirectory { get; set; } - - /// - /// Free-form string tags to categorize or label this build target. - /// For example, can be used by the client to: - /// - customize how the target should be translated into the client's project model. - /// - group together different but related targets in the user interface. - /// - display icons or colors in the user interface. - /// Pre-defined tags are listed in `BuildTargetTag` but clients and servers - /// are free to define new tags for custom purposes. - /// - [DataMember(Name = "tags")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public IReadOnlyCollection Tags { get; set; } = []; - - /// - /// The set of languages that this target contains. - /// The ID string for each language is defined in the LSP. - /// - [DataMember(Name = "languageIds")] - public IReadOnlyCollection LanguageIds { get; set; } = []; - - /// - /// The direct upstream build target dependencies of this build target - /// - [DataMember(Name = "dependencies")] - public IReadOnlyCollection Dependencies { get; set; } = []; - - /// - /// The capabilities of this build target. - /// - [DataMember(Name = "capabilities")] - public required BuildTargetCapabilities Capabilities { get; set; } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, - /// the kind of data is not specified. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public BuildTargetDataKind? DataKind { get; set; } - - /// - /// Language-specific metadata about this target. - /// See ScalaBuildTarget as an example. - /// - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTargetCapabilities.cs b/src/bsp-client/Protocol/BuildTargetCapabilities.cs deleted file mode 100644 index 4c2f232..0000000 --- a/src/bsp-client/Protocol/BuildTargetCapabilities.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class BuildTargetCapabilities -{ - /** This target can be compiled by the BSP server. */ - [DataMember(Name="canCompile")] - [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] - public bool? CanCompile { get; set; } - - /** This target can be tested by the BSP server. */ - [DataMember(Name="canTest")] - [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] - public bool? CanTest { get; set; } - - /** This target can be run by the BSP server. */ - [DataMember(Name="canRun")] - [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] - public bool? CanRun { get; set; } - - /** This target can be debugged by the BSP server. */ - [DataMember(Name="canDebug")] - [JsonProperty(NullValueHandling=NullValueHandling.Ignore)] - public bool? CanDebug { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTargetDataKind.cs b/src/bsp-client/Protocol/BuildTargetDataKind.cs deleted file mode 100644 index caa71eb..0000000 --- a/src/bsp-client/Protocol/BuildTargetDataKind.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -public enum BuildTargetDataKind -{ - /** `data` field must contain a CargoBuildTarget object. */ - [EnumMember(Value="cargo")] - Cargo, - - /** `data` field must contain a CppBuildTarget object. */ - [EnumMember(Value="cpp")] - Cpp, - - /** `data` field must contain a JvmBuildTarget object. */ - [EnumMember(Value="jvm")] - Jvm, - - /** `data` field must contain a PythonBuildTarget object. */ - [EnumMember(Value="python")] - Python, - - /** `data` field must contain a SbtBuildTarget object. */ - [EnumMember(Value="sbt")] - Sbt, - - /** `data` field must contain a ScalaBuildTarget object. */ - [EnumMember(Value="scala")] - Scala, -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTargetIdentifier.cs b/src/bsp-client/Protocol/BuildTargetIdentifier.cs deleted file mode 100644 index 31b1815..0000000 --- a/src/bsp-client/Protocol/BuildTargetIdentifier.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record BuildTargetIdentifier -{ - [DataMember(Name="uri")] - public required Uri Uri { get; set; } - - public override string ToString() - { - return Uri.LocalPath.ToString(); - } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/BuildTargetTag.cs b/src/bsp-client/Protocol/BuildTargetTag.cs deleted file mode 100644 index 0bfb97e..0000000 --- a/src/bsp-client/Protocol/BuildTargetTag.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace bsp4csharp.Protocol; - -[JsonConverter(typeof(StringEnumConverter))] -public enum BuildTargetTag -{ - /** Target contains source code for producing any kind of application, may have - * but does not require the `canRun` capability. */ - [EnumMember(Value="application")] - Application, - - /** Target contains source code to measure performance of a program, may have - * but does not require the `canRun` build target capability. */ - [EnumMember(Value="benchmark")] - Benchmark, - - /** Target contains source code for integration testing purposes, may have - * but does not require the `canTest` capability. - * The difference between "test" and "integration-test" is that - * integration tests traditionally run slower compared to normal tests - * and require more computing resources to execute. */ - [EnumMember(Value="integration-test")] - IntegrationTest, - - /** Target contains re-usable functionality for downstream targets. May have any - * combination of capabilities. */ - [EnumMember(Value="library")] - Library, - - /** Actions on the target such as build and test should only be invoked manually - * and explicitly. For example, triggering a build on all targets in the workspace - * should by default not include this target. - * The original motivation to add the "manual" tag comes from a similar functionality - * that exists in Bazel, where targets with this tag have to be specified explicitly - * on the command line. */ - [EnumMember(Value="manual")] - Manual, - - /** Target should be ignored by IDEs. */ - [EnumMember(Value="no-ide")] - NoIde, - - /** Target contains source code for testing purposes, may have but does not - * require the `canTest` capability. */ - [EnumMember(Value="test")] - Test, -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CleanCacheParams.cs b/src/bsp-client/Protocol/CleanCacheParams.cs deleted file mode 100644 index 1dc9e0f..0000000 --- a/src/bsp-client/Protocol/CleanCacheParams.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class CleanCacheParams -{ - /** A sequence of build targets to clean. */ - [DataMember(Name="targets")] - public BuildTargetIdentifier[] Targets { get; set; } = []; -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CleanCacheResult.cs b/src/bsp-client/Protocol/CleanCacheResult.cs deleted file mode 100644 index e27410b..0000000 --- a/src/bsp-client/Protocol/CleanCacheResult.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class CleanCacheResult -{ - /** Optional message to display to the user. */ - [DataMember(Name = "message")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? Message { get; set; } - - /** Indicates whether the clean cache request was performed or not. */ - [DataMember(Name = "cleaned")] - public bool Cleaned { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileParams.cs b/src/bsp-client/Protocol/CompileParams.cs deleted file mode 100644 index fefa078..0000000 --- a/src/bsp-client/Protocol/CompileParams.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class CompileParams -{ - /** A sequence of build targets to compile. */ - [DataMember(Name="targets")] - public BuildTargetIdentifier[] Targets { get; set; } = []; - - /** A unique identifier generated by the client to identify this request. - * The server may include this id in triggered notifications or responses. */ - [DataMember(Name="originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** Optional arguments to the compilation process. */ - [DataMember(Name="arguments")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string[]? Arguments { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileProvider.cs b/src/bsp-client/Protocol/CompileProvider.cs deleted file mode 100644 index 657898c..0000000 --- a/src/bsp-client/Protocol/CompileProvider.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class CompileProvider -{ - [DataMember(Name="languageIds")] - public ICollection LanguageIds { get; } = new List(); -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileReport.cs b/src/bsp-client/Protocol/CompileReport.cs deleted file mode 100644 index 788bcb5..0000000 --- a/src/bsp-client/Protocol/CompileReport.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Identifier = string; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record CompileReport -{ - [DataMember(Name = "target")] - public required BuildTargetIdentifier Target { get; set; } - - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Identifier? OriginId { get; set; } - - [DataMember(Name = "errors")] - public int Errors { get; set; } - - [DataMember(Name = "warnings")] - public int Warnings { get; set; } - - [DataMember(Name = "time")] - public long? Time { get; set; } - - [DataMember(Name = "noOp")] - public bool? NoOp { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileResult.cs b/src/bsp-client/Protocol/CompileResult.cs deleted file mode 100644 index 6b3a2f7..0000000 --- a/src/bsp-client/Protocol/CompileResult.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class CompileResult -{ - /** An optional request id to know the origin of this report. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** A status code for the execution. */ - [DataMember(Name = "statusCode")] - public StatusCode StatusCode { get; set; } - - /** Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. */ - [DataMember(Name = "dataKind")] - public string? DataKind { get; set; } - - /** A field containing language-specific information, like products - * of compilation or compiler-specific metadata the client needs to know. */ - [DataMember(Name = "data")] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/CompileTask.cs b/src/bsp-client/Protocol/CompileTask.cs deleted file mode 100644 index db22cdf..0000000 --- a/src/bsp-client/Protocol/CompileTask.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record CompileTask -{ - [DataMember(Name = "target")] - public required BuildTargetIdentifier Target { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/DebugProvider.cs b/src/bsp-client/Protocol/DebugProvider.cs deleted file mode 100644 index d2cbd80..0000000 --- a/src/bsp-client/Protocol/DebugProvider.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class DebugProvider -{ - [DataMember(Name="languageIds")] - public ICollection LanguageIds { get; } = new List(); -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/DebugSessionAddress.cs b/src/bsp-client/Protocol/DebugSessionAddress.cs deleted file mode 100644 index 66229a1..0000000 --- a/src/bsp-client/Protocol/DebugSessionAddress.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class DebugSessionAddress -{ - /// - /// The Debug Adapter Protocol server's connection uri - /// - [DataMember(Name = "uri")] - public required Uri Uri { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/DebugSessionParams.cs b/src/bsp-client/Protocol/DebugSessionParams.cs deleted file mode 100644 index b1f4cbf..0000000 --- a/src/bsp-client/Protocol/DebugSessionParams.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Newtonsoft.Json; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class DebugSessionParams -{ - /** A sequence of build targets to run. */ - [DataMember(Name="targets")] - public required BuildTargetIdentifier[] Targets { get; set; } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. - /// - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } - - /// - /// Language-specific metadata for this execution. - /// See ScalaMainClass as an example. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DataKind { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Diagnostic.cs b/src/bsp-client/Protocol/Diagnostic.cs deleted file mode 100644 index 9f333b9..0000000 --- a/src/bsp-client/Protocol/Diagnostic.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class Diagnostic -{ - /** The range at which the message applies. */ - [DataMember(Name = "range")] - public required Range Range { get; set; } - - /** The diagnostic's severity. Can be omitted. If omitted it is up to the - * client to interpret diagnostics as error, warning, info or hint. */ - [DataMember(Name = "severity")] - public DiagnosticSeverity? Severity { get; set; } - - /** The diagnostic's code, which might appear in the user interface. */ - [DataMember(Name = "code")] - public string? Code { get; set; } - - /** An optional property to describe the error code. */ - // public CodeDescription? CodeDescription { get; set; } - - /** A human-readable string describing the source of this - * diagnostic, e.g. 'typescript' or 'super lint'. */ - [DataMember(Name = "source")] - public string? Source { get; set; } - - /** The diagnostic's message. */ - [DataMember(Name = "message")] - public required string Message { get; set; } - - // /** Additional metadata about the diagnostic. */ - // public DiagnosticTag[]? Tags { get; set; } - // - // /** An array of related diagnostic information, e.g. when symbol-names within - // * a scope collide all definitions can be marked via this property. */ - // public DiagnosticRelatedInformation[]? RelatedInformation { get; set; } - // - // /** Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. */ - // public DiagnosticDataKind? DataKind { get; set; } - // - // /** A data entry field that is preserved between a - // * `textDocument/publishDiagnostics` notification and - // * `textDocument/codeAction` request. */ - // public DiagnosticData? Data { get; set; } -} diff --git a/src/bsp-client/Protocol/DiagnosticSeverity.cs b/src/bsp-client/Protocol/DiagnosticSeverity.cs deleted file mode 100644 index a207c49..0000000 --- a/src/bsp-client/Protocol/DiagnosticSeverity.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace bsp4csharp.Protocol; - -public enum DiagnosticSeverity -{ - /** Reports an error. */ - Error = 1, - - /** Reports a warning. */ - Warning = 2, - - /** Reports an information. */ - Information = 3, - - /** Reports a hint. */ - Hint = 4, -} diff --git a/src/bsp-client/Protocol/DotnetTestParamsData.cs b/src/bsp-client/Protocol/DotnetTestParamsData.cs deleted file mode 100644 index 9b650cc..0000000 --- a/src/bsp-client/Protocol/DotnetTestParamsData.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Runtime.Serialization; - -namespace dotnet_bsp.Handlers -{ - [DataContract] - public class DotnetTestParamsData - { - [DataMember(Name = "filter")] - public required string Filter { get; set; } - - [DataMember(Name = "runSettings")] - public string? RunSettings { get; set; } - } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/InitializeBuildParams.cs b/src/bsp-client/Protocol/InitializeBuildParams.cs deleted file mode 100644 index d03c603..0000000 --- a/src/bsp-client/Protocol/InitializeBuildParams.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -/// -/// Class which represents the parameter sent with an initialize method request. -/// -/// See the Build Server Protocol specification for additional information. -/// -[DataContract] -public class InitializeBuildParams -{ - /// - /// Name of the client - /// - [DataMember(Name = "displayName")] - public required string DisplayName { get; set; } - - /// - /// The version of the client - /// - [DataMember(Name = "version")] - public required string Version { get; set; } - - /// - /// The BSP version that the client speaks - /// - [DataMember(Name = "bspVersion")] - public required string BspVersion { get; set; } - - /// - /// Gets or sets the capabilities supported by the client. - /// - [DataMember(Name = "capabilities")] - public required BuildClientCapabilities Capabilities - { - get; - set; - } - - /// - /// The rootUri of the workspace - /// - [DataMember(Name = "rootUri")] - public required Uri RootUri { get; set; } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DataKind { get; set; } - - /// - /// Additional metadata about the client - /// - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/InitializeBuildResult.cs b/src/bsp-client/Protocol/InitializeBuildResult.cs deleted file mode 100644 index 96494a7..0000000 --- a/src/bsp-client/Protocol/InitializeBuildResult.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -/// -/// Class which represents the result returned by the initialize request. -/// -/// See the Build Server Protocol specification for additional information. -/// -[DataContract] -public class InitializeBuildResult -{ - /// - /// Name of the server - /// - [DataMember(Name = "displayName")] - public required string DisplayName { get; set; } - - /// - /// The version of the server - /// - [DataMember(Name = "version")] - public required string Version { get; set; } - - /// - /// The BSP version that the server speaks - /// - [DataMember(Name = "bspVersion")] - public required string BspVersion { get; set; } - - /// - /// Gets or sets the server capabilities. - /// - [DataMember(Name = "capabilities")] - public required BuildServerCapabilities Capabilities - { - get; - set; - } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DataKind { get; set; } - - /// - /// Additional metadata about the server - /// - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } -} diff --git a/src/bsp-client/Protocol/InitializedBuildParams.cs b/src/bsp-client/Protocol/InitializedBuildParams.cs deleted file mode 100644 index 1c6601b..0000000 --- a/src/bsp-client/Protocol/InitializedBuildParams.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class InitializedBuildParams -{ -} - diff --git a/src/bsp-client/Protocol/LanguageId.cs b/src/bsp-client/Protocol/LanguageId.cs deleted file mode 100644 index 9208f4c..0000000 --- a/src/bsp-client/Protocol/LanguageId.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace bsp4csharp.Protocol; - -public static class LanguageId -{ - public const string Csharp = "csharp"; -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Location.cs b/src/bsp-client/Protocol/Location.cs deleted file mode 100644 index b8c236c..0000000 --- a/src/bsp-client/Protocol/Location.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record Location -{ - [DataMember(Name = "uri")] - public required Uri Uri { get; set; } - - [DataMember(Name = "range")] - public required Range Range { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/LogMessageParams.cs b/src/bsp-client/Protocol/LogMessageParams.cs deleted file mode 100644 index 5282290..0000000 --- a/src/bsp-client/Protocol/LogMessageParams.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Newtonsoft.Json; -using System.Runtime.Serialization; -using Identifier = string; - -namespace bsp4csharp.Protocol; - -/// -/// Class which represents parameter sent with window/logMessage requests. -/// -/// See the Base Protocol specification for additional information. -/// -[DataContract] -public class LogMessageParams -{ - /// - /// Gets or sets the type of message. - /// - [DataMember(Name = "type")] - public MessageType MessageType { get; set; } - - /// - /// Gets or sets the message. - /// - [DataMember(Name = "message")] - public required string Message { get; set; } - - /** Unique id of the task with optional reference to parent task id */ - [DataMember(Name = "taskId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public TaskId? TaskId { get; set; } - - /** A unique identifier generated by the client to identify this request. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Identifier? OriginId { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/MessageType.cs b/src/bsp-client/Protocol/MessageType.cs deleted file mode 100644 index 0c9129c..0000000 --- a/src/bsp-client/Protocol/MessageType.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace bsp4csharp.Protocol; - -public enum MessageType -{ - /// - /// Error message. - /// - Error = 1, - - /// - /// Warning message. - /// - Warning = 2, - - /// - /// Info message. - /// - Info = 3, - - /// - /// Log message. - /// - Log = 4, -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Methods.cs b/src/bsp-client/Protocol/Methods.cs deleted file mode 100644 index 31537f7..0000000 --- a/src/bsp-client/Protocol/Methods.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace bsp4csharp.Protocol; - -/// -/// Class which contains the string values for all common build server protocol methods. -/// -public static class Methods -{ - // server methods - public const string BuildInitialize = "build/initialize"; - public const string BuildInitialized = "build/initialized"; - public const string BuildShutdown = "build/shutdown"; - public const string BuildExit = "build/exit"; - public const string WorkspaceBuildTargets = "workspace/buildTargets"; - public const string WorkspaceReload = "workspace/reload"; - public const string BuildTargetSources = "buildTarget/sources"; - public const string BuildTargetInverseSources = "buildTarget/inverseSources"; - public const string BuildTargetDependencySources = "buildTarget/dependencySources"; - public const string BuildTargetDependencyModules = "buildTarget/dependencyModules"; - public const string BuildTargetResources = "buildTarget/resources"; - public const string BuildTargetOutputPaths = "buildTarget/outputPaths"; - public const string BuildTargetCompile = "buildTarget/compile"; - public const string BuildTargetRun = "buildTarget/run"; - public const string BuildTargetTest = "buildTarget/test"; - public const string BuildTargetTestCaseDiscovery = "buildTarget/testCaseDiscovery"; - public const string BuildTargetCleanCache = "buildTarget/cleanCache"; - public const string DebugSessionStart = "debugSession/start"; - public const string RunReadStdin = "run/readStdin"; - - // client methods - public const string BuildShowMessage = "build/showMessage"; - public const string BuildLogMessage = "build/logMessage"; - public const string BuildPublishDiagnostics = "build/publishDiagnostics"; - public const string BuildTargetDidChange = "buildTarget/didChange"; - public const string BuildTaskStart = "build/taskStart"; - public const string BuildTaskProgress = "build/taskProgress"; - public const string BuildTaskFinish = "build/taskFinish"; - public const string RunPrintStdout = "run/printStdout"; - public const string RunPrintStderr = "run/printStderr"; -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Position.cs b/src/bsp-client/Protocol/Position.cs deleted file mode 100644 index 00b0a71..0000000 --- a/src/bsp-client/Protocol/Position.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record Position -{ - /** Line position in a document (zero-based). */ - [DataMember(Name = "line")] - public int Line { get; set; } - - /** Character offset on a line in a document (zero-based) - * - * If the character value is greater than the line length it defaults back - * to the line length. */ - [DataMember(Name = "character")] - public int Character { get; set; } -} - diff --git a/src/bsp-client/Protocol/PrintParams.cs b/src/bsp-client/Protocol/PrintParams.cs deleted file mode 100644 index cd65429..0000000 --- a/src/bsp-client/Protocol/PrintParams.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class PrintParams -{ - /** An optional request id to know the origin of this report. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** Relevant only for test tasks. - * Allows to tell the client from which task the output is coming from. - **/ - [DataMember(Name = "taskId")] - public TaskId? TaskId { get; set; } - - /** Message content can contain arbitrary bytes. - * They should be escaped as per [javascript encoding](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#using_special_characters_in_strings) - **/ - [DataMember(Name = "message")] - public required string Message { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/PublishDiagnosticsParams.cs b/src/bsp-client/Protocol/PublishDiagnosticsParams.cs deleted file mode 100644 index de3c880..0000000 --- a/src/bsp-client/Protocol/PublishDiagnosticsParams.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class PublishDiagnosticsParams -{ - /// - /// The document where the diagnostics are published. - /// - [DataMember(Name = "textDocument")] - public required TextDocumentIdentifier TextDocument { get; set; } - - /** The build target where the diagnostics origin. - * It is valid for one text document to belong to multiple - * build targets, for example sources that are compiled against multiple - * platforms (JVM, JavaScript). */ - [DataMember(Name = "buildTarget")] - public required BuildTargetIdentifier BuildTarget { get; set; } - - /** The request id that originated this notification. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** The diagnostics to be published by the client. */ - [DataMember(Name = "diagnostics")] - public ICollection Diagnostics { get; } = new List(); - - /** Whether the client should clear the previous diagnostics - * mapped to the same `textDocument` and `buildTarget`. */ - [DataMember(Name = "reset")] - public bool Reset { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/Range.cs b/src/bsp-client/Protocol/Range.cs deleted file mode 100644 index 7f6ecfa..0000000 --- a/src/bsp-client/Protocol/Range.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record Range -{ - [DataMember(Name = "start")] - public required Position Start { get; set; } - [DataMember(Name = "end")] - public required Position End { get; set; } -} - diff --git a/src/bsp-client/Protocol/ReadParams.cs b/src/bsp-client/Protocol/ReadParams.cs deleted file mode 100644 index c48bb89..0000000 --- a/src/bsp-client/Protocol/ReadParams.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Newtonsoft.Json; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class ReadParams -{ - // Id of the request - [DataMember(Name="originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - [DataMember(Name = "task")] - public TaskId? TaskId { get; set; } - - [DataMember(Name = "message")] - public required string Message { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/RunParams.cs b/src/bsp-client/Protocol/RunParams.cs deleted file mode 100644 index a8dff3c..0000000 --- a/src/bsp-client/Protocol/RunParams.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using Newtonsoft.Json; -using System.Runtime.Serialization; -using System.Collections.Generic; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class RunParams -{ - /** A sequence of build targets to run. */ - [DataMember(Name="target")] - public required BuildTargetIdentifier Target { get; set; } - - /** A unique identifier generated by the client to identify this request. - * The server may include this id in triggered notifications or responses. */ - [DataMember(Name="originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** Optional arguments to the compilation process. */ - [DataMember(Name="arguments")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string[]? Arguments { get; set; } - - /** Optional environment variables to set before running the tests. */ - [DataMember(Name="environmentVariables")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Dictionary EnvironmentVariables { get; set; } = []; - - /** Optional working directory */ - [DataMember(Name="workingDirectory")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Uri? WorkingDirectory { get; set; } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DataKind { get; set; } - - /** Optional metadata about the task. - * Objects for specific tasks like compile, test, etc are specified in the protocol. */ - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/RunProvider.cs b/src/bsp-client/Protocol/RunProvider.cs deleted file mode 100644 index df60fbe..0000000 --- a/src/bsp-client/Protocol/RunProvider.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class RunProvider -{ - [DataMember(Name="languageIds")] - public ICollection LanguageIds { get; } = new List(); -} diff --git a/src/bsp-client/Protocol/RunResult.cs b/src/bsp-client/Protocol/RunResult.cs deleted file mode 100644 index a4587cd..0000000 --- a/src/bsp-client/Protocol/RunResult.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class RunResult -{ - /** An optional request id to know the origin of this report. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** A status code for the execution. */ - [DataMember(Name = "statusCode")] - public StatusCode StatusCode { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/SourceItem.cs b/src/bsp-client/Protocol/SourceItem.cs deleted file mode 100644 index 301a326..0000000 --- a/src/bsp-client/Protocol/SourceItem.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record SourceItem -{ - /** - * Either a text document or a directory. A directory entry must end with a forward - * slash "/" and a directory entry implies that every nested text document within the - * directory belongs to this source item. - * - **/ - [DataMember(Name = "uri")] - public required Uri Uri { get; init; } - - /** - * Type of file of the source item, such as whether it is file or directory. - * - **/ - [DataMember(Name = "kind")] - public required SourceItemKind Kind { get; init; } - - /** - * Indicates if this source is automatically generated by the build and is not - * intended to be manually edited by the user. - * - **/ - public bool Generated { get; init; } -} - -public enum SourceItemKind -{ - File = 1, - Directory = 2, -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/SourcesItem.cs b/src/bsp-client/Protocol/SourcesItem.cs deleted file mode 100644 index 6f94e81..0000000 --- a/src/bsp-client/Protocol/SourcesItem.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record SourcesItem -{ - [DataMember(Name = "target")] - public required BuildTargetIdentifier Target { get; init; } - - // - // The text documents or and directories that belong to this build target. - // - [DataMember(Name = "sources")] - public required SourceItem[] Sources { get; init; } - - - // - // The root directories from where source files should be relativized. - // Example: ["file://Users/name/dev/metals/src/main/scala"] - // - [DataMember(Name = "roots")] - public Uri[]? Roots { get; init; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/SourcesParams.cs b/src/bsp-client/Protocol/SourcesParams.cs deleted file mode 100644 index 6aea8a0..0000000 --- a/src/bsp-client/Protocol/SourcesParams.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record SourcesParams -{ - - [DataMember(Name = "targets")] - public required BuildTargetIdentifier[] Targets { get; init; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/SourcesResult.cs b/src/bsp-client/Protocol/SourcesResult.cs deleted file mode 100644 index b5f6b90..0000000 --- a/src/bsp-client/Protocol/SourcesResult.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record SourcesResult -{ - [DataMember(Name = "items")] - public required SourcesItem[] Items { get; init; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/StatusCode.cs b/src/bsp-client/Protocol/StatusCode.cs deleted file mode 100644 index 3a78220..0000000 --- a/src/bsp-client/Protocol/StatusCode.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace bsp4csharp.Protocol; - -public enum StatusCode -{ - /** Execution was successful. */ - Ok = 1, - - /** Execution failed. */ - Error = 2, - - /** Execution was cancelled. */ - Cancelled = 3, -} - diff --git a/src/bsp-client/Protocol/TaskFinishDataKind.cs b/src/bsp-client/Protocol/TaskFinishDataKind.cs deleted file mode 100644 index 38a9733..0000000 --- a/src/bsp-client/Protocol/TaskFinishDataKind.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace bsp4csharp.Protocol; - -public static class TaskFinishDataKind -{ - public static string CompileReport = "compile-report"; - public static string TestFinish = "test-finish"; - public static string TestReport = "test-report"; - public static string TestCaseDiscoveryFinish = "test-case-discovery-finish"; -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskFinishParams.cs b/src/bsp-client/Protocol/TaskFinishParams.cs deleted file mode 100644 index 136a166..0000000 --- a/src/bsp-client/Protocol/TaskFinishParams.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Identifier = string; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TaskFinishParams -{ - /** Unique id of the task with optional reference to parent task id */ - [DataMember(Name = "taskId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public required TaskId TaskId { get; set; } - - /** A unique identifier generated by the client to identify this request. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Identifier? OriginId { get; set; } - - /** Timestamp of when the event started in milliseconds since Epoch. */ - [DataMember(Name = "eventTime")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public long? EventTime { get; set; } - - /** Message describing the task. */ - [DataMember(Name = "message")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? Message { get; set; } - - /** Task completion status. */ - [DataMember(Name = "status")] - public StatusCode Status { get; set; } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DataKind { get; set; } - - /** Optional metadata about the task. - * Objects for specific tasks like compile, test, etc are specified in the protocol. */ - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskId.cs b/src/bsp-client/Protocol/TaskId.cs deleted file mode 100644 index 99fece7..0000000 --- a/src/bsp-client/Protocol/TaskId.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Identifier = string; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class TaskId -{ - /** A unique identifier */ - [DataMember(Name = "id")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public required Identifier Id { get; set; } - - /** The parent task ids, if any. A non-empty parents field means - * this task is a sub-task of every parent task id. The child-parent - * relationship of tasks makes it possible to render tasks in - * a tree-like user interface or inspect what caused a certain task - * execution. - * OriginId should not be included in the parents field, there is a separate - * field for that. */ - [DataMember(Name = "parents")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Identifier[]? Parents { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskProgressDataKind.cs b/src/bsp-client/Protocol/TaskProgressDataKind.cs deleted file mode 100644 index 7ceba25..0000000 --- a/src/bsp-client/Protocol/TaskProgressDataKind.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace bsp4csharp.Protocol; - -public static class TaskProgressDataKind -{ - public static string TestCaseDiscovered = "test-case-discovered"; - public static string TestResult = "test-result"; -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskProgressParams.cs b/src/bsp-client/Protocol/TaskProgressParams.cs deleted file mode 100644 index 7882160..0000000 --- a/src/bsp-client/Protocol/TaskProgressParams.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Identifier = string; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TaskProgressParams -{ - /** Unique id of the task with optional reference to parent task id */ - [DataMember(Name = "taskId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public required TaskId TaskId { get; set; } - - /** A unique identifier generated by the client to identify this request. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Identifier? OriginId { get; set; } - - /** Timestamp of when the event started in milliseconds since Epoch. */ - [DataMember(Name = "eventTime")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public long? EventTime { get; set; } - - /** Message describing the task. */ - [DataMember(Name = "message")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? Message { get; set; } - - /** If known, total amount of work units in this task. */ - [DataMember(Name = "total")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public long? Total { get; set; } - - /** If known, completed amount of work units in this task. */ - [DataMember(Name = "progress")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public long? Progress { get; set; } - - /** Name of a work unit. For example, "files" or "tests". May be empty. */ - [DataMember(Name = "unit")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? Unit { get; set; } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DataKind { get; set; } - - /** Optional metadata about the task. - * Objects for specific tasks like compile, test, etc are specified in the protocol. */ - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskStartData.cs b/src/bsp-client/Protocol/TaskStartData.cs deleted file mode 100644 index 79c42af..0000000 --- a/src/bsp-client/Protocol/TaskStartData.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TaskStartData -{ - /** Display name of the test **/ - [DataMember(Name = "displayName")] - public required string DisplayName { get; set; } - - /** Source location of the test, as LSP location. **/ - [DataMember(Name = "location")] - public Location? Location { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskStartDataKind.cs b/src/bsp-client/Protocol/TaskStartDataKind.cs deleted file mode 100644 index ffc0690..0000000 --- a/src/bsp-client/Protocol/TaskStartDataKind.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace bsp4csharp.Protocol; - -public static class TaskStartDataKind -{ - public static string CompileTask = "compile-task"; - public static string TestStart = "test-start"; - public static string TestTask = "test-task"; - public static string TestCaseDiscoveryTask = "test-case-discovery-task"; -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TaskStartParams.cs b/src/bsp-client/Protocol/TaskStartParams.cs deleted file mode 100644 index b3875f0..0000000 --- a/src/bsp-client/Protocol/TaskStartParams.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; -using Identifier = string; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TaskStartParams -{ - /** Unique id of the task with optional reference to parent task id */ - [DataMember(Name = "taskId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public required TaskId TaskId { get; set; } - - /** A unique identifier generated by the client to identify this request. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Identifier? OriginId { get; set; } - - /** Timestamp of when the event started in milliseconds since Epoch. */ - [DataMember(Name = "eventTime")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public long? EventTime { get; set; } - - /** Message describing the task. */ - [DataMember(Name = "message")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? Message { get; set; } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DataKind { get; set; } - - /** Optional metadata about the task. - * Objects for specific tasks like compile, test, etc are specified in the protocol. */ - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestCaseDiscoveredData.cs b/src/bsp-client/Protocol/TestCaseDiscoveredData.cs deleted file mode 100644 index 002f012..0000000 --- a/src/bsp-client/Protocol/TestCaseDiscoveredData.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TestCaseDiscoveredData -{ - [DataMember(Name = "id")] - public required string Id { get; set; } - - [DataMember(Name = "displayName")] - public required string DisplayName { get; set; } - - [DataMember(Name = "fullyQualifiedName")] - public required string FullyQualifiedName { get; set; } - - [DataMember(Name = "source")] - public required string Source { get; set; } - - [DataMember(Name = "line")] - public int Line { get; set; } - - [DataMember(Name = "filePath")] - public required string FilePath { get; set; } - - [DataMember(Name = "buildTarget")] - public required BuildTargetIdentifier BuildTarget { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestCaseDiscoveryParams.cs b/src/bsp-client/Protocol/TestCaseDiscoveryParams.cs deleted file mode 100644 index ba9bfac..0000000 --- a/src/bsp-client/Protocol/TestCaseDiscoveryParams.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Newtonsoft.Json; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class TestCaseDiscoveryParams -{ - /** A sequence of build targets to compile. */ - [DataMember(Name="targets")] - public BuildTargetIdentifier[] Targets { get; set; } = []; - - /** A unique identifier generated by the client to identify this request. - * The server may include this id in triggered notifications or responses. */ - [DataMember(Name="originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestCaseDiscoveryProvider.cs b/src/bsp-client/Protocol/TestCaseDiscoveryProvider.cs deleted file mode 100644 index 91d00d9..0000000 --- a/src/bsp-client/Protocol/TestCaseDiscoveryProvider.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class TestCaseDiscoveryProvider -{ - [DataMember(Name="languageIds")] - public ICollection LanguageIds { get; } = new List(); -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestCaseDiscoveryResult.cs b/src/bsp-client/Protocol/TestCaseDiscoveryResult.cs deleted file mode 100644 index 82f12a4..0000000 --- a/src/bsp-client/Protocol/TestCaseDiscoveryResult.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class TestCaseDiscoveryResult -{ - /** An optional request id to know the origin of this report. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** A status code for the execution. */ - [DataMember(Name = "statusCode")] - public StatusCode StatusCode { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestFinishData.cs b/src/bsp-client/Protocol/TestFinishData.cs deleted file mode 100644 index a12125c..0000000 --- a/src/bsp-client/Protocol/TestFinishData.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TestFinishData -{ - [DataMember(Name = "id")] - public required string Id { get; set; } - - [DataMember(Name = "buildTarget")] - public required BuildTargetIdentifier BuildTarget { get; set; } - - [DataMember(Name = "fullyQualifiedName")] - public required string FullyQualifiedName { get; set; } - - /** Name or description of the test. */ - [DataMember(Name = "displayName")] - public required string DisplayName { get; set; } - - /** Information about completion of the test, for example an error message. */ - [DataMember(Name = "message")] - public string? Message { get; set; } - - /** Completion status of the test. */ - [DataMember(Name = "status")] - public TestStatus Status { get; set; } - - /** Source location of the test, as LSP location. */ - [DataMember(Name = "location")] - public Location? Location { get; set; } - - /** Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. */ - [DataMember(Name = "dataKind")] - public string? DataKind { get; set; } - - /** Optionally, structured metadata about the test completion. - * For example: stack traces, expected/actual values. */ - [DataMember(Name = "data")] - public TestFinishData? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestParams.cs b/src/bsp-client/Protocol/TestParams.cs deleted file mode 100644 index c8ab640..0000000 --- a/src/bsp-client/Protocol/TestParams.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using Newtonsoft.Json; -using System.Runtime.Serialization; -using System.Collections.Generic; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class TestParams -{ - /** A sequence of build targets to compile. */ - [DataMember(Name="targets")] - public BuildTargetIdentifier[] Targets { get; set; } = []; - - /** A unique identifier generated by the client to identify this request. - * The server may include this id in triggered notifications or responses. */ - [DataMember(Name="originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** Optional arguments to the compilation process. */ - [DataMember(Name="arguments")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string[]? Arguments { get; set; } - - /** Optional environment variables to set before running the tests. */ - [DataMember(Name="environmentVariables")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Dictionary EnvironmentVariables { get; set; } = []; - - /** Optional working directory */ - [DataMember(Name="workingDirectory")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public Uri? WorkingDirectory { get; set; } - - /// - /// Kind of data to expect in the `data` field. If this field is not set, the kind of data is not specified. - /// - [DataMember(Name = "dataKind")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? DataKind { get; set; } - - /** Optional metadata about the task. - * Objects for specific tasks like compile, test, etc are specified in the protocol. */ - [DataMember(Name = "data")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestParamsDataKinds.cs b/src/bsp-client/Protocol/TestParamsDataKinds.cs deleted file mode 100644 index bbe723b..0000000 --- a/src/bsp-client/Protocol/TestParamsDataKinds.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace dotnet_bsp.Handlers -{ - public class TestParamsDataKinds - { - public static readonly string DotnetTest = "dotnet-test"; - } -} diff --git a/src/bsp-client/Protocol/TestProvider.cs b/src/bsp-client/Protocol/TestProvider.cs deleted file mode 100644 index 36507d9..0000000 --- a/src/bsp-client/Protocol/TestProvider.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class TestProvider -{ - [DataMember(Name="languageIds")] - public ICollection LanguageIds { get; } = new List(); -} diff --git a/src/bsp-client/Protocol/TestReportData.cs b/src/bsp-client/Protocol/TestReportData.cs deleted file mode 100644 index 3184b90..0000000 --- a/src/bsp-client/Protocol/TestReportData.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Newtonsoft.Json; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TestReportData -{ - /** The build target that was compiled. */ - [DataMember(Name = "target")] - public required BuildTargetIdentifier Target { get; set; } - - /** The total number of milliseconds tests take to run (e.g. doesn't include compile times). */ - [DataMember(Name = "time")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public long? Time { get; set; } - - /** The total number of successful tests. */ - [DataMember(Name = "passed")] - public int Passed { get; set; } - - /** The total number of failed tests. */ - [DataMember(Name = "failed")] - public int Failed { get; set; } - - /** The total number of cancelled tests. */ - [DataMember(Name = "cancelled")] - public int Cancelled { get; set; } - - /** The total number of ignored tests. */ - [DataMember(Name = "ignored")] - public int Ignored { get; set; } - - /** The total number of skipped tests. */ - [DataMember(Name = "skipped")] - public int Skipped { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestResult.cs b/src/bsp-client/Protocol/TestResult.cs deleted file mode 100644 index ecb57f3..0000000 --- a/src/bsp-client/Protocol/TestResult.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class TestResult -{ - /** An optional request id to know the origin of this report. */ - [DataMember(Name = "originId")] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string? OriginId { get; set; } - - /** A status code for the execution. */ - [DataMember(Name = "statusCode")] - public StatusCode StatusCode { get; set; } - - /** Kind of data to expect in the `data` field. - * If this field is not set, the kind of data is not specified. */ - [DataMember(Name = "dataKind")] - public string? DataKind { get; set; } - - /** Language-specific metadata about the test result. - * See ScalaTestParams as an example. */ - [DataMember(Name = "data")] - public object? Data { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestStatus.cs b/src/bsp-client/Protocol/TestStatus.cs deleted file mode 100644 index 3a338b5..0000000 --- a/src/bsp-client/Protocol/TestStatus.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace bsp4csharp.Protocol; - -public enum TestStatus -{ - /** The test passed successfully. */ - Passed = 1, - - /** The test failed. */ - Failed = 2, - - /** The test was marked as ignored. */ - Ignored = 3, - - /** The test execution was cancelled. */ - Cancelled = 4, - - /** The was not included in execution. */ - Skipped = 5, -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/TestTaskData.cs b/src/bsp-client/Protocol/TestTaskData.cs deleted file mode 100644 index bf7d8d8..0000000 --- a/src/bsp-client/Protocol/TestTaskData.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TestTaskData -{ - /** The build target that was compiled. */ - [DataMember(Name = "target")] - public required BuildTargetIdentifier Target { get; set; } -} diff --git a/src/bsp-client/Protocol/TextDocumentIdentifier.cs b/src/bsp-client/Protocol/TextDocumentIdentifier.cs deleted file mode 100644 index 1279656..0000000 --- a/src/bsp-client/Protocol/TextDocumentIdentifier.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public record TextDocumentIdentifier -{ - [DataMember(Name="uri")] - public required Uri Uri { get; set; } -} \ No newline at end of file diff --git a/src/bsp-client/Protocol/WorkspaceBuildTargetsResult.cs b/src/bsp-client/Protocol/WorkspaceBuildTargetsResult.cs deleted file mode 100644 index 53b9642..0000000 --- a/src/bsp-client/Protocol/WorkspaceBuildTargetsResult.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace bsp4csharp.Protocol; - -[DataContract] -public class WorkspaceBuildTargetsResult -{ - /// - /// The build targets in this workspace that - /// contain sources with the given language ids. - /// - [DataMember(Name = "targets")] - public IReadOnlyCollection Targets { get; set; } = []; -} \ No newline at end of file diff --git a/src/bsp-client/bsp-client.csproj b/src/bsp-client/bsp-client.csproj index 80d0aba..ff5bc2e 100644 --- a/src/bsp-client/bsp-client.csproj +++ b/src/bsp-client/bsp-client.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/src/bsp-client/packages.lock.json b/src/bsp-client/packages.lock.json index b64901c..144ab72 100644 --- a/src/bsp-client/packages.lock.json +++ b/src/bsp-client/packages.lock.json @@ -117,6 +117,20 @@ "resolved": "6.1.0", "contentHash": "5o/HZxx6RVqYlhKSq8/zronDkALJZUT2Vz0hx43f0gwe8mwlM0y2nYlqdBwLMzr262Bwvpikeb/yEwkAa5PADg==" }, + "bp": { + "type": "Project", + "dependencies": { + "Microsoft.Extensions.DependencyInjection": "[10.0.0, )", + "Microsoft.Extensions.Logging": "[10.0.0, )", + "StreamJsonRpc": "[2.22.23, )" + } + }, + "bsp4csharp": { + "type": "Project", + "dependencies": { + "bp": "[1.0.0, )" + } + }, "Microsoft.Extensions.Logging.Abstractions": { "type": "CentralTransitive", "requested": "[10.0.0, )", diff --git a/test/bsp-server.tests.csproj b/test/bsp-server.tests.csproj index cf82fde..c61eb0f 100644 --- a/test/bsp-server.tests.csproj +++ b/test/bsp-server.tests.csproj @@ -23,7 +23,7 @@ - + diff --git a/test/packages.lock.json b/test/packages.lock.json index d92091f..2c89a8f 100644 --- a/test/packages.lock.json +++ b/test/packages.lock.json @@ -287,7 +287,8 @@ "dependencies": { "Microsoft.Extensions.DependencyInjection": "[10.0.0, )", "Microsoft.Extensions.Logging": "[10.0.0, )", - "StreamJsonRpc": "[2.22.23, )" + "StreamJsonRpc": "[2.22.23, )", + "bsp4csharp": "[1.0.0, )" } }, "bsp4csharp": { From ebab5e08fa1cf66f9bc7628d386f087f860f3112 Mon Sep 17 00:00:00 2001 From: Alexej Kowalew <616b2f@gmail.com> Date: Tue, 17 Mar 2026 19:37:07 +0100 Subject: [PATCH 3/3] chore: update package.lock files --- src/bsp-client/packages.lock.json | 54 +++++++++++++++---------------- test/packages.lock.json | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/bsp-client/packages.lock.json b/src/bsp-client/packages.lock.json index 144ab72..99e410f 100644 --- a/src/bsp-client/packages.lock.json +++ b/src/bsp-client/packages.lock.json @@ -4,22 +4,22 @@ "net8.0": { "Microsoft.Extensions.DependencyInjection": { "type": "Direct", - "requested": "[10.0.0, )", - "resolved": "10.0.0", - "contentHash": "f0RBabswJq+gRu5a+hWIobrLWiUYPKMhCD9WO3sYBAdSy3FFH14LMvLVFZc2kPSCimBLxSuitUhsd6tb0TAY6A==", + "requested": "[10.0.5, )", + "resolved": "10.0.5", + "contentHash": "v1SVsowG6YE1YnHVGmLWz57YTRCQRx9pH5ebIESXfm5isI9gA3QaMyg/oMTzPpXYZwSAVDzYItGJKfmV+pqXkQ==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.5" } }, "Microsoft.Extensions.Logging": { "type": "Direct", - "requested": "[10.0.0, )", - "resolved": "10.0.0", - "contentHash": "BStFkd5CcnEtarlcgYDBcFzGYCuuNMzPs02wN3WBsOFoYIEmYoUdAiU+au6opzoqfTYJsMTW00AeqDdnXH2CvA==", + "requested": "[10.0.5, )", + "resolved": "10.0.5", + "contentHash": "+XTMKQyDWg4ODoNHU/BN3BaI1jhGO7VCS+BnzT/4IauiG6y2iPAte7MyD7rHKS+hNP0TkFkjrae8DFjDUxtcxg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection": "10.0.0", - "Microsoft.Extensions.Logging.Abstractions": "10.0.0", - "Microsoft.Extensions.Options": "10.0.0" + "Microsoft.Extensions.DependencyInjection": "10.0.5", + "Microsoft.Extensions.Logging.Abstractions": "10.0.5", + "Microsoft.Extensions.Options": "10.0.5" } }, "StreamJsonRpc": { @@ -52,22 +52,22 @@ }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Transitive", - "resolved": "10.0.0", - "contentHash": "L3AdmZ1WOK4XXT5YFPEwyt0ep6l8lGIPs7F5OOBZc77Zqeo01Of7XXICy47628sdVl0v/owxYJTe86DTgFwKCA==" + "resolved": "10.0.5", + "contentHash": "iVMtq9eRvzyhx8949EGT0OCYJfXi737SbRVzWXE5GrOgGj5AaZ9eUuxA/BSUfmOMALKn/g8KfFaNQw0eiB3lyA==" }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "10.0.0", - "contentHash": "8oCAgXOow5XDrY9HaXX1QmH3ORsyZO/ANVHBlhLyCeWTH5Sg4UuqZeOTWJi6484M+LqSx0RqQXDJtdYy2BNiLQ==", + "resolved": "10.0.5", + "contentHash": "MDaQMdUplw0AIRhWWmbLA7yQEXaLIHb+9CTroTiNS8OlI0LMXS4LCxtopqauiqGCWlRgJ+xyraVD8t6veRAFbw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.0", - "Microsoft.Extensions.Primitives": "10.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.5", + "Microsoft.Extensions.Primitives": "10.0.5" } }, "Microsoft.Extensions.Primitives": { "type": "Transitive", - "resolved": "10.0.0", - "contentHash": "inRnbpCS0nwO/RuoZIAqxQUuyjaknOOnCEZB55KSMMjRhl0RQDttSmLSGsUJN3RQ3ocf5NDLFd2mOQViHqMK5w==" + "resolved": "10.0.5", + "contentHash": "/HUHJ0tw/LQvD0DZrz50eQy/3z7PfX7WWEaXnjKTV9/TNdcgFlNTZGo49QhS7PTmhDqMyHRMqAXSBxLh0vso4g==" }, "Microsoft.VisualStudio.Threading.Only": { "type": "Transitive", @@ -99,8 +99,8 @@ }, "System.Diagnostics.DiagnosticSource": { "type": "Transitive", - "resolved": "10.0.0", - "contentHash": "0KdBK+h7G13PuOSC2R/DalAoFMvdYMznvGRuICtkdcUMXgl/gYXsG6z4yUvTxHSMACorWgHCU1Faq0KUHU6yAQ==" + "resolved": "10.0.5", + "contentHash": "CCbzHQ26L3jskdwHh+4bxxW84lUMIrAAmeSlpO69AlrQV0DKbj1/I+feLaLSuZeqXPr9UlSy0OcgZoXOk2a6/g==" }, "System.IO.Pipelines": { "type": "Transitive", @@ -120,8 +120,8 @@ "bp": { "type": "Project", "dependencies": { - "Microsoft.Extensions.DependencyInjection": "[10.0.0, )", - "Microsoft.Extensions.Logging": "[10.0.0, )", + "Microsoft.Extensions.DependencyInjection": "[10.0.5, )", + "Microsoft.Extensions.Logging": "[10.0.5, )", "StreamJsonRpc": "[2.22.23, )" } }, @@ -133,12 +133,12 @@ }, "Microsoft.Extensions.Logging.Abstractions": { "type": "CentralTransitive", - "requested": "[10.0.0, )", - "resolved": "10.0.0", - "contentHash": "FU/IfjDfwaMuKr414SSQNTIti/69bHEMb+QKrskRb26oVqpx3lNFXMjs/RC9ZUuhBhcwDM2BwOgoMw+PZ+beqQ==", + "requested": "[10.0.5, )", + "resolved": "10.0.5", + "contentHash": "9HOdqlDtPptVcmKAjsQ/Nr5Rxfq6FMYLdhvZh1lVmeKR738qeYecQD7+ldooXf+u2KzzR1kafSphWngIM3C6ug==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.0", - "System.Diagnostics.DiagnosticSource": "10.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.5", + "System.Diagnostics.DiagnosticSource": "10.0.5" } }, "Microsoft.NET.StringTools": { diff --git a/test/packages.lock.json b/test/packages.lock.json index 6c1c395..b54130e 100644 --- a/test/packages.lock.json +++ b/test/packages.lock.json @@ -285,8 +285,8 @@ "bsp-client": { "type": "Project", "dependencies": { - "Microsoft.Extensions.DependencyInjection": "[10.0.0, )", - "Microsoft.Extensions.Logging": "[10.0.0, )", + "Microsoft.Extensions.DependencyInjection": "[10.0.5, )", + "Microsoft.Extensions.Logging": "[10.0.5, )", "StreamJsonRpc": "[2.22.23, )", "bsp4csharp": "[1.0.0, )" }