You should get TypeDefinition
for Foo
from the ModuleDefinition.Types
, and in turn get PropertyDefinition
for Foo
from the TypeDefinition.Properties
. And later you can get the set method and its instructions.
Don't use any of the constructors, as they are used to build new metadata, not analyze existing. Calling them in your code in fact builds new references/definitions, and exceptions are expected as you did not build them correctly.