private void AddOutputBindingsFromReturnType()

in sdk/Sdk/FunctionMetadataGenerator.cs [262:288]


        private void AddOutputBindingsFromReturnType(IList<ExpandoObject> bindingMetadata, MethodDefinition method)
        {
            TypeReference? returnType = GetTaskElementType(method.ReturnType);

            if (returnType is not null && !string.Equals(returnType.FullName, Constants.VoidType, StringComparison.Ordinal))
            {
                if (string.Equals(returnType.FullName, Constants.HttpResponseType, StringComparison.Ordinal))
                {
                    AddHttpOutputBinding(bindingMetadata, Constants.ReturnBindingName);
                }
                else
                {
                    TypeDefinition returnDefinition = returnType.Resolve()
                        ?? throw new FunctionsMetadataGenerationException($"Couldn't find the type definition '{returnType}' for method '{method.FullName}'");

                    bool hasOutputModel = TryAddOutputBindingsFromProperties(bindingMetadata, returnDefinition);

                    // Special handling for HTTP results using POCOs/Types other
                    // than HttpResponseData. We should improve this to expand this
                    // support to other triggers without special handling
                    if (!hasOutputModel && bindingMetadata.Any(d => IsHttpTrigger(d)))
                    {
                        AddHttpOutputBinding(bindingMetadata, Constants.ReturnBindingName);
                    }
                }
            }
        }