Add host context-based entry points for native hosting#5859
Conversation
1f06d7a to
bbc65d3
Compare
|
I quickly scanned through it and it looks good, I'll do the thorough review later on. One request: Could you please separate the "Fail early on duplicate properties" into its own PR? (I think about it as a pre-req for this work, and it should make this PR slightly smaller) |
|
Separated into: #5898 |
bbc65d3 to
628e92c
Compare
72cf00e to
fc34c2c
Compare
948d6e8 to
32c2885
Compare
|
I think this should be in a reasonable state now. Things that I would like to keep separate and do in follow-up changes (in an attempt to break things up and keep this review a little smaller...):
|
vitek-karas
left a comment
There was a problem hiding this comment.
I think I'm done reviewing the "Scenarios". That is thinking through the various paths which should work.
I'll need to do another pass on the whole thing (for nits and so on)....
One request: Can you please add the test automation to this change (and not do it in a followup)? Even if there's small test coverage I think it's important to have at least something in place from the get go, to avoid big breaks.
non-context-based APIs
hostpolicy internally tracks its context and external functions just operate on the one context and error out if it is not in the expected state for that operation
Placeholder TODOs for compatibility checks Comments
…tion request (which may not yet have started) to complete
32c2885 to
14bd34f
Compare
|
Basic tests are in the latest commit. They only hit the most basic 'happy' path right now - not hitting failures or concurrent requests. |
vitek-karas
left a comment
There was a problem hiding this comment.
We're almost there - this looks good. I only quickly looked through the tests since we know we need to do more work there, but the product changes look solid.
| corehost_main_with_output_buffer_fn host_main = nullptr; | ||
|
|
||
| int code = load_hostpolicy(impl_dll_dir, &corehost, host_contract, "corehost_main_with_output_buffer", &host_main); | ||
| int code = load_hostpolicy(impl_dll_dir, &corehost, hostpolicy_contract, "corehost_main_with_output_buffer", &host_main); |
There was a problem hiding this comment.
Just a worry:
I guess this already exists as a problem today... but still.
If somebody calls this - it will load hostpolicy.
After that it's possible to call some other entry point which will also load hostpolicy, potentially a different one.
If it's the same one, we're probably fine since this calls unload.
If it's a different one, not sure how OS handles it... maybe it just works (two different dlls with the same name)
In any case, since this doesn't perform any synchronization we rely on the caller to not mix/match.
Probably a non-issue... just wanted to raise this for awareness.
There was a problem hiding this comment.
I added a log line for if hostpolicy was already loaded, the directory it was loaded from, and the requested directory (but did not change the existing behaviour).
Rename corehost -> hostpolicy_dll
|
There's another related issue - component hosts ( I filed a separate issue #6236 for this, but feel free to fix it in this PR if you want (although it's probably a relatively non-trivial change, since it needs different defines and so on... |
|
Switched to blocking initializing for self-contained components and will plan handle 6236 in a separate change. |
…etup#5859) - Track existing hostpolicy_context in hostpolicy - Add host_context to hostfxr to represent active (first) and secondary contexts - Switch com/ijw/winrt hosts to use host context-based APIs - Update nativehost test executable to exercise new APIs - Make non-context-based entry points check for existing context and create an empty context - Basic automated tests for context-based entry points Commit migrated from dotnet/core-setup@4f7fefe
hostpolicy_contextinhostpolicyhost_contexttohostfxrto represent active (first) and secondary contextshostfxrAPI surface changes:hostfxr_initialize_for_apphostfxr_initialize_for_runtime_confighostfxr_run_apphostfxr_get_runtime_property_valuehostfxr_set_runtime_property_valuehostfxr_get_runtime_propertieshostfxr_closehostfxr_get_runtime_delegatesignature to use host contexthostpolicyAPI surface changes:corehost_initializecorehost_get_coreclr_delegateFailure handling:
Mixed usage of non-context-based and context-based entry points:
hostfxr_get_runtime_property_valueorhostfxr_get_runtime_properties) is not supportedcorehost_initializeto indicate that it requires waiting for initialization (through a different request) to completeNot handled in this:
hostfxrlibrary if it is already loaded