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

Analyzers throw exceptions when an orchestrator uses C# 8 local functions #1357

Closed
juunas11 opened this issue May 19, 2020 · 2 comments · Fixed by #1358
Closed

Analyzers throw exceptions when an orchestrator uses C# 8 local functions #1357

juunas11 opened this issue May 19, 2020 · 2 comments · Fixed by #1358
Assignees
Labels
analyzer Issues with the Roslyn analyzer bug

Comments

@juunas11
Copy link

Description

Installing version 2.2.1 (or 2.2.0) of Microsoft.Azure.WebJobs.Extensions.DurableTask and by extension 0.2.1 of the Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers caused our build to crash as we got warnings that the analyzer had ran into an exception (and we treat warnings as errors).
I made a small repro, and it seems to be due to us using C# 8 local functions in orchestrators.

Expected behavior

Analyzer gives warnings and errors that it is able to give.

Actual behavior

Warning when building the project:

Warning
AD0001
'Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers.OrchestratorAnalyzer' threw an exception of type 'System.InvalidCastException' with message 'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax'.'.

Version 0.2.1 and 0.2.2 of the analyzers throw the same exception.

Relevant source code snippets

Modifying the "Hello world" orchestrator like this is enough to trigger the warning:

[FunctionName("TestOrchestrator")]
public static async Task<List<string>> RunOrchestrator(
    [OrchestrationTrigger] IDurableOrchestrationContext context)
{
    var outputs = new List<string>();

    async Task<string> CallAsync(string name)
    {
        return await context.CallActivityAsync<string>("TestOrchestrator_Hello", name);
    }

    outputs.Add(await CallAsync("Tokyo"));
    outputs.Add(await CallAsync("Seattle"));
    outputs.Add(await CallAsync("London"));

    return outputs;
}

Known workarounds

Downgraded the DurableTask extension to 2.1.1 and removed the analyzer.

App Details

  • Durable Functions extension version (e.g. v1.8.3): 2.2.1
  • Azure Functions runtime version (1.0 or 2.0): 3.0
  • Programming language used: C#
@ghost ghost added the Needs: Triage 🔍 label May 19, 2020
@amdeel amdeel added analyzer Issues with the Roslyn analyzer bug and removed Needs: Triage 🔍 labels May 19, 2020
@amdeel
Copy link
Contributor

amdeel commented May 19, 2020

Hey @juunas11, thanks for letting me know about this issue. This will be fixed in the next analyzer release.

@amdeel
Copy link
Contributor

amdeel commented May 26, 2020

Hey @juunas11, I just wanted to let you know that this fix is in the 0.2.3 analyzer release, which is available now if you reference this directly. It will also be added by default with the durable extension starting with the (upcoming) Durable 2.2.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer Issues with the Roslyn analyzer bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants