You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warning for partial ComImport types with members in more than one type part #59013
The same reasoning applies as the reasoning for why partial enums wouldn't make sense. The meaning of a member in a ComImport type changes based on its order within the type.
There is currently no warning for a pair of source files like this, but there should be:
That will give "CS0267: The 'partial' modifier can only appear immediately before 'class', 'record', 'struct', 'interface', or a method return type." (dotnet/csharplang#2669) Even if partial enums with explicit ordering were allowed in the future, you'd want errors or warnings if the order wasn't explicitly given. That error/warning would be analogous to what we're asking for in ComImport types.
Moving to roslyn-analyzers as this feels more like an analyzer issue vs. a core compiler one. The reasoning being that [ComImport] isn't really a concept that is understood by the compiler. It exists outside of it. That's very much in analyzer territory.
@elachlan Can you elaborate on how lack of an analyzer would be a blocker for WinForms? At best it seems to me it would just help you write correct code. But when would WinForms define partial COM interfaces? CsWin32 is being used in WinForms without marshaling, so interfaces aren't even being generated.
Activity
AArnott commentedon Jul 21, 2021
partial enums are fine if the first enum value declared in each partial explicitly prescribes the value. For example, there's no problem here:
jnm2 commentedon Jul 21, 2021
That will give "CS0267: The 'partial' modifier can only appear immediately before 'class', 'record', 'struct', 'interface', or a method return type." (dotnet/csharplang#2669) Even if partial enums with explicit ordering were allowed in the future, you'd want errors or warnings if the order wasn't explicitly given. That error/warning would be analogous to what we're asking for in ComImport types.
jaredpar commentedon Aug 2, 2021
Moving to roslyn-analyzers as this feels more like an analyzer issue vs. a core compiler one. The reasoning being that
[ComImport]isn't really a concept that is understood by the compiler. It exists outside of it. That's very much in analyzer territory.mavasani commentedon Sep 13, 2021
Needs to be triaged/approved by dotnet/runtime.
elachlan commentedon Aug 17, 2022
This is a potential blocker for winforms as we attempt to migrate interop code to CsWin32.
CC: @JeremyKuhne, @lonitra
elachlan commentedon Aug 18, 2022
@danmoseley can you please see if you can get this unstuck?
AArnott commentedon Aug 19, 2022
@elachlan Can you elaborate on how lack of an analyzer would be a blocker for WinForms? At best it seems to me it would just help you write correct code. But when would WinForms define partial COM interfaces? CsWin32 is being used in WinForms without marshaling, so interfaces aren't even being generated.
dotnet-policy-service commentedon Apr 13, 2026
Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.