takekazuomi / fast-member

Automatically exported from code.google.com/p/fast-member
0 stars 0 forks source link

Nicer error message when ArgumentOutOfRangeException exceptions are thrown #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If you change the code from 

il.Emit(OpCodes.Ldstr, "name");
il.Emit(OpCodes.Newobj, typeof(ArgumentOutOfRangeException).GetConstructor(new 
Type[] { typeof(string) }));
il.Emit(OpCodes.Throw);

To this:

il.Emit(OpCodes.Ldarg, 2);
il.Emit(OpCodes.Newobj, typeof(ArgumentOutOfRangeException).GetConstructor(new 
Type[] { typeof(string) }));
il.Emit(OpCodes.Throw);

It'll shown you the actual Argument name that is causing the issue, at the 
moment it just says the parameter name is "name"

This could be changed here 
http://code.google.com/p/fast-member/source/browse/FastMember/TypeAccessor.cs#11
3 and 
http://code.google.com/p/fast-member/source/browse/FastMember/TypeAccessor.cs#16
8 and 

Original issue reported on code.google.com by mattd...@gmail.com on 2 May 2012 at 5:00

GoogleCodeExporter commented 9 years ago
sddh

Original comment by tzg...@gmail.com on 16 Aug 2014 at 2:06