Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in FunctionMetadataProviderGenerator after upgrading Microsoft.Azure.Functions.Worker.Sdk to 1.17.3 #2588

Closed
roycornelissen opened this issue Jul 10, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@roycornelissen
Copy link

roycornelissen commented Jul 10, 2024

Description

After upgrading Microsoft.Azure.Functions.Worker.Sdk to 1.17.3 this morning, our FunctionApp gives a warning:

CS8785	Generator 'FunctionMetadataProviderGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'NullReferenceException' with message 'Object reference not set to an instance of an object.'.

Since we turned on WarningsAsErrors it started failing our builds which is pretty annoying. Our Function app has durable entities, orchestrations and httptriggered functions.

When building with diagnostic level verbosity, there is a little bit more detail:

13:20:28.961   1:7>CSC : error CS8785: Generator 'FunctionMetadataProviderGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'NullReferenceException' with message 'Object reference not set to an instance of an object.'. [C:\repo\Inkomen.IKV.Wegwijzer\portal\Api\Api.csproj]
                     System.NullReferenceException: Object reference not set to an instance of an object. (TaskId:190)
                     at Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionMetadataProviderGenerator.Parser.TryGetAttributeProperties(AttributeData attributeData, Location attribLocation, IDictionary`2& attrProperties) in D:\a\_work\1\s\sdk\Sdk.Generators\FunctionMetadataProviderGenerator\FunctionMetadataProviderGenerator.Parser.cs:line 615 (TaskId:190)
                     at Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionMetadataProviderGenerator.Parser.TryCreateBindingDictionary(AttributeData bindingAttrData, String bindingName, Location bindingLocation, IDictionary`2& bindings, Boolean supportsDeferredBinding) in D:\a\_work\1\s\sdk\Sdk.Generators\FunctionMetadataProviderGenerator\FunctionMetadataProviderGenerator.Parser.cs:line 565 (TaskId:190)
                     at Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionMetadataProviderGenerator.Parser.TryGetReturnTypePropertyBindings(ITypeSymbol returnTypeSymbol, Boolean hasHttpTrigger, Boolean hasMethodOutputBinding, IList`1& bindingsList) in D:\a\_work\1\s\sdk\Sdk.Generators\FunctionMetadataProviderGenerator\FunctionMetadataProviderGenerator.Parser.cs:line 456 (TaskId:190)
                     at Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionMetadataProviderGenerator.Parser.TryGetReturnTypeBindings(IMethodSymbol method, Boolean hasHttpTrigger, Boolean hasMethodOutputBinding, IList`1& bindingsList) in D:\a\_work\1\s\sdk\Sdk.Generators\FunctionMetadataProviderGenerator\FunctionMetadataProviderGenerator.Parser.cs:line 443 (TaskId:190)
                     at Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionMetadataProviderGenerator.Parser.TryGetBindings(IMethodSymbol method, IList`1& bindings, Boolean& hasHttpTrigger, GeneratorRetryOptions& validatedRetryOptions) in D:\a\_work\1\s\sdk\Sdk.Generators\FunctionMetadataProviderGenerator\FunctionMetadataProviderGenerator.Parser.cs:line 97 (TaskId:190)
                     at Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionMetadataProviderGenerator.Parser.GetFunctionMetadataInfo(List`1 methods, FunctionsMetadataParsingContext parsingContext) in D:\a\_work\1\s\sdk\Sdk.Generators\FunctionMetadataProviderGenerator\FunctionMetadataProviderGenerator.Parser.cs:line 69 (TaskId:190)
                     at Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionMetadataProviderGenerator.Execute(GeneratorExecutionContext context) in D:\a\_work\1\s\sdk\Sdk.Generators\FunctionMetadataProviderGenerator\FunctionMetadataProviderGenerator.cs:line 52 (TaskId:190)
                     at Microsoft.CodeAnalysis.SourceGeneratorAdaptor.<Initialize>b__5_5(SourceProductionContext productionContext, GeneratorContextBuilder contextBuilder) (TaskId:190)
                     at Microsoft.CodeAnalysis.UserFunctionExtensions.<>c__DisplayClass3_0`2.<WrapUserAction>b__0(TInput1 input1, TInput2 input2, CancellationToken token) (TaskId:190)
                     ----- (TaskId:190)
                     CompilerServer: server - server processed compilation - Api (net8.0) (TaskId:190)

Steps to reproduce

  • Create a new Azure Function project in Visual Studio, using .NET 8 and dotnet-isolated
  • Pick Durable Orchestrations as a starting point
  • Update all Nuget packages to latest
  • Build the project, the warning will appear

If you downgrade Microsoft.Azure.Functions.Worker.Sdk to 1.17.2, the warning disappears.

Note: I have also upgraded Visual Studio to Version 17.10.4 and .NET SDK to 8.0.303 this morning, not sure if it's related.

@roycornelissen roycornelissen added the potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug label Jul 10, 2024
@roycornelissen roycornelissen changed the title NullReferenceException in FunctionMetadataProviderGenerator after upgrading Microsoft.Azure.Functions.Worker.Sdk to 1.17.3 NullReferenceException in FunctionMetadataProviderGenerator after upgrading Microsoft.Azure.Functions.Worker.Sdk to 1.17.3 Jul 10, 2024
@kshyju
Copy link
Member

kshyju commented Jul 10, 2024

I am confident that the NullReferenceException issue is resolved in #2579, particularly in this line.

However, we will investigate further and release a new version of the package with the fix. Thank you!

@satvu FYI

@kshyju kshyju added bug Something isn't working and removed Needs: Triage (Functions) potential-bug Items opened using the bug report template, not yet triaged and confirmed as a bug labels Jul 10, 2024
@Robson-Rocha
Copy link

Robson-Rocha commented Jul 10, 2024

We are facing the same issue and almost the same scenario, except we don't use durable entities, but we use orchestrators and HTTP-triggered functions.
Our VS still needs to be upgraded, but the packages have been.

@roycornelissen
Copy link
Author

@kshyju thanks for your swift action and response. I’d be happy to test and validate it if there is a pre-release of the package.

@Stephan-Hoffmann
Copy link

Same here - I'm just using HTTP triggered functions ...

@satvu
Copy link
Member

satvu commented Jul 11, 2024

Used the repro from @roycornelissen and was able to resolve it with the latest fixes that @kshyju mentioned - we've released SDK 1.17.4 with the fixes. Please upgrade to resolve this error. Thanks for the reports and repros!

@roycornelissen
Copy link
Author

Awesome, 1.17.4 also works for us. Thanks!

@kshyju
Copy link
Member

kshyju commented Jul 12, 2024

Thanks for confirming @roycornelissen.

@kshyju kshyju closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants