Ejemplo n.º 1
0
 /// <summary>
 /// Remove abstract methods that override another abstract method.
 /// </summary>
 private static void RemoveAbstractOverrides(NetTypeDefinition typeDef)
 {
     foreach (var iterator in typeDef.Methods.Where(x => x.IsAbstract).ToList())
     {
         var method = iterator;
         if (typeDef.GetBaseTypesWithoutInterfaces().SelectMany(x => x.GetElementType().Methods).Any(x => x.IsAbstract && x.IsExactDuplicate(method)))
         {
             typeDef.Methods.Remove(method);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Remove all properties that override a property that does not exist.
        /// </summary>
        private void FixOverridenProperties()
        {
            if (!typeDef.Properties.Any())
            {
                return;
            }

            var allBaseProperties = typeDef.GetBaseTypesWithoutInterfaces().SelectMany(x => x.GetElementType().Properties).ToList();

            foreach (var iterator in typeDef.Properties.Where(x => x.Getter.NeedsOverrideKeyword && !DoNotFixOverridenProperty(x)).ToList())
            {
                var prop = iterator;
                var sameBaseProperties = allBaseProperties.Where(prop.AreSame).ToList();

                // Check for existing property in base class
                if (sameBaseProperties.Count == 0)
                {
                    // Property has no override
                    typeDef.Properties.Remove(prop);
                    continue;
                }

                // Check for base property with setter
                if (prop.Setter != null)
                {
                    if (sameBaseProperties.Any(x => x.Setter == null))
                    {
                        // Remove setter
                        prop.Setter = null;
                    }
                }
                else
                {
                    // Check for any base property with setter
                }
            }
        }