Joslian / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

Calling GetSchema can cause call to serialize to throw an exception #442

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Create a program with code like this:
long[] test = new long[2];
test[0] = 1;
test[1] = 2;

//Type type = test.GetType();
//string hmm = RuntimeTypeModel.Default.GetSchema(type);

using (var ms = new MemoryStream())
{
  Serializer.NonGeneric.Serialize(ms, test);
}
2. Run it, and it should work fine.
3. Uncomment the two lines that are commented out
4. Run it, and you should get an exception on this line in CompilerContext.cs:
method = new DynamicMethod("proto_" + uniqueIdentifier.ToString(), returnType, 
paramTypes, associatedType.IsInterface ? typeof(object) : associatedType, true);

The associatedType is an Int64[], but DynamicMethod does not allow arrays.

What is the expected output? What do you see instead?
I expect it to serialize properly, but instead it crashes.

What version of the product are you using? On what operating system?
I'm using the source from r668

Please provide any additional information below.

Original issue reported on code.google.com by paulbsm...@gmail.com on 22 Apr 2014 at 5:01