How are .NET 4 GUIDs generated?

后端 未结 2 2065
小鲜肉
小鲜肉 2020-11-27 17:34

I am aware of the multitude of questions here as well as Raymond\'s excellent (as usual) post. However, since the algorithm to create GUIDs was changed apparently, I found i

2条回答
  •  佛祖请我去吃肉
    2020-11-27 18:08

    Yes, there was a change in .NET 4.0, Guid.NewGuid() directly calls CoCreateGuid(), a small wrapper around UuidCreate(). Previous versions of .NET called a helper function in the CLR, GuidNative::CompleteGuid(). Which calls CoCreateGuid. Not sure why this change was made, smells like nothing more than a minor optimization.

    At any rate, the exact same Windows function generates the Guid, the algorithm has been the same for the past 10 years, it is as reliable as it ever was.

提交回复
热议问题