From 33cf51e5a583d1a2c6f5ab80368136ab1bd2cd1b Mon Sep 17 00:00:00 2001 From: tompipe Date: Thu, 30 Oct 2025 18:15:57 +0000 Subject: [PATCH 1/2] Make marker interfaces partial to support user extensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When --generate-marker-interfaces is enabled, generated nested interfaces are now marked as 'partial' to allow users to extend them with manual method implementations. This is critical when: - Methods are excluded via --exclude or other exclusion flags - Template methods or other unsupported constructs need manual implementation - Helper methods should be part of the interface contract for generic constraints Changed: public interface Interface -> public partial interface Interface 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../CSharp/CSharpOutputBuilder.VisitDecl.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs index 5060f29d..fc214b61 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs @@ -826,7 +826,7 @@ public void BeginStruct(in StructDesc desc) public void BeginMarkerInterface(string[]? baseTypeNames) { - WriteIndented("public interface Interface"); + WriteIndented("public partial interface Interface"); if (baseTypeNames is not null) { From 4d83c8ba57aee1925f5d54afa2a3f8d2fd1d0915 Mon Sep 17 00:00:00 2001 From: tompipe Date: Sat, 1 Nov 2025 12:23:52 +0000 Subject: [PATCH 2/2] updated tests for partial interface --- .../CSharpCompatibleUnix/CXXMethodDeclarationTest.cs | 2 +- .../CSharpCompatibleWindows/CXXMethodDeclarationTest.cs | 2 +- .../CSharpDefaultUnix/CXXMethodDeclarationTest.cs | 2 +- .../CSharpDefaultWindows/CXXMethodDeclarationTest.cs | 2 +- .../CSharpLatestUnix/CXXMethodDeclarationTest.cs | 2 +- .../CSharpLatestWindows/CXXMethodDeclarationTest.cs | 2 +- .../CSharpPreviewUnix/CXXMethodDeclarationTest.cs | 2 +- .../CSharpPreviewWindows/CXXMethodDeclarationTest.cs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs index 5a363544..22fb1ccb 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs @@ -633,7 +633,7 @@ public int GetType(int objA, int objB) }} }} - public interface Interface + public partial interface Interface {{ int GetType(int obj); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs index 88bd0b5e..089347c5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs @@ -628,7 +628,7 @@ public int GetType(int obj) }} }} - public interface Interface + public partial interface Interface {{ int GetType(int objA, int objB); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs index 9049cd5d..f2d3692c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs @@ -571,7 +571,7 @@ public int GetType(int objA, int objB) return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); }} - public interface Interface + public partial interface Interface {{ int GetType(int obj); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs index a668f2c1..9158c581 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs @@ -576,7 +576,7 @@ public int GetType(int obj) return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); }} - public interface Interface + public partial interface Interface {{ int GetType(int objA, int objB); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs index 6d422c23..dbba2f3a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs @@ -571,7 +571,7 @@ public int GetType(int objA, int objB) return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); }} - public interface Interface + public partial interface Interface {{ int GetType(int obj); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs index 731613c9..f9e04214 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs @@ -571,7 +571,7 @@ public int GetType(int obj) return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); }} - public interface Interface + public partial interface Interface {{ int GetType(int objA, int objB); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs index d0e056f3..18e9f345 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs @@ -571,7 +571,7 @@ public int GetType(int objA, int objB) return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); }} - public interface Interface + public partial interface Interface {{ int GetType(int obj); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs index a49a18d3..3b98b60e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs @@ -571,7 +571,7 @@ public int GetType(int obj) return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); }} - public interface Interface + public partial interface Interface {{ int GetType(int objA, int objB);