Example #1
0
        public void Compile()
        {
            IFunctionAppConfiguration configuration = ConfigurationLocator.FindConfiguration(_configurationSourceAssembly);

            if (configuration == null)
            {
                throw new ConfigurationException($"The assembly {_configurationSourceAssembly.GetName().Name} does not contain a public class implementing the IFunctionAppConfiguration interface");
            }

            string newAssemblyNamespace = $"{_configurationSourceAssembly.GetName().Name}.Functions";
            FunctionHostBuilder builder = new FunctionHostBuilder(_serviceCollection, _commandRegistry, false);

            configuration.Build(builder);
            new PostBuildPatcher().Patch(builder, newAssemblyNamespace);

            VerifyCommandAndResponseTypes(builder);

            IReadOnlyCollection <string> externalAssemblies = GetExternalAssemblyLocations(builder.FunctionDefinitions);
            OpenApiOutputModel           openApi            = _openApiCompiler.Compile(builder.OpenApiConfiguration, builder.FunctionDefinitions, _outputBinaryFolder);

            _jsonCompiler.Compile(builder.FunctionDefinitions, openApi, _outputBinaryFolder, newAssemblyNamespace);
            if (_outputProxiesJson && builder.AreProxiesEnabled)
            {
                _proxiesJsonCompiler.Compile(builder.FunctionDefinitions, builder.OpenApiConfiguration, openApi, _outputBinaryFolder);
            }

            _assemblyCompiler.Compile(builder.FunctionDefinitions,
                                      configuration.GetType(),
                                      newAssemblyNamespace,
                                      externalAssemblies,
                                      _outputBinaryFolder,
                                      $"{newAssemblyNamespace}.dll",
                                      openApi,
                                      _target, builder.OutputAuthoredSourceFolder);
        }
        public bool CompileAssets(IFunctionCompilerMetadata functionCompilerMetadata,
                                  string newAssemblyNamespace,
                                  IFunctionAppConfiguration configuration,
                                  IReadOnlyCollection <string> externalAssemblies,
                                  string outputBinaryFolder)
        {
            HandlebarsHelpers.AzureFunctions.HandlebarsHelperRegistration.RegisterHelpers();

            bool isFSharpProject = functionCompilerMetadata.FunctionDefinitions.Any(x => x.IsFunctionalFunction);

            if (isFSharpProject)
            {
                _compilerLog.Warning("FSharp output is currently experimental");
            }

            OpenApiOutputModel openApi = _openApiCompiler.Compile(functionCompilerMetadata.OpenApiConfiguration,
                                                                  functionCompilerMetadata.FunctionDefinitions, outputBinaryFolder);

            _assemblyCompiler.OpenApiOutputModel = openApi;

            _jsonCompiler.Compile(functionCompilerMetadata.FunctionDefinitions, openApi, outputBinaryFolder,
                                  newAssemblyNamespace);

            return(_assemblyCompiler.Compile(functionCompilerMetadata.FunctionDefinitions,
                                             configuration?.GetType() ?? functionCompilerMetadata.BacklinkReferenceType,
                                             configuration != null ? null : functionCompilerMetadata.BacklinkPropertyInfo,
                                             newAssemblyNamespace,
                                             externalAssemblies,
                                             outputBinaryFolder,
                                             $"{newAssemblyNamespace}.dll",
                                             functionCompilerMetadata.CompilerOptions,
                                             functionCompilerMetadata.OutputAuthoredSourceFolder));
        }
Example #3
0
        public bool Compile()
        {
            string newAssemblyNamespace = $"{_configurationSourceAssembly.GetName().Name.Replace("-", "_")}.Functions";
            IFunctionCompilerMetadata functionCompilerMetadata = null;
            IFunctionAppConfiguration configuration            = ConfigurationLocator.FindConfiguration(_configurationSourceAssembly);

            if (configuration == null)
            {
                functionCompilerMetadata = ConfigurationLocator.FindCompilerMetadata(_configurationSourceAssembly);
                if (functionCompilerMetadata == null)
                {
                    _compilerLog.Error($"The assembly {_configurationSourceAssembly.GetName().Name} does not contain a public class implementing the IFunctionAppConfiguration interface");
                    return(false);
                }
            }
            else
            {
                FunctionHostBuilder builder = new FunctionHostBuilder(_serviceCollection, _commandRegistry, false);
                configuration.Build(builder);
                new PostBuildPatcher().Patch(builder, newAssemblyNamespace);
                if (!VerifyCommandAndResponseTypes(builder))
                {
                    return(false);
                }

                functionCompilerMetadata = new FunctionCompilerMetadata
                {
                    FunctionDefinitions        = builder.FunctionDefinitions,
                    OpenApiConfiguration       = builder.OpenApiConfiguration,
                    OutputAuthoredSourceFolder = builder.OutputAuthoredSourceFolder
                };
            }

            IReadOnlyCollection <string> externalAssemblies = GetExternalAssemblyLocations(functionCompilerMetadata.FunctionDefinitions);
            OpenApiOutputModel           openApi            = _openApiCompiler.Compile(functionCompilerMetadata.OpenApiConfiguration, functionCompilerMetadata.FunctionDefinitions, _outputBinaryFolder);

            _jsonCompiler.Compile(functionCompilerMetadata.FunctionDefinitions, openApi, _outputBinaryFolder, newAssemblyNamespace);

            return(_assemblyCompiler.Compile(functionCompilerMetadata.FunctionDefinitions,
                                             configuration?.GetType() ?? functionCompilerMetadata.BacklinkReferenceType,
                                             configuration != null ? null : functionCompilerMetadata.BacklinkPropertyInfo,
                                             newAssemblyNamespace,
                                             externalAssemblies,
                                             _outputBinaryFolder,
                                             $"{newAssemblyNamespace}.dll",
                                             openApi,
                                             _compileTarget, functionCompilerMetadata.OutputAuthoredSourceFolder));
        }
Example #4
0
        public bool CompileAssets(IFunctionCompilerMetadata functionCompilerMetadata, string newAssemblyNamespace,
                                  IFunctionAppConfiguration configuration, IReadOnlyCollection <string> externalAssemblies, string outputBinaryFolder)
        {
            _compilerLog.Warning("ASP.Net Core output is currently experimental");

            FunctionMonkey.Compiler.Core.HandlebarsHelpers.AspNetCore.HandlebarsHelperRegistration.RegisterHelpers();

            OpenApiOutputModel openApi = _openApiCompiler.Compile(functionCompilerMetadata.OpenApiConfiguration,
                                                                  functionCompilerMetadata.FunctionDefinitions, outputBinaryFolder);

            _assemblyCompiler.OpenApiOutputModel = openApi;

            return(_assemblyCompiler.Compile(functionCompilerMetadata.FunctionDefinitions,
                                             configuration?.GetType() ?? functionCompilerMetadata.BacklinkReferenceType,
                                             configuration != null ? null : functionCompilerMetadata.BacklinkPropertyInfo,
                                             newAssemblyNamespace,
                                             externalAssemblies,
                                             outputBinaryFolder,
                                             $"{newAssemblyNamespace}.dll",
                                             functionCompilerMetadata.CompilerOptions,
                                             functionCompilerMetadata.OutputAuthoredSourceFolder));
        }