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

Can't use complex type as input & output with ActivityTrigger Attribute #62

Closed
NielsFilter opened this issue Oct 13, 2022 · 1 comment
Closed

Comments

@NielsFilter
Copy link

I'm testing out durable tasks using isolated function in .NET 7

I seem to be having trouble building to project when I have a complex type as inputs parameters or return types for my activity functions.

[Function("CalculateBuyProbability")]
public static async Task<SentimentResult> Calculate([ActivityTrigger] int userId, ILogger log)
{
    ...
}

...

[Function("PrintReport")]
public static async Task Print([ActivityTrigger] List<SentimentResult> results, SentimentResult test, ILogger log)
{
   ...
}

SentimentResult here is a basic complex type

public class SentimentResult
{
    public int UserId { get; set; }
    public int Sentiment { get; set; }
}

I get build error:
C:\Users\niels\RiderProjects\TestApps\Company.FunctionApp1\Company.FunctionApp1\Microsoft.DurableTask.Generators\Microsoft.DurableTask.Generators.DurableTaskSourceGenerator\GeneratedDurableTaskExtensions.cs(13,33): error CS0246: The type or namespace name 'SentimentResult' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\niels\RiderProjects\TestApps\Company.FunctionApp1\Company.FunctionApp1\Company.FunctionApp1.cspro
j]

What I've tried:

  • Removing the ActivityTriggerAttribute fixes the build error
  • Returning object instead of complex type fixes the build error

I'm using Rider as my IDE, but I don't think it's related as dotnet build via terminal returns the same.

In case it matters, my csproj with the package versions I'm using:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <AzureFunctionsVersion>V4</AzureFunctionsVersion>
        <OutputType>Exe</OutputType>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.11.0-preview2" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="0.4.1-beta" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.8.0-preview2" />
    </ItemGroup>
    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
    </ItemGroup>
</Project>
@NielsFilter
Copy link
Author

I see this was already logged here: #35 Closing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant