Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/installer/tests/HostActivation.Tests/RuntimeProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,21 @@ public void DuplicateCommonProperty_Fails()
}

[Fact]
public void SpecifiedInConfigAndDevConfig_ConfigWins()
public void SpecifiedInConfigAndDevConfig_DevConfigWins()
{
var app = sharedState.App.Copy();

const string devConfigValue = "VALUE_FROM_DEV_CONFIG";
RuntimeConfig.FromFile(app.RuntimeDevConfigJson)
.WithProperty(SharedTestState.AppTestPropertyName, "VALUE_FROM_DEV_CONFIG")
.WithProperty(SharedTestState.AppTestPropertyName, devConfigValue)
.Save();

sharedState.DotNet.Exec(app.AppDll, PrintProperties, SharedTestState.AppTestPropertyName)
.EnableTracingAndCaptureOutputs()
.Execute()
.Should().Pass()
.And.HaveStdErrContaining($"Property {SharedTestState.AppTestPropertyName} = {SharedTestState.AppTestPropertyValue}")
.And.HaveStdOutContaining($"AppContext.GetData({SharedTestState.AppTestPropertyName}) = {SharedTestState.AppTestPropertyValue}");
.And.HaveStdErrContaining($"Property {SharedTestState.AppTestPropertyName} = {devConfigValue}")
.And.HaveStdOutContaining($"AppContext.GetData({SharedTestState.AppTestPropertyName}) = {devConfigValue}");
}

public class SharedTestState : IDisposable
Expand Down
9 changes: 8 additions & 1 deletion src/native/corehost/runtime_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void runtime_config_t::parse(const pal::string_t& path, const pal::string_t& dev
bool runtime_config_t::parse_opts(const json_parser_t::value_t& opts)
{
// Note: both runtime_config and dev_runtime_config call into the function.
// runtime_config will override whatever dev_runtime_config populated.
// dev_runtime_config is parsed first, and properties it specifies take precedence -
// values for the same property from runtime_config are ignored.
if (opts.IsNull())
{
return true;
Expand All @@ -93,6 +94,12 @@ bool runtime_config_t::parse_opts(const json_parser_t::value_t& opts)
m_properties.reserve(properties_obj.MemberCount());
for (const auto& property : properties_obj)
{
// If the property was already set (by dev_runtime_config), do not overwrite it.
if (m_properties.count(property.name.GetString()) != 0)
{
continue;
}

if (property.value.IsString())
{
m_properties[property.name.GetString()] = property.value.GetString();
Expand Down
Loading