Testura/Testura.Code

Bug in TypeBuilderBase

Closed this issue · 2 comments

Flaw in

protected BaseListSyntax CreateBaseList()
{
if (!_inheritance.Any())
{
return null;
}

        return BaseList(
            SeparatedList<BaseTypeSyntax>(
                _inheritance.Select(i => SimpleBaseType(TypeGenerator.Create(i))), 
                _inheritance.Select(i => Token(SyntaxKind.CommaToken))));
    }

No matter how many base classes, a "," is always appended to the base class list.

Possible fix:

`
protected BaseListSyntax CreateBaseList()
{
if (!_inheritance.Any())
{
return null;
}

        return BaseList(
            SeparatedList<BaseTypeSyntax>(
                _inheritance.Select(i => SimpleBaseType(TypeGenerator.Create(i))),
                Enumerable.Range(0, _inheritance.Count - 1).Select(_ => SyntaxFactory.Token(SyntaxKind.CommaToken))));
    }

`

A bit late but thanks for reporting and this is now fixed and will come in next nuget release.