internal static DuplicatedPropertiesInfo FindDuplicatedPropertieInInheritanceTree(IInterface thisInterface, InheritanceTree inheritanceTree) { if (inheritanceTree == null) { inheritanceTree = thisInterface.GetInheritanceTree(); inheritanceTree.RebuildTree(true); } var inheritanceTreeList = inheritanceTree.GetFlatList(InheritanceListMode.WholeTree).Select(node => node.Interface); List <IPropertyBase> scalarPropertiesWithDifferentType = new List <IPropertyBase>(); List <IPropertyBase> scalarPropertiesWithSameType = new List <IPropertyBase>(); List <IPropertyBase> structurePropertiesWithDifferentType = new List <IPropertyBase>(); List <IPropertyBase> structurePropertiesWithSameType = new List <IPropertyBase>(); List <IPropertyBase> navigationPropertiesWithDifferentType = new List <IPropertyBase>(); List <IPropertyBase> navigationPropertiesWithSameType = new List <IPropertyBase>(); // iterate scalar properties foreach (var scalarProperty in thisInterface.GetScalarProperties()) { if (scalarProperty.IsInherited) { continue; } var query = from childInterface in inheritanceTreeList let childScalarProperties = childInterface.Properties.Where(item => item.PropertyKind == PropertyKind.Scalar).Cast <IScalarProperty>() where childScalarProperties.Any(childScalarProperty => Util.StringEqual(childScalarProperty.Name, scalarProperty.Name, true)) select new { PropertiesWithDifferentType = childScalarProperties .Where(childScalarProperty => !childScalarProperty.Type.EqualsTo(scalarProperty.Type)), PropertiesWithSameType = childScalarProperties .Where(childScalarProperty => childScalarProperty.Type.EqualsTo(scalarProperty.Type)) }; scalarPropertiesWithDifferentType.AddRange( query.SelectMany(arg => arg.PropertiesWithDifferentType).Cast <IPropertyBase>().ToList()); scalarPropertiesWithSameType.AddRange( query.SelectMany(arg => arg.PropertiesWithSameType).Cast <IPropertyBase>().ToList()); } // iterate structures properties foreach (var structureProperty in thisInterface.GetStructureProperties()) { if (structureProperty.IsInherited) { continue; } var query = from childInterface in inheritanceTreeList let childStructureProperties = childInterface.Properties.Where(item => item.PropertyKind == PropertyKind.Structure).Cast <IStructureProperty>() where childStructureProperties.Any(childStructureProperty => Util.StringEqual(childStructureProperty.Name, structureProperty.Name, true)) select new { PropertiesWithDifferentType = childStructureProperties .Where(childScalarProperty => childScalarProperty.TypeOf != structureProperty.TypeOf), PropertiesWithSameType = childStructureProperties .Where(childScalarProperty => childScalarProperty.TypeOf == structureProperty.TypeOf) }; structurePropertiesWithDifferentType.AddRange( query.SelectMany(arg => arg.PropertiesWithDifferentType).Cast <IPropertyBase>().ToList()); structurePropertiesWithSameType.AddRange( query.SelectMany(arg => arg.PropertiesWithSameType).Cast <IPropertyBase>().ToList()); } // iterate navigation properties foreach (var navigationProperty in thisInterface.NavigationProperties) { if (navigationProperty.IsInherited) { continue; } var query = from childInterface in inheritanceTreeList let childNavigationProperties = childInterface.NavigationProperties where childNavigationProperties.Any(childStructureProperty => Util.StringEqual(childStructureProperty.Name, navigationProperty.Name, true)) select new { PropertiesWithDifferentType = childNavigationProperties .Where(childScalarProperty => !childScalarProperty.PersistentTypeHasAssociations.EqualAssociationLinkTo(navigationProperty.PersistentTypeHasAssociations)), PropertiesWithSameType = childNavigationProperties .Where(childScalarProperty => childScalarProperty.PersistentTypeHasAssociations.EqualAssociationLinkTo(navigationProperty.PersistentTypeHasAssociations)) }; navigationPropertiesWithDifferentType.AddRange( query.SelectMany(arg => arg.PropertiesWithDifferentType).Cast <IPropertyBase>().ToList()); navigationPropertiesWithSameType.AddRange( query.SelectMany(arg => arg.PropertiesWithSameType).Cast <IPropertyBase>().ToList()); } var propertiesWithDifferentType = scalarPropertiesWithDifferentType.Concat(structurePropertiesWithDifferentType).Concat( navigationPropertiesWithDifferentType); var propertiesWithSameType = scalarPropertiesWithSameType.Concat(structurePropertiesWithSameType).Concat( navigationPropertiesWithSameType); int inheritancePathsCount = inheritanceTree.GetUniquePathsSuperRoots().Count(); DuplicatedPropertiesInfo info = new DuplicatedPropertiesInfo(propertiesWithDifferentType, propertiesWithSameType, inheritancePathsCount); return(info); }