Make marker interfaces partial to support user extensions
Summary
Makes generated marker interfaces partial to allow users to manually extend them with custom implementations.
Fixes #647
Changes
- Modified
CSharpOutputBuilder.VisitDecl.cs:829to generatepublic partial interface Interfaceinstead ofpublic interface Interface
Why
When --generate-marker-interfaces is enabled, users may want to manually add custom helper methods to the interface contract. Without the partial keyword, this is impossible.
Impact
- Non-breaking: Adding
partialto an interface is backward compatible - Consistent: Matches the existing pattern where generated structs are already
partial - Enables: User extensions for excluded methods, custom helpers, or manual implementations of unsupported C++ constructs
Testing
- Built successfully with
dotnet build - No compilation errors or warnings
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]
@dotnet-policy-service agree
When --generate-marker-interfaces is enabled, users may want to manually add custom helper methods to the interface contract. Without the partial keyword, this is impossible.
This is potentially problematic as it can break the ABI compatibility if users try to use these types with COM wrappers or similar functionality.
When --generate-marker-interfaces is enabled, users may want to manually add custom helper methods to the interface contract. Without the partial keyword, this is impossible.
This is potentially problematic as it can break the ABI compatibility if users try to use these types with COM wrappers or similar functionality.
True. But the primary use is to map methods that don't map correctly, at present that's possible for the main struct/class, but not the interface.
But the primary use is to map methods that don't map correctly
The bindings should all be correct, if they aren't there is a bug in ClangSharp that needs fixing (particularly since that means you'd have a "bad definition" persisting in the interface).
Do you have an example of something that doesn't bind correctly?