Skip to content

Commit

Permalink
Merge pull request #326 from tannergooding/main
Browse files Browse the repository at this point in the history
Adding `unchecked` to a few more places involving pointers
  • Loading branch information
tannergooding authored Aug 27, 2022
2 parents 1ae292b + c8352f8 commit 57abf25
Show file tree
Hide file tree
Showing 131 changed files with 1,241 additions and 1,242 deletions.
1 change: 0 additions & 1 deletion sources/Interop/Windows/DirectX/um/d2d1_2/DirectX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ public static unsafe partial class DirectX
/// <include file='DirectX.xml' path='doc/member[@name="DirectX.D2D1ComputeMaximumScaleFactor"]/*' />
[DllImport("d2d1", ExactSpelling = true)]
[SupportedOSPlatform("windows6.3")]
[SuppressGCTransition]
public static extern float D2D1ComputeMaximumScaleFactor([NativeTypeName("const D2D1_MATRIX_3X2_F *")] D2D_MATRIX_3X2_F* matrix);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,43 @@ public APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(void* value)

public static implicit operator HANDLE(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => new HANDLE(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(byte value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(byte value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static explicit operator byte(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (byte)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(short value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(short value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static explicit operator short(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (short)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(int value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(int value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static explicit operator int(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (int)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(long value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(long value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static explicit operator long(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (long)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(nint value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(nint value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static implicit operator nint(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (nint)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(sbyte value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(sbyte value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static explicit operator sbyte(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (sbyte)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(ushort value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(ushort value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static explicit operator ushort(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (ushort)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(uint value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(uint value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static explicit operator uint(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (uint)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(ulong value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(ulong value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static explicit operator ulong(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (ulong)(value.Value);

public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(nuint value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE((void*)(value));
public static explicit operator APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(nuint value) => new APARTMENT_SHUTDOWN_REGISTRATION_COOKIE(unchecked((void*)(value)));

public static implicit operator nuint(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE value) => (nuint)(value.Value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,43 @@ public ASYNCCOMPLETIONHANDLE(void* value)

public static implicit operator void*(ASYNCCOMPLETIONHANDLE value) => value.Value;

public static explicit operator ASYNCCOMPLETIONHANDLE(byte value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(byte value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static explicit operator byte(ASYNCCOMPLETIONHANDLE value) => (byte)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(short value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(short value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static explicit operator short(ASYNCCOMPLETIONHANDLE value) => (short)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(int value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(int value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static explicit operator int(ASYNCCOMPLETIONHANDLE value) => (int)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(long value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(long value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static explicit operator long(ASYNCCOMPLETIONHANDLE value) => (long)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(nint value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(nint value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static implicit operator nint(ASYNCCOMPLETIONHANDLE value) => (nint)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(sbyte value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(sbyte value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static explicit operator sbyte(ASYNCCOMPLETIONHANDLE value) => (sbyte)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(ushort value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(ushort value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static explicit operator ushort(ASYNCCOMPLETIONHANDLE value) => (ushort)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(uint value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(uint value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static explicit operator uint(ASYNCCOMPLETIONHANDLE value) => (uint)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(ulong value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(ulong value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static explicit operator ulong(ASYNCCOMPLETIONHANDLE value) => (ulong)(value.Value);

public static explicit operator ASYNCCOMPLETIONHANDLE(nuint value) => new ASYNCCOMPLETIONHANDLE((void*)(value));
public static explicit operator ASYNCCOMPLETIONHANDLE(nuint value) => new ASYNCCOMPLETIONHANDLE(unchecked((void*)(value)));

public static implicit operator nuint(ASYNCCOMPLETIONHANDLE value) => (nuint)(value.Value);

Expand Down
10 changes: 5 additions & 5 deletions sources/Interop/Windows/Windows/other/helper-types/BOOL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public BOOL(int value)

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

public static explicit operator BOOL(long value) => new BOOL((int)(value));
public static explicit operator BOOL(long value) => new BOOL(unchecked((int)(value)));

public static implicit operator long(BOOL value) => value.Value;

public static explicit operator BOOL(nint value) => new BOOL((int)(value));
public static explicit operator BOOL(nint value) => new BOOL(unchecked((int)(value)));

public static implicit operator nint(BOOL value) => value.Value;

Expand All @@ -65,15 +65,15 @@ public BOOL(int value)

public static explicit operator ushort(BOOL value) => (ushort)(value.Value);

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

public static explicit operator uint(BOOL value) => (uint)(value.Value);

public static explicit operator BOOL(ulong value) => new BOOL((int)(value));
public static explicit operator BOOL(ulong value) => new BOOL(unchecked((int)(value)));

public static explicit operator ulong(BOOL value) => (ulong)(value.Value);

public static explicit operator BOOL(nuint value) => new BOOL((int)(value));
public static explicit operator BOOL(nuint value) => new BOOL(unchecked((int)(value)));

public static explicit operator nuint(BOOL value) => (nuint)(value.Value);

Expand Down
14 changes: 7 additions & 7 deletions sources/Interop/Windows/Windows/other/helper-types/COLORREF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ public COLORREF(uint value)

public static explicit operator byte(COLORREF value) => (byte)(value.Value);

public static explicit operator COLORREF(short value) => new COLORREF((uint)(value));
public static explicit operator COLORREF(short value) => new COLORREF(unchecked((uint)(value)));

public static explicit operator short(COLORREF value) => (short)(value.Value);

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

public static explicit operator int(COLORREF value) => (int)(value.Value);

public static explicit operator COLORREF(long value) => new COLORREF((uint)(value));
public static explicit operator COLORREF(long value) => new COLORREF(unchecked((uint)(value)));

public static implicit operator long(COLORREF value) => value.Value;

public static explicit operator COLORREF(nint value) => new COLORREF((uint)(value));
public static explicit operator COLORREF(nint value) => new COLORREF(unchecked((uint)(value)));

public static explicit operator nint(COLORREF value) => (nint)(value.Value);

public static explicit operator COLORREF(sbyte value) => new COLORREF((uint)(value));
public static explicit operator COLORREF(sbyte value) => new COLORREF(unchecked((uint)(value)));

public static explicit operator sbyte(COLORREF value) => (sbyte)(value.Value);

Expand All @@ -57,11 +57,11 @@ public COLORREF(uint value)

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

public static explicit operator COLORREF(ulong value) => new COLORREF((uint)(value));
public static explicit operator COLORREF(ulong value) => new COLORREF(unchecked((uint)(value)));

public static implicit operator ulong(COLORREF value) => value.Value;

public static explicit operator COLORREF(nuint value) => new COLORREF((uint)(value));
public static explicit operator COLORREF(nuint value) => new COLORREF(unchecked((uint)(value)));

public static implicit operator nuint(COLORREF value) => value.Value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,43 @@ public COMPRESSOR_HANDLE(void* value)

public static implicit operator HANDLE(COMPRESSOR_HANDLE value) => new HANDLE(value.Value);

public static explicit operator COMPRESSOR_HANDLE(byte value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(byte value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static explicit operator byte(COMPRESSOR_HANDLE value) => (byte)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(short value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(short value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static explicit operator short(COMPRESSOR_HANDLE value) => (short)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(int value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(int value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static explicit operator int(COMPRESSOR_HANDLE value) => (int)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(long value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(long value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static explicit operator long(COMPRESSOR_HANDLE value) => (long)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(nint value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(nint value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static implicit operator nint(COMPRESSOR_HANDLE value) => (nint)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(sbyte value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(sbyte value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static explicit operator sbyte(COMPRESSOR_HANDLE value) => (sbyte)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(ushort value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(ushort value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static explicit operator ushort(COMPRESSOR_HANDLE value) => (ushort)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(uint value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(uint value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static explicit operator uint(COMPRESSOR_HANDLE value) => (uint)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(ulong value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(ulong value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static explicit operator ulong(COMPRESSOR_HANDLE value) => (ulong)(value.Value);

public static explicit operator COMPRESSOR_HANDLE(nuint value) => new COMPRESSOR_HANDLE((void*)(value));
public static explicit operator COMPRESSOR_HANDLE(nuint value) => new COMPRESSOR_HANDLE(unchecked((void*)(value)));

public static implicit operator nuint(COMPRESSOR_HANDLE value) => (nuint)(value.Value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,43 @@ public CO_DEVICE_CATALOG_COOKIE(void* value)

public static implicit operator HANDLE(CO_DEVICE_CATALOG_COOKIE value) => new HANDLE(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(byte value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(byte value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static explicit operator byte(CO_DEVICE_CATALOG_COOKIE value) => (byte)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(short value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(short value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static explicit operator short(CO_DEVICE_CATALOG_COOKIE value) => (short)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(int value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(int value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static explicit operator int(CO_DEVICE_CATALOG_COOKIE value) => (int)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(long value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(long value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static explicit operator long(CO_DEVICE_CATALOG_COOKIE value) => (long)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(nint value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(nint value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static implicit operator nint(CO_DEVICE_CATALOG_COOKIE value) => (nint)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(sbyte value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(sbyte value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static explicit operator sbyte(CO_DEVICE_CATALOG_COOKIE value) => (sbyte)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(ushort value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(ushort value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static explicit operator ushort(CO_DEVICE_CATALOG_COOKIE value) => (ushort)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(uint value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(uint value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static explicit operator uint(CO_DEVICE_CATALOG_COOKIE value) => (uint)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(ulong value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(ulong value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static explicit operator ulong(CO_DEVICE_CATALOG_COOKIE value) => (ulong)(value.Value);

public static explicit operator CO_DEVICE_CATALOG_COOKIE(nuint value) => new CO_DEVICE_CATALOG_COOKIE((void*)(value));
public static explicit operator CO_DEVICE_CATALOG_COOKIE(nuint value) => new CO_DEVICE_CATALOG_COOKIE(unchecked((void*)(value)));

public static implicit operator nuint(CO_DEVICE_CATALOG_COOKIE value) => (nuint)(value.Value);

Expand Down
Loading

0 comments on commit 57abf25

Please sign in to comment.