MemberInfo.MetadataToken 在编译器运行中是否稳定?
在我们的应用程序中,我们需要一种方法来唯一标识 C# 中的反射元数据对象。 反射 API 有一个 MemberInfo.MetadataToken
属性,该属性已记录为完成此任务。 然而,没有记录的是,在模块名称、命名空间、声明类型名称和成员名称不变的情况下,在同一模块的下一次构建之后,该标记是否相同。
有谁知道这个的实施细节吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,他们不会。元数据标记值取决于程序集中的其他所有内容,以及编译器在输出程序集中生成类型的确切顺序。如果输入代码或项目以任何方式发生变化,那么所有令牌都可能发生变化。
为什么需要这样做?
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?