为什么GUID属性需要摆在首位?首位、属性、GUID

2023-09-02 23:44:58 作者:穷小子 #

什么是必要的GUID属性?为什么不只是让编译程序自动处理这个?!

What is the necessity for the GUID attribute? why don't just let the compiler handle this automatically?!

推荐答案

如果编译器自动处理这一点,你会落得两种情况之一。

If the compiler handled this automatically, you'd end up with one of two situations.

一个新的GUID每次编译 - 因为GUID的都应该公布,这将失败

A new GUID every time you compiled - since GUIDs are supposed to be published, this would fail.

碰撞 - 如果GUID是相同的每一次,基于名称的(说)一个Hash,多个项目最终将使用相同​​的GUID用于不同的目的。

Collisions - if the GUID was the same every time, based on (say) a Hash of the name, multiple projects would end up using the same GUID for different purposes.

现有的方法 - 一个明确的GUID使开发人员根据需要控制这些电力

The existing approach - an explicit GUID gives developers the power to control these as required.