Skip to content

Commit fcfb86c

Browse files
committed
Fixing Transform Functions
added manual file importer added a progress bar in some cases for QoL moved rename function into NameUtils
1 parent af96ea8 commit fcfb86c

File tree

554 files changed

+84861
-28337
lines changed

Some content is hidden

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

554 files changed

+84861
-28337
lines changed

generator.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"DefaultLicenseHeader": "eng/silktouch/header.txt",
88
"Mods": [
99
"ClangScraper",
10+
"ManualFileImporter",
1011
"ChangeNamespace",
1112
"TransformInterfaces",
1213
"TransformCOM",
@@ -25,8 +26,8 @@
2526
"sources/Windows/um/httpserv/IHttpResponse4.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/httpserv/IHttpResponse4.cs",
2627
"sources/Windows/um/httpserv/IHttpTraceContext.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/httpserv/IHttpTraceContext.cs",
2728
"sources/Windows/um/httpserv/CHttpModule.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/httpserv/CHttpModule.cs",
28-
"sources/Windows/um/winioctl/TXFS_READ_BACKUP_INFORMATION_OUT.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/winioctl/TXFS_READ_BACKUP_INFORMATION_OUT.cs",
2929
"sources/Windows/um/winioctl/STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/winioctl/STORAGE_QUERY_DEPENDENT_VOLUME_RESPONSE.cs",
30+
"sources/Windows/um/winioctl/TXFS_READ_BACKUP_INFORMATION_OUT.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/winioctl/TXFS_READ_BACKUP_INFORMATION_OUT.cs",
3031
"sources/Windows/um/WinUser/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/um/WinUser/Windows.cs",
3132
"sources/Windows/shared/strsafe/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/shared/strsafe/Windows.cs",
3233
"sources/Windows/shared/ws2ipdef/Windows.gen.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/Windows/shared/ws2ipdef/Windows.cs",
@@ -48,6 +49,34 @@
4849
"tests/DirectX/d3dx12/d3dx12_barriers/**.cs"
4950
]
5051
},
52+
"ManualFileImporter": {
53+
"ManualImports": {
54+
"sources/**.Manual.cs": "eng/submodules/terrafx.interop.windows/sources/Interop/Windows/**.Manual.cs",
55+
"!sources/**/INativeGuid.Manual.cs": "!**/INativeGuid.Manual.cs",
56+
"!sources/**/ID2D1*.Manual.cs": "!**/ID2D1*.Manual.cs",
57+
"!sources/**/d2d1_1helper/DirectX.Manual.cs": "!**/d2d1_1helper/DirectX.Manual.cs",
58+
"!sources/**/DirectXHelpers/DirectX.Manual.cs": "!**/DirectXHelpers/DirectX.Manual.cs",
59+
"!sources/**/d2d1/DirectX.Manual.cs": "!**/d2d1/DirectX.Manual.cs",
60+
"!sources/**/IWeakReference.Manual.cs": "!**/IWeakReference.Manual.cs",
61+
"!sources/**/IDispatchEx.Manual.cs": "!**/IDispatchEx.Manual.cs",
62+
"!sources/**/CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER.Manual.cs": "!**/CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER.Manual.cs",
63+
"!sources/**/CD3DX12_PIPELINE_STATE_STREAM1_PARSE_HELPER.Manual.cs": "!**/CD3DX12_PIPELINE_STATE_STREAM1_PARSE_HELPER.Manual.cs",
64+
"!sources/**/CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER.Manual.cs": "!**/CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER.Manual.cs",
65+
"!sources/**/CD3DX12_PIPELINE_STATE_STREAM3_PARSE_HELPER.Manual.cs": "!**/CD3DX12_PIPELINE_STATE_STREAM3_PARSE_HELPER.Manual.cs",
66+
"!sources/**/CD3DX12_PIPELINE_STATE_STREAM4_PARSE_HELPER.Manual.cs": "!**/CD3DX12_PIPELINE_STATE_STREAM4_PARSE_HELPER.Manual.cs",
67+
"!sources/**/CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER.Manual.cs": "!**/CD3DX12_PIPELINE_STATE_STREAM5_PARSE_HELPER.Manual.cs",
68+
"!sources/**/ShObjIdl_core/Windows.Manual.cs": "!**/ShObjIdl_core/Windows.Manual.cs",
69+
"!sources/**/propvarutil/Windows.Manual.cs": "!**/propvarutil/Windows.Manual.cs",
70+
"!sources/**/uuids/Windows.Manual.cs": "!**/uuids/Windows.Manual.cs",
71+
"!sources/**/gdipluscolor/Color.Manual.cs": "!**/gdipluscolor/Color.Manual.cs",
72+
"!sources/**/windows.ui.input/IID.Manual.cs": "!**/windows.ui.input/IID.Manual.cs",
73+
"!sources/**/windows.security.authentication.web.core/IID.Manual.cs": "!**/windows.security.authentication.web.core/IID.Manual.cs",
74+
"!sources/**/roapi/WinRT.Manual.cs": "!**/roapi/WinRT.Manual.cs",
75+
"!sources/**/windows.graphics.directx.direct3d11.interop/WinRT.Manual.cs": "!**/windows.graphics.directx.direct3d11.interop/WinRT.Manual.cs",
76+
"!sources/**/roparameterizediid/**.Manual.cs": "!**/roparameterizediid/**.Manual.cs",
77+
"!sources/**/d2d1_1/D2D1_**.Manual.cs": "!**/d2d1_1/D2D1_**.Manual.cs"
78+
}
79+
},
5180
"ChangeNamespace": {
5281
"Mappings": {
5382
"TerraFX.Interop.Windows(.*)": "Silk.NET.Win32$1",

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,34 @@ public static implicit operator MaybeBool<T>(bool value)
5454
/// <returns>The boolean value.</returns>
5555
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
5656
public static implicit operator bool(MaybeBool<T> value) => !value.Value.Equals(default);
57+
58+
/// <summary>
59+
/// compares boolean value and int
60+
/// </summary>
61+
/// <param name="lh"></param>
62+
/// <param name="rh"></param>
63+
/// <returns></returns>
64+
public static bool operator ==(MaybeBool<T> lh, int rh) => lh == (rh != 0);
65+
/// <summary>
66+
/// Compares boolean value and int
67+
/// </summary>
68+
/// <param name="lh"></param>
69+
/// <param name="rh"></param>
70+
/// <returns></returns>
71+
public static bool operator !=(MaybeBool<T> lh, int rh) => lh != (rh != 0);
72+
73+
/// <summary>
74+
/// compares boolean value and int
75+
/// </summary>
76+
/// <param name="lh"></param>
77+
/// <param name="rh"></param>
78+
/// <returns></returns>
79+
public static bool operator ==(int lh, MaybeBool<T> rh) => (lh != 0) == rh;
80+
/// <summary>
81+
/// Compares boolean value and int
82+
/// </summary>
83+
/// <param name="lh"></param>
84+
/// <param name="rh"></param>
85+
/// <returns></returns>
86+
public static bool operator !=(int lh, MaybeBool<T> rh) => (lh != 0) != rh;
5787
}

sources/Core/Core/INativeInterface.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public unsafe interface INativeInterface
1313
/// </summary>
1414
/// <typeparam name="TNativeInterface">The native interface object type</typeparam>
1515
/// <returns>pointer to interface object address </returns>
16-
TNativeInterface** GetAddressOf<TNativeInterface>() where TNativeInterface : unmanaged;
16+
Ptr2D<TNativeInterface> GetAddressOf<TNativeInterface>() where TNativeInterface : unmanaged;
1717
/// <summary>
1818
/// Gets the address of the pointer to the interface object address
1919
/// </summary>
2020
/// <returns>pointer to interface object address </returns>
21-
void** GetAddressOf();
21+
Ptr2D GetAddressOf();
2222
}
2323
}

sources/Core/Core/Pointers/Ptr.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,42 @@ public T[] ToArray<T>(int length)
222222
)]
223223
public static implicit operator void*(Ptr ptr) => ptr.Native;
224224

225+
/// <summary>
226+
/// Creates a <see cref="nuint"/> from a <see cref="Ptr"/>
227+
/// </summary>
228+
/// <param name="ptr"></param>
229+
[MethodImpl(
230+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
231+
)]
232+
public static implicit operator nuint(Ptr ptr) => new(ptr.Native);
233+
234+
/// <summary>
235+
/// Creates a <see cref="Ptr"/> from a <see cref="nuint"/>
236+
/// </summary>
237+
/// <param name="ptr"></param>
238+
[MethodImpl(
239+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
240+
)]
241+
public static implicit operator Ptr(nuint ptr) => new(ptr.ToPointer());
242+
243+
/// <summary>
244+
/// Creates a <see cref="nint"/> from a <see cref="Ptr"/>
245+
/// </summary>
246+
/// <param name="ptr"></param>
247+
[MethodImpl(
248+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
249+
)]
250+
public static implicit operator nint(Ptr ptr) => new(ptr.Native);
251+
252+
/// <summary>
253+
/// Creates a <see cref="Ptr"/> from a <see cref="nint"/>
254+
/// </summary>
255+
/// <param name="ptr"></param>
256+
[MethodImpl(
257+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
258+
)]
259+
public static implicit operator Ptr(nint ptr) => new(ptr.ToPointer());
260+
225261
/// <summary>
226262
/// Creates a <see cref="Ref"/> from a <see cref="Ptr"/>
227263
/// </summary>

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,43 @@ 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+
315+
/// <summary>
316+
/// Creates a <see cref="nuint"/> from a <see cref="Ptr{T}"/>
317+
/// </summary>
318+
/// <param name="ptr"></param>
319+
[MethodImpl(
320+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
321+
)]
322+
public static implicit operator nuint(Ptr<T> ptr) => new(ptr.Native);
323+
324+
/// <summary>
325+
/// Creates a <see cref="Ptr"/> from a <see cref="nuint"/>
326+
/// </summary>
327+
/// <param name="ptr"></param>
328+
[MethodImpl(
329+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
330+
)]
331+
public static implicit operator Ptr<T>(nuint ptr) => new((T*)ptr.ToPointer());
332+
333+
/// <summary>
334+
/// Creates a <see cref="nint"/> from a <see cref="Ptr{T}"/>
335+
/// </summary>
336+
/// <param name="ptr"></param>
337+
[MethodImpl(
338+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
339+
)]
340+
public static implicit operator nint(Ptr<T> ptr) => new(ptr.Native);
341+
342+
/// <summary>
343+
/// Creates a <see cref="Ptr{T}"/> from a <see cref="nint"/>
344+
/// </summary>
345+
/// <param name="ptr"></param>
346+
[MethodImpl(
347+
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
348+
)]
349+
public static implicit operator Ptr<T>(nint ptr) => new((T*)ptr.ToPointer());
350+
314351
/// <summary>
315352
/// Creates a <see cref="Ref{T}"/> from a <see cref="Ptr{T}"/>
316353
/// </summary>

sources/Core/Core/PublicAPI/net8.0/PublicAPI.Unshipped.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ Silk.NET.Core.INativeWindow.TryGetPlatformInfo<TPlatformInfo>(out TPlatformInfo?
107107
Silk.NET.Core.INativeGuid
108108
Silk.NET.Core.INativeGuid.NativeGuid.get -> System.Guid*
109109
Silk.NET.Core.INativeInterface
110-
Silk.NET.Core.INativeInterface.GetAddressOf() -> void**
111-
Silk.NET.Core.INativeInterface.GetAddressOf<TNativeInterface>() -> TNativeInterface**
110+
Silk.NET.Core.INativeInterface.GetAddressOf() -> Silk.NET.Core.Ptr2D
111+
Silk.NET.Core.INativeInterface.GetAddressOf<TNativeInterface>() -> Silk.NET.Core.Ptr2D<TNativeInterface>
112112
Silk.NET.Core.Loader.DefaultNativeContext
113113
Silk.NET.Core.Loader.DefaultNativeContext.DefaultNativeContext() -> void
114114
Silk.NET.Core.Loader.DefaultNativeContext.Dispose() -> void
@@ -363,6 +363,10 @@ static Silk.NET.Core.MaybeBool<T>.implicit operator bool(Silk.NET.Core.MaybeBool
363363
static Silk.NET.Core.MaybeBool<T>.implicit operator Silk.NET.Core.MaybeBool<T>(bool value) -> Silk.NET.Core.MaybeBool<T>
364364
static Silk.NET.Core.MaybeBool<T>.implicit operator Silk.NET.Core.MaybeBool<T>(T Value) -> Silk.NET.Core.MaybeBool<T>
365365
static Silk.NET.Core.MaybeBool<T>.implicit operator T(Silk.NET.Core.MaybeBool<T> value) -> T
366+
static Silk.NET.Core.MaybeBool<T>.operator !=(int lh, Silk.NET.Core.MaybeBool<T> rh) -> bool
367+
static Silk.NET.Core.MaybeBool<T>.operator !=(Silk.NET.Core.MaybeBool<T> lh, int rh) -> bool
368+
static Silk.NET.Core.MaybeBool<T>.operator ==(int lh, Silk.NET.Core.MaybeBool<T> rh) -> bool
369+
static Silk.NET.Core.MaybeBool<T>.operator ==(Silk.NET.Core.MaybeBool<T> lh, int rh) -> bool
366370
static Silk.NET.Core.NullPtr.implicit operator void*(Silk.NET.Core.NullPtr _) -> void*
367371
static Silk.NET.Core.PointerExtensions.ReadToString(this Silk.NET.Core.Ptr<byte> this) -> string!
368372
static Silk.NET.Core.PointerExtensions.ReadToString(this Silk.NET.Core.Ptr<byte> this, int length) -> string!
@@ -424,6 +428,10 @@ static Silk.NET.Core.Ptr.explicit operator nint(Silk.NET.Core.Ptr ptr) -> nint
424428
static Silk.NET.Core.Ptr.explicit operator Silk.NET.Core.Ptr(nint ptr) -> Silk.NET.Core.Ptr
425429
static Silk.NET.Core.Ptr.explicit operator Silk.NET.Core.Ptr(Silk.NET.Core.Ref ptr) -> Silk.NET.Core.Ptr
426430
static Silk.NET.Core.Ptr.explicit operator string!(Silk.NET.Core.Ptr ptr) -> string!
431+
static Silk.NET.Core.Ptr.implicit operator nint(Silk.NET.Core.Ptr ptr) -> nint
432+
static Silk.NET.Core.Ptr.implicit operator nuint(Silk.NET.Core.Ptr ptr) -> nuint
433+
static Silk.NET.Core.Ptr.implicit operator Silk.NET.Core.Ptr(nint ptr) -> Silk.NET.Core.Ptr
434+
static Silk.NET.Core.Ptr.implicit operator Silk.NET.Core.Ptr(nuint ptr) -> Silk.NET.Core.Ptr
427435
static Silk.NET.Core.Ptr.implicit operator Silk.NET.Core.Ptr(Silk.NET.Core.NullPtr ptr) -> Silk.NET.Core.Ptr
428436
static Silk.NET.Core.Ptr.implicit operator Silk.NET.Core.Ptr(void* ptr) -> Silk.NET.Core.Ptr
429437
static Silk.NET.Core.Ptr.implicit operator Silk.NET.Core.Ref(Silk.NET.Core.Ptr ptr) -> Silk.NET.Core.Ref
@@ -599,7 +607,11 @@ static Silk.NET.Core.Ptr3D<T>.operator ==(void* lh, Silk.NET.Core.Ptr3D<T> rh) -
599607
static Silk.NET.Core.Ptr3D<T>.operator ==(void** lh, Silk.NET.Core.Ptr3D<T> rh) -> bool
600608
static Silk.NET.Core.Ptr<T>.explicit operator Silk.NET.Core.Ptr<T>(Silk.NET.Core.Ref<T> ptr) -> Silk.NET.Core.Ptr<T>
601609
static Silk.NET.Core.Ptr<T>.explicit operator string!(Silk.NET.Core.Ptr<T> ptr) -> string!
610+
static Silk.NET.Core.Ptr<T>.implicit operator nint(Silk.NET.Core.Ptr<T> ptr) -> nint
611+
static Silk.NET.Core.Ptr<T>.implicit operator nuint(Silk.NET.Core.Ptr<T> ptr) -> nuint
602612
static Silk.NET.Core.Ptr<T>.implicit operator Silk.NET.Core.Ptr(Silk.NET.Core.Ptr<T> ptr) -> Silk.NET.Core.Ptr
613+
static Silk.NET.Core.Ptr<T>.implicit operator Silk.NET.Core.Ptr<T>(nint ptr) -> Silk.NET.Core.Ptr<T>
614+
static Silk.NET.Core.Ptr<T>.implicit operator Silk.NET.Core.Ptr<T>(nuint ptr) -> Silk.NET.Core.Ptr<T>
603615
static Silk.NET.Core.Ptr<T>.implicit operator Silk.NET.Core.Ptr<T>(Silk.NET.Core.NullPtr ptr) -> Silk.NET.Core.Ptr<T>
604616
static Silk.NET.Core.Ptr<T>.implicit operator Silk.NET.Core.Ptr<T>(Silk.NET.Core.Ptr ptr) -> Silk.NET.Core.Ptr<T>
605617
static Silk.NET.Core.Ptr<T>.implicit operator Silk.NET.Core.Ptr<T>(T* ptr) -> Silk.NET.Core.Ptr<T>

sources/SilkTouch/SilkTouch/Clang/ClangScraper.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.IO;
99
using System.IO.Hashing;
1010
using System.Linq;
11+
using System.Numerics;
1112
using System.Runtime.InteropServices;
1213
using System.Text.RegularExpressions;
1314
using System.Threading;
@@ -23,6 +24,7 @@
2324
using Silk.NET.SilkTouch.Caching;
2425
using Silk.NET.SilkTouch.Mods;
2526
using Silk.NET.SilkTouch.Sources;
27+
using Silk.NET.SilkTouch.Utility;
2628
using static ClangSharp.Interop.CXDiagnosticSeverity;
2729
using static ClangSharp.Interop.CXErrorCode;
2830

@@ -160,7 +162,9 @@ out var handle
160162
if (translationUnitError != CXError_Success)
161163
{
162164
var msg = $"Parsing failed for '{fileName}' due to '{translationUnitError}'.";
165+
163166
logger.LogError(msg);
167+
164168
skipProcessing = true;
165169
}
166170
else if (handle.NumDiagnostics != 0)
@@ -172,8 +176,7 @@ out var handle
172176
using var diagnostic = handle.GetDiagnostic(i);
173177

174178
logger.Log(
175-
diagnostic.Severity switch
176-
{
179+
diagnostic.Severity switch {
177180
CXDiagnostic_Ignored => LogLevel.Trace,
178181
CXDiagnostic_Note => LogLevel.Debug,
179182
CXDiagnostic_Warning => LogLevel.Warning,
@@ -210,6 +213,7 @@ out var handle
210213
rspIndex,
211214
rspCount
212215
);
216+
213217
pinvokeGenerator.GenerateBindings(
214218
translationUnit,
215219
filePath,

sources/SilkTouch/SilkTouch/Clang/ResponseFileHandler.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using ClangSharp;
1212
using Microsoft.Extensions.FileSystemGlobbing;
1313
using Microsoft.Extensions.Logging;
14+
using Silk.NET.SilkTouch.Utility;
1415
using static ClangSharp.Interop.CXTranslationUnit_Flags;
1516

1617
namespace Silk.NET.SilkTouch.Clang;
@@ -1355,6 +1356,7 @@ out Dictionary<string, string> withPackings
13551356
{
13561357
foreach (var error in errorList)
13571358
{
1359+
ProgressBarUtility.Hide(LogLevel.Information);
13581360
logger.LogError($"Error in args for '{files.FirstOrDefault()}': {error}");
13591361
}
13601362
}
@@ -1492,18 +1494,28 @@ IReadOnlyList<string> globs
14921494
directory,
14931495
Environment.CurrentDirectory
14941496
);
1495-
foreach (var rsp in Glob(globs))
1497+
IEnumerable<string> rsps = Glob(globs);
1498+
int index = 0;
1499+
int count = rsps.Count();
1500+
ProgressBarUtility.SetPercentage(0);
1501+
ProgressBarUtility.Show(LogLevel.Information);
1502+
foreach (var rsp in rsps)
14961503
{
1504+
index++;
14971505
logger.LogDebug("Reading found file: {0}", rsp);
14981506
var dir =
14991507
Path.GetDirectoryName(rsp)
15001508
?? throw new InvalidOperationException("Couldn't get directory name of path");
15011509
var read = ReadResponseFile(RspRelativeTo(dir, rsp).ToArray(), dir, rsp);
1510+
1511+
ProgressBarUtility.SetPercentage(index / (float)count);
15021512
yield return read with
15031513
{
15041514
FileDirectory = dir,
15051515
};
15061516
}
1517+
1518+
ProgressBarUtility.Hide(LogLevel.Information);
15071519
}
15081520

15091521
private IEnumerable<string> RspRelativeTo(string directory, string fullPath)
@@ -1545,12 +1557,7 @@ internal static string PathFixup(string path)
15451557
internal static IEnumerable<string> Glob(IReadOnlyCollection<string> paths, string? cd = null)
15461558
{
15471559
cd ??= Environment.CurrentDirectory;
1548-
var matcher = new Matcher();
1549-
1550-
matcher.AddIncludePatterns(paths.Where(x => !x.StartsWith("!")).Select(PathFixup));
1551-
matcher.AddExcludePatterns(
1552-
paths.Where(x => x.StartsWith("!")).Select(x => x[1..]).Select(PathFixup)
1553-
);
1560+
var matcher = GetGlobMatcher(paths);
15541561

15551562
return matcher
15561563
.GetResultsInFullPath(cd)
@@ -1568,4 +1575,16 @@ internal static IEnumerable<string> Glob(IReadOnlyCollection<string> paths, stri
15681575
.Distinct()
15691576
.ToArray();
15701577
}
1578+
1579+
internal static Matcher GetGlobMatcher(IReadOnlyCollection<string> paths)
1580+
{
1581+
var matcher = new Matcher();
1582+
1583+
matcher.AddIncludePatterns(paths.Where(x => !x.StartsWith("!")).Select(PathFixup));
1584+
matcher.AddExcludePatterns(
1585+
paths.Where(x => x.StartsWith("!")).Select(x => x[1..]).Select(PathFixup)
1586+
);
1587+
1588+
return matcher;
1589+
}
15711590
}

sources/SilkTouch/SilkTouch/Mods/ChangeNamespace.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
using Microsoft.CodeAnalysis.CSharp;
1111
using Microsoft.CodeAnalysis.CSharp.Syntax;
1212
using Microsoft.Extensions.Options;
13+
using Microsoft.Extensions.Logging;
1314
using Silk.NET.SilkTouch.Clang;
15+
using Silk.NET.SilkTouch.Utility;
1416
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
1517

1618
namespace Silk.NET.SilkTouch.Mods;
@@ -45,6 +47,8 @@ public Task<List<ResponseFile>> BeforeScrapeAsync(string key, List<ResponseFile>
4547
config.Get(key).Mappings?.Select(kvp => (new Regex(kvp.Key), kvp.Value)).ToArray()
4648
?? Array.Empty<(Regex, string)>();
4749
var tmp = Path.GetTempFileName();
50+
ProgressBarUtility.SetPercentage(0);
51+
ProgressBarUtility.Show(LogLevel.Information);
4852
for (var i = 0; i < rsps.Count; i++)
4953
{
5054
var rsp = rsps[i];
@@ -97,8 +101,10 @@ public Task<List<ResponseFile>> BeforeScrapeAsync(string key, List<ResponseFile>
97101
WithPackings = rsp.GeneratorConfiguration.WithPackings,
98102
}
99103
};
100-
}
101104

105+
ProgressBarUtility.SetPercentage(i / (float)rsps.Count);
106+
}
107+
ProgressBarUtility.Hide(LogLevel.Information);
102108
_jobs[key] = (
103109
rsps.Select(x => x.GeneratorConfiguration.DefaultNamespace)
104110
.Concat(

sources/SilkTouch/SilkTouch/Mods/Common/ModLoader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class ModLoader
3232
nameof(TransformInterfaces) => typeof(TransformInterfaces),
3333
nameof(TransformCOM) => typeof(TransformCOM),
3434
nameof(DisableWarnings) => typeof(DisableWarnings),
35+
nameof(ManualFileImporter) => typeof(ManualFileImporter),
3536
_ => null,
3637
};
3738
}

0 commit comments

Comments
 (0)