I want to use a class generated with TypeSpec.classBuilder as a property in another class that I am generating. But for this I need to get a TypeName and I cannot find a way to access it. Only from the superclass. Anyone knows a way to do this?
Asked
Active
Viewed 1,185 times
1 Answers
4
You should be perfectly fine with using ClassName
there.
And the easiest way of obtaining the ClassName
is to pass the package
and the name
of the generated type:
ClassName("your.package.here", "NameOfType")
You can see here how I'm specifying a receiver
of an extension function ("similar" use-case):

Bartek Lipinski
- 30,698
- 10
- 94
- 132
-
1Thanks! This worked - upvoted the answer. Will accept later unless a more elegant solution comes around. It works but does not really feel DRY.. – ligi Nov 17 '19 at 09:58
-
@ligi can you provide a part of your `class`-generating code? Maybe there's a "DRYier" solution – Bartek Lipinski Nov 18 '19 at 10:38