Fix pragma warning restore (dotnet/coreclr#26389)
[mono-project.git] / netcore / System.Private.CoreLib / shared / System / Guid.Windows.cs
blob5947cea46184bfc2fe3d15e1999d173588b0949a
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 namespace System
7 public partial struct Guid
9 public static Guid NewGuid()
11 // CoCreateGuid should never return Guid.Empty, since it attempts to maintain some
12 // uniqueness guarantees.
14 Guid g;
15 int hr = Interop.Ole32.CoCreateGuid(out g);
16 // We don't expect that this will ever throw an error, none are even documented, and so we don't want to pull
17 // in the HR to ComException mappings into the core library just for this so we will try a generic exception if
18 // we ever hit this condition.
19 if (hr != 0)
21 Exception ex = new Exception();
22 ex.HResult = hr;
23 throw ex;
25 return g;