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

@@ -12,10 +12,9 @@
<DebugType>embedded</DebugType>
<Features>strict</Features>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<RestoreConfigFile>$(MSBuildThisFileDirectory)NuGet.config</RestoreConfigFile>
<VersionPrefix>1.8.9</VersionPrefix>
<VersionPrefix>1.9.0</VersionPrefix>
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -44,9 +43,4 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="all" />
<PackageReference Include="PolySharp" PrivateAssets="all" />
</ItemGroup>
</Project>

View File

@@ -1,23 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- https://learn.microsoft.com/nuget/consume-packages/central-package-management -->
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<!--
Directory.Packages.props is automatically picked up and imported by
Microsoft.Common.targets. This file needs to exist, even if empty so that
files in the parent directory tree, with the same name, are not imported
instead. The import fairly late and most other props/targets will have been
imported beforehand. We also don't need to add ourselves to
MSBuildAllProjects, as that is done by the file that imports us.
-->
<!-- Package versions for package references across all projects -->
<ItemGroup>
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.2.1" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<GlobalPackageReference Include="PolySharp" Version="1.8.1" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageVersion Include="PolySharp" Version="1.8.0" />
<PackageVersion Include="CommunityToolkit.Diagnostics" Version="8.0.0" />
<PackageVersion Include="System.Memory" Version="4.5.4" />

View File

@@ -4,7 +4,7 @@
[![Build status](https://github.com/amerkoleci/Vortice.Win32/workflows/Build/badge.svg)](https://github.com/amerkoleci/Vortice.Win32/actions)
[![NuGet](https://img.shields.io/nuget/v/Vortice.Win32.svg)](https://www.nuget.org/packages/Vortice.Win32)
**Vortice.Win32** is a .NET Standard 2.0 and .NET 6.0 low-level bindings for Win32, generation is based on json files from [win32json](https://github.com/marlersoft/win32json), follows naming conventions of Vortice.Windows but small GC allocation and using unsafe struct for COM objects.
**Vortice.Win32** is a .NET Standard 2.0, .NET 6.0 and .NET 7.0 low-level bindings for Win32, generation is based on json files from [win32json](https://github.com/marlersoft/win32json), follows naming conventions of Vortice.Windows but small GC allocation and using unsafe struct for COM objects.
## Sponsors
To further help development of these bindings library or other projects, please consider [SPONSOR](https://github.com/sponsors/amerkoleci) my profile in order to allow faster issue triaging and new features to be implemented.

View File

@@ -1,9 +1,11 @@
{
"sdk": {
"version": "7.0.100",
"rollForward": "latestFeature"
"rollForward": "latestMinor",
"allowPrerelease": false
},
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "3.0.44"
"MSBuild.Sdk.Extras": "3.0.44",
"Microsoft.Build.NoTargets": "3.3.0"
}
}

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>