Skip to content
This repository was archived by the owner on Aug 26, 2022. It is now read-only.

Commit 6a4bca6

Browse files
authored
Addresses #339. Tries to load exe.config file when present. (#340)
1 parent c91cf79 commit 6a4bca6

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

Source/TestingServices/Engines/AbstractTestingEngine.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//-----------------------------------------------------------------------
22
// <copyright file="AbstractTestingEngine.cs">
33
// Copyright (c) Microsoft Corporation. All rights reserved.
4-
//
4+
//
55
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
66
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
77
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -19,6 +19,7 @@
1919
using System.Reflection;
2020
using System.Threading;
2121
using System.Threading.Tasks;
22+
using System.Configuration;
2223

2324
using Microsoft.PSharp.IO;
2425
using Microsoft.PSharp.TestingServices.Scheduling;
@@ -197,6 +198,31 @@ protected AbstractTestingEngine(Configuration configuration)
197198
Error.ReportAndExit(ex.Message);
198199
}
199200

201+
#if NET46 || NET45
202+
// Load config file and absorb its settings.
203+
try
204+
{
205+
var configFile = ConfigurationManager.OpenExeConfiguration(configuration.AssemblyToBeAnalyzed);
206+
207+
var settings = configFile.AppSettings.Settings;
208+
foreach (var key in settings.AllKeys)
209+
{
210+
if (ConfigurationManager.AppSettings.Get(key) == null)
211+
{
212+
ConfigurationManager.AppSettings.Set(key, settings[key].Value);
213+
}
214+
else
215+
{
216+
ConfigurationManager.AppSettings.Add(key, settings[key].Value);
217+
}
218+
}
219+
}
220+
catch (ConfigurationErrorsException ex)
221+
{
222+
Error.Report(ex.Message);
223+
}
224+
#endif
225+
200226
if (configuration.TestingRuntimeAssembly != "")
201227
{
202228
try
@@ -324,7 +350,7 @@ private void Initialize()
324350
else if (this.Configuration.SchedulingStrategy == SchedulingStrategy.RDPOR)
325351
{
326352
this.Strategy = new DPORStrategy(
327-
new ContractAsserter(),
353+
new ContractAsserter(),
328354
this.RandomNumberGenerator,
329355
-1,
330356
this.Configuration.MaxFairSchedulingSteps);

Source/TestingServices/TestingServices.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@
1919
<ProjectReference Include="..\Core\Core.csproj" />
2020
<ProjectReference Include="..\SchedulingStrategies\SchedulingStrategies.csproj" />
2121
</ItemGroup>
22+
<ItemGroup Condition="'$(TargetFramework)'=='net46'">
23+
<Reference Include="System.Configuration" />
24+
</ItemGroup>
25+
<ItemGroup Condition="'$(TargetFramework)'=='net45'">
26+
<Reference Include="System.Configuration" />
27+
</ItemGroup>
28+
2229
</Project>

0 commit comments

Comments
 (0)