In our application, we need a way to uniquely identify reflection metadata objects in C#. Reflection API has a MemberInfo.MetadataToken property, which is documented to fulfil this task. However, what isn't documented, is whether this token will be the same after the next build of the same module, given that module name, namespace, declaring type name, and member name are unchanged.
Does anyone know about the details of implementation of this?
Thanks! Mirko
No, they won't be. The metadata token value is dependant on everything else in the assembly, and the exact order which the compiler generates types in the output assembly. If the input code or project changes in any way whatsoever, then all the tokens could change.
Why do you need to do this?