1
- #pragma warning disable CS1591
2
-
3
- using System ;
1
+ using System ;
4
2
using System . Collections ;
5
3
using System . Collections . Generic ;
6
- using System . Diagnostics . Contracts ;
7
4
using System . Linq ;
8
5
using System . Reflection ;
9
6
12
9
// no namespace.
13
10
14
11
[ System . Diagnostics . DebuggerStepThroughAttribute ]
15
- [ ContractVerification ( false ) ]
16
12
public static partial class ChainingAssertion
17
13
{
18
14
/// <summary>Assert.AreEqual, if T is IEnumerable then CollectionAssert.AreEqual</summary>
@@ -219,7 +215,7 @@ public static void IsStructuralEqual(this object actual, object expected, string
219
215
if ( ! r . IsEquals )
220
216
{
221
217
var msg = string . Format ( "is not structural equal, failed at {0}, actual = {1} expected = {2}" ,
222
- string . Join ( "." , r . Names ) , r . Left , r . Right ) ;
218
+ string . Join ( "." , r . Names . ToArray ( ) ) , r . Left , r . Right ) ;
223
219
throw new AssertionException ( msg , message ) ;
224
220
}
225
221
}
@@ -318,9 +314,9 @@ static EqualInfo StructuralEqual(object left, object right, IEnumerable<string>
318
314
// is object
319
315
var fields = left . GetType ( ) . GetFields ( BindingFlags . Instance | BindingFlags . Public ) ;
320
316
var properties = left . GetType ( ) . GetProperties ( BindingFlags . Instance | BindingFlags . Public ) . Where ( x => x . GetGetMethod ( false ) != null ) ;
321
- var members = fields . Cast < MemberInfo > ( ) . Concat ( properties ) ;
317
+ var members = fields . Cast < MemberInfo > ( ) . Concat ( properties . Cast < MemberInfo > ( ) ) ;
322
318
323
- foreach ( var mi in fields . Cast < MemberInfo > ( ) . Concat ( properties ) )
319
+ foreach ( var mi in members )
324
320
{
325
321
var concatNames = names . Concat ( new [ ] { ( string ) mi . Name } ) ;
326
322
@@ -336,8 +332,8 @@ static EqualInfo StructuralEqual(object left, object right, IEnumerable<string>
336
332
else
337
333
{
338
334
var i = mi as PropertyInfo ;
339
- lv = i . GetValue ( left ) ;
340
- rv = i . GetValue ( right ) ;
335
+ lv = i . GetValue ( left , null ) ;
336
+ rv = i . GetValue ( right , null ) ;
341
337
}
342
338
343
339
var result = StructuralEqual ( lv , rv , concatNames ) ;
0 commit comments