-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Enable calling get_runtime_delegate from app context #37473
Enable calling get_runtime_delegate from app context #37473
Conversation
Tagging subscribers to this area: @vitek-karas, @swaroop-sridhar |
Can you please fix the design doc in this PR as well?. In this section it states that the |
Re breaking changes:
I think this is good - you're right that we should not do any work if we know it's going to fail. So I like this change in general (I have yet to look at the implementation details).
I'm not sure about this one. I do agree that the returned value is not great (misleading to say the least). That said I know about several cases where the exact exist code is used by calling code to make decisions. So changing it feels risky to me. If this would be a change in the runtime I would not worry too much as we're OK taking small breaking changes in major releases (with good reason). Unfortunately this is a change in I think we should not make this change - I know the number value is bad, but we at least print out the right error message. |
The reason I thought it was acceptable is because there is no way for the native host to distinguish this from the case where the config file is actually invalid. So I think their code was brittle to begin with. But I understand if we can't take this change. I'm also making |
For some reason I think it is more OK than the other 🤷. This one is a clear programmer error, so it's unlikely there will be fallback code paths which react to the error code to do something meaningful. The first one is data driven - depends on the So yes - I'm OK taking the change on |
a195f94
to
a2011c2
Compare
src/installer/corehost/cli/fxr/standalone/hostpolicy_resolver.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - thanks a lot for the change!
Please wait a day or two for @AaronRobinsonMSFT and @elinor-fung to have a change to take a look as well.
ac67575
to
9c8da06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
…gate types. This is required so that the runtime isn't loaded if the request has no chance of succeeding. Fix spelling of initialization_options_t. Add context_contract_version_set flag to initialization_options_t. This allows hostpolicy to know whether it can rely on the version field of corehost_context_contract to be valid. Also always initialize corehost_context_contract to {}.
Currently, it may only request the load_assembly_and_get_function_pointer delegate. Fix discrepancy in design doc. Add error code HostApiUnsupportedScenario for blocks that might be removed. This gives the native host better information on why the request failed. Add tests for running a component from an app context.
9c8da06
to
c993c7f
Compare
I added the comment about |
@rseanhall thanks a lot for the changes! |
This is the first part of implementing #35465. This pull request is supposed to address all the complexities of allowing
hostfxr_get_runtime_delegate
to be called from a context fromhostfxr_initialize_for_dotnet_command_line
. As designed in #36990, an app context may only ask forhdt_load_assembly_and_get_function_pointer
. Implementing the newhdt_get_function_pointer
type will be done in a subsequent pull request after this one is merged.As part of this change, there are a couple of behavior changes that may technically be breaking changes.
Loading the runtime when given an invalid delegate type
In 3.x,
hostfxr_get_runtime_delegate
doesn't error out when given an invalid delegate type. This means that it will load the runtime before calling intohostpolicy
. Then theget_delegate
call inhostpolicy
is where it errors out. This behavior is unacceptable because the native host needs to have control over starting the runtime if there's no chance of getting a delegate fromhostfxr
.In order to implement this change, I started making
hostpolicy
return the highest delegate type it knows about. Thenhostfxr
will check against that (orhdt_load_assembly_and_get_function_pointer
if it's an oldhostpolicy
) before trying to load the runtime.Error code when trying to load SCD componentIn 3.x,hostfxr_initialize_for_runtime_config
returns the error codeInvalidConfigFile
when the config is for an SCD component. This error code is misleading since the config file is valid, just not currently supported byhostfxr
. I madehostfxr
return the newHostApiUnsupportedScenario
error code in this case to give the native host better error information.