Skip to content

Commit fcb5796

Browse files
committed
Addressed Review Feedback
Also split some common classes out into core
1 parent fe2f36c commit fcb5796

File tree

101 files changed

+6788
-1728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+6788
-1728
lines changed

Silk.NET.sln

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ Global
128128
{48F43535-3AFC-45E7-A98D-C2609B3B9757}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
129129
{48F43535-3AFC-45E7-A98D-C2609B3B9757}.Debug|Any CPU.Build.0 = Debug|Any CPU
130130
{48F43535-3AFC-45E7-A98D-C2609B3B9757}.Release|Any CPU.ActiveCfg = Release|Any CPU
131-
{48F43535-3AFC-45E7-A98D-C2609B3B9757}.Release|Any CPU.Build.0 = Release|Any CPU
132131
{A87E1861-07E4-4B7A-9173-0853370A7D4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
133132
{A87E1861-07E4-4B7A-9173-0853370A7D4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
134133
{A87E1861-07E4-4B7A-9173-0853370A7D4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -161,24 +160,18 @@ Global
161160
{6FA628B8-9696-4847-89F9-E58F470AF4FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
162161
{6FA628B8-9696-4847-89F9-E58F470AF4FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
163162
{6FA628B8-9696-4847-89F9-E58F470AF4FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
164-
{6FA628B8-9696-4847-89F9-E58F470AF4FB}.Release|Any CPU.Build.0 = Release|Any CPU
165163
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
166164
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
167165
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
168-
{F16C0AB9-DE7E-4C09-9EE9-DAA8B8E935A6}.Release|Any CPU.Build.0 = Release|Any CPU
169166
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
170167
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
171168
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
172-
{EF07CBB5-D253-4CA9-A5DA-8B3DF2B0DF8E}.Release|Any CPU.Build.0 = Release|Any CPU
173169
{BB33CC4A-EA3A-4D4F-879A-F93C617C5E63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
170+
{BB33CC4A-EA3A-4D4F-879A-F93C617C5E63}.Debug|Any CPU.Build.0 = Debug|Any CPU
174171
{BB33CC4A-EA3A-4D4F-879A-F93C617C5E63}.Release|Any CPU.ActiveCfg = Release|Any CPU
175172
{C8F32825-1F93-44F0-AB88-26167C21CADF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
173+
{C8F32825-1F93-44F0-AB88-26167C21CADF}.Debug|Any CPU.Build.0 = Debug|Any CPU
176174
{C8F32825-1F93-44F0-AB88-26167C21CADF}.Release|Any CPU.ActiveCfg = Release|Any CPU
177-
{C8F32825-1F93-44F0-AB88-26167C21CADF}.Release|Any CPU.Build.0 = Release|Any CPU
178-
{49A42CE3-94C5-4239-B0FC-F1FF8D7AAADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
179-
{49A42CE3-94C5-4239-B0FC-F1FF8D7AAADA}.Debug|Any CPU.Build.0 = Debug|Any CPU
180-
{49A42CE3-94C5-4239-B0FC-F1FF8D7AAADA}.Release|Any CPU.ActiveCfg = Release|Any CPU
181-
{49A42CE3-94C5-4239-B0FC-F1FF8D7AAADA}.Release|Any CPU.Build.0 = Release|Any CPU
182175
EndGlobalSection
183176
GlobalSection(SolutionProperties) = preSolution
184177
HideSolutionNode = FALSE
@@ -214,8 +207,6 @@ Global
214207
{BB33CC4A-EA3A-4D4F-879A-F93C617C5E63} = {6E739132-EEAB-43A5-83C7-EB58C50D03A1}
215208
{BA20152E-2FF8-48F0-A90E-682A7A8CF657} = {A5578D12-9E77-4647-8C22-0DBD17760BFF}
216209
{C8F32825-1F93-44F0-AB88-26167C21CADF} = {BA20152E-2FF8-48F0-A90E-682A7A8CF657}
217-
{33ED9765-8C36-4A9D-95E8-AF037FE104B3} = {DD29EA8F-B1A6-45AA-8D2E-B38DA56D9EF6}
218-
{49A42CE3-94C5-4239-B0FC-F1FF8D7AAADA} = {33ED9765-8C36-4A9D-95E8-AF037FE104B3}
219210
EndGlobalSection
220211
GlobalSection(ExtensibilityGlobals) = postSolution
221212
SolutionGuid = {78D2CF6A-60A1-43E3-837B-00B73C9DA384}

generator.json

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"ClangScraper": {
1818
"ClangSharpResponseFiles": [
1919
"eng/submodules/terrafx.interop.windows/generation/**/generate.rsp",
20-
"!eng/submodules/terrafx.interop.windows/generation/DirectX/d3dx12/d3dx12_state_object/generate.rsp"
20+
"!eng/submodules/terrafx.interop.windows/generation/DirectX/d3dx12/d3dx12_state_object/generate.rsp",
21+
"!eng/submodules/terrafx.interop.windows/generation/Windows/um/Unknwnbase/generate.rsp",
22+
"!eng/submodules/terrafx.interop.windows/generation/WinRT/winrt/inspectable/generate.rsp",
2123
],
2224
"ManualOverrides": {
2325
"sources/Windows/um/httpserv/IHttpResponse.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/httpserv/IHttpResponse.cs",
@@ -46,13 +48,20 @@
4648
"CacheOutput": false,
4749
"GeneratedToRemove": [
4850
"tests/DirectX/d3dx12/d3dx12_core/**.cs",
49-
"tests/DirectX/d3dx12/d3dx12_barriers/**.cs"
50-
]
51+
"tests/DirectX/d3dx12/d3dx12_barriers/**.cs",
52+
"sources/**/HANDLE.gen.cs",
53+
"sources/**/helper-types/*Attribute.gen.cs",
54+
"sources/**/helper-types/HRESULT.gen.cs",
55+
"sources/**/helper-types/BOOL.gen.cs",
56+
"sources/**/helper-types/HSTRING.gen.cs",
57+
],
5158
},
5259
"ImportManualFiles": {
5360
"ManualImports": {
5461
"sources/**.Manual.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/**.Manual.cs",
5562
"!sources/**/INativeGuid.Manual.cs": "!**/INativeGuid.Manual.cs",
63+
"!sources/**/HWND.Manual.cs": "!**/HWND.Manual.cs",
64+
"!sources/**/HRESULT.Manual.cs": "!**/HRESULT.Manual.cs",
5665
"!sources/**/ID2D1*.Manual.cs": "!**/ID2D1*.Manual.cs",
5766
"!sources/**/d2d1_1helper/DirectX.Manual.cs": "!**/d2d1_1helper/DirectX.Manual.cs",
5867
"!sources/**/DirectXHelpers/DirectX.Manual.cs": "!**/DirectXHelpers/DirectX.Manual.cs",
@@ -85,18 +94,37 @@
8594
},
8695
"TransformInterfaces": {
8796
"AdditionalInterfaces": [
88-
"IDispatchEx"
97+
"IDispatchEx",
98+
"IUnknown",
99+
"IInspectable",
100+
"IClassFactory",
101+
"AsyncIUknown"
89102
]
90103
},
91104
"TransformCOM": {
92105
"BaseTypes": {
93-
"IUnknown.Native.Interface": "Silk.NET.Win32.IUnknown.Native.Interface"
106+
"IUnknown.Interface": "Silk.NET.Core.IUnknown.Interface"
94107
},
95108
"AdditionalCOMTypes": {
96-
"IDispatchEx.Native.Interface": {
109+
"IDispatchEx.Interface": {
97110
"Namespace": "Silk.NET.Win32",
98-
"Parent": "IDispatch.Native.Interface"
99-
111+
"Parent": "IDispatch.Interface"
112+
},
113+
"IInspectable.Interface": {
114+
"Namespace": "Silk.NET.Core",
115+
"Parent": "IUnknown.Interface"
116+
},
117+
"IClassFactory.Interface": {
118+
"Namespace": "Silk.NET.Core",
119+
"Parent": "IUnknown.Interface"
120+
},
121+
"AsyncIUnknown.Interface": {
122+
"Namespace": "Silk.NET.Core",
123+
"Parent": "IUnknown.Interface"
124+
},
125+
"IUnknown.Interface": {
126+
"Namespace": "Silk.NET.Core",
127+
"Parent": ""
100128
}
101129
}
102130
},
@@ -114,6 +142,66 @@
114142
}
115143
}
116144
},
145+
"Core": {
146+
"Solution": "Silk.NET.sln",
147+
"SourceProject": "sources/Core/Core/Silk.NET.Core.csproj",
148+
"TestProject": "tests/Core/Core/Silk.NET.Core.UnitTests.csproj",
149+
"DefaultLicenseHeader": "eng/silktouch/header.txt",
150+
"Mods": [
151+
"ClangScraper",
152+
"ChangeNamespace",
153+
"TransformInterfaces",
154+
"TransformCOM",
155+
"DisableWarnings",
156+
"TransformFunctions"
157+
],
158+
"ClangScraper": {
159+
"ClangSharpResponseFiles": [
160+
"eng/submodules/terrafx.interop.windows/generation/Windows/um/Unknwnbase/generate.rsp",
161+
"eng/submodules/terrafx.interop.windows/generation/WinRT/winrt/inspectable/generate.rsp",
162+
"eng/submodules/terrafx.interop.windows/generation/Windows/other/helper-types/generate.rsp"
163+
],
164+
"InputSourceRoot": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows",
165+
"InputTestRoot": "eng/submodules/terrafx.interop.windows/tests/Interop/Windows",
166+
"SkipScrapeIf": [
167+
"!win"
168+
],
169+
"CacheOutput": false,
170+
"GeneratedToRemove": [
171+
"sources/**/helper-types/*.gen.cs",
172+
"!sources/**/helper-types/HRESULT.gen.cs",
173+
"!sources/**/helper-types/BOOL.gen.cs",
174+
"!sources/**/helper-types/HSTRING.gen.cs",
175+
"!sources/**/helper-types/HANDLE.gen.cs"
176+
]
177+
},
178+
"ChangeNamespace": {
179+
"Mappings": {
180+
"TerraFX.Interop(.*)": "Silk.NET.Core",
181+
}
182+
},
183+
"TransformInterfaces": {
184+
},
185+
"TransformCOM": {
186+
"BaseTypes": {
187+
"IUnknown.Interface": "Silk.NET.Core.IUnknown.Interface"
188+
}
189+
},
190+
"DisableWarnings": {
191+
"WarningCodes": [
192+
"CS1589", //XML Comments missing (due to missing docs)
193+
"CS1591", //Missing Summaries
194+
"CS0419", //Inheritdoc issue (due to bug)
195+
"CA1416", //Function available outside of target os (intended)
196+
"CS0618" //Obsolete Warnings (intended)
197+
]
198+
},
199+
"TransformFunctions": {
200+
"BoolTypes": {
201+
"BOOL": null
202+
}
203+
}
204+
},
117205
"SDL": {
118206
"SourceProject": "sources/SDL/SDL/Silk.NET.SDL.csproj",
119207
"TestProject": "tests/SDL/SDL/Silk.NET.SDL.UnitTests.csproj",

sources/Win32/Win32/Windows/other/helper-types/BOOL.Manual.cs renamed to sources/Core/Core/BOOL.Manual.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33

44
using System.Numerics;
55

6-
namespace Silk.NET.Win32;
6+
namespace Silk.NET.Core;
77

8+
/// <summary>
9+
/// Boolean value commonly used by Microsoft
10+
/// </summary>
811
public readonly partial struct BOOL : IIncrementOperators<BOOL>
912
{
13+
/// <summary>
14+
/// Increment boolean value
15+
/// </summary>
16+
/// <param name="value">bool value to increment</param>
17+
/// <returns>incremented bool value</returns>
1018
public static BOOL operator ++(BOOL value) => new(value.Value + 1);
1119
}

sources/Core/Core/DSL/MaybeBool`1.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,32 @@ public static implicit operator MaybeBool<T>(bool value)
5858
/// <summary>
5959
/// compares boolean value and int
6060
/// </summary>
61-
/// <param name="lh"></param>
62-
/// <param name="rh"></param>
61+
/// <param name="lh">left hand value</param>
62+
/// <param name="rh">right hand value</param>
6363
/// <returns></returns>
6464
public static bool operator ==(MaybeBool<T> lh, int rh) => lh == (rh != 0);
65+
6566
/// <summary>
6667
/// Compares boolean value and int
6768
/// </summary>
68-
/// <param name="lh"></param>
69-
/// <param name="rh"></param>
69+
/// <param name="lh">left hand value</param>
70+
/// <param name="rh">right hand value</param>
7071
/// <returns></returns>
7172
public static bool operator !=(MaybeBool<T> lh, int rh) => lh != (rh != 0);
7273

7374
/// <summary>
7475
/// compares boolean value and int
7576
/// </summary>
76-
/// <param name="lh"></param>
77-
/// <param name="rh"></param>
77+
/// <param name="lh">left hand value</param>
78+
/// <param name="rh">right hand value</param>
7879
/// <returns></returns>
7980
public static bool operator ==(int lh, MaybeBool<T> rh) => (lh != 0) == rh;
81+
8082
/// <summary>
8183
/// Compares boolean value and int
8284
/// </summary>
83-
/// <param name="lh"></param>
84-
/// <param name="rh"></param>
85+
/// <param name="lh">left hand value</param>
86+
/// <param name="rh">right hand value</param>
8587
/// <returns></returns>
8688
public static bool operator !=(int lh, MaybeBool<T> rh) => (lh != 0) != rh;
8789
}

sources/Core/Core/HRESULT.Manual.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
#pragma warning disable CS1589, CS0419, CA1416, CS0618
5+
namespace Silk.NET.Core;
6+
7+
/// <summary>
8+
/// Common error code value returned by Microsoft methods
9+
/// </summary>
10+
public partial struct HRESULT
11+
{
12+
/// <summary>
13+
/// Has the function failed
14+
/// </summary>
15+
public bool FAILED => Value < 0;
16+
17+
/// <summary>
18+
/// Has the function succeeded
19+
/// </summary>
20+
public bool SUCCEEDED => Value >= 0;
21+
}

sources/Core/Core/IComInterface.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@ namespace Silk.NET.Core
66
/// <summary>
77
/// A specialized native interface representing a ComType
88
/// </summary>
9-
public interface IComInterface : INativeInterface, INativeGuid
9+
public interface IComInterface : INativeGuid
1010
{
11+
/// <summary>
12+
/// Gets the address of the pointer to the interface object address
13+
/// </summary>
14+
/// <typeparam name="TNativeInterface">The native interface object type</typeparam>
15+
/// <returns>pointer to interface object address </returns>
16+
Ptr2D<TNativeInterface> GetAddressOf<TNativeInterface>()
17+
where TNativeInterface : unmanaged;
18+
19+
/// <summary>
20+
/// Gets the address of the pointer to the interface object address
21+
/// </summary>
22+
/// <returns>pointer to interface object address </returns>
23+
Ptr2D GetAddressOf();
1124
}
1225
}

sources/Core/Core/INativeInterface.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

sources/Core/Core/Pointers/Ptr.generic.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ public unsafe struct Ptr<T>(T* ptr)
311311
/// <param name="ptr"></param>
312312
public static implicit operator T*(Ptr<T> ptr) => ptr.Native;
313313

314-
315314
/// <summary>
316315
/// Creates a <see cref="nuint"/> from a <see cref="Ptr{T}"/>
317316
/// </summary>

0 commit comments

Comments
 (0)