[
https://issues.apache.org/jira/browse/THRIFT-1742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13527563#comment-13527563
]
Jens Geyer edited comment on THRIFT-1742 at 12/9/12 6:33 PM:
-------------------------------------------------------------
Can't say much about the hash itslf, but this IDL causes a compiler error after
applying the patch. Note the "Object" member. I want to emphasize that the code
indeed compiled before, despite the Object member.
{code}
struct ProductText {
1 : required string Object,
2 : required string TextTypeID,
3 : required string TextTypeDisplay,
4 : required string Content
}
{code}
Generated Equals() code:
{code}
public override bool Equals(object that) {
var other = that as ProductText;
if (other == null) return false;
if (Object.ReferenceEquals(this, other)) return true;
return ((__isset.Object == other.__isset.Object) && ((!__isset.Object) ||
(Object.Equals(other.Object))))
&& ((__isset.TextTypeID == other.__isset.TextTypeID) &&
((!__isset.TextTypeID) || (TextTypeID.Equals(other.TextTypeID))))
&& ((__isset.TextTypeDisplay == other.__isset.TextTypeDisplay) &&
((!__isset.TextTypeDisplay) || (TextTypeDisplay.Equals(other.TextTypeDisplay))))
&& ((__isset.Content == other.__isset.Content) && ((!__isset.Content)
|| (Content.Equals(other.Content))));
}
{code}
Eror: Member 'object.ReferenceEquals(object, object)' cannot be accessed with
an instance reference; qualify it with a type name instead.
was (Author: jensg):
Can't say much about the hash itslf, but this IDL causes a compiler error
after applying the patch. Note the "Object" member.
{code}
struct ProductText {
1 : required string Object,
2 : required string TextTypeID,
3 : required string TextTypeDisplay,
4 : required string Content
}
{code}
Generated Equals() code:
{code}
public override bool Equals(object that) {
var other = that as ProductText;
if (other == null) return false;
if (Object.ReferenceEquals(this, other)) return true;
return ((__isset.Object == other.__isset.Object) && ((!__isset.Object) ||
(Object.Equals(other.Object))))
&& ((__isset.TextTypeID == other.__isset.TextTypeID) &&
((!__isset.TextTypeID) || (TextTypeID.Equals(other.TextTypeID))))
&& ((__isset.TextTypeDisplay == other.__isset.TextTypeDisplay) &&
((!__isset.TextTypeDisplay) || (TextTypeDisplay.Equals(other.TextTypeDisplay))))
&& ((__isset.Content == other.__isset.Content) && ((!__isset.Content)
|| (Content.Equals(other.Content))));
}
{code}
Member 'object.ReferenceEquals(object, object)' cannot be accessed with an
instance reference; qualify it with a type name instead
> Optionally implement hashcode and equals in c#
> ----------------------------------------------
>
> Key: THRIFT-1742
> URL: https://issues.apache.org/jira/browse/THRIFT-1742
> Project: Thrift
> Issue Type: Improvement
> Components: C# - Compiler
> Reporter: T Jake Luciani
> Attachments: 1742.patch
>
>
> It would be very helpful to have a compiler flag that implements hashCode and
> equals for c# generated structs. Java has this capability.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira