Azure-functions-durable-extension: AD0001 build warnings due to System.ArgumentException in FunctionAnalyzer

Created on 15 Apr 2020  路  1Comment  路  Source: Azure/azure-functions-durable-extension

Description

After a build of my .NETCore 3.1 Function App using DurableTask v2.2.1 with the DurableTask.Analyzers v0.2.1, I see warnings in the build output: CSC : warning AD0001: Analyzer 'Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers.FunctionAnalyzer' threw an exception of type 'System.ArgumentException' with message 'Syntax node is not within syntax tree'.

Expected behavior

No build warnings, or specific (DFxxx) warnings related to the DurableTask Analyzer.

Actual behavior

Copied from build output:

1>------ Build started: Project: DurableFunctions.Demo.DotNetCore, Configuration: Debug Any CPU ------
1>CSC : warning AD0001: Analyzer 'Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers.FunctionAnalyzer' threw an exception of type 'System.ArgumentException' with message 'Syntax node is not within syntax tree'.
1>CSC : warning AD0001: Analyzer 'Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers.FunctionAnalyzer' threw an exception of type 'System.ArgumentException' with message 'Syntax node is not within syntax tree'.
1>CSC : warning AD0001: Analyzer 'Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers.FunctionAnalyzer' threw an exception of type 'System.ArgumentException' with message 'Syntax node is not within syntax tree'.
1>DurableFunctions.Demo.DotNetCore -> C:\dev\git\personal\demos-azure-durable-functions\src\DurableFunctions.Demo.DotNetCore\bin\Debug\netcoreapp3.1\bin\DurableFunctions.Demo.DotNetCore.dll
1>Done building project "DurableFunctions.Demo.DotNetCore.csproj".
2>------ Build started: Project: DurableFunctions.Demo.DotNetCore.Test, Configuration: Debug Any CPU ------
2>DurableFunctions.Demo.DotNetCore.Test -> C:\dev\git\personal\demos-azure-durable-functions\src\DurableFunctions.Demo.DotNetCore.Test\bin\Debug\netcoreapp3.1\DurableFunctions.Demo.DotNetCore.Test.dll
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Known workarounds

I temporarily removed the dependency to the Analyzer by modifying the DurableTask extension nuspec:

  • Go to the local folder where the DurableTask package is stored. For me this is: C:\Users\%User%.nuget\packages\microsoft.azure.webjobs.extensions.durabletask\2.2.1
  • Open the nuspec file and comment out (or remove) the two dependencies for Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers, one for .NETFramework4.6.1, and one for .NETStandard2.0.
  • Save the nuspec
  • In the IDE, remove the package reference to the DurableTask extension.
  • Add the DurableTask extension again. Since the package it's still in the local NuGet folder it should not download it from nuget.org. It will load the extension but not with the Analyzer now.

App Details

  • Durable Functions extension version (e.g. v2.1.1):
  • Durable Functions extension version (e.g. v0.2.1):
analyzer bug

Most helpful comment

Oh, I've seen this issue before. I know exactly what this is.

If you're curious, this issue has to do with a recent change in the FunctionAnalyzer that passes around semantic models. I encountered this when I made the changes to the OrchestratorAnalyzer and added a method (GetSyntaxTreeSemanticModel, admittedly not the best name I've ever given a method) to get the SemanticModel for the syntax tree.

Thank you so much for letting me know about this! I'll fix this and try to have another analyzer patch release really soon.

>All comments

Oh, I've seen this issue before. I know exactly what this is.

If you're curious, this issue has to do with a recent change in the FunctionAnalyzer that passes around semantic models. I encountered this when I made the changes to the OrchestratorAnalyzer and added a method (GetSyntaxTreeSemanticModel, admittedly not the best name I've ever given a method) to get the SemanticModel for the syntax tree.

Thank you so much for letting me know about this! I'll fix this and try to have another analyzer patch release really soon.

Was this page helpful?
0 / 5 - 0 ratings