pulumi/pkg/codegen
Pat Gavlin 0a45f8d3ab
[codegen/go] Rewrite cyclic types. (#8049)
When computing the type name for a field of an object type, we must
ensure that we do not generate invalid recursive struct types. A struct
type T contains invalid recursion if the closure of its fields and its
struct-typed fields' fields includes a field of type T. A few examples:

Directly invalid:

    type T struct { Invalid T }

Indirectly invalid:

    type T struct { Invalid S }

    type S struct { Invalid T }

In order to avoid generating invalid struct types, we replace all
references to types involved in a cyclical definition with *T. The
examples above therefore become:

(1) type T struct { Valid *T }

(2) type T struct { Valid *S }

    type S struct { Valid *T }

We do this using a rewriter that turns all fields involved in reference
cycles into optional fields.

These changes also include an enhancement to the SDK codegen test
driver in the interest of making iterating and debugging more convenient:  if the -sdk.no-checks flag is passed, the driver will not run post-generation checks.
2021-09-28 07:33:14 -07:00
..
docs Codegen testing upgrades (#7989) 2021-09-22 13:55:20 -04:00
dotnet iwahbe/turn on dotnet compile checks (#8044) 2021-09-23 14:31:17 -07:00
go [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
hcl2 Implemented filebase64() support for Code Generator (#7863) 2021-09-10 23:09:28 +01:00
importer [codegen] Unify program codegen testing (#7657) 2021-07-27 18:00:39 -07:00
internal [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
nodejs [codegen/nodejs] - Fix provider enum with env var (#8051) 2021-09-24 15:02:56 -07:00
python [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
schema [codegen/go] - Resolve type name collisions (#7985) 2021-09-23 15:42:48 -07:00
docs.go [codegen/docs] Emit docs for methods (#7731) 2021-08-12 14:31:15 -07:00
docs_test.go [codegen/docs] Reimplement example extraction. (#4851) 2020-06-18 12:32:15 -07:00
utilities.go [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
utilities_test.go [codegen] Fix SimplifyInputUnion. (#7459) 2021-07-08 16:01:35 -07:00
utilities_types.go [codegen] Fix SimplifyInputUnion. (#7459) 2021-07-08 16:01:35 -07:00