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

EnumerableSerializer incorrect output when used inside another enumeration #9

Closed
wants to merge 1 commit into from

Conversation

ievsiukovi
Copy link

Hello, I found unexpected serialization behavior when tried to serialize complex enumerations.
For example we have a Message to serialize:

public class Message
{
  public List<Dictionary<int, int>> Items { get; set; }
}

Let's do a test (extension calls are used as a short):

public static void Main()
{
  Message example = new Message()
  {
	Items = new List<Dictionary<int, int>>()
	{
	  new Dictionary<int, int>() { { 11, 11 } },
	  new Dictionary<int, int>() { { 13, 13 } }
	}
  };
  byte[] avro = example.ToAvro(); // produced bytes: 2 4 2 2 22 22 0 2 2 0 0 
		                  // when expected is: 2 4 2 2 22 22 0 2 2 26 26 0 0
  Message back = avro.FromAvro<Message>();
}

EnumerableSerializer do unexpected break when processing a second member of a sequence.
It happens because of a serializer instance that loops over a many members.
Reset chunkCounter on every serializer block helps to correct an output.

…er enumeration.

Hello, I found unexpected serialization behavior when tried to serialize complex enumerations.
For example we have a Message to serialize:
```
public class Message
{
  public List<Dictionary<int, int>> Items { get; set; }
}
```
Let's do a test (extension calls are used as a short): 
```
public static void Main()
{
  Message example = new Message()
  {
	Items = new List<Dictionary<int, int>>()
	{
	  new Dictionary<int, int>() { { 11, 11 } },
	  new Dictionary<int, int>() { { 13, 13 } }
	}
  };
  byte[] avro = example.ToAvro(); // produced bytes: 2 4 2 2 22 22 0 2 2 0 0 
					           // when expected is: 2 4 2 2 22 22 0 2 2 26 26 0 0
  Message back = avro.FromAvro<Message>();
}
```
EnumerableSerializer do unexpected break when processing a second member of a sequence.
It happens because of a serializer instance that loops over a many members. 
Reset chunkCounter on every serializer block helps to correct an output.
@ievsiukovi ievsiukovi closed this Oct 17, 2019
@ievsiukovi
Copy link
Author

a part of the next pull request #10

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.

1 participant