private bool TryCreateFunctionMetadata()

in sdk/Sdk/FunctionMetadataGenerator.cs [155:198]


        private bool TryCreateFunctionMetadata(MethodDefinition method, out SdkFunctionMetadata? function)
        {
            function = null;
            SdkRetryOptions? retryOptions = null;

            foreach (CustomAttribute attribute in method.CustomAttributes)
            {
                if (string.Equals(attribute.AttributeType.FullName, Constants.FunctionNameType, StringComparison.Ordinal))
                {
                    string functionName = attribute.ConstructorArguments.SingleOrDefault().Value.ToString();

                    if (string.IsNullOrEmpty(functionName))
                    {
                        continue;
                    }

                    TypeDefinition declaringType = method.DeclaringType;

                    string actualMethodName = method.Name;
                    string declaringTypeName = declaringType.GetReflectionFullName();
                    string assemblyFileName = Path.GetFileName(declaringType.Module.FileName);

                    function = CreateSdkFunctionMetadata(functionName, actualMethodName, declaringTypeName, assemblyFileName);
                }
                else if (string.Equals(attribute.AttributeType.FullName, Constants.FixedDelayRetryAttributeType, StringComparison.Ordinal) ||
                    string.Equals(attribute.AttributeType.FullName, Constants.ExponentialBackoffRetryAttributeType, StringComparison.Ordinal))
                {
                    retryOptions = CreateSdkRetryOptions(attribute);
                }
            }

            if (function is null)
            {
                return false;
            }

            // if a retry attribute is defined, add it to the function.
            if (retryOptions != null)
            {
                function.Retry = retryOptions;
            }

            return true;
        }