/// <summary>
        /// Run loads assembly in <see cref="_assemblyPath"/> then:
        /// |> GetExportedTypes
        /// |> GetMethods
        /// |> Where method is SDK method
        /// |> Convert that to function.json
        /// |> Create folder \{functionName}\
        /// |> Write \{functionName}\function.json
        ///
        /// This means that every <see cref="MethodInfo"/> will be N binding objects on <see cref="FunctionJsonSchema"/>
        /// Where N == total number of SDK attributes on the method parameters.
        /// </summary>
        internal bool TryRun()
        {
            try
            {
                CleanOutputPath();
#if NET46
                var assembly = Assembly.LoadFrom(_assemblyPath);
#else
                var assembly = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(_assemblyPath);
#endif
                var relativeAssemblyPath = PathUtility.MakeRelativePath(Path.Combine(_outputPath, "dummyFunctionName"), assembly.Location);
                foreach (var type in assembly.GetExportedTypes())
                {
                    foreach (var method in type.GetMethods())
                    {
                        if (method.IsWebJobsSdkMethod())
                        {
                            var functionJson = method.ToFunctionJson(relativeAssemblyPath);
                            var functionName = method.GetSdkFunctionName();
                            var path         = Path.Combine(_outputPath, functionName, "function.json");
                            functionJson.Serialize(path);
                        }
                        else if (method.HasFunctionNameAttribute())
                        {
                            _log.LogWarning($"Method {method.Name} is missing a trigger attribute. Both a trigger attribute and FunctionName attribute are required for an Azure function definition.");
                        }
                        else if (method.HasWebJobSdkAttribute())
                        {
                            _log.LogWarning($"Method {method.Name} is missing the 'FunctionName' attribute. Both a trigger attribute and 'FunctionName' are required for an Azure function definition.");
                        }
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                _log.LogErrorFromException(e);
                return(false);
            }
        }
 private bool Try(Action action, string message, bool isError)
 {
     try
     {
         action();
         return(true);
     }
     catch (Exception e)
     {
         if (isError)
         {
             _logger.LogError(message);
             _logger.LogErrorFromException(e);
         }
         else
         {
             _logger.LogWarning(message);
             _logger.LogWarningFromException(e);
         }
         return(!isError);
     }
 }
        /// <summary>
        /// Run loads assembly in <see cref="_assemblyPath"/> then:
        /// |> GetExportedTypes
        /// |> GetMethods
        /// |> Where method is SDK method
        /// |> Convert that to function.json
        /// |> Create folder \{functionName}\
        /// |> Write \{functionName}\function.json
        ///
        /// This means that every <see cref="MethodInfo"/> will be N binding objects on <see cref="FunctionJsonSchema"/>
        /// Where N == total number of SDK attributes on the method parameters.
        /// </summary>
        internal bool TryRun()
        {
            try
            {
                this._functionNamesSet.Clear();
                if (!_buildArtifactsLog.TryClearBuildArtifactsLog())
                {
                    _log.LogError("Unable to clean build artifacts file.");
                    return(false);
                }

                CleanOutputPath();
                CopyFunctionArtifacts();

                return(TryGenerateFunctionJsons());
            }
            catch (Exception e)
            {
                _log.LogErrorFromException(e);
                return(false);
            }
        }