From 4da340c41a6a93b04b3f5ed1fd1a295ab7223e2b Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 14 Mar 2025 14:50:11 -0400 Subject: [PATCH 1/2] Add DontUseUsingStaticsForGuidMember --- .../PInvokeGenerator.VisitDecl.cs | 36 ++++++++++++++++--- .../PInvokeGeneratorConfiguration.cs | 2 ++ .../PInvokeGeneratorConfigurationOptions.cs | 2 ++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs index 1d771de4..2e37bb02 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs @@ -1411,7 +1411,15 @@ private void VisitRecordDecl(RecordDecl recordDecl) var className = GetClass(uuidName); _testOutputBuilder.AddUsingDirective("System"); - _testOutputBuilder.AddUsingDirective($"static {GetNamespace(className)}.{className}"); + + if (_config.DontUseUsingStaticsForGuidMember) + { + _testOutputBuilder.AddUsingDirective($"{GetNamespace(className)}"); + } + else + { + _testOutputBuilder.AddUsingDirective($"static {GetNamespace(className)}.{className}"); + } _testOutputBuilder.WriteIndented("/// Validates that the of the ExcludedNames public bool StripEnumMemberTypeName => _options.HasFlag(PInvokeGeneratorConfigurationOptions.StripEnumMemberTypeName); + public bool DontUseUsingStaticsForGuidMember => _options.HasFlag(PInvokeGeneratorConfigurationOptions.DontUseUsingStaticsForGuidMember); + public string HeaderText => _headerText; [AllowNull] diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs index c2a34293..cd77e71c 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs @@ -88,4 +88,6 @@ public enum PInvokeGeneratorConfigurationOptions : long GenerateGenericPointerWrapper = 1L << 38, StripEnumMemberTypeName = 1L << 39, + + DontUseUsingStaticsForGuidMember = 1L << 40, } From 969491251309f3fba346a1dff9d599836f7e4ef8 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 14 Mar 2025 15:56:25 -0400 Subject: [PATCH 2/2] add missing code to read rsp files --- sources/ClangSharpPInvokeGenerator/Program.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sources/ClangSharpPInvokeGenerator/Program.cs b/sources/ClangSharpPInvokeGenerator/Program.cs index 322ef1e4..8bad0657 100644 --- a/sources/ClangSharpPInvokeGenerator/Program.cs +++ b/sources/ClangSharpPInvokeGenerator/Program.cs @@ -444,6 +444,13 @@ public static void Run(InvocationContext context) break; } + case "exclude-using-statics-for-guid-members": + case "dont-use-using-statics-for-guid-members": + { + configOptions |= PInvokeGeneratorConfigurationOptions.DontUseUsingStaticsForGuidMember; + break; + } + // VTBL Options case "explicit-vtbls":