mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-20 01:25:41 -05:00
Adding project property support to SqlProj service (#1883)
* Nuget update * Updating nuget * implementation * GetProperties test * Adding SetDatabaseSource * adding comment * Nuget update * PR feedback * Fixing cross-plat path tests * Updating to signed nuget * fixing None test
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// 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.Hosting.Protocol.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the cross-platform compatibility status for a project
|
||||
/// </summary>
|
||||
public class GetProjectPropertiesRequest
|
||||
{
|
||||
public static readonly RequestType<SqlProjectParams, GetProjectPropertiesResult> Type = RequestType<SqlProjectParams, GetProjectPropertiesResult>.Create("sqlProjects/getProjectProperties");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Result containing project properties contained in the .sqlproj XML
|
||||
/// </summary>
|
||||
public class GetProjectPropertiesResult : ResultStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// GUID for the SQL project
|
||||
/// </summary>
|
||||
public string ProjectGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Build configuration, defaulted to Debug if not specified
|
||||
/// </summary>
|
||||
public string Configuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Build platform, defaulted to AnyCPU if not specified
|
||||
/// </summary>
|
||||
public string Platform { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Output path for build, defaulted to "bin/Debug" if not specified.
|
||||
/// May be absolute or relative.
|
||||
/// </summary>
|
||||
public string OutputPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Default collation for the project, defaulted to SQL_Latin1_General_CP1_CI_AS if not specified
|
||||
/// </summary>
|
||||
public string DefaultCollation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Source of the database schema, used in telemetry
|
||||
/// </summary>
|
||||
public string? DatabaseSource { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
#nullable disable
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.SqlProjects.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for setting the DatabaseSource property of a .sqlproj file
|
||||
/// </summary>
|
||||
public class SetDatabaseSourceParams : SqlProjectParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Source of the database schema, used in telemetry
|
||||
/// </summary>
|
||||
public string DatabaseSource { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the DatabaseSource property of a .sqlproj file
|
||||
/// </summary>
|
||||
public class SetDatabaseSourceRequest
|
||||
{
|
||||
public static readonly RequestType<SetDatabaseSourceParams, ResultStatus> Type = RequestType<SetDatabaseSourceParams, ResultStatus>.Create("sqlProjects/setDatabaseSource");
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,8 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
|
||||
serviceHost.SetRequestHandler(CreateSqlProjectRequest.Type, HandleCreateSqlProjectRequest, isParallelProcessingSupported: true);
|
||||
serviceHost.SetRequestHandler(GetCrossPlatformCompatibilityRequest.Type, HandleGetCrossPlatformCompatibilityRequest, isParallelProcessingSupported: true);
|
||||
serviceHost.SetRequestHandler(UpdateProjectForCrossPlatformRequest.Type, HandleUpdateProjectForCrossPlatformRequest, isParallelProcessingSupported: false);
|
||||
serviceHost.SetRequestHandler(GetProjectPropertiesRequest.Type, HandleGetProjectPropertiesRequest, isParallelProcessingSupported: true);
|
||||
serviceHost.SetRequestHandler(SetDatabaseSourceRequest.Type, HandleSetDatabaseSourceRequest, isParallelProcessingSupported: false);
|
||||
|
||||
// SQL object script functions
|
||||
serviceHost.SetRequestHandler(GetSqlObjectScriptsRequest.Type, HandleGetSqlObjectScriptsRequest, isParallelProcessingSupported: true);
|
||||
@@ -133,6 +135,31 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
|
||||
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).UpdateForCrossPlatform(), requestContext);
|
||||
}
|
||||
|
||||
internal async Task HandleGetProjectPropertiesRequest(SqlProjectParams requestParams, RequestContext<GetProjectPropertiesResult> requestContext)
|
||||
{
|
||||
await RunWithErrorHandling(() =>
|
||||
{
|
||||
SqlProjectProperties props = GetProject(requestParams.ProjectUri).Properties;
|
||||
|
||||
return new GetProjectPropertiesResult()
|
||||
{
|
||||
Success = true,
|
||||
ErrorMessage = null,
|
||||
ProjectGuid = props.ProjectGuid,
|
||||
Configuration = props.Configuration,
|
||||
Platform = props.Platform,
|
||||
OutputPath = props.OutputPath,
|
||||
DefaultCollation = props.DefaultCollation,
|
||||
DatabaseSource = props.DatabaseSource,
|
||||
};
|
||||
}, requestContext);
|
||||
}
|
||||
|
||||
internal async Task HandleSetDatabaseSourceRequest(SetDatabaseSourceParams requestParams, RequestContext<ResultStatus> requestContext)
|
||||
{
|
||||
await RunWithErrorHandling(() => GetProject(requestParams.ProjectUri).Properties.DatabaseSource = requestParams.DatabaseSource, requestContext);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Script/folder functions
|
||||
@@ -310,7 +337,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
|
||||
|
||||
#endregion
|
||||
|
||||
#region Database Reference functions
|
||||
#region Database reference functions
|
||||
|
||||
internal async Task HandleGetDatabaseReferencesRequest(SqlProjectParams requestParams, RequestContext<GetDatabaseReferencesResult> requestContext)
|
||||
{
|
||||
@@ -459,7 +486,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlProjects
|
||||
{
|
||||
if (!Projects.ContainsKey(projectUri))
|
||||
{
|
||||
Projects[projectUri] = new SqlProject(projectUri);
|
||||
Projects[projectUri] = SqlProject.OpenProject(projectUri);
|
||||
}
|
||||
|
||||
return Projects[projectUri];
|
||||
|
||||
Reference in New Issue
Block a user