From a1bc1bc344f976cb7e22d9353d8fbc51d602d4c7 Mon Sep 17 00:00:00 2001 From: Leila Lali Date: Thu, 13 Apr 2017 15:57:56 -0700 Subject: [PATCH] fixed the issue with loading dlls for service provider (#312) * fixed the issue with loading dlls for service provider --- .../Extensibility/ExtensionServiceProvider.cs | 14 +++++++------- src/Microsoft.SqlTools.Hosting/project.json | 3 ++- .../Formatter/TSqlFormatterService.cs | 3 ++- .../ObjectExplorer/ObjectExplorerService.cs | 14 +++++++++++++- src/Microsoft.SqlTools.ServiceLayer/project.json | 5 +++-- .../ObjectExplorer/ObjectExplorerServiceTests.cs | 1 + 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs b/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs index 8cdc27c6..d5600d32 100644 --- a/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs +++ b/src/Microsoft.SqlTools.Hosting/Extensibility/ExtensionServiceProvider.cs @@ -124,12 +124,12 @@ namespace Microsoft.SqlTools.Extensibility /// Function that returns the configuration to be used public ExtensionStore(Type contractType, Func configure) { - Validate.IsNotNull(nameof(contractType), contractType); - Validate.IsNotNull(nameof(configure), configure); - this.contractType = contractType; - ConventionBuilder builder = GetExportBuilder(); - ContainerConfiguration config = configure(builder); - host = config.CreateContainer(); + Validate.IsNotNull(nameof(contractType), contractType); + Validate.IsNotNull(nameof(configure), configure); + this.contractType = contractType; + ConventionBuilder builder = GetExportBuilder(); + ContainerConfiguration config = configure(builder); + host = config.CreateContainer(); } /// @@ -222,7 +222,7 @@ namespace Microsoft.SqlTools.Extensibility { var asl = new AssemblyLoader(apiApplicationFileInfo.DirectoryName); return asl.LoadFromAssemblyPath(apiApplicationFileInfo.FullName); - } + } } return Assembly.Load(assemblyName); } diff --git a/src/Microsoft.SqlTools.Hosting/project.json b/src/Microsoft.SqlTools.Hosting/project.json index 10abb1c3..916099de 100644 --- a/src/Microsoft.SqlTools.Hosting/project.json +++ b/src/Microsoft.SqlTools.Hosting/project.json @@ -3,7 +3,8 @@ "version": "1.0.0-*", "buildOptions": { "debugType": "portable", - "emitEntryPoint": false + "emitEntryPoint": false, + "preserveCompilationContext": true }, "configurations": { "Integration": { diff --git a/src/Microsoft.SqlTools.ServiceLayer/Formatter/TSqlFormatterService.cs b/src/Microsoft.SqlTools.ServiceLayer/Formatter/TSqlFormatterService.cs index e7d7a740..b88c97b0 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Formatter/TSqlFormatterService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Formatter/TSqlFormatterService.cs @@ -38,7 +38,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter public override void InitializeService(IProtocolEndpoint serviceHost) - { + { + Logger.Write(LogLevel.Verbose, "TSqlFormatter initialized"); serviceHost.SetRequestHandler(DocumentFormattingRequest.Type, HandleDocFormatRequest); serviceHost.SetRequestHandler(DocumentRangeFormattingRequest.Type, HandleDocRangeFormatRequest); WorkspaceService?.RegisterConfigChangeCallback(HandleDidChangeConfigurationNotification); diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs index bedad392..9917d9b9 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/ObjectExplorerService.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; +using System.Composition; using System.Globalization; using System.Linq; using System.Threading.Tasks; @@ -24,6 +25,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer /// A Service to support querying server and database information as an Object Explorer tree. /// The APIs used for this are modeled closely on the VSCode TreeExplorerNodeProvider API. /// + [Export(typeof(IHostedService))] public class ObjectExplorerService : HostedService, IComposableService { internal const string uriPrefix = "objectexplorer://"; @@ -79,6 +81,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer /// The service host instance to register with public override void InitializeService(IProtocolEndpoint serviceHost) { + Logger.Write(LogLevel.Verbose, "ObjectExplorer service initialized"); this.serviceHost = serviceHost; // Register handlers for requests serviceHost.SetRequestHandler(CreateSessionRequest.Type, HandleCreateSessionRequest); @@ -165,7 +168,16 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer { // open connection based on request details ConnectionCompleteParams result = await connectionService.Connect(connectParams); - return result; + if(result != null && !string.IsNullOrEmpty(result.ConnectionId)) + { + return result; + } + else + { + await serviceHost.SendEvent(ConnectionCompleteNotification.Type, result); + return null; + } + } catch (Exception ex) { diff --git a/src/Microsoft.SqlTools.ServiceLayer/project.json b/src/Microsoft.SqlTools.ServiceLayer/project.json index a7c5692b..84de7de6 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/project.json +++ b/src/Microsoft.SqlTools.ServiceLayer/project.json @@ -3,7 +3,8 @@ "version": "1.0.0-*", "buildOptions": { "debugType": "portable", - "emitEntryPoint": true + "emitEntryPoint": true, + "preserveCompilationContext": true }, "configurations": { "Integration": { @@ -33,7 +34,7 @@ "System.Threading.Thread": "4.0.0", "System.Runtime.Loader": "4.0.0", "System.Composition": "1.0.31-beta-24326-02", - "Microsoft.Extensions.DependencyModel": "1.0.0", + "Microsoft.Extensions.DependencyModel": "1.0.0", "Microsoft.SqlTools.Hosting": { "target": "project" }, diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs index a357dfd3..e2fb3a84 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs @@ -115,6 +115,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer { return new ConnectionCompleteParams() { + ConnectionId = Guid.NewGuid().ToString(), OwnerUri = uri, ConnectionSummary = new ConnectionSummary() {