Testura / Testura.Code

Testura.Code is a wrapper around the Roslyn API and used for generation, saving and compiling C# code. It provides methods and helpers to generate classes, methods, statements and expressions.
MIT License
297 stars 30 forks source link

Bug in TypeBuilderBase #67

Closed Illeris closed 2 years ago

Illeris commented 3 years ago

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.

Illeris commented 3 years ago

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))));
    }

`

MilleBo commented 2 years ago

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