Object Types are getting from DacFx ObjectTypes (#1574)

* Include Object Types are getting from DacFx

* All tests are passing now with excludObjectType casting

* Test fix with new ExccvludeObjectType change

* Added test case for the include objects types

* Updated  name to objectTypesDictionary and objectType getName from Display attribute

* code Review updates

* Removing Exclude word logic here as the options were updated on DacFx

* updating the null check

* DacFx vBump

* code updates according to review comments
This commit is contained in:
Sai Avishkar Sreerama
2022-08-05 15:28:39 -05:00
committed by GitHub
parent d78ff94b31
commit 1342a8a085
7 changed files with 170 additions and 71 deletions

View File

@@ -43,15 +43,30 @@ namespace Microsoft.SqlTools.ServiceLayer.SchemaCompare
foreach (PropertyInfo deployOptionsProp in deploymentOptionsProperties)
{
var prop = propType.GetProperty(deployOptionsProp.Name);
if (prop != null)
// Set the excludeObjectTypes values to the DacDeployOptions
if (prop != null && deployOptionsProp.Name == nameof(deploymentOptions.ExcludeObjectTypes))
{
List<ObjectType> finalExcludeObjects = new List<ObjectType> { };
var val = deployOptionsProp.GetValue(deploymentOptions);
var selectedVal = val.GetType().GetProperty("Value").GetValue(val);
string[] excludeObjectTypeOptionsArray = (string[])val.GetType().GetProperty("Value").GetValue(val);
// Set the excludeObjectTypes values to the DacDeployOptions
if (selectedVal != null && deployOptionsProp.Name == nameof(deploymentOptions.ExcludeObjectTypes))
if (excludeObjectTypeOptionsArray != null)
{
prop.SetValue(dacOptions, selectedVal);
foreach(string objectTypeValue in excludeObjectTypeOptionsArray)
{
ObjectType objectTypeName = new ObjectType();
if (objectTypeValue != null && Enum.TryParse(objectTypeValue, ignoreCase: true, out objectTypeName))
{
finalExcludeObjects.Add(objectTypeName);
}
else
{
Logger.Write(TraceEventType.Error, string.Format($"{objectTypeValue} is not part of ObjectTypes enum"));
}
}
// set final values to excludeObjectType property
prop.SetValue(dacOptions, finalExcludeObjects.ToArray());
}
}