File: Windows.Win32.HRESULT.g.cs
Project: src\src\Servers\IIS\IIS\src\Microsoft.AspNetCore.Server.IIS.csproj (Microsoft.AspNetCore.Server.IIS)
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------

#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
using global::System;
using global::System.Diagnostics;
using global::System.Diagnostics.CodeAnalysis;
using global::System.Runtime.CompilerServices;
using global::System.Runtime.InteropServices;
using global::System.Runtime.Versioning;
using winmdroot = global::Windows.Win32;
namespace Windows.Win32
{
	namespace Foundation
	{
		/// <remarks>
		/// <para>The **HRESULT** data type is the same as the [SCODE](scode.md) data type. An **HRESULT** value consists of the following fields: - A 1-bit code indicating severity, where zero represents success and 1 represents failure. - A 4-bit reserved value. - An 11-bit code indicating responsibility for the error or warning, also known as a facility code. - A 16-bit code describing the error or warning. Most MAPI interface methods and functions return **HRESULT** values to provide detailed cause formation. **HRESULT** values are also used widely in OLE interface methods. OLE provides several macros for converting between **HRESULT** values and **SCODE** values, another common data type for error handling. > [!NOTE] > In 64-bit MAPI, **HRESULT** is still a 32-bit value. For information about the OLE use of **HRESULT** values, see the  *OLE Programmer's Reference*. For more information about the use of these values in MAPI, see [Error Handling](error-handling-in-mapi.md) and any of the following interface methods: [IABLogon::GetLastError](iablogon-getlasterror.md) [IMAPISupport::GetLastError](imapisupport-getlasterror.md) [IMAPIControl::GetLastError](imapicontrol-getlasterror.md) [IMAPITable::GetLastError](imapitable-getlasterror.md) [IMAPIProp::GetLastError](imapiprop-getlasterror.md) [IMAPIViewAdviseSink::OnPrint](imapiviewadvisesink-onprint.md)</para>
		/// <para><see href="https://learn.microsoft.com/office/client-developer/outlook/mapi/hresult#">Read more on docs.microsoft.com</see>.</para>
		/// </remarks>
		[DebuggerDisplay("{Value}")]
		[global::System.CodeDom.Compiler.GeneratedCode("Microsoft.Windows.CsWin32", "0.3.46-beta+dd815b2b9b")]
		internal readonly partial struct HRESULT
			: IEquatable<HRESULT>
		{
			internal readonly int Value;

			internal HRESULT(int value) => this.Value = value;

			public static implicit operator int(HRESULT value) => value.Value;

			public static explicit operator HRESULT(int value) => new HRESULT(value);

			public static bool operator ==(HRESULT left, HRESULT right) => left.Value == right.Value;

			public static bool operator !=(HRESULT left, HRESULT right) => !(left == right);

			public bool Equals(HRESULT other) => this.Value == other.Value;

			public override bool Equals(object obj) => obj is HRESULT other && this.Equals(other);

			public override int GetHashCode() => this.Value.GetHashCode();


			public override string ToString() => string.Format(global::System.Globalization.CultureInfo.InvariantCulture, "0x{0:X8}", this.Value);

			public static implicit operator uint(HRESULT value) => (uint)value.Value;

			public static explicit operator HRESULT(uint value) => new HRESULT((int)value);


			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			internal bool Succeeded => this.Value >= 0;


			[DebuggerBrowsable(DebuggerBrowsableState.Never)]
			internal bool Failed => this.Value < 0;


			/// <inheritdoc cref="Marshal.ThrowExceptionForHR(int, IntPtr)" />
			/// <param name="errorInfo">
			/// A pointer to the IErrorInfo interface that provides more information about the
			/// error. You can specify <see cref="IntPtr.Zero"/> to use the current IErrorInfo interface, or
			/// <c>new IntPtr(-1)</c> to ignore the current IErrorInfo interface and construct the exception
			/// just from the error code.
			/// </param>
			/// <returns><see langword="this"/> <see cref="HRESULT"/>, if it does not reflect an error.</returns>
			/// <seealso cref="Marshal.ThrowExceptionForHR(int, IntPtr)"/>
			internal HRESULT ThrowOnFailure(IntPtr errorInfo = default)

			{
				Marshal.ThrowExceptionForHR(this.Value, errorInfo);
				return this;
			}


			internal string ToString(string format, IFormatProvider formatProvider) => ((uint)this.Value).ToString(format, formatProvider);
		}
	}
}