Skip to content

Commit

Permalink
Merge pull request #1799 from SMI/fix/dynamic-rules-load
Browse files Browse the repository at this point in the history
fix DynamicRejector constructor to allow reflection
  • Loading branch information
rkm authored Apr 19, 2024
2 parents 98b57b9 + bfe2452 commit c1e35d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/1799-bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Re-add a parameterless constructor to DynamicRejector so it can be loaded via reflection in CohortExtractorHost.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ public class DynamicRejector : IRejector
private readonly Script<string> _script;
private const string DefaultDynamicRulesPath = "./DynamicRules.txt";

public DynamicRejector()
: this(null) {}

public DynamicRejector(string? dynamicRulesPath, IFileSystem? fileSystem = null)
{
if (dynamicRulesPath == null)
dynamicRulesPath = DefaultDynamicRulesPath;

dynamicRulesPath ??= DefaultDynamicRulesPath;
fileSystem ??= new FileSystem();

if (!fileSystem.File.Exists(dynamicRulesPath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,11 @@ public void Constructor_MissingRulesFile_Throws()
Assert.Throws<FileNotFoundException>(() => new DynamicRejector("foo.txt", new MockFileSystem()));
}

[Test]
public void Constructor_ExistsWithNoArgs()
{
_ = new DynamicRejector();
}

#endregion
}

0 comments on commit c1e35d2

Please sign in to comment.