mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Add v2 of the Hosting Service and build nuget packages for it (#675)
* Port v2 of Hosting service to SqlToolsService - Renamed project to .v2 so that existing hosted service isn't impacted - Copied over the CoreServices project which contains ConnectionServiceCore and other reusable services for anything interacting with MSSQL - Ported unit test project across and verified tests run. * Nuget package support for reusable DLLs * Use 1.1 version per Karl's suggestion * Use correct license URL and project URL * Use new SMO packages
This commit is contained in:
33
src/Microsoft.SqlTools.Hosting.Contracts/EventType.cs
Normal file
33
src/Microsoft.SqlTools.Hosting.Contracts/EventType.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.Hosting.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an event type with a particular method name.
|
||||
/// </summary>
|
||||
/// <typeparam name="TParams">The parameter type for this event.</typeparam>
|
||||
public class EventType<TParams>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the method name for the event type.
|
||||
/// </summary>
|
||||
public string MethodName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates an EventType instance with the given parameter type and method name.
|
||||
/// </summary>
|
||||
/// <param name="methodName">The method name of the event.</param>
|
||||
/// <returns>A new EventType instance for the defined type.</returns>
|
||||
public static EventType<TParams> Create(string methodName)
|
||||
{
|
||||
return new EventType<TParams>()
|
||||
{
|
||||
MethodName = methodName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
23
src/Microsoft.SqlTools.Hosting.Contracts/Internal/Error.cs
Normal file
23
src/Microsoft.SqlTools.Hosting.Contracts/Internal/Error.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.Hosting.Contracts.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the message contract for errors returned via <see cref="Microsoft.SqlTools.Hosting.Protocol.RequestContext.SendError"/>
|
||||
/// </summary>
|
||||
public class Error
|
||||
{
|
||||
/// <summary>
|
||||
/// Error code. If omitted will default to 0
|
||||
/// </summary>
|
||||
public int Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Error message
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.Hosting.Contracts.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an event that is sent from the client to notify that
|
||||
/// the client is exiting and the server should as well.
|
||||
/// </summary>
|
||||
public class ExitNotification
|
||||
{
|
||||
public static readonly EventType<object> Type = EventType<object>.Create("exit");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.Hosting.Contracts.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters to be used for reporting hosting-level errors, such as protocol violations
|
||||
/// </summary>
|
||||
public class HostingErrorParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The message of the error
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public class HostingErrorNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<HostingErrorParams> Type =
|
||||
EventType<HostingErrorParams>.Create("hosting/error");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.Hosting.Contracts.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a message that is sent from the client to request
|
||||
/// that the server shut down.
|
||||
/// </summary>
|
||||
public class ShutdownRequest
|
||||
{
|
||||
public static readonly RequestType<object, object> Type = RequestType<object, object>.Create("shutdown");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageDescription>
|
||||
Defines the core messages needed for the Microsoft.SqlTools.Hosting service to communicate over the VSCode Language Server Protocol.
|
||||
</PackageDescription>
|
||||
<Description>$(PackageDescription)</Description>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\sqltools.common.targets" />
|
||||
</Project>
|
||||
24
src/Microsoft.SqlTools.Hosting.Contracts/RequestType.cs
Normal file
24
src/Microsoft.SqlTools.Hosting.Contracts/RequestType.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.SqlTools.Hosting.Contracts
|
||||
{
|
||||
[DebuggerDisplay("RequestType MethodName = {MethodName}")]
|
||||
public class RequestType<TParams, TResult>
|
||||
{
|
||||
public string MethodName { get; private set; }
|
||||
|
||||
public static RequestType<TParams, TResult> Create(string typeName)
|
||||
{
|
||||
return new RequestType<TParams, TResult>()
|
||||
{
|
||||
MethodName = typeName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user