-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
COM interfaces are not declared with the partial
keyword
#324
Comments
Using |
I think the entire risk could be mitigated with a new source generator error if any user-defined parts contain (non-type) members. But maybe the use case of adding attributes is too niche to be worth it. |
Honestly, a C# compiler-level warning when methods are added to two parts of a |
There is no warning (sharplab). Since this affects existing C#, I expect they will only want to add this in a warning wave. Things like this tend to be designed at dotnet/roslyn rather than dotnet/csharplang, which is good news because only a few things that require a spec change ever ship and it's usually years out. |
I checked on the repo contribution Discord channel and Fred confirmed that this would probably be a feature request for the Roslyn repo. https://github.com/dotnet/roslyn/issues/55006 |
@kant2002 does your COM Wrapper work in winforms need a partial interface at all? I believe winforms is going to use cswin32 without marshalling, so the interfaces will not be generated? Just making sure this doesn't end up blocking your work. |
I’m was not able to properly check current state of CsWin32 , but in general I never use partials for COM interface declaration so I’m fine with that. What’s important is that DllImport gives IntPtr for interface parameters. All I need is control of how COM proxy is created. With DllImport + IntPtr parameter I do that manually. With LibraryImport + IComInterface I think it’s possible to provide marshalers so I can control that part. Need more time to properly get context to answer you more targeted |
Thanks, we should know more when they start to look at it. |
Quick glanceFrom what I see on
RCWCurrently RCW build like this.
With current autogenerated structs
or
Still require manual passing all parameters. AddRef/Release/QI function is pointless because they never would be used. CCWCurrently CCW build like this
if
not much of a difference. Additional commentsSo basically for one scenario I need structs, for another interface.
I may screw with * here, but that's for illustrative purposes for now. |
@kant2002, thank you for your write-up.
I think I'll need more time to study the rest of your comments. |
I re-read this whole thread. I'm not clear on whether the |
I never need the partial on codegen. My ask onlly Until .NET 8 have COM source generators provide ability to use IntPtr instead of interfaces. That allow supply ComWrappers manually. |
@kant2002 what changes in .NET8? Do ComWrappers get easier? |
Interop team plans to add source generators which would works with LibraryImportGenerator . I do not sure if happens for sure, but plans are really here. |
Could you please link the associated issue? |
Do not know the issue, but plans are present https://twitter.com/mstrehovsky/status/1573203145236582403?s=46&t=mSvL8EQaVWZs8crDDX4qtg Interop team usually rock solid when they implement something. |
I'll close this based on this feedback. We can reactivate if anyone decides this is important. |
0.1.506-beta
I wanted to try something out by writing this:
But the IShellLinkW.g.cs declaration does not use the
partial
keyword:The text was updated successfully, but these errors were encountered: