Skip to content

Commit

Permalink
Store some parameters as members on fx_resolver_t
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung committed Apr 19, 2024
1 parent 63a96c5 commit 9907366
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/native/corehost/fxr/fx_muxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ namespace
}
else
{
rc = fx_resolver_t::resolve_frameworks_for_app(host_info, app_config.get_is_multilevel_lookup_disabled(), override_settings, app_config, fx_definitions, mode == host_mode_t::muxer ? app_candidate.c_str() : nullptr);
rc = fx_resolver_t::resolve_frameworks_for_app(host_info.dotnet_root, override_settings, app_config, fx_definitions, mode == host_mode_t::muxer ? app_candidate.c_str() : host_info.host_path.c_str());
if (rc != StatusCode::Success)
{
return rc;
Expand Down Expand Up @@ -619,7 +619,7 @@ namespace
return StatusCode::InvalidConfigFile;
}

rc = fx_resolver_t::resolve_frameworks_for_app(host_info, app_config.get_is_multilevel_lookup_disabled(), override_settings, app_config, fx_definitions);
rc = fx_resolver_t::resolve_frameworks_for_app(host_info.dotnet_root, override_settings, app_config, fx_definitions, host_info.host_path.c_str());
if (rc != StatusCode::Success)
return rc;

Expand Down
32 changes: 15 additions & 17 deletions src/native/corehost/fxr/fx_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,10 @@ void fx_resolver_t::update_newest_references(
// FrameworkMissingFailure - the resolution failed because the requested framework doesn't exist on disk.
// InvalidConfigFile - reading of a runtime config for some of the processed frameworks has failed.
StatusCode fx_resolver_t::read_framework(
const host_startup_info_t & host_info,
bool disable_multilevel_lookup,
const runtime_config_t::settings_t& override_settings,
const runtime_config_t & config,
const fx_reference_t * effective_parent_fx_ref,
fx_definition_vector_t & fx_definitions,
const pal::string_t& dotnet_root,
const runtime_config_t& config,
const fx_reference_t* effective_parent_fx_ref,
fx_definition_vector_t& fx_definitions,
resolution_failure_info& resolution_failure)
{
// This reconciles duplicate references to minimize the number of resolve retries.
Expand Down Expand Up @@ -440,7 +438,7 @@ StatusCode fx_resolver_t::read_framework(
m_effective_fx_references[fx_name] = new_effective_fx_ref;

// Resolve the effective framework reference against the existing physical framework folders
std::unique_ptr<fx_definition_t> fx = resolve_framework_reference(new_effective_fx_ref, m_oldest_fx_references[fx_name].get_fx_version(), host_info.dotnet_root, disable_multilevel_lookup);
std::unique_ptr<fx_definition_t> fx = resolve_framework_reference(new_effective_fx_ref, m_oldest_fx_references[fx_name].get_fx_version(), dotnet_root, m_disable_multilevel_lookup);
if (fx == nullptr)
{
resolution_failure.missing = std::move(new_effective_fx_ref);
Expand All @@ -461,7 +459,7 @@ StatusCode fx_resolver_t::read_framework(
pal::string_t config_file;
pal::string_t dev_config_file;
get_runtime_config_paths(fx->get_dir(), fx_name, &config_file, &dev_config_file);
fx->parse_runtime_config(config_file, dev_config_file, override_settings);
fx->parse_runtime_config(config_file, dev_config_file, m_override_settings);

runtime_config_t new_config = fx->get_runtime_config();
if (!new_config.is_valid())
Expand All @@ -471,7 +469,7 @@ StatusCode fx_resolver_t::read_framework(
}

fx_definitions.push_back(std::move(fx));
rc = read_framework(host_info, disable_multilevel_lookup, override_settings, new_config, &new_effective_fx_ref, fx_definitions, resolution_failure);
rc = read_framework(dotnet_root, new_config, &new_effective_fx_ref, fx_definitions, resolution_failure);
if (rc != StatusCode::Success)
return rc;
}
Expand All @@ -496,15 +494,15 @@ StatusCode fx_resolver_t::read_framework(
}

StatusCode fx_resolver_t::resolve_frameworks_for_app(
const host_startup_info_t & host_info,
bool disable_multilevel_lookup,
const pal::string_t& dotnet_root,
const runtime_config_t::settings_t& override_settings,
const runtime_config_t & app_config,
fx_definition_vector_t & fx_definitions,
const runtime_config_t& app_config,
fx_definition_vector_t& fx_definitions,
const pal::char_t* app_display_name,
bool print_errors)
{
fx_resolver_t resolver;
bool disable_multilevel_lookup = app_config.get_is_multilevel_lookup_disabled();
fx_resolver_t resolver{ disable_multilevel_lookup, override_settings };

// Read the shared frameworks; retry is necessary when a framework is already resolved, but then a newer compatible version is processed.
resolution_failure_info resolution_failure;
Expand All @@ -513,7 +511,7 @@ StatusCode fx_resolver_t::resolve_frameworks_for_app(
do
{
fx_definitions.resize(1); // Erase any existing frameworks for re-try
rc = resolver.read_framework(host_info, disable_multilevel_lookup, override_settings, app_config, /*effective_parent_fx_ref*/ nullptr, fx_definitions, resolution_failure);
rc = resolver.read_framework(dotnet_root, app_config, /*effective_parent_fx_ref*/ nullptr, fx_definitions, resolution_failure);
} while (rc == StatusCode::FrameworkCompatRetry && retry_count++ < Max_Framework_Resolve_Retries);

assert(retry_count < Max_Framework_Resolve_Retries);
Expand All @@ -532,9 +530,9 @@ StatusCode fx_resolver_t::resolve_frameworks_for_app(
_X("\n\n")
_X("App: %s\n")
_X("Architecture: %s"),
app_display_name != nullptr ? app_display_name : host_info.host_path.c_str(),
app_display_name,
get_current_arch_name());
display_missing_framework_error(resolution_failure.missing.get_fx_name(), resolution_failure.missing.get_fx_version(), pal::string_t(), host_info.dotnet_root, disable_multilevel_lookup);
display_missing_framework_error(resolution_failure.missing.get_fx_name(), resolution_failure.missing.get_fx_version(), pal::string_t(), dotnet_root, disable_multilevel_lookup);
break;
case StatusCode::FrameworkCompatFailure:
display_incompatible_framework_error(resolution_failure.incompatible_higher.get_fx_version(), resolution_failure.incompatible_lower);
Expand Down
17 changes: 10 additions & 7 deletions src/native/corehost/fxr/fx_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ class fx_resolver_t

public:
static StatusCode resolve_frameworks_for_app(
const host_startup_info_t& host_info,
bool disable_multilevel_lookup,
const pal::string_t& dotnet_root,
const runtime_config_t::settings_t& override_settings,
const runtime_config_t& app_config,
/*in_out*/ fx_definition_vector_t& fx_definitions,
const pal::char_t* app_display_name = nullptr,
const pal::char_t* app_display_name,
bool print_errors = true);

static bool is_config_compatible_with_frameworks(
const runtime_config_t& config,
const std::unordered_map<pal::string_t, const fx_ver_t> &existing_framework_versions_by_name);

private:
fx_resolver_t() = default;
fx_resolver_t(bool disable_multilevel_lookup, const runtime_config_t::settings_t& override_settings)
: m_disable_multilevel_lookup{disable_multilevel_lookup}
, m_override_settings{override_settings}
{ }

void update_newest_references(
const runtime_config_t& config);
StatusCode read_framework(
const host_startup_info_t& host_info,
bool disable_multilevel_lookup,
const runtime_config_t::settings_t& override_settings,
const pal::string_t& dotnet_root,
const runtime_config_t& config,
const fx_reference_t * effective_parent_fx_ref,
fx_definition_vector_t& fx_definitions,
Expand Down Expand Up @@ -90,6 +90,9 @@ class fx_resolver_t
// to fill the "oldest reference" for each resolved framework in the end. It does not affect the behavior
// of the algorithm.
fx_name_to_fx_reference_map_t m_oldest_fx_references;

bool m_disable_multilevel_lookup;
const runtime_config_t::settings_t& m_override_settings;
};

#endif // __FX_RESOLVER_H__

0 comments on commit 9907366

Please sign in to comment.