-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
Milestone
Description
I have a Orleans 7.0 project with and I'm having an issue with the new default serializer.
The old serializer in Orleans 3.6.5 worked fine and it was serializing all the models and Dtos in the several internal Nuget packages.
Now in Orleans 7.0 the project does not recognize the models in the Nuget packages and I get this error:
Orleans.Serialization.CodecNotFoundException: Could not find a copier for type InternalProject.Model.
at Orleans.Serialization.Serializers.CodecProvider.ThrowCopierNotFound(Type type) in /_/src/Orleans.Serialization/Serializers/CodecProvider.cs:line 666
at Orleans.Serialization.Serializers.CodecProvider.GetDeepCopier[T]() in /_/src/Orleans.Serialization/Serializers/CodecProvider.cs:line 300
at Orleans.Serialization.ServiceCollectionExtensions.CopierHolder`1.get_Value() in /_/src/Orleans.Serialization/Hosting/ServiceCollectionExtensions.cs:line 203
at Orleans.Serialization.GeneratedCodeHelpers.OrleansGeneratedCodeHelper.GetService[TService](Object caller, ICodecProvider codecProvider) in /_/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs:lin
e 75
at OrleansCodeGen.InternalProject.Model.Copier_SpecificModel..ctor(ICodecProvider codecProvider) in C:\Projects\InternalProject.Model\Orleans.CodeGenerator\Orleans.CodeGenerator.Orle
ansSerializationSourceGenerator\InternalProject.Model.orleans.g.cs:line 20736
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance[T](IServiceProvider provider)
at Orleans.Serialization.GeneratedCodeHelpers.OrleansGeneratedCodeHelper.GetService[TService](Object caller, ICodecProvider codecProvider) in /_/src/Orleans.Serialization/GeneratedCodeHelpers/OrleansGeneratedCodeHelper.cs:lin
e 72
Now for the interesting part: when I copy paste the exact same class in my main project I no longer get this error, and the class serializes perfectly fine.
I tried referencing the Nuget project directly in the main project(ProjectReference), the result is the same.
I only get rid of errors in two scenarios:
- when I use the Json Serializer with IgnoreCycles (undesirable in my scenario, doesn't get rid of the underlying problem)
siloBuilder.Services.AddSerializer(sb =>
{
sb.AddJsonSerializer(
isSupported: type => type.Namespace.StartsWith("Nuget.Namespace"),
new JsonSerializerOptions()
{
ReferenceHandler = ReferenceHandler.IgnoreCycles
}
);
});
- when I add the classes directly in the main project. Example class from the error:
[GenerateSerializer]
public sealed class Class1: Class1Base
{
public Class1()
{
}
public Class1(IRequest request, bool boolean, InternalClass internalClass)
: base(request, boolean)
{
InternalClass = internalClass;
}
[Id(0)]
public InternalClass InternalClass{ get; set; }
}
[GenerateSerializer]
public class Class1Base
{
public Class1Base()
{
}
public Class1Base(IRequest request, bool boolean)
{
Request = request;
Boolean= boolean;
}
[Id(0)]
public IRequest Request { get; set; }
[Id(1)]
public bool Boolean{ get; set; }
}