Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3001

C# Equals fails for binary fields (byte[])

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.2
    • Fix Version/s: 0.9.3
    • Component/s: C# - Compiler
    • Labels:
    • Environment:

      Windows, OSX (most probably all others as well)

    • Patch Info:
      Patch Available

      Description

      The genrated code for Equals is using System.Object.Equals() for byte[].

      byte[] a =

      {1};
      byte[] b = {1}

      ;
      bool equals1 = System.Object.Equals(a, b);
      bool equals2 = Thrift.Collections.TCollections.Equals(a, b);

      equals1 ist False and equals2 is True.

      The effects is, that two thrift-objects that have binary fields never compare Equal.

      test/reproduction:

      • create a thrift-model with a binary field.
      • compile this thrift-model with the c# compiler with the hashcode option enabled.
      • create two instances of this model (o1, o2) and fill the binary filed with equal data
      • note the result of o1.Equals(o2)

      fix: in t_csharp_generator.cc: change the check in the "Equals"-generator to also use TCollections.Equals for the binary type

        Attachments

          Activity

            People

            • Assignee:
              jensg Jens Geyer
              Reporter:
              beschulz Benjamin Schulz
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified