Make marker interfaces partial to support user extensions#648
Make marker interfaces partial to support user extensions#648tompipe wants to merge 2 commits intodotnet:mainfrom
Conversation
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 <noreply@anthropic.com>
|
@dotnet-policy-service agree |
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. |
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? |
Summary
Makes generated marker interfaces
partialto allow users to manually extend them with custom implementations.Fixes #647
Changes
CSharpOutputBuilder.VisitDecl.cs:829to generatepublic partial interface Interfaceinstead ofpublic interface InterfaceWhy
When
--generate-marker-interfacesis enabled, users may want to manually add custom helper methods to the interface contract. Without thepartialkeyword, this is impossible.Impact
partialto an interface is backward compatiblepartialTesting
dotnet build🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com