From 3f1d3cb9db9b3a419e721dd80025a32199be28a0 Mon Sep 17 00:00:00 2001 From: Leila Lali Date: Mon, 22 Aug 2016 15:08:44 -0700 Subject: [PATCH 1/2] Added a new request handler to return back the service version --- .../Hosting/Contracts/VersionRequest.cs | 16 ++++++++++++++++ .../Hosting/ServiceHost.cs | 12 ++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/Microsoft.SqlTools.ServiceLayer/Hosting/Contracts/VersionRequest.cs diff --git a/src/Microsoft.SqlTools.ServiceLayer/Hosting/Contracts/VersionRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/Hosting/Contracts/VersionRequest.cs new file mode 100644 index 00000000..96a1808c --- /dev/null +++ b/src/Microsoft.SqlTools.ServiceLayer/Hosting/Contracts/VersionRequest.cs @@ -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. +// + +using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts; + +namespace Microsoft.SqlTools.ServiceLayer.Hosting.Contracts +{ + public class VersionRequest + { + public static readonly + RequestType Type = + RequestType.Create("version"); + } +} diff --git a/src/Microsoft.SqlTools.ServiceLayer/Hosting/ServiceHost.cs b/src/Microsoft.SqlTools.ServiceLayer/Hosting/ServiceHost.cs index 0f2a0d9a..46fc1db5 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Hosting/ServiceHost.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Hosting/ServiceHost.cs @@ -11,6 +11,7 @@ using Microsoft.SqlTools.EditorServices.Utility; using Microsoft.SqlTools.ServiceLayer.Hosting.Contracts; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol; using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel; +using System.Reflection; namespace Microsoft.SqlTools.ServiceLayer.Hosting { @@ -55,6 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting // Register the requests that this service host will handle this.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest); this.SetRequestHandler(ShutdownRequest.Type, this.HandleShutdownRequest); + this.SetRequestHandler(VersionRequest.Type, HandleVersionRequest); } #endregion @@ -69,6 +71,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting private readonly List initializeCallbacks; + private static Version _serviceServion = Assembly.GetEntryAssembly().GetName().Version; + #endregion #region Public Methods @@ -149,6 +153,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting }); } + private static async Task HandleVersionRequest( + string workspaceSymbolParams, + RequestContext requestContext) + { + Logger.Write(LogLevel.Verbose, "HandleVersionRequest"); + await requestContext.SendResult(_serviceServion.ToString()); + } + #endregion } } From ebfc5c57a54210e467fa4cc74c2599981ed738fb Mon Sep 17 00:00:00 2001 From: Leila Lali Date: Mon, 22 Aug 2016 15:32:41 -0700 Subject: [PATCH 2/2] Fixing some issues, added documents --- .../Hosting/Contracts/VersionRequest.cs | 8 ++++++-- .../Hosting/ServiceHost.cs | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Hosting/Contracts/VersionRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/Hosting/Contracts/VersionRequest.cs index 96a1808c..ed7ab358 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Hosting/Contracts/VersionRequest.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Hosting/Contracts/VersionRequest.cs @@ -7,10 +7,14 @@ using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts; namespace Microsoft.SqlTools.ServiceLayer.Hosting.Contracts { + /// + /// Defines a message that is sent from the client to request + /// the version of the server. + /// public class VersionRequest { public static readonly - RequestType Type = - RequestType.Create("version"); + RequestType Type = + RequestType.Create("version"); } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/Hosting/ServiceHost.cs b/src/Microsoft.SqlTools.ServiceLayer/Hosting/ServiceHost.cs index 46fc1db5..1270982f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Hosting/ServiceHost.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Hosting/ServiceHost.cs @@ -71,7 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting private readonly List initializeCallbacks; - private static Version _serviceServion = Assembly.GetEntryAssembly().GetName().Version; + private static readonly Version serviceVersion = Assembly.GetEntryAssembly().GetName().Version; #endregion @@ -153,12 +153,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting }); } + /// + /// Handles the version request. Sends back the server version as result. + /// private static async Task HandleVersionRequest( - string workspaceSymbolParams, + object versionRequestParams, RequestContext requestContext) { Logger.Write(LogLevel.Verbose, "HandleVersionRequest"); - await requestContext.SendResult(_serviceServion.ToString()); + await requestContext.SendResult(serviceVersion.ToString()); } #endregion