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, } 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":