1- #pragma warning disable CS1591
2-
3- using System ;
1+ using System ;
42using System . Collections ;
53using System . Collections . Generic ;
6- using System . Diagnostics . Contracts ;
74using System . Linq ;
85using System . Reflection ;
96
129// no namespace.
1310
1411[ System . Diagnostics . DebuggerStepThroughAttribute ]
15- [ ContractVerification ( false ) ]
1612public static partial class ChainingAssertion
1713{
1814 /// <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
219215 if ( ! r . IsEquals )
220216 {
221217 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 ) ;
223219 throw new AssertionException ( msg , message ) ;
224220 }
225221 }
@@ -318,9 +314,9 @@ static EqualInfo StructuralEqual(object left, object right, IEnumerable<string>
318314 // is object
319315 var fields = left . GetType ( ) . GetFields ( BindingFlags . Instance | BindingFlags . Public ) ;
320316 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 > ( ) ) ;
322318
323- foreach ( var mi in fields . Cast < MemberInfo > ( ) . Concat ( properties ) )
319+ foreach ( var mi in members )
324320 {
325321 var concatNames = names . Concat ( new [ ] { ( string ) mi . Name } ) ;
326322
@@ -336,8 +332,8 @@ static EqualInfo StructuralEqual(object left, object right, IEnumerable<string>
336332 else
337333 {
338334 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 ) ;
341337 }
342338
343339 var result = StructuralEqual ( lv , rv , concatNames ) ;
0 commit comments