public override SyntaxNode VisitInterfaceDeclaration(InterfaceDeclarationSyntax node) { node = (InterfaceDeclarationSyntax)base.VisitInterfaceDeclaration(node); int i = 0; if (node.BaseList != null) { foreach (BaseTypeSyntax baseType in node.BaseList.Types) { if ((baseType.Type.IsKind(SyntaxKind.GenericName) && String.Equals(((GenericNameSyntax)baseType.Type).Identifier.Text, BaseInterfaceToRemove)) || ((baseType.Type.IsKind(SyntaxKind.IdentifierName) && String.Equals(((IdentifierNameSyntax)baseType.Type).Identifier.Text, BaseInterfaceToRemove)))) { node = node.WithBaseList(node.BaseList.WithTypes(node.BaseList.Types.RemoveAt(i))); continue; } i++; } } // Fails: without it, leaves behind dangling colon, but we're not reparsing, so it's tolerated //if (node.BaseList.Types.Count == 0) //{ // node = node.WithBaseList(null); //} return(node); }
public static InterfaceDeclarationSyntax RemoveBase(InterfaceDeclarationSyntax type, string baseName) { return(type.WithBaseList(RemoveBase(type.BaseList, baseName))); }
public static InterfaceDeclarationSyntax AddBase(InterfaceDeclarationSyntax type, string baseName) { return type.WithBaseList(AddBase(type.BaseList, baseName)); }