Various improvements and cleanups.

This commit is contained in:
Amer Koleci
2022-12-01 14:15:47 +01:00
parent 3ca1ac082d
commit b04caed143
20 changed files with 63 additions and 73 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>Direct2D1 bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>DXC bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>FXC bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>Direct3D11 bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>Direct3D11on12 bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>Direct3D12 bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>DirectComposition bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>DirectWrite bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -0,0 +1,12 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
namespace Win32.Graphics.Dxgi;
unsafe partial class Apis
{
public static HResult CreateDXGIFactory2(bool debug, Guid* riid, void** ppFactory)
{
return CreateDXGIFactory2(debug ? DXGI_CREATE_FACTORY_DEBUG : 0u, riid, ppFactory);
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>Dxgi bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>

View File

@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<Description>DXC bindings.</Description>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>WIC bindings.</Description>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>
</PropertyGroup>

View File

@@ -1,10 +1,6 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.ComTypes;
namespace Win32.Com;
[Guid("3127CA40-446E-11CE-8135-00AA004BB851")]

View File

@@ -41,20 +41,32 @@ public unsafe partial struct IUnknown : INativeGuid
[VtblIndex(0)]
public HResult QueryInterface(Guid* riid, void** ppvObject)
{
#if NET6_0_OR_GREATER
return ((delegate* unmanaged<IUnknown*, Guid*, void**, int>)(lpVtbl[0]))((IUnknown*)Unsafe.AsPointer(ref this), riid, ppvObject);
#else
return ((delegate* unmanaged[Stdcall]<IUnknown*, Guid*, void**, int>)(lpVtbl[0]))((IUnknown*)Unsafe.AsPointer(ref this), riid, ppvObject);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(1)]
public uint AddRef()
{
#if NET6_0_OR_GREATER
return ((delegate* unmanaged<IUnknown*, uint>)(lpVtbl[1]))((IUnknown*)Unsafe.AsPointer(ref this));
#else
return ((delegate* unmanaged[Stdcall]<IUnknown*, uint>)(lpVtbl[1]))((IUnknown*)Unsafe.AsPointer(ref this));
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(2)]
public uint Release()
{
#if NET6_0_OR_GREATER
return ((delegate* unmanaged<IUnknown*, uint>)(lpVtbl[2]))((IUnknown*)Unsafe.AsPointer(ref this));
#else
return ((delegate* unmanaged[Stdcall]<IUnknown*, uint>)(lpVtbl[2]))((IUnknown*)Unsafe.AsPointer(ref this));
#endif
}
}

View File

@@ -1,13 +1,6 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
#if NETSTANDARD2_0
using MemoryMarshal = Win32.MemoryMarshal;
#endif
namespace Win32;
[StructLayout(LayoutKind.Explicit)]
@@ -18,7 +11,6 @@ public partial struct LargeInteger
public _Anonymous_e__Struct Anonymous;
[FieldOffset(0)]
[NativeTypeName("struct (anonymous struct at C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um/winnt.h:879:5)")]
public _u_e__Struct u;
[FieldOffset(0)]
@@ -31,11 +23,7 @@ public partial struct LargeInteger
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if NET7_0_OR_GREATER
return ref Anonymous.LowPart;
#else
return ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Anonymous.LowPart, 1));
#endif
}
}
@@ -45,11 +33,7 @@ public partial struct LargeInteger
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if NET7_0_OR_GREATER
return ref Anonymous.HighPart;
#else
return ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Anonymous.HighPart, 1));
#endif
}
}
@@ -69,4 +53,13 @@ public partial struct LargeInteger
[NativeTypeName("LONG")]
public int HighPart;
}
public static implicit operator long(LargeInteger value) => value.QuadPart;
public static implicit operator LargeInteger(long value)
{
Unsafe.SkipInit(out LargeInteger result);
result.QuadPart = value;
return result;
}
}

View File

@@ -1,13 +1,6 @@
// Copyright © Amer Koleci and Contributors.
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
#if NETSTANDARD2_0
using MemoryMarshal = Win32.MemoryMarshal;
#endif
namespace Win32;
[StructLayout(LayoutKind.Explicit)]
@@ -15,11 +8,9 @@ namespace Win32;
public partial struct ULargeInteger
{
[FieldOffset(0)]
[NativeTypeName("_ULARGE_INTEGER::(anonymous struct at C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um/winnt.h:895:5)")]
public _Anonymous_e__Struct Anonymous;
[FieldOffset(0)]
[NativeTypeName("struct (anonymous struct at C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/um/winnt.h:899:5)")]
public _u_e__Struct u;
[FieldOffset(0)]
@@ -32,11 +23,7 @@ public partial struct ULargeInteger
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if NET7_0_OR_GREATER
return ref Anonymous.LowPart;
#else
return ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Anonymous.LowPart, 1));
#endif
}
}
@@ -46,11 +33,7 @@ public partial struct ULargeInteger
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if NET7_0_OR_GREATER
return ref Anonymous.HighPart;
#else
return ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref Anonymous.HighPart, 1));
#endif
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<Description>Windows API low level bindings.</Description>
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
<NoWarn>$(NoWarn);CS0419;IDE0017</NoWarn>