orleans icon indicating copy to clipboard operation
orleans copied to clipboard

With Orleans upgrade to 1.0.10 codegen compilation is failing

Open shubhanjalik opened this issue 11 years ago • 12 comments

Hi, We have a class which is decorated with [Serializable] attribute and which implements ObserverSubscriptionManager interface. This was working with the previous version (1.0.9) of Orleans, but when we upgraded to 1.0.10 the generated codegen fails to compile with error:

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?

shubhanjalik avatar Sep 24 '15 12:09 shubhanjalik

ObserverSubscriptionManager is a class, not an interface. What interfaces does your class implement?

sergeybykov avatar Sep 24 '15 14:09 sergeybykov

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

shubhanjalik avatar Sep 24 '15 16:09 shubhanjalik

What's the line/type/method in orleans.codegen.cs that the compiler is complaining about?

sergeybykov avatar Sep 24 '15 17:09 sergeybykov

[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

shubhanjalik avatar Sep 24 '15 17:09 shubhanjalik

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.

sergeybykov avatar Sep 24 '15 18:09 sergeybykov

Unfortunately, removing [Serializable] attribute causes problem during runtime with error "Perhaps you need to mark it [Serializable] or define a custom serializer for it"

shubhanjalik avatar Sep 24 '15 18:09 shubhanjalik

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,...

gabikliot avatar Sep 24 '15 19:09 gabikliot

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.

shubhanjalik avatar Sep 24 '15 20:09 shubhanjalik

I'll look if I can reproduce this locally. I suspect this is a one line fix in the codegen code.

sergeybykov avatar Sep 24 '15 21:09 sergeybykov

@shubhanjalik I was able to reproduce the problem. Can you confirm that https://github.com/dotnet/orleans/pull/841 fixes it?

sergeybykov avatar Sep 24 '15 22:09 sergeybykov

@sergeybykov Thanks for the quick fix. What is the current policy for providing updated nugets for breaking changes?

ponsakthi avatar Sep 25 '15 06:09 ponsakthi

No policy. We make official (codesigned) releases periodically, and everyone can build private NuGets in between.

sergeybykov avatar Sep 25 '15 14:09 sergeybykov