File tree Expand file tree Collapse file tree 3 files changed +19
-12
lines changed
RabbitMQ.Client/client/api Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -156,9 +156,9 @@ public override bool Equals(object obj)
156
156
157
157
public bool Equals ( AmqpString other )
158
158
{
159
- if ( _value == null )
159
+ if ( _value is null || other . _value is null )
160
160
{
161
- return _stringBytes . Equals ( other . _stringBytes ) ;
161
+ return GetHashCode ( ) . Equals ( other . GetHashCode ( ) ) ;
162
162
}
163
163
else
164
164
{
@@ -168,19 +168,12 @@ public bool Equals(AmqpString other)
168
168
169
169
public override int GetHashCode ( )
170
170
{
171
- if ( _value == null )
172
- {
173
- return ReadOnlyMemoryOfByteEqualityComparer . CalculateHashCode ( _stringBytes ) ;
174
- }
175
- else
176
- {
177
- return _value . GetHashCode ( ) ;
178
- }
171
+ return ReadOnlyMemoryOfByteEqualityComparer . CalculateHashCode ( _stringBytes ) ;
179
172
}
180
173
181
174
public int CompareTo ( AmqpString other )
182
175
{
183
- if ( _value == null )
176
+ if ( _value is null || other . _value is null )
184
177
{
185
178
return GetHashCode ( ) . CompareTo ( other . GetHashCode ( ) ) ;
186
179
}
Original file line number Diff line number Diff line change 36
36
namespace RabbitMQ . Client
37
37
{
38
38
/// <summary>
39
- /// Convenience struct providing compile-time names for standard exchange types.
39
+ /// Convenience class providing compile-time names for standard exchange types.
40
40
/// </summary>
41
41
/// <remarks>
42
42
/// Use the static members of this class as values for the
Original file line number Diff line number Diff line change @@ -140,5 +140,19 @@ public void TestEqualityWhenUsingReadOnlyMemoryOfByte()
140
140
var ex2 = new ExchangeName ( b2 ) ;
141
141
Assert . Equal ( ex1 , ex2 ) ;
142
142
}
143
+
144
+ [ Fact ]
145
+ public void TestEqualityWhenUsingMixOfReadOnlyMemoryOfByteAndString ( )
146
+ {
147
+ ReadOnlyMemory < byte > b1 = new byte [ ] { ( byte ) 'f' , ( byte ) 'o' , ( byte ) 'o' } ;
148
+ var ex1 = new ExchangeName ( b1 ) ;
149
+
150
+ string b2str = "foo" ;
151
+ var ex2 = new ExchangeName ( b2str ) ;
152
+
153
+ Assert . Equal ( ex1 , ex2 ) ;
154
+ Assert . Equal ( ex1 , b2str ) ;
155
+ Assert . Equal ( ex2 , b2str ) ;
156
+ }
143
157
}
144
158
}
You can’t perform that action at this time.
0 commit comments