public static PropertyDeclaration add_Property(this TypeDeclaration typeDeclaration, IProperty iProperty) { foreach (var child in typeDeclaration.Children) { if (child is PropertyDeclaration) { if ((child as PropertyDeclaration).Name == iProperty.Name) { return(child as PropertyDeclaration); } } } //if (field != null) // return field; AttributedNode property = null; var classFinder = new ClassFinder(iProperty.DeclaringType, 0, 0); property = ICSharpCode.SharpDevelop.Dom.Refactoring.CodeGenerator.ConvertMember(iProperty, classFinder); if (property != null && property is PropertyDeclaration) { return(typeDeclaration.add_Property(property as PropertyDeclaration)); } //typeDeclaration.Children.Insert(0, property); if (property is PropertyDeclaration) { return((PropertyDeclaration)property); } "in add_Property could not convert property into PropertyDeclaration, because it is: {0}".error(property.typeName()); return(null); }