JamesRandall / FunctionMonkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs. Docs can be found at https://functionmonkey.azurefromthetrenches.com
MIT License
294 stars 50 forks source link

Various Compiler issues #93

Open alexeymarkov opened 5 years ago

alexeymarkov commented 5 years ago

Hello,

first of all thank you for the great framework!

I found some inconvenient issues (correct me, if I am wrong and this is by design unsupported).

  1. If I try to use .AddOpenIdConnectTokenValidator(Environment.GetEnvironmentVariable("Authority"), "myapi") the compilation fails with _Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at FunctionMonkey.TokenValidator.Implementation.TokenValidatorConfiguration..ctor(String wellKnownEndpoint, String audience, Func 3 tokenValidationParameterFunc) at FunctionMonkey.TokenValidator.IAuthorizationBuilderExtensions.AddOpenIdConnectTokenValidator(IAuthorizationBuilder builder, String wellKnownEndpoint, String audience, Func 3 tokenValidationParameterFunc, String header)

The workaround is to use a custom ITokenValidator implementation which takes IOptions via DI.

  1. Using any class in FunctionAppConfiguration from another assembly (RootNamespace.HelperAssembly) with a namespace with the same root as the function assembly (RootNamespace.FunctionAssembly) produces Unhandled Exception: FunctionMonkey.ConfigurationException: CS0234:The type or namespace name "ReferenceLinkBackAttribute" is not found in the namespace "RootNamespace.HelperAssembly". at FunctionMonkey.Compiler.Implementation.AssemblyCompiler.CompileAssembly(IReadOnlyCollection`1 syntaxTrees, IReadOnlyCollection 1 externalAssemblyLocations, OpenApiOutputModel openApiOutputModel, String outputBinaryFolder, String outputAssemblyName, String assemblyNamespace, TargetEnum target) at FunctionMonkey.Compiler.Implementation.FunctionCompiler.Compile() in /Users/jamesrandall/code/myOpenSource/functionMonkeyMaster/Source/FunctionMonkey.Compiler/Implementation/FunctionCompiler.cs:line 86 at FunctionMonkey.Compiler.Program.Main(String[] args) in /Users/jamesrandall/code/myOpenSource/functionMonkeyMaster/Source/FunctionMonkey.Compiler/Program.cs:line 47

The workaround is to use another namespace root name.

JamesRandall commented 5 years ago

Thanks - I'll get that fixed.