Testura/Testura.Code

Need to add InterfaceBuildMember

Closed this issue · 3 comments

I was in need of creating a namespace with multiple interfaces and classes. The class builder was supported, but not the interface. Here is the code I added

public class InterfaceBuildMember : IBuildMember
{
    private readonly TypeDeclarationSyntax _interface;

    public InterfaceBuildMember(InterfaceBuilder interfaceBuilder)
    {
        _interface = interfaceBuilder.BuildWithoutNamespace();
    }

    public InterfaceBuildMember(TypeDeclarationSyntax @interface)
    {
        _interface = @interface;
    }

    public SyntaxList<MemberDeclarationSyntax> AddMember(SyntaxList<MemberDeclarationSyntax> members)
    {
        return members.Add(_interface);
    }
}

Oh I must have missed that! Could you create a pull request with this code (and maybe a unit test?) so we can add it to the next release?

This have now been added to the code base and will be included in next nuget update.