[cs] fix DynamicObject setField

see #2528

i also cherry-picked commit from #2515 that re-enables TestCSharp, because it's not merged yet and I wanted to add this test case to make sure it won't be broken again.