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

Revert "Simplified invokes: SDK-gen and program-gen implementation for dotnet and nodejs" #11701

Merged
merged 1 commit into from Dec 21, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions pkg/codegen/docs/gen.go
Expand Up @@ -1721,14 +1721,11 @@ func (mod *modContext) getTypes(member interface{}, types nestedTypeUsageInfo) {
mod.getTypes(m.Function, types)
}
case *schema.Function:
if t.Inputs != nil && !t.MultiArgumentInputs {
if t.Inputs != nil {
mod.getNestedTypes(t.Inputs, types, true)
}

if t.ReturnType != nil {
if objectType, ok := t.ReturnType.(*schema.ObjectType); ok && objectType != nil {
mod.getNestedTypes(objectType, types, false)
}
if t.Outputs != nil {
mod.getNestedTypes(t.Outputs, types, false)
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/codegen/docs/gen_function.go
Expand Up @@ -443,11 +443,8 @@ func (mod *modContext) genFunction(f *schema.Function) functionDocArgs {
if f.Inputs != nil {
inputProps[lang] = mod.getProperties(f.Inputs.Properties, lang, true, false, false)
}
if f.ReturnType != nil {
if objectObject, ok := f.ReturnType.(*schema.ObjectType); ok {
outputProps[lang] = mod.getProperties(objectObject.Properties,
lang, false, false, false)
}
if f.Outputs != nil {
outputProps[lang] = mod.getProperties(f.Outputs.Properties, lang, false, false, false)
}
}

Expand Down
10 changes: 4 additions & 6 deletions pkg/codegen/docs/gen_method.go
Expand Up @@ -78,11 +78,9 @@ func (mod *modContext) genMethod(r *schema.Resource, m *schema.Method) methodDoc
inputProps[lang] = props
}
}
if f.ReturnType != nil {
if objectType, ok := f.ReturnType.(*schema.ObjectType); ok && objectType != nil {
outputProps[lang] = mod.getPropertiesWithIDPrefixAndExclude(objectType.Properties, lang, false, false, false,
fmt.Sprintf("%s_result_", m.Name), nil)
}
if f.Outputs != nil {
outputProps[lang] = mod.getPropertiesWithIDPrefixAndExclude(f.Outputs.Properties, lang, false, false, false,
fmt.Sprintf("%s_result_", m.Name), nil)
}
}

Expand Down Expand Up @@ -326,7 +324,7 @@ func (mod *modContext) getMethodResult(r *schema.Resource, m *schema.Method) map

var resultTypeName string
for _, lang := range dctx.supportedLanguages {
if m.Function.ReturnType != nil {
if m.Function.Outputs != nil && len(m.Function.Outputs.Properties) > 0 {
def, err := mod.pkg.Definition()
contract.AssertNoError(err)
resultTypeName = dctx.getLanguageDocHelper(lang).GetMethodResultName(def, mod.mod, r, m)
Expand Down
20 changes: 2 additions & 18 deletions pkg/codegen/dotnet/doc.go
Expand Up @@ -110,24 +110,8 @@ func (d DocLanguageHelper) GetMethodName(m *schema.Method) string {
func (d DocLanguageHelper) GetMethodResultName(pkg *schema.Package, modName string, r *schema.Resource,
m *schema.Method) string {

var returnType *schema.ObjectType
if m.Function.ReturnType != nil {
if objectType, ok := m.Function.ReturnType.(*schema.ObjectType); ok {
returnType = objectType
} else {
typeDetails := map[*schema.ObjectType]*typeDetails{}
mod := &modContext{
pkg: pkg.Reference(),
mod: modName,
typeDetails: typeDetails,
namespaces: d.Namespaces,
}
return mod.typeString(m.Function.ReturnType, "", false, false, false)
}
}

if info, ok := pkg.Language["csharp"].(CSharpPackageInfo); ok {
if info.LiftSingleValueMethodReturns && returnType != nil && len(returnType.Properties) == 1 {
if info.LiftSingleValueMethodReturns && m.Function.Outputs != nil && len(m.Function.Outputs.Properties) == 1 {
typeDetails := map[*schema.ObjectType]*typeDetails{}
mod := &modContext{
pkg: pkg.Reference(),
Expand All @@ -136,7 +120,7 @@ func (d DocLanguageHelper) GetMethodResultName(pkg *schema.Package, modName stri
namespaces: d.Namespaces,
rootNamespace: info.GetRootNamespace(),
}
return mod.typeString(returnType.Properties[0].Type, "", false, false, false)
return mod.typeString(m.Function.Outputs.Properties[0].Type, "", false, false, false)
}
}
return fmt.Sprintf("%s.%sResult", resourceName(r), d.GetMethodName(m))
Expand Down