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

Serialization for CalendarSystem. #2

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

havarnov
Copy link
Owner

No description provided.

@havarnov havarnov force-pushed the feature/calendarsystem-serialization branch from 905fa2c to abf6061 Compare April 24, 2023 20:07
where TBufferWriter : IBufferWriter<byte>
{
// If the value is null, write it as the null reference.
if (value is null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use this instead:

if (ReferenceCodec.TryWriteReferenceField(ref writer, fieldIdDelta, expectedType, value))
{
  return;
}

You should delete the MarkValueField line below, too, since this is a reference typed value.


public bool IsSupportedType(Type type)
{
return type == typeof(CalendarSystem);
Copy link
Contributor

Choose a reason for hiding this comment

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

If CalendarSystem is an abstract class, this should use typeof(CalendarSystem).IsAssignableFrom(type) instead.

Otherwise, if it's concrete and subtypes are not copyable by this implementation (eg, they are not immutable), then you should delete this and the IGeneralizedCodec interface

Copy link
Owner Author

Choose a reason for hiding this comment

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

That's actually was my assumption as well. This is the definition of CalendarSystem:

    [Immutable]
    public sealed class CalendarSystem
    {

But, If I remove IGeneralizedCopier there are multiple tests that fail:

Orleans.Serialization.CodecNotFoundException: Could not find a copier for type NodaTime.CalendarSystem.

public CalendarSystem? ReadValue<TInput>(ref Reader<TInput> reader, Field field)
{
// This will only be true if the value is null.
if (field.WireType == WireType.Reference)
Copy link
Contributor

@ReubenBond ReubenBond Apr 24, 2023

Choose a reason for hiding this comment

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

if (field.WireType == WireType.Reference)
{
  return ReferenceCodec.ReadReference<CalendarSystem?, TInput>(ref reader, field);
}

Also, I recommend you remove MarkValueField and use ReferenceCodec.RecordObject instead.

@havarnov havarnov force-pushed the feature/calendarsystem-serialization branch from abf6061 to 8a18327 Compare April 25, 2023 06:23
@havarnov havarnov force-pushed the feature/calendarsystem-serialization branch from 943d47e to 320d17c Compare January 11, 2024 21:31
@havarnov havarnov merged commit 481ba86 into master Jan 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants