Skip to content

Commit

Permalink
Merge pull request #119 from nenoNaninu/fix_nested_type_global
Browse files Browse the repository at this point in the history
Fix nested type transpilation (global)
  • Loading branch information
nenoNaninu authored Sep 17, 2023
2 parents 2d92ebe + d2e5b63 commit edb7af1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
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;
}
";
}

0 comments on commit edb7af1

Please sign in to comment.