mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Remove serialization service (#661)
- This isn't actually used so is dead code. Would like to clean up before refactoring other code areas.
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
"MainProjects": [
|
"MainProjects": [
|
||||||
"Microsoft.SqlTools.ServiceLayer",
|
"Microsoft.SqlTools.ServiceLayer",
|
||||||
"Microsoft.SqlTools.Credentials",
|
"Microsoft.SqlTools.Credentials",
|
||||||
"Microsoft.SqlTools.Serialization",
|
|
||||||
"Microsoft.SqlTools.ResourceProvider"
|
"Microsoft.SqlTools.ResourceProvider"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ServiceL
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ServiceLayer.TestEnvConfig", "test\Microsoft.SqlTools.ServiceLayer.TestEnvConfig\Microsoft.SqlTools.ServiceLayer.TestEnvConfig.csproj", "{2C290C58-C98D-46B2-BCED-44D9B67F6D31}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ServiceLayer.TestEnvConfig", "test\Microsoft.SqlTools.ServiceLayer.TestEnvConfig\Microsoft.SqlTools.ServiceLayer.TestEnvConfig.csproj", "{2C290C58-C98D-46B2-BCED-44D9B67F6D31}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.Serialization", "src\Microsoft.SqlTools.Serialization\Microsoft.SqlTools.Serialization.csproj", "{75E1A89F-9DF6-4DA3-9EF1-5FD966331E06}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ResourceProvider", "src\Microsoft.SqlTools.ResourceProvider\Microsoft.SqlTools.ResourceProvider.csproj", "{6FEE7E14-8A1D-454E-8F7C-B63597801787}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ResourceProvider", "src\Microsoft.SqlTools.ResourceProvider\Microsoft.SqlTools.ResourceProvider.csproj", "{6FEE7E14-8A1D-454E-8F7C-B63597801787}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ResourceProvider.Core", "src\Microsoft.SqlTools.ResourceProvider.Core\Microsoft.SqlTools.ResourceProvider.Core.csproj", "{70E63BC1-2C82-41C0-89D6-272FD3C7B0C9}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.SqlTools.ResourceProvider.Core", "src\Microsoft.SqlTools.ResourceProvider.Core\Microsoft.SqlTools.ResourceProvider.Core.csproj", "{70E63BC1-2C82-41C0-89D6-272FD3C7B0C9}"
|
||||||
@@ -145,12 +143,6 @@ Global
|
|||||||
{2C290C58-C98D-46B2-BCED-44D9B67F6D31}.Integration|Any CPU.Build.0 = Debug|Any CPU
|
{2C290C58-C98D-46B2-BCED-44D9B67F6D31}.Integration|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2C290C58-C98D-46B2-BCED-44D9B67F6D31}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2C290C58-C98D-46B2-BCED-44D9B67F6D31}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2C290C58-C98D-46B2-BCED-44D9B67F6D31}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2C290C58-C98D-46B2-BCED-44D9B67F6D31}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{75E1A89F-9DF6-4DA3-9EF1-5FD966331E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{75E1A89F-9DF6-4DA3-9EF1-5FD966331E06}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{75E1A89F-9DF6-4DA3-9EF1-5FD966331E06}.Integration|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{75E1A89F-9DF6-4DA3-9EF1-5FD966331E06}.Integration|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{75E1A89F-9DF6-4DA3-9EF1-5FD966331E06}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{75E1A89F-9DF6-4DA3-9EF1-5FD966331E06}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{6FEE7E14-8A1D-454E-8F7C-B63597801787}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{6FEE7E14-8A1D-454E-8F7C-B63597801787}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{6FEE7E14-8A1D-454E-8F7C-B63597801787}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6FEE7E14-8A1D-454E-8F7C-B63597801787}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6FEE7E14-8A1D-454E-8F7C-B63597801787}.Integration|Any CPU.ActiveCfg = Debug|Any CPU
|
{6FEE7E14-8A1D-454E-8F7C-B63597801787}.Integration|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
@@ -186,7 +178,6 @@ Global
|
|||||||
{E985A5AA-63E4-48DC-A6D8-D3953A50D7E3} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
|
{E985A5AA-63E4-48DC-A6D8-D3953A50D7E3} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
|
||||||
{501DB3B2-AF92-41CF-82F6-780F9C37C219} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
|
{501DB3B2-AF92-41CF-82F6-780F9C37C219} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
|
||||||
{2C290C58-C98D-46B2-BCED-44D9B67F6D31} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
|
{2C290C58-C98D-46B2-BCED-44D9B67F6D31} = {AB9CA2B8-6F70-431C-8A1D-67479D8A7BE4}
|
||||||
{75E1A89F-9DF6-4DA3-9EF1-5FD966331E06} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
|
||||||
{6FEE7E14-8A1D-454E-8F7C-B63597801787} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
{6FEE7E14-8A1D-454E-8F7C-B63597801787} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
||||||
{70E63BC1-2C82-41C0-89D6-272FD3C7B0C9} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
{70E63BC1-2C82-41C0-89D6-272FD3C7B0C9} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
||||||
{EFB39C03-F7D2-4E8D-BE51-09121CD71973} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
{EFB39C03-F7D2-4E8D-BE51-09121CD71973} = {2BBD7364-054F-4693-97CD-1C395E3E84A9}
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
//
|
|
||||||
// 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.Extensibility;
|
|
||||||
using Microsoft.SqlTools.Hosting;
|
|
||||||
using Microsoft.SqlTools.Hosting.Protocol;
|
|
||||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
|
||||||
using Microsoft.SqlTools.Utility;
|
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.Serialization
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Provides support for starting up a service host. This is a common responsibility
|
|
||||||
/// for both the main service program and test driver that interacts with it
|
|
||||||
/// </summary>
|
|
||||||
public static class HostLoader
|
|
||||||
{
|
|
||||||
private static object lockObject = new object();
|
|
||||||
private static bool isLoaded;
|
|
||||||
|
|
||||||
internal static UtilityServiceHost CreateAndStartServiceHost(SqlToolsContext sqlToolsContext)
|
|
||||||
{
|
|
||||||
UtilityServiceHost serviceHost = UtilityServiceHost.Instance;
|
|
||||||
lock (lockObject)
|
|
||||||
{
|
|
||||||
if (!isLoaded)
|
|
||||||
{
|
|
||||||
// Grab the instance of the service host
|
|
||||||
serviceHost.Initialize();
|
|
||||||
|
|
||||||
InitializeRequestHandlersAndServices(serviceHost, sqlToolsContext);
|
|
||||||
|
|
||||||
// Start the service only after all request handlers are setup. This is vital
|
|
||||||
// as otherwise the Initialize event can be lost - it's processed and discarded before the handler
|
|
||||||
// is hooked up to receive the message
|
|
||||||
serviceHost.Start().Wait();
|
|
||||||
isLoaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return serviceHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void InitializeRequestHandlersAndServices(UtilityServiceHost serviceHost, SqlToolsContext sqlToolsContext)
|
|
||||||
{
|
|
||||||
// Load extension provider, which currently finds all exports in current DLL. Can be changed to find based
|
|
||||||
// on directory or assembly list quite easily in the future
|
|
||||||
ExtensionServiceProvider serviceProvider = ExtensionServiceProvider.CreateDefaultServiceProvider();
|
|
||||||
serviceProvider.RegisterSingleService(sqlToolsContext);
|
|
||||||
serviceProvider.RegisterSingleService(serviceHost);
|
|
||||||
|
|
||||||
SerializationService serializationService = serviceProvider.GetService<SerializationService>();
|
|
||||||
serializationService.InitializeService(serviceHost);
|
|
||||||
serviceProvider.RegisterSingleService(serializationService);
|
|
||||||
|
|
||||||
InitializeHostedServices(serviceProvider, serviceHost);
|
|
||||||
|
|
||||||
serviceHost.InitializeRequestHandlers();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Internal to support testing. Initializes <see cref="IHostedService"/> instances in the service,
|
|
||||||
/// and registers them for their preferred service type
|
|
||||||
/// </summary>
|
|
||||||
internal static void InitializeHostedServices(RegisteredServiceProvider provider, IProtocolEndpoint host)
|
|
||||||
{
|
|
||||||
// Pre-register all services before initializing. This ensures that if one service wishes to reference
|
|
||||||
// another one during initialization, it will be able to safely do so
|
|
||||||
foreach (IHostedService service in provider.GetServices<IHostedService>())
|
|
||||||
{
|
|
||||||
provider.RegisterSingleService(service.ServiceType, service);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (IHostedService service in provider.GetServices<IHostedService>())
|
|
||||||
{
|
|
||||||
// Initialize all hosted services, and register them in the service provider for their requested
|
|
||||||
// service type. This ensures that when searching for the ConnectionService you can get it without
|
|
||||||
// searching for an IHostedService of type ConnectionService
|
|
||||||
service.InitializeService(host);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
|
||||||
<PackageId>SqlSerializationService</PackageId>
|
|
||||||
<AssemblyName>SqlSerializationService</AssemblyName>
|
|
||||||
<Company>Microsoft</Company>
|
|
||||||
<Product>Sql Tools Serialization Service</Product>
|
|
||||||
<Description>Provides serialization functionality.</Description>
|
|
||||||
<Copyright><EFBFBD> Microsoft Corporation. All rights reserved.</Copyright>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
|
||||||
<DefineConstants>TRACE;DEBUG;NETCOREAPP1_0;NETCOREAPP2_0</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Microsoft.SqlTools.Hosting\Microsoft.SqlTools.Hosting.csproj" />
|
|
||||||
<ProjectReference Include="..\Microsoft.SqlTools.ServiceLayer\Microsoft.SqlTools.ServiceLayer.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) Microsoft. All rights reserved.
|
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using Microsoft.SqlTools.Hosting.Utility;
|
|
||||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
|
||||||
using Microsoft.SqlTools.Utility;
|
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.Serialization
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Main application class for Serialization Service Host executable
|
|
||||||
/// </summary>
|
|
||||||
internal class Program
|
|
||||||
{
|
|
||||||
private const string ServiceName = "SqlSerializationService.exe";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Main entry point into the Serialization Service Host
|
|
||||||
/// </summary>
|
|
||||||
internal static void Main(string[] args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// read command-line arguments
|
|
||||||
CommandOptions commandOptions = new CommandOptions(args, ServiceName);
|
|
||||||
if (commandOptions.ShouldExit)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string logFilePath = "serialization";
|
|
||||||
if (!string.IsNullOrWhiteSpace(commandOptions.LoggingDirectory))
|
|
||||||
{
|
|
||||||
logFilePath = Path.Combine(commandOptions.LoggingDirectory, logFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// turn on Verbose logging during early development
|
|
||||||
// we need to switch to Normal when preparing for public preview
|
|
||||||
Logger.Initialize(logFilePath: logFilePath, minimumLogLevel: LogLevel.Verbose, isEnabled: commandOptions.EnableLogging);
|
|
||||||
Logger.Write(LogLevel.Normal, "Starting SqlTools Serialization Provider");
|
|
||||||
|
|
||||||
// set up the host details and profile paths
|
|
||||||
var hostDetails = new HostDetails(
|
|
||||||
name: "SqlTools Serialization Provider",
|
|
||||||
profileId: "Microsoft.SqlTools.Serialization",
|
|
||||||
version: new Version(1, 0));
|
|
||||||
|
|
||||||
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails);
|
|
||||||
UtilityServiceHost serviceHost = HostLoader.CreateAndStartServiceHost(sqlToolsContext);
|
|
||||||
|
|
||||||
serviceHost.WaitForExit();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Logger.Write(LogLevel.Error, string.Format("An unhandled exception occurred: {0}", e));
|
|
||||||
Environment.Exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) Microsoft. All rights reserved.
|
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
||||||
//
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Composition;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.SqlTools.Extensibility;
|
|
||||||
using Microsoft.SqlTools.Hosting;
|
|
||||||
using Microsoft.SqlTools.Hosting.Protocol;
|
|
||||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
|
||||||
using Microsoft.SqlTools.Utility;
|
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.Serialization
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Service responsible for securing credentials in a platform-neutral manner. This provides
|
|
||||||
/// a generic API for read, save and delete credentials
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
[Export(typeof(IHostedService))]
|
|
||||||
public class SerializationService : HostedService<SerializationService>, IComposableService
|
|
||||||
{
|
|
||||||
public override void InitializeService(IProtocolEndpoint serviceHost)
|
|
||||||
{
|
|
||||||
Logger.Write(LogLevel.Verbose, "Serialization initialized");
|
|
||||||
// Register request and event handlers with the Service Host
|
|
||||||
serviceHost.SetRequestHandler(SaveAsRequest.Type, HandleSaveAsRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task HandleSaveAsRequest(SaveResultsInfo resultsInfo, RequestContext<SaveResultRequestResult> requestContext)
|
|
||||||
{
|
|
||||||
Func<Task<SaveResultRequestResult>> doSave = () =>
|
|
||||||
{
|
|
||||||
return SaveAsAsync(resultsInfo, requestContext);
|
|
||||||
};
|
|
||||||
|
|
||||||
await HandleRequest(doSave, requestContext, "HandleSaveAsRequest");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<SaveResultRequestResult> SaveAsAsync(SaveResultsInfo resultsInfo, RequestContext<SaveResultRequestResult> requestContext)
|
|
||||||
{
|
|
||||||
// TODO: Refactor currently available serialization code in sqltools to be utilized here
|
|
||||||
// Issue here: https://github.com/Microsoft/carbon/issues/1789
|
|
||||||
switch (resultsInfo.SaveFormat) {
|
|
||||||
case "json":
|
|
||||||
throw new NotImplementedException("Converting to " + resultsInfo.SaveFormat + " is not implemented.");
|
|
||||||
case "csv":
|
|
||||||
throw new NotImplementedException("Converting to " + resultsInfo.SaveFormat + " is not implemented.");
|
|
||||||
case "excel":
|
|
||||||
throw new NotImplementedException("Converting to " + resultsInfo.SaveFormat + " is not implemented.");
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException("Converting to " + resultsInfo.SaveFormat + " is not implemented.");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task HandleRequest<T>(Func<Task<T>> handler, RequestContext<T> requestContext, string requestType)
|
|
||||||
{
|
|
||||||
Logger.Write(LogLevel.Verbose, requestType);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
T result = await handler();
|
|
||||||
await requestContext.SendResult(result);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await requestContext.SendError(ex.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user