mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-29 17:24:34 -05:00
Adding new Dac Deployment Options and getting descriptions from DacFx API (#1357)
* Adding missing Deploy options * SQL DB Project database genScript/Publish working but tests * Test cases fixed for the changes for DacFx and SC services * Refactored the model name and tested the changes with ADS extensions. * updated DeploymentOptionProperty model and corresponding updates. * Adding DisplayNames to the deploymentOptionProperty to maintain names in STS for all extensions. * MapTabe intialization in constructor * Updated comment with more meaning * Porperty strong type update with actual type * Creating model with generic type getting using Activator.CreateInstance * Rebase to main and resolved merge conflicts * Xml comments added and code updated * Deployment options update * Deployoptions typo and comments updates a * updated deployment options comments * removed unnecessary using statement * code refactor
This commit is contained in:
committed by
GitHub
parent
70be8f5ef5
commit
a3a66137b8
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.SqlServer.Dac;
|
||||
using Microsoft.SqlServer.Dac.Compare;
|
||||
@@ -24,7 +25,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
{
|
||||
internal static DacDeployOptions CreateSchemaCompareOptions(DeploymentOptions deploymentOptions)
|
||||
{
|
||||
System.Reflection.PropertyInfo[] deploymentOptionsProperties = deploymentOptions.GetType().GetProperties();
|
||||
PropertyInfo[] deploymentOptionsProperties = deploymentOptions.GetType().GetProperties();
|
||||
|
||||
DacDeployOptions dacOptions = new DacDeployOptions();
|
||||
foreach (var deployOptionsProp in deploymentOptionsProperties)
|
||||
@@ -32,7 +33,18 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
|
||||
var prop = dacOptions.GetType().GetProperty(deployOptionsProp.Name);
|
||||
if (prop != null)
|
||||
{
|
||||
prop.SetValue(dacOptions, deployOptionsProp.GetValue(deploymentOptions));
|
||||
var val = deployOptionsProp.GetValue(deploymentOptions);
|
||||
var selectedVal = val.GetType().GetProperty("Value").GetValue(val);
|
||||
|
||||
// JSON.NET by default reads Number type as Int64, deserializing an object type to dacOptions of Int32 type required to convert into Int32 from Int64.
|
||||
// If not converted setting value(Int64) to dacOption(Int32) will throw {"Object of type 'System.Int64' cannot be converted to type 'System.Int32'."}.
|
||||
// As these integer type options are non-editable and are not availbale in ADS to update, integer overflow exception will not be happening here.
|
||||
if (selectedVal != null && selectedVal.GetType() == typeof(System.Int64))
|
||||
{
|
||||
selectedVal = Convert.ToInt32(selectedVal);
|
||||
}
|
||||
|
||||
prop.SetValue(dacOptions, selectedVal);
|
||||
}
|
||||
}
|
||||
return dacOptions;
|
||||
|
||||
Reference in New Issue
Block a user