Skip to content

Commit

Permalink
Add missing sections in implicit machine.config (#88553)
Browse files Browse the repository at this point in the history
This will add the missing sections of type IgnoreSection to the
implicitly generated machine.config.

Fix #930
  • Loading branch information
mpidash committed Jul 13, 2023
1 parent 28a4c95 commit 62d6335
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public override Stream OpenStreamForRead(string streamName)
<section name='satelliteassemblies' type='System.Configuration.IgnoreSection, System.Configuration.ConfigurationManager' allowLocation='false' />
<section name='startup' type='System.Configuration.IgnoreSection, System.Configuration.ConfigurationManager' allowLocation='false' />
<section name='system.diagnostics' type='System.Diagnostics.SystemDiagnosticsSection, System.Configuration.ConfigurationManager' allowLocation='false' />
<section name='system.runtime.remoting' type='System.Configuration.IgnoreSection, System.Configuration.ConfigurationManager' allowLocation='false' />
<section name='windows' type='System.Configuration.IgnoreSection, System.Configuration.ConfigurationManager' allowLocation='false' />
</configSections>
<configProtectedData defaultProvider='RsaProtectedConfigurationProvider'>
<providers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Configuration;
using System.Configuration.Internal;
using System.IO;
using Microsoft.DotNet.RemoteExecutor;

using Xunit;

namespace System.ConfigurationTests
Expand All @@ -18,6 +20,30 @@ public void RuntimeAppSettingsAccessible()
Assert.NotNull(appSettings);
}

[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public void RuntimeAppSettingsSystemRuntimeRemotingSectionIsSupported()
{
using (var temp = new TempConfig(TestData.SystemRuntimeRemotingSectionConfig))
{
RemoteExecutor.Invoke((string configFilePath) => {
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", configFilePath);
Assert.NotNull(ConfigurationManager.GetSection("system.runtime.remoting"));
}, temp.ConfigPath).Dispose();
}
}

[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public void RuntimeAppSettingsWindowsSectionIsSupported()
{
using (var temp = new TempConfig(TestData.WindowsSectionConfig))
{
RemoteExecutor.Invoke((string configFilePath) => {
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", configFilePath);
Assert.NotNull(ConfigurationManager.GetSection("windows"));
}, temp.ConfigPath).Dispose();
}
}

[Fact]
public void DesignTimeAppSettingsAccessible()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,23 @@ public static class TestData
<add key='BarKey' value='BarValue' />
</appSettings>
</configuration>";

public static string SystemRuntimeRemotingSectionConfig =
@"<?xml version='1.0' encoding='utf-8' ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref='tcp' port='1111' />
</channels>
</application>
</system.runtime.remoting>
</configuration>";

public static string WindowsSectionConfig =
@"<?xml version='1.0' encoding='utf-8' ?>
<configuration>
<windows />
</configuration>";
}
}

0 comments on commit 62d6335

Please sign in to comment.