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

Add code analyzer #253

Open
jviau opened this issue Dec 6, 2023 · 4 comments
Open

Add code analyzer #253

jviau opened this issue Dec 6, 2023 · 4 comments
Labels
Analyzer Enhancement New feature or request P2

Comments

@jviau
Copy link
Member

jviau commented Dec 6, 2023

This issue is copied from Azure/azure-functions-durable-extension#2682. Original author is @Alan-Hinton

Is your feature request related to a problem? Please describe.
Durable functions are very useful, however there are multiple gotchas that the compiler doesn't catch. We use isolated mode c# function apps so we don't have access to the Analyzer to help us avoid these issue at build time. These issues therefore take much longer to find and fix at runtime.

Are there any existing GitHub discussions or issues filed that help give some context to this proposal?
Not that I can see

Describe the solution you'd like
I would like the durable function Analyzer to work for isolated mode c# function apps.

Describe alternatives you've considered
At the moment we are hitting errors at runtime and then fixing them. Rather than seeing them at build time.

Additional context
Common durable function gotchas (not sure which of these the Analyzer handles)

@allantargino
Copy link
Member

allantargino commented Jun 10, 2024

Hey @jviau, is it ok if we close this issue in favor of more specific ones?
I just created 2 new issues - the rest of the features asked in the description is already covered by the current implementation.

@Alan-Hinton
Copy link

It doesn't seem that the Analyzer is catching any of these errors e.g.

[Function(nameof(Activity))]
public async Task<string> Activity([ActivityTrigger] string param)  => await Task.Run(() => param);

[Function(nameof(Orchestrator))]
public async Task Orchestrator([OrchestrationTrigger] TaskOrchestrationContext context)
{
    var param= DateTime.Now;  // expect error due to using DateTime.Now
    var result = await context.CallActivityAsync<int>(nameof(Activity), param);  // Expect error because param is a DateTime, not a string; also expect an error because result is an int, not a string
    var result2 = await Activity("test") // expect an error due to calling an async function directly from an orchestrator
}

@allantargino
Copy link
Member

allantargino commented Jun 14, 2024

Hey @Alan-Hinton, how are you using the Analyzer? Did you manually add a reference to this assembly?
I am asking because it wasn't released it (it should be soon).

I tested your snippet, and the analyzer were able to catch the 3/4 expected errors:
image

The direct async function call detection is not supported yet, you are right.

@Alan-Hinton
Copy link

Hey @Alan-Hinton, how are you using the Analyzer? Did you manually add a reference to this assembly? I am asking because it wasn't released it (it should be soon).

I followed the instructions, in the readme of this repo, to add the 'preview-1' version of the analyzer. I look forward to the release of the new version with these improvements. Hopefully this issue will be closed when the new version is released, so I get a notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analyzer Enhancement New feature or request P2
Projects
None yet
Development

No branches or pull requests

3 participants