[ https://issues.apache.org/jira/browse/GEODE-8754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17243295#comment-17243295 ]
ASF GitHub Bot commented on GEODE-8754: --------------------------------------- mmartell commented on a change in pull request #704: URL: https://github.com/apache/geode-native/pull/704#discussion_r535353084 ########## File path: clicache/integration-test2/SerializationTests.cs ########## @@ -25,7 +26,335 @@ namespace Apache.Geode.Client.IntegrationTests { - public class Order : IDataSerializable + public class TestClassA : IDataSerializable + { + public int Id { get; set; } + public string Name { get; set; } + public short NumSides { get; set; } + + // A default constructor is required for deserialization + public TestClassA() { } + + public TestClassA(int id, string name, short numSides) + { + Id = id; + Name = name; + NumSides = numSides; + } + + public override string ToString() + { + return string.Format("TestClassA: [{0}, {1}, {2}]", Id, Name, NumSides); + } + + public void ToData(DataOutput output) + { + output.WriteInt32(Id); + output.WriteUTF(Name); + output.WriteInt16(NumSides); + } + + public void FromData(DataInput input) + { + Id = input.ReadInt32(); + Name = input.ReadUTF(); + NumSides = input.ReadInt16(); + } + + public ulong ObjectSize + { + get { return 0; } + } + + public static ISerializable CreateDeserializable() + { + return new TestClassA(); + } + + public override bool Equals(object obj) + { + if (obj == null) + return false; + if (obj == this) + return true; + + var other = obj as TestClassA; + + if (Id == other.Id && + Name == other.Name && + NumSides == other.NumSides) + return true; + else + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + public class TestClassB : IDataSerializable + { + public int Width { get; set; } + public int Height { get; set; } + public string Name { get; set; } + + // A default constructor is required for deserialization + public TestClassB() { } + + public TestClassB(int width, int height, string name) + { + Width = width; + Height = height; + Name = name; + } + + public override string ToString() + { + return string.Format("TestClassB: [{0}, {1}, {2}]", Width, Height, Name); + } + + public void ToData(DataOutput output) + { + output.WriteInt32(Width); + output.WriteInt32(Height); + output.WriteUTF(Name); + } + + public void FromData(DataInput input) + { + Width = input.ReadInt32(); + Height = input.ReadInt32(); + Name = input.ReadUTF(); + } + + public ulong ObjectSize + { + get { return 0; } + } + + public static ISerializable CreateDeserializable() + { + return new TestClassB(); + } + + public override bool Equals(object obj) + { + if (obj == null) + return false; + if (obj == this) + return true; + + var other = obj as TestClassB; + + if (Width == other.Width && + Name == other.Name && + Height == other.Height) + return true; + else + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + public class TestClassC : IDataSerializable + { + public string Color { get; set; } + public string Make { get; set; } + public int Year { get; set; } + + // A default constructor is required for deserialization + public TestClassC() { } + + public TestClassC(string color, string make, int year) + { + Color = color; + Make = make; + Year = year; + } + + public override string ToString() + { + return string.Format("TestClassC: [{0}, {1}, {2}]", Color, Make, Year); + } + + public void ToData(DataOutput output) + { + output.WriteUTF(Color); + output.WriteUTF(Make); + output.WriteInt32(Year); + } + + public void FromData(DataInput input) + { + Color = input.ReadUTF(); + Make = input.ReadUTF(); + Year = input.ReadInt32(); + } + + public ulong ObjectSize + { + get { return 0; } + } + + public static ISerializable CreateDeserializable() + { + return new TestClassC(); + } + + public override bool Equals(object obj) + { + if (obj == null) + return false; + if (obj == this) + return true; + + var other = obj as TestClassC; + + if (Color == other.Color && + Make == other.Make && + Year == other.Year) + return true; + else + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + public class CompositeClass : IDataSerializable + { + private TestClassA testclassA; + private List<TestClassB> testclassBs; + private List<TestClassC> testclassCs; + + public CompositeClass() + { + testclassA = new TestClassA(); + testclassBs = new List<TestClassB>(); + testclassCs = new List<TestClassC>(); + } + + public TestClassA A + { + get + { + return testclassA; + } + set + { + testclassA = value; + } + } + + public List<TestClassB> Bs + { + get + { + return testclassBs; + } + set + { + testclassBs = value; + } + } + + public List<TestClassC> Cs + { + get + { + return testclassCs; + } + set + { + testclassCs = value; + } + } + + public void ToData(DataOutput output) + { + testclassA.ToData(output); + output.WriteObject(testclassBs); + output.WriteObject(testclassCs); + } + + //private unsafe void fillstack(Int64[] val) + //{ + // return; + //} + public void FromData(DataInput input) + { + testclassA.FromData(input); + + // Fill the stack with Order typeid: 66 Review comment: Fixed. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Deserialization Error in .NET DataInput::ReadObject > --------------------------------------------------- > > Key: GEODE-8754 > URL: https://issues.apache.org/jira/browse/GEODE-8754 > Project: Geode > Issue Type: Bug > Components: native client > Reporter: Michael Martell > Priority: Major > Labels: pull-request-available > > Using the IDataSerializable interface for user defined .NET types sometimes > fails in a Release build. Specifically, the DataInput::ReadObject() function > may fail in a Release build. > Note: DataInput::ReadObject() never fails in a Debug build. > -- This message was sent by Atlassian Jira (v8.3.4#803005)