If by "exact state of the object" you simply mean all the instance fields it contains (if not, can you clarify?), then you should be able to do it with a single statement -- there's no significant difference between fields you declare explicitly, and backing fields for auto-properties that the compiler adds for you. If you define a class:
public class FieldInfoTest
{
private string testField;
public string TestProperty { get; set; }
}
...you can access them all in one fell swoop with
FieldInfo[] fields = typeof(FieldInfoTest).GetFields(BindingFlags.Instance |
BindingFlags.Public |
BindingFlags.NonPublic);
foreach (var f in fields)
{
Console.WriteLine(f.Name);
}
This will yield:
testField
<TestProperty>k__BackingField