With Orleans upgrade to 1.0.10 codegen compilation is failing
Hi,
We have a class which is decorated with [Serializable] attribute and which implements ObserverSubscriptionManager
Error 42 The type or namespace name 'IGrainObserver' could not be found (are you missing a using directive or an assembly reference?) C:\Git\....\orleans.codegen.cs
Can you please help in resolving this?
ObserverSubscriptionManager is a class, not an interface. What interfaces does your class implement?
Sorry, I did not make it clear. We were deriving from ObserverSubscriptionManager class to add some functionalities and derived class declaration looks like this.
[Serializable]
public class MyObserverSubscriptionManager<T> : ObserverSubscriptionManager<T> where T : IGrainObserver
What's the line/type/method in orleans.codegen.cs that the compiler is complaining about?
[System.CodeDom.Compiler.GeneratedCodeAttribute("Orleans-CodeGenerator", "1.0.10.0")]
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute()]
internal class SampleProject_SampleGrain_SampleObserver_MyObserverSubscriptionManagerSerialization<T>
where T : IGrainObserver
Compiler complains about IGrainObserver in the last line saying that "The type or namespace name 'IGrainObserver' could not be found " . These are the namespaces that were added in codegen file.
using System;
using System.Collections.Generic;
using System.Reflection;
using Orleans.Serialization;
using SampleProject.SampleGrain.SampleObserver
Try removing [Serializable] attribute from the class. Because of it codegen is trying to generate a serializer for it. There's probably a bug in the serializer generation code that it doesn't put a full name of IGrainObserver there. But you can avoid it if you prevent generation of a serializer for the class.
Unfortunately, removing [Serializable] attribute causes problem during runtime with error "Perhaps you need to mark it [Serializable] or define a custom serializer for it"
This should not be happening. MyObserverSubscriptionManager is not something you should be ever trying to serialize. Are you by chance trying to pass it in grain methods? You shouldn't.
If that does not help, can you provide more context about this runtime error. The full log statement, stack trace,...
MyObserverSubscriptionManager is part of the grain state class and hence it is trying to Serialize. I need to persist the list of subscribers and hence MyObserverSubscriptionManager is part of the state.
I'll look if I can reproduce this locally. I suspect this is a one line fix in the codegen code.
@shubhanjalik I was able to reproduce the problem. Can you confirm that https://github.com/dotnet/orleans/pull/841 fixes it?
@sergeybykov Thanks for the quick fix. What is the current policy for providing updated nugets for breaking changes?
No policy. We make official (codesigned) releases periodically, and everyone can build private NuGets in between.