/// <summary> /// Check for breaking changes in the public API of types. /// </summary> /// <param name="oldTypeMetadataDictionary">Dictionary of type names mapped to metadata from the old module.</param> /// <param name="newTypeMetadataDictionary">Dictionary of type names mapped to metadata from the new module.</param> /// <param name="issueLogger">Temporary logger used to track the breaking changes found.</param> private void CheckBreakingChangesInTypes( Dictionary <string, TypeMetadata> oldTypeMetadataDictionary, Dictionary <string, TypeMetadata> newTypeMetadataDictionary, ReportLogger <BreakingChangeIssue> issueLogger) { var typeMetadataHelper = new TypeMetadataHelper(oldTypeMetadataDictionary, newTypeMetadataDictionary); foreach (var type in oldTypeMetadataDictionary.Keys) { var cmdletMetadata = new CmdletMetadata() { NounName = "Common", VerbName = type }; if (!newTypeMetadataDictionary.ContainsKey(type)) { issueLogger?.LogBreakingChangeIssue( cmdlet: cmdletMetadata, severity: 0, problemId: 0, description: string.Empty, remediation: string.Empty); continue; } var oldTypeMetadata = oldTypeMetadataDictionary[type]; var newTypeMetadata = newTypeMetadataDictionary[type]; typeMetadataHelper.CompareTypeMetadata(cmdletMetadata, oldTypeMetadata, newTypeMetadata, issueLogger); typeMetadataHelper.CompareMethodSignatures(cmdletMetadata, oldTypeMetadata.Methods, newTypeMetadata.Methods, issueLogger); typeMetadataHelper.CompareMethodSignatures(cmdletMetadata, oldTypeMetadata.Constructors, newTypeMetadata.Constructors, issueLogger); } }
public static string Generate() { GlobalSettings.JsonSerializer = new JsonDotNetSerializer(); var helper = new TypeMetadataHelper(); helper.BuildForAllEndpointSubclassesOf<ApiController>(); return helper.GetMetadata(); }
public static string Generate() { GlobalSettings.JsonSerializer = new JsonDotNetSerializer(); var helper = new TypeMetadataHelper(); helper.BuildForAllEndpointSubclassesOf <ApiController>(); return(helper.GetMetadata()); }
/// <summary> /// Compare two module metadata objects for breaking changes from /// the old metadata to the new metadata. /// </summary> /// <param name="oldModuleMetadata">ModuleMetadata object containing the old module information.</param> /// <param name="newModuleMetadata">ModuleMetadata object containing the new module information.</param> /// <param name="issueLogger">Temporary logger used to track the breaking changes found.</param> private void CheckBreakingChangesInModules( ModuleMetadata oldModuleMetadata, ModuleMetadata newModuleMetadata, ReportLogger <BreakingChangeIssue> issueLogger) { var oldCmdlets = oldModuleMetadata.Cmdlets; var newCmdlets = newModuleMetadata.Cmdlets; var oldTypeDictionary = oldModuleMetadata.TypeDictionary; var newTypeDictionary = newModuleMetadata.TypeDictionary; TypeMetadataHelper typeMetadataHelper = new TypeMetadataHelper(oldTypeDictionary, newTypeDictionary); CmdletMetadataHelper cmdletMetadataHelper = new CmdletMetadataHelper(typeMetadataHelper); cmdletMetadataHelper.CompareCmdletMetadata(oldCmdlets, newCmdlets, issueLogger); }
/// <summary> /// Initialize the column metadata for the result set. /// </summary> public void InitializeColumns(object obj) { LogUtilities.LogFunctionEntrance(Log); //get the info the build the columns ResultEntityType = obj.GetType(); ResultFields = ResultEntityType.GetFields().ToList(); //fields to remove that we do not want in results List <FieldInfo> remove = new List <FieldInfo>(); //parse the fields foreach (var field in ResultFields) { //make sure this not collection type if (field.FieldType.GetInterface("ICollection") != null) { //remove this field remove.Add(field); } else { //create the column DSIColumn column = new DSIColumn(TypeMetadataHelper.CreateTypeMetadata(field.FieldType)); column.IsNullable = Nullability.Nullable; column.Catalog = m_Properties.Catalog; column.Schema = Driver.B_SCHEMA; column.TableName = "Results"; column.Name = field.Name; column.Label = column.Name; if (field.FieldType == typeof(string)) { column.Size = 1000; column.IsSearchable = Searchable.Searchable; } else { column.IsSearchable = Searchable.PredicateBasic; } m_Columns.Add(column); } } //remove the fields foreach (var field in remove) { ResultFields.Remove(field); } }
public static void Configure() { GlobalSettings.JsonSerializer = new JsonDotNetSerializer(); TypeMetadataHelper.BuildForAllEndpointSubclassesOf <ApiController>(); }
/// <summary> /// Initialize the fake data /// </summary> public void InitializeFakeData(string sql) { LogUtilities.LogFunctionEntrance(Log); List <object> fake_row = new List <object>(); string sql_no_select = sql.Substring(sql.IndexOf("SELECT ") + 7); string sql_no_top = sql_no_select; if (sql_no_select.IndexOf("TOP ") != -1) { sql_no_top = sql_no_select.Substring(sql_no_select.IndexOf("TOP ") + 4).Trim(); sql_no_top = sql_no_top.Substring(sql_no_top.IndexOf(" ") + 1).Trim(); } string sql_no_from = sql_no_top.Substring(0, sql_no_top.IndexOf("FROM ")); string[] columns_with_alias = sql_no_from.Split(','); foreach (var field_alias in columns_with_alias) { string[] aliases = field_alias.Split(new string[] { " AS ", " as " }, StringSplitOptions.None); string field = ""; string alias = ""; if (aliases.Length > 0) { field = aliases[0].Trim(); } if (aliases.Length > 1) { alias = aliases[1].Trim(); } field = field.Replace("\"", ""); alias = alias.Replace("\"", ""); string table = ""; if (field.IndexOf('.') != -1) { table = field.Substring(0, field.IndexOf('.')); field = field.Substring(field.IndexOf('.') + 1); } var column_meta = m_TableColumns.Where(c => c.Table == table && c.Column == field).FirstOrDefault(); Type type; bool added = false; if (column_meta != null) { type = Type.GetType(column_meta.DataType); } else { double num; if (double.TryParse(field, out num)) { type = typeof(double); fake_row.Add(num); added = true; } else { type = typeof(string); fake_row.Add(field); } } if (!added) { if (type == typeof(string)) { fake_row.Add("FakeData"); } else if (type == typeof(DateTime)) { fake_row.Add(DateTime.UtcNow); } else if (type == typeof(bool)) { byte b = 0; fake_row.Add(b); } else { fake_row.Add(Activator.CreateInstance(type)); } } DSIColumn column = new DSIColumn(TypeMetadataHelper.CreateTypeMetadata(type)); column.IsNullable = Nullability.Nullable; column.Catalog = m_Properties.Catalog; column.Schema = Driver.B_SCHEMA; column.TableName = "Results"; column.Name = alias; column.Label = alias; if (type == typeof(string)) { column.Size = 1000; column.IsSearchable = Searchable.Searchable; } else { column.IsSearchable = Searchable.PredicateBasic; } m_Columns.Add(column); } RowCount = 10; for (int x = 0; x < RowCount; x++) { m_Data.Add(fake_row); } }