diff --git a/CHANGELOG.md b/CHANGELOG.md
index c839fa14a..edaabeaea 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
* Fix: Visual Studio locks Reqnroll.Tools.MsBuild.Generation task files. Using `TaskHostFactory` for our tasks on Windows. (#293)
* Fix: Project dependencies transiently refer to System.Text.Json 8.0.4 that has security vulnerability. Microsoft.Extensions.DependencyModel updated to v8.0.2. (#291)
+* Fix: Could not load System.CodeDom exception with xRetry.Reqnroll plugin (#310)
*Contributors of this release (in alphabetical order):* @gasparnagy, @obligaron, @Romfos, @Tiberriver256
diff --git a/Reqnroll.Tools.MsBuild.Generation/AssemblyResolveLogger.cs b/Reqnroll.Tools.MsBuild.Generation/AssemblyResolveLogger.cs
index f8793ac77..0b4d53672 100644
--- a/Reqnroll.Tools.MsBuild.Generation/AssemblyResolveLogger.cs
+++ b/Reqnroll.Tools.MsBuild.Generation/AssemblyResolveLogger.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using System.Reflection;
namespace Reqnroll.Tools.MsBuild.Generation
@@ -23,6 +24,18 @@ public Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs ar
{
_taskLoggingWrapper.LogMessage(args.Name);
+ try
+ {
+ var requestedAssemblyName = new AssemblyName(args.Name);
+ var loadedAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == requestedAssemblyName.Name);
+ if (loadedAssembly != null) return loadedAssembly;
+ }
+ catch (Exception ex)
+ {
+ _taskLoggingWrapper.LogError(ex.Message);
+ return null;
+ }
+
return null;
}
diff --git a/Tests/Reqnroll.SystemTests/Plugins/XRetryPluginTest.cs b/Tests/Reqnroll.SystemTests/Plugins/XRetryPluginTest.cs
new file mode 100644
index 000000000..e5481ad4b
--- /dev/null
+++ b/Tests/Reqnroll.SystemTests/Plugins/XRetryPluginTest.cs
@@ -0,0 +1,41 @@
+using FluentAssertions;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Reqnroll.TestProjectGenerator;
+using Reqnroll.TestProjectGenerator.Driver;
+using System.Linq;
+
+namespace Reqnroll.SystemTests.Plugins;
+
+[TestClass]
+public class XRetryPluginTest : SystemTestBase
+{
+ protected override void TestInitialize()
+ {
+ base.TestInitialize();
+ _testRunConfiguration.UnitTestProvider = UnitTestProvider.xUnit;
+ _projectsDriver.AddNuGetPackage("xRetry.Reqnroll", "1.0.0");
+ }
+
+ [TestMethod]
+ public void XRetry_should_work_with_Reqnroll()
+ {
+ AddFeatureFileFromResource("XRetryPlugin/XRetryPluginTestFeature.feature");
+ AddBindingClassFromResource("XRetryPlugin/XRetryPluginTestStepDefinitions.cs");
+
+ ExecuteTests();
+
+ ShouldAllScenariosPass();
+
+ var simulatedErrors = _bindingDriver.GetActualLogLines("simulated-error").ToList();
+ simulatedErrors.Should().HaveCount(_preparedTests * 2); // two simulated error per test
+ }
+
+ [TestMethod]
+ [TestCategory("MsBuild")]
+ public void XRetry_should_work_with_Reqnroll_on_DotNetFramework_generation()
+ {
+ // compiling with MsBuild forces the generation to run with .NET Framework
+ _compilationDriver.SetBuildTool(BuildTool.MSBuild);
+ XRetry_should_work_with_Reqnroll();
+ }
+}
diff --git a/Tests/Reqnroll.SystemTests/Reqnroll.SystemTests.csproj b/Tests/Reqnroll.SystemTests/Reqnroll.SystemTests.csproj
index 6edea576d..312f05d27 100644
--- a/Tests/Reqnroll.SystemTests/Reqnroll.SystemTests.csproj
+++ b/Tests/Reqnroll.SystemTests/Reqnroll.SystemTests.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/Tests/Reqnroll.SystemTests/Resources/XRetryPlugin/XRetryPluginTestFeature.feature b/Tests/Reqnroll.SystemTests/Resources/XRetryPlugin/XRetryPluginTestFeature.feature
new file mode 100644
index 000000000..ce51d746c
--- /dev/null
+++ b/Tests/Reqnroll.SystemTests/Resources/XRetryPlugin/XRetryPluginTestFeature.feature
@@ -0,0 +1,15 @@
+Feature: XRetryPluginFeature
+
+Used by Reqnroll.SystemTests.Plugins.XRetryPluginTest
+
+@retry
+Scenario: Scenario with Retry
+ When fail for first 2 times A
+
+@retry
+Scenario Outline: Scenario outline with Retry
+ When fail for first 2 times