Skip to content

Actor source generator does not copy generic constraints for type parameters #1534

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

Open
oising opened this issue May 12, 2025 · 4 comments · May be fixed by #1535
Open

Actor source generator does not copy generic constraints for type parameters #1534

oising opened this issue May 12, 2025 · 4 comments · May be fixed by #1535
Labels
area/actor/client kind/bug Something isn't working kind/enhancement New feature or request

Comments

@oising
Copy link

oising commented May 12, 2025

Expected Behavior

Given the following actor interface:

using Dapr.Actors.Generators;
using System.Threading.Tasks;

namespace Test
{
    public interface ITrait 
    {
        string GetName();
    }
    
    [GenerateActorClient]
    public interface ITestActor<TTrait> where TTrait : ITrait
    {
        Task<bool> SetTrait(TTrait trait);
        Task<TTrait> GetTrait(string name);
    }
}

it should generate a class definition like this:

public sealed class TestActorClient<TTrait> : Test.ITestActor<TTrait> where TTrait : Test.ITrait
...

Actual Behavior

instead, it generates this:

public sealed class TestActorClient<TTrait> : Test.ITestActor<TTrait>
...

The constraints are not copied.

Steps to Reproduce the Problem

Use the DAPR source generator package with the above actor interface, then examine the analyzer output (or try to compile it.) It will fail.

Release Note

RELEASE NOTE:

@oising oising added the kind/bug Something isn't working label May 12, 2025
@oising oising linked a pull request May 12, 2025 that will close this issue
3 tasks
@oising
Copy link
Author

oising commented May 13, 2025

This is not of immediate use but is more for completeness since dapr dotnet actors currently forbid generic methods due to old service fabric limitiations (soap + datacontract serializer) but it would work with system.text.json serialization.

@WhitWaldo
Copy link
Contributor

Especially with the upcoming changes to the actor runtime to support streaming and pubsub, this might introduce a good opportunity to release a next-gen actors SDK that seeks to break from the older limitations and work with more generic serialization support. This isn't likely for the 1.16 release as it'd be a lot of work, but this is certainly worth keeping in mind.

@m3nax
Copy link
Contributor

m3nax commented May 19, 2025

Especially with the upcoming changes to the actor runtime to support streaming and pubsub, this might introduce a good opportunity to release a next-gen actors SDK that seeks to break from the older limitations and work with more generic serialization support. This isn't likely for the 1.16 release as it'd be a lot of work, but this is certainly worth keeping in mind.

What do you mean next-get actor sdk? What is planned to change?

@WhitWaldo
Copy link
Contributor

@m3nax
Actor PubSub
Bi-directional streaming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/actor/client kind/bug Something isn't working kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants