Skip to content

Commit

Permalink
Update CsWin32 version
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyKuhne committed Nov 20, 2024
1 parent c54532b commit 891f9bd
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/thirtytwo/DeviceContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public unsafe void Dispose()
}

public static implicit operator HDC(DeviceContext context) => context.Handle;
public static unsafe explicit operator DeviceContext(WPARAM wparam) => Create(new(new(wparam)));
public static unsafe explicit operator DeviceContext(WPARAM wparam) => Create(new((nint)wparam));

[Flags]
private enum ContextState
Expand Down
2 changes: 1 addition & 1 deletion src/thirtytwo/Wdk/Interop.NtQueryKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Runtime.InteropServices;
using Windows.Wdk.System.SystemServices;
using Windows.Wdk.System.Registry;
using Windows.Win32.System.Registry;

namespace Windows.Wdk;
Expand Down
2 changes: 1 addition & 1 deletion src/thirtytwo/Win32/Foundation/HANDLE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Windows.Win32.Foundation;
{
public unsafe void Dispose()
{
if (Value != 0 && Value != -1)
if ((nint)Value != 0 && (nint)Value != -1)
{
Interop.CloseHandle(this).ThrowLastErrorIfFalse();
}
Expand Down
10 changes: 10 additions & 0 deletions src/thirtytwo/Win32/Foundation/LRESULT.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Jeremy W. Kuhne. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Windows.Win32.Foundation;

public unsafe readonly partial struct LRESULT
{
public static explicit operator void*(LRESULT value) => (void*)value.Value;
public static explicit operator LRESULT(void* value) => new((nint)value);
}
6 changes: 3 additions & 3 deletions src/thirtytwo/Win32/Foundation/WPARAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

namespace Windows.Win32.Foundation;

public readonly partial struct WPARAM
public unsafe readonly partial struct WPARAM
{
public static unsafe implicit operator void*(WPARAM value) => (void*)value.Value;
public static unsafe implicit operator WPARAM(void* value) => new((nuint)value);
public static implicit operator void*(WPARAM value) => (void*)value.Value;
public static implicit operator WPARAM(void* value) => new((nuint)value);

public static explicit operator HWND(WPARAM value) => (HWND)(nint)value.Value;
public static explicit operator WPARAM(HWND value) => new((nuint)value.Value);
Expand Down
2 changes: 1 addition & 1 deletion src/thirtytwo/Win32/Graphics/Gdi/HBRUSH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static explicit operator HBRUSH(HGDIOBJ handle)

public void Dispose()
{
if (Value != 0 && Value != -1)
if ((nint)Value != 0 && (nint)Value != -1)
{
Interop.DeleteObject(this);
Unsafe.AsRef(in this) = default;
Expand Down
4 changes: 1 addition & 3 deletions src/thirtytwo/Win32/Graphics/Gdi/HDC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

namespace Windows.Win32.Graphics.Gdi;

public partial struct HDC : IHandle<HDC>
public unsafe partial struct HDC : IHandle<HDC>
{
HDC IHandle<HDC>.Handle => this;
object? IHandle<HDC>.Wrapper => null;

public bool IsNull => Value == 0;

public static explicit operator HDC(HGDIOBJ handle)
{
Debug.Assert(handle.IsNull || (OBJ_TYPE)Interop.GetObjectType(handle) == OBJ_TYPE.OBJ_DC);
Expand Down
10 changes: 5 additions & 5 deletions src/thirtytwo/Win32/Graphics/Gdi/HGDIOBJ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public unsafe partial struct HGDIOBJ
{
public OBJ_TYPE GetObjectType() => (OBJ_TYPE)Interop.GetObjectType(this);

public static implicit operator HGDIOBJ(StockFont font) => new(Interop.GetStockObject((GET_STOCK_OBJECT_FLAGS)font));
public static implicit operator HGDIOBJ(StockBrush brush) => new(Interop.GetStockObject((GET_STOCK_OBJECT_FLAGS)brush));
public static implicit operator HGDIOBJ(SystemColor color) => new(Interop.GetStockObject((GET_STOCK_OBJECT_FLAGS)color));
public static implicit operator HGDIOBJ(StockPen pen) => new(Interop.GetStockObject((GET_STOCK_OBJECT_FLAGS)pen));
public static implicit operator HGDIOBJ(GET_STOCK_OBJECT_FLAGS stockObject) => new(Interop.GetStockObject(stockObject));
public static implicit operator HGDIOBJ(StockFont font) => new((nint)Interop.GetStockObject((GET_STOCK_OBJECT_FLAGS)font));
public static implicit operator HGDIOBJ(StockBrush brush) => new((nint)Interop.GetStockObject((GET_STOCK_OBJECT_FLAGS)brush));
public static implicit operator HGDIOBJ(SystemColor color) => new((nint)Interop.GetStockObject((GET_STOCK_OBJECT_FLAGS)color));
public static implicit operator HGDIOBJ(StockPen pen) => new((nint)Interop.GetStockObject((GET_STOCK_OBJECT_FLAGS)pen));
public static implicit operator HGDIOBJ(GET_STOCK_OBJECT_FLAGS stockObject) => new((nint)Interop.GetStockObject(stockObject));
}
2 changes: 1 addition & 1 deletion src/thirtytwo/Win32/Graphics/Gdi/HPEN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static explicit operator HPEN(HGDIOBJ handle)

public void Dispose()
{
if (Value != 0 && Value != -1)
if ((nint)Value != 0 && (nint)Value != -1)
{
Interop.DeleteObject(this);
Unsafe.AsRef(in this) = default;
Expand Down
2 changes: 1 addition & 1 deletion src/thirtytwo/Win32/Graphics/Gdi/HRGN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Dispose()
/// <summary>
/// Special <see cref="HRGN"/> sent during WM_NCPAINT to indicate the entire window.
/// </summary>
public static HRGN Full { get; } = (HRGN)1;
public static HRGN Full { get; } = (HRGN)(nint)1;

/// <summary>
/// Is special <see cref="HRGN.Full"/> value.
Expand Down
6 changes: 3 additions & 3 deletions src/thirtytwo/Win32/System/Registry/HKEY.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Windows.Win32.System.Registry;

public partial struct HKEY : IDisposable
public unsafe partial struct HKEY : IDisposable
{
private const uint REMOTE_HANDLE_TAG = 0x00000001;
private const uint REG_CLASSES_SPECIAL_TAG = 0x00000002;
Expand All @@ -16,13 +16,13 @@ public bool IsPerfKey()
/// <summary>
/// Returns true if the key is from the local machine.
/// </summary>
public bool IsLocalKey => (Value & REMOTE_HANDLE_TAG) == 0;
public bool IsLocalKey => ((nuint)Value & REMOTE_HANDLE_TAG) == 0;

/// <summary>
/// Returns true if the key is special (notably in <see cref="HKEY.HKEY_CLASSES_ROOT"/>, where
/// it might be redirected to per user settings).
/// </summary>
public bool IsSpecialKey => (Value & REG_CLASSES_SPECIAL_TAG) != 0;
public bool IsSpecialKey => ((nuint)Value & REG_CLASSES_SPECIAL_TAG) != 0;

public void Dispose()
{
Expand Down
1 change: 1 addition & 0 deletions src/thirtytwo/Win32/System/Registry/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Buffers.Binary;
using System.Runtime.InteropServices;
using Windows.Support;
using Windows.Wdk.System.Registry;
using Windows.Wdk.System.SystemServices;

namespace Windows.Win32.System.Registry;
Expand Down
9 changes: 0 additions & 9 deletions src/thirtytwo/Win32/UI/HiDpi/DPI_AWARENESS_CONTEXT.cs

This file was deleted.

8 changes: 6 additions & 2 deletions src/thirtytwo/thirtytwo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.106">
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.151">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="Win32\UI\HiDpi\" />
</ItemGroup>

</Project>

0 comments on commit 891f9bd

Please sign in to comment.