Are automatically generated GUIDs for types in .NET consistent?

后端 未结 2 584
暗喜
暗喜 2020-12-05 23:43

Are the automatically generated GUIDs for C# Types consistent? For example, if I get a GUID for my interface, IFoo (typeof(IFoo).GUID), the first time a run the

相关标签:
2条回答
  • 2020-12-06 00:19

    See: System.Type.GUID stability. It appears that the current implementation of the method relies an internal call that is implemented by the CLR itself. Unless Microsoft clarifies the contracts for the auto-generated Guids (the Type.GUID documentation is currently silent on this issue), I wouldn't rely on the observed behaviour. To be sure about consistency, I recommend explicitly decorating the types in question with the GuidAttribute.

    0 讨论(0)
  • 2020-12-06 00:45

    It's not documented so i wouldn't completly rely on them, said that the implementation may or may not change in the future.

    0 讨论(0)
提交回复
热议问题