Skip to content

Error in generated Activator after upgrading Orleans 9.x to 10.x and migrating [OrleansConstructor] to [GeneratedActivatorConstructor] #9895

@ikkentim

Description

@ikkentim

After upgrading from Orleans 9.x to 10.x and following the migration path specified in https://learn.microsoft.com/en-us/dotnet/orleans/migration-guide?pivots=orleans-10-0 I get the following error:

Unable to resolve service for type 'System.String' while attempting to activate 'OrleansCodeGen.My.Lib.Activator_MyType`1[My.Lib.SimpleRecord]'.

If I migrate from [OrleansConstructor] to [ActivatorUtilitiesConstructor] instead of [GeneratedActivatorConstructor] it works just fine.

namespace My.Lib;

[GenerateSerializer]
public class MyType<T>
{
    public MyType(OtherType original)
    {
      // ...
    }

    // tested attributes
    // [OrleansConstructor] // obsolete, but works
    // [GeneratedActivatorConstructor] // the migration path as specified in docs, but gives error 
    // [ActivatorUtilitiesConstructor] // workaround - solves the issue.

    [GeneratedActivatorConstructor] 
    public MyType(string a, string b, T? c)
    {
        // ...
    }

    [Id(0)]
    public string A { get; }
    [Id(1)]
    public string? B { get; }
    [Id(2)]
    public T? C { get; set; }
}

Either the generator doesn't work as expected or the docs are wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions