Skip to content
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

Add Ts of grain classes that extend Grain<T> to consider for serializer generation #1211

Merged
merged 1 commit into from
Dec 30, 2015

Conversation

sergeybykov
Copy link
Contributor

This is to help #1060.

Today we generate serializers for grain state classes that extend GrainState. With #1060 any POCO class can represent grain state. This change adds Ts of all classes that extend Grain to consider for serializer generation.

{
includedTypes.Add(type);
if (!grainStateType.IsNested && !grainStateType.IsGenericParameter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably remove the .IsNested requirement and shift the IsGenericParameter requirement into SerializerGeneratorManager.RecordTypeToGenerate if it isn't there already (it should be in there)

@ReubenBond
Copy link
Member

LGTM after addressing the comment about deduplication/simplification. Thanks, Sergey :)

@sergeybykov sergeybykov force-pushed the state-class-serializer branch 2 times, most recently from debdec8 to 43ee518 Compare December 29, 2015 06:26
@sergeybykov
Copy link
Contributor Author

@ReubenBond Good point. I think I addressed it. In the process I believe I also fixed a bug in SerializerGeneratorManager.RecordTypeToGenerate - the missing return false. Without it the change didn't work.

@gabikliot
Copy link
Contributor

22:26:36 Test method Tester.CodeGenTests.RuntimeCodeGenerationTests.RuntimeCodeGenNestedGenericTest threw exception:
22:26:36 System.AggregateException: One or more errors occurred. ---> Orleans.Runtime.OrleansException: Unexpected error serializing message to gateway gwy.tcp://127.0.0.1:40000/0. System.ArgumentException: No serializer found for object of type NestedGeneric<System.Int32>.Nested. Perhaps you need to mark it [Serializable] or define a custom serializer for it?

@sergeybykov
Copy link
Contributor Author

Hmm. That's why I was afraid to touch this logic. I'll try to step back a bit as the original version worked.

@sergeybykov
Copy link
Contributor Author

I reverted my "bug fix" and added back an explicit check for type.IsNested in RecordType. The test passes now.

@gabikliot
Copy link
Contributor

But do we actually have a test that it generates the serializer? All state POCO classes in #1060 are marked with [Serializable].

@ReubenBond
Copy link
Member

I can't see the broken diff, but did you remove the IsNested check or just move it?
Why does this check exist?

@sergeybykov
Copy link
Contributor Author

@gabikliot We do have a couple of tests in VSO. They pointed to the issue. Once this is in, I think we should remove [Serializable] from all grain state classes.

@ReubenBond What broken diff?

I removed the code duplication that you pointed to, by moving the shared code to RoslynCodeGenerator.RecordType. I left the check for IsNested there but removed the redundant check for IsGenericParameter which is already done inside SerializerGenerationManager.RecordTypeToGenerate.

When I tried to remove the check for IsNested from RoslynCodeGenerator.RecordType, I ran into codegen issues. It should be possible to remove it. I just didn't have time to dig deeper and didn't want to hold #1060 for that.

ReubenBond added a commit that referenced this pull request Dec 30, 2015
Add Ts of grain classes that extend Grain<T> to consider for serializer generation
@ReubenBond ReubenBond merged commit 66171a7 into dotnet:master Dec 30, 2015
@ReubenBond
Copy link
Member

Perhaps I'll look into refactoring the logic at another time, when the VSO tests are all ported and easy to run.

if (typeInfo.IsSerializable)
RecordType(type, module, targetAssembly, includedTypes);

Type grainStateType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing an else here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The grain class may be marked as [Serializable], yet it may also have a T (grainStateType) that needs to be recorded. An exotic case but not impossible.

@sergeybykov sergeybykov deleted the state-class-serializer branch January 5, 2016 15:35
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants