Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nested type transpilation (global) #119

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Tapper/GlobalNamedTypeCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public override void VisitNamespace(INamespaceSymbol symbol)
public override void VisitNamedType(INamedTypeSymbol symbol)
{
_namedTypeSymbols.Add(symbol);

foreach (var member in symbol.GetTypeMembers())
{
member.Accept(this);
}
}

public INamedTypeSymbol[] ToArray() => _namedTypeSymbols.ToArray();
Expand Down
8 changes: 8 additions & 0 deletions tests/Tapper.Tests.AsmReference.SourceTypes2/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ public class Class2
public string? Name2 { get; init; }
public Guid Id { get; set; }
}

[TranspilationSource]
public record NestedTypeParentRequest
(IReadOnlyList<NestedTypeParentRequest.NestedTypeNestedTypeParentRequestItem> Items)
{
[TranspilationSource]
public record NestedTypeNestedTypeParentRequestItem(int Value, string? Message);
}
14 changes: 14 additions & 0 deletions tests/Tapper.Tests.AsmReference/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,19 @@ private static async Task ExecCommand(string generatorProject, string projectFul
id: string;
}

/** Transpiled from Tapper.Tests.AsmReference.SourceTypes2.NestedTypeParentRequest */
export type NestedTypeParentRequest = {
/** Transpiled from System.Collections.Generic.IReadOnlyList<Tapper.Tests.AsmReference.SourceTypes2.NestedTypeParentRequest.NestedTypeNestedTypeParentRequestItem> */
items: NestedTypeNestedTypeParentRequestItem[];
}

/** Transpiled from Tapper.Tests.AsmReference.SourceTypes2.NestedTypeParentRequest.NestedTypeNestedTypeParentRequestItem */
export type NestedTypeNestedTypeParentRequestItem = {
/** Transpiled from int */
value: number;
/** Transpiled from string? */
message?: string;
}

";
}