Repository navigation
Fix MSO interfaces - #1565
Fix MSO interfaces#1565
Conversation
There was a problem hiding this comment.
I've done a first look through this, seems like you have made a mistake with the component ids. I'm referencing office 2010 headers, if you have newer onces yours might be more correct, but I doubt they broke compatibility. (The office 2010 headers are in your VS 2017 installation under VSSDK\VisualStudioIntegration\Common\Inc\office10 - don't know if VS 2019 has them somewhere different. You can find the component manager headers in msoci.h and the VS version in the parent folder under olecm.h, but VS doesn't support 64 bit so the office ones are to be preferred I think)
In addition to your component id confusion you added dereferencing operations into the component ids which are not supposed to be there. Component IDs are DWORD_PTR in my header and while the host (VS or Office) can put a pointer to an uint there it doesn't have to, it might just as well be a numeric counter. DWORD_PTR does not mean "pointer to DWORD", it means it was a DWORD potentially holding a pointer variable on 32 bit, so it needed to be extended on 64 bit Windows. Since you aren't the owner of the content in no case can you safely dereference a DWORD_PTR because you don't know what it points to, or if it points to anything at all and isn't just a plain numeric value.
I didn't review Application.ComponentManager.cs and Application.ThreadContext.cs because they moved to a different file so its not easily viewed in github, I might check later with external tools.
Also I noted that you didn't yet refactor the AppDomain code to always assume Default Domain, which means the changeset won't run as-is on .NET Core because it tries to a call a nonexistant API (throws at runtime)
Codecov Report
@@ Coverage Diff @@
## master #1565 +/- ##
==================================================
- Coverage 26.03666% 26.0097% -0.02696%
==================================================
Files 830 815 -15
Lines 267542 267258 -284
Branches 37941 37893 -48
==================================================
- Hits 69659 69513 -146
+ Misses 192956 192814 -142
- Partials 4927 4931 +4
|
4b22546 to
89a85a5
Compare
|
Broke this into 3 commits. First is just breaking out the classes, second is fixing style (and using Path.Join in one spot), third is the actual functional changes. |
|
Tried hardening FGetActiveComponent. Sort of ugly, but I think I'm doing the right thing... |
weltkante
left a comment
There was a problem hiding this comment.
Generally looks good to me now, with one minor bug introduced in FOnComponentExitState.
I'll have to do some further review of the usage of MSG structs across callers/implementors before I agree that your removal of the ANSI/UNICODE split is safe.
b3fcde9 to
93b69c8
Compare
|
I put back the A/W Get/Dispatch and extended it to FContinueMessageLoop. |
|
@JeremyKuhne please fill in the compliance sections. |
Proposed changes
Customer Impact
Regression?
Risk
Test methodology
The tests that still don't exist are message pumping related. Can probably do it if we fire up a separate thread for that specific test with it's own message pump? |
Did anyone even test if this is working with Office? If you unblock the currently not working scenario of writing a .NET Core Office Addin without having tested the refactored code at all against a native IComponentManager I would consider that a not unsignificant risk of breaking Office. Previously this threw a PlatformNotSupportedException or something along those lines, due to the usage of AppDomain code. This prevents people from writing bad addins by failing early. Personally I don't think moving untested code into 3.0 release is a good idea. If you really want to get it in untested against Office you may want to consider disabling Office integration by turning off the lookup of a native IComponentManager. |
No, as I presume we're fundamentally broken there with .NET Core. If you know of how to do this, please share. I'm actually surprised that anything would work unless VSTO was updated for .NET Core. (I also have no idea how the runtime is hosted for Office. I presumed that loading Core into a process with Framework wasn't possible- so we may be fundamentally blocked?) I do understand that this area isn't well tested, the reason I put this up here was that I had already started investigating and I didn't want others to duplicate effort. I wanted a reference that could be used to potentially fix issues in the Framework version of WinForms. That all said, this does remove a lot of cruft and sets us up with a much less broken starting point, if not a working starting point. It is at least unit tested, which is more than we did have. I'd rather people be exploring and opening issues on this base than the other, but I'm also fine with this going in after 3.0 branches away. |
This is a COM addin API, loading of the framework happens as a side effect, Office has no part in it. Since I understand COM is supported by .NET Core 3 you can register the necessary keys and Office will load the addin just like any other addin. We have several Office addins on Desktop Framework in our products and our current plan is to look at a first attempt porting them when approaching dotnet 5. (We first have to move and restructure a lot of other components since they are using several parts of Desktop Framework which are no longer supported on Core.) There is currently no time pressure getting this in, I don't think anyone asked for this feature, my only worry is not getting it right the first time. I may be able to write some simple example addin on a weekend if it helps, but ideally someone from Office would coordinate since this is very much underdocumented internal API.
Yes I understand that, I just wanted to raise a word of caution against breaking Office. If this scenarion is unlocked people will eventually try it out, and if it breaks Office this isn't great. The problem with waiting for issues raised is that this kind of breaking can go undetected a very long time and just surface on customer sides. I doubt the average Office user will be raising issues against WinForms Core because some modal dialog locks up when having a certain combination of addins active. A workable compromise may be removing the native ComponentManager integration for now (just not query for it and always use your own). This sacrifices communication of modality with Office, but at least its not breaking things actively. I don't know how WPF works in Office addins (we only ever used WinForms in our projects) but as far as I can look into the WPF source I have yet to see any ComponentManager integration. Maybe removing this works just as well and it only needs to be re-added if Office says they need it for modality handling. |
|
@merriemcgaw do you know who we can engage from the Office team to help us test the changes? |
|
@OliaG may know our contact as well 🌘 👩🚀 |
|
Rebased |
|
I don't want anything to be merged before #1684 is complete. We have found few issues already, I don't want to deal with red herrings. |
Thanks for the details! |
|
Created #1763 to track understanding/testing Office interop. Removed WIP as the code is reviewed and unit tested and would like to get this in as a baseline for further work. |
|
@RussKie, @zsd4yr if you're ok with the state of this can you approve? I've written unit tests and I've created an issue to track understanding the interop scenario. I don't think it's worth trying to hold onto this PR until we understand the scenario better. It's taxing and will conflict a ton with other pending cleanup work. |
RussKie
left a comment
There was a problem hiding this comment.
Overall looks good to me.
I'm still confused with the use of bool and BOOL in p/invokes - what are the guidelines for these?
Move the nested classes in Application to separate files.
This fixes MSO component interfaces so that they correctly match the COM interface definitions. It also hardens against being invoked with null pointers.
…pDomain world of .NET Core. Attempt to reduce the complexity on component manager initialization.
|
Rebased and addressed feedback |
This fixes MSO component interfaces so that they correctly match the COM interface definitions. It also hardens against being invoked with null pointers.
See related issue: #247
Need to define the interop scenarios with Office to fully test this. Wanted to make sure this PR is active for visibility. (And to prevent others from replicating the work I did here.)
Proposed changes
Customer Impact
Regression?
Risk
Test methodology
The tests that still don't exist are message pumping related. Can probably do it if we fire up a separate thread for that specific test with it's own message pump?
Microsoft Reviewers: Open in CodeFlow