Open GoogleCodeExporter opened 9 years ago
public class Foo
{
private string _str; // -)
public Foo(string str)
{
_str = str;
}
}
Original comment by brokenpi...@gmail.com
on 22 Nov 2012 at 2:16
I've submitted a patch upstream which allows access to private and protected
members when you create a type accessor like:
var accessor = TypeAccessor.Create(typeof(yourClass), true);
The patchset is attached to this comment.
Original comment by ghes...@chaosink.co.uk
on 10 Jan 2014 at 11:04
Attachments:
I applied the patch and I still only get public members returned.
If you look in MemberSet.cs @ 16, it makes sense because type.GetFields() only
returns public members if there are no arguments.
Adding:
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance
to the arguments of that method call does seem to work.
Original comment by stefanlu...@gmail.com
on 6 Feb 2015 at 3:50
Oh well, that didn't work either. Apparantly you can't access private fields,
you'll get an exception if you try. See here:
http://stackoverflow.com/questions/6356371/help-needed-with-typeaccessexception-
attempt-by-method-to-access-type-f
Original comment by stefanlu...@gmail.com
on 6 Feb 2015 at 5:08
Original issue reported on code.google.com by
brokenpi...@gmail.com
on 22 Nov 2012 at 2:15