Testura/Testura.Code

ThatInheritFrom - fails on multiple types

Closed this issue · 6 comments

i think the fix would be

file: src/Testura.Code/Builders/Base/TypeBuilderBase.cs
line: 183

                syntaxNodeOrToken[n] = SyntaxFactory.SimpleBaseType(TypeGenerator.Create(_inheritance[n / 2]));
                if (n + 1 < (_inheritance.Count * 2) - 1)

Oh thanks I will check it out and make a fix.

LINQ approach - should give the same result

    protected BaseListSyntax CreateBaseList() =>
        _inheritance.Any()
            ? SyntaxFactory.BaseList(
                SyntaxFactory.SeparatedList<BaseTypeSyntax>(
                    _inheritance.Select(i => SyntaxFactory.SimpleBaseType(TypeGenerator.Create(i))),
                    Enumerable.Range(0, _inheritance.Count - 1).Select(_ => SyntaxFactory.Token(SyntaxKind.CommaToken))))
            : null!;

Cool I had totally missed the built in seperator list. Thanks! It should now be fixed in the 0.17.0 version,

slight issue. there is an extra comma at the end

Oh damn, I did a unit test but used "contains" to assert the string and forgot to manually check so totally missed the extra comma. I will fix it later today.

This is now fixed and will come in next release.