Guid.NewGuid(); behind the scenes in .NET Core

♀尐吖头ヾ 提交于 2020-01-22 20:12:06

问题


Researching the subject yesterday, I found several interesting questions (such as this one) on how GUIDs are ultimately generated. In brief; it seems that Guid.NewGuid(); calls CoCreateGuid in the COM, which in turn calls UuidCreate in the Windows RPC (docs here and here).

I found myself wondering; How does this work when the OS is not Windows, such as might be the case with .NET Core, and does this affect the 'version' algorithm used to generate the GUID (which I understand is Version 4 on Windows)?


回答1:


On non-windows machines, .NET Core will use either uuid_create on BSD (which is "version 1") or libuuid's uuid_generate_random function on macOS and linux ("version 4").

The implementation for the replacement CoCreateGuid function can be found in CoreCLR's source code on GitHub.



来源:https://stackoverflow.com/questions/44924804/guid-newguid-behind-the-scenes-in-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!