public static InterfaceDeclarationSyntax AddPropertyIfNotExists(this InterfaceDeclarationSyntax node, string typeName, string identifier) { var stateProperty = node.DescendantNodes().OfType <PropertyDeclarationSyntax>() .FirstOrDefault(p => p.Type.ToString() == typeName); if (stateProperty == null) { node = node.AddProperty(typeName, identifier); } return(node); }