Skip to content

Commit

Permalink
Remove Equ more cleanly (#617)
Browse files Browse the repository at this point in the history
* Remove Equ more cleanly

* Remove Equ entry from PACKAGES.md

---------

Co-authored-by: James A Sutherland <>
  • Loading branch information
jas88 authored Jan 13, 2025
1 parent 8e29f0d commit 0479e1a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 13 deletions.
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.3" />
<PackageVersion Include="CsvHelper" Version="33.0.1" />
<PackageVersion Include="Equ" Version="2.3.0" />
<PackageVersion Include="fo-dicom.Imaging.ImageSharp" Version="5.1.5" />
<PackageVersion Include="HIC.DicomTypeTranslation" Version="4.1.5" />
<PackageVersion Include="HIC.FAnsiSql" Version="3.2.7" />
Expand Down
1 change: 1 addition & 0 deletions IsIdentifiable.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
CHANGELOG.md = CHANGELOG.md
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
PACKAGES.md = PACKAGES.md
README.md = README.md
Expand Down
3 changes: 1 addition & 2 deletions IsIdentifiable/Failures/Failure.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Equ;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand All @@ -12,7 +11,7 @@ namespace IsIdentifiable.Failures;
/// along with the <see cref="ResourcePrimaryKey"/> (if any) so that the row on which
/// the data was found can located (e.g. to perform redaction).
/// </summary>
public class Failure : MemberwiseEquatable<Failure>
public record Failure
{
/// <summary>
/// Each sub part of <see cref="ProblemValue"/> that the system had a problem with
Expand Down
4 changes: 1 addition & 3 deletions IsIdentifiable/Failures/FailurePart.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Equ;

namespace IsIdentifiable.Failures;

/// <summary>
/// Part of a <see cref="Failure"/>. Describes a section (e.g. a word) of the full cell that is marked as IsIdentifiable.
/// A <see cref="Failure"/> can have multiple <see cref="FailurePart"/> e.g. if it is free text with multiple failing
/// words.
/// </summary>
public class FailurePart : MemberwiseEquatable<FailurePart>
public record FailurePart
{
/// <summary>
/// The classification of the failure e.g. CHI, PERSON, TextInPixel
Expand Down
1 change: 0 additions & 1 deletion IsIdentifiable/IsIdentifiable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" />
<PackageReference Include="CsvHelper" />
<PackageReference Include="Equ" />
<PackageReference Include="fo-dicom.Imaging.ImageSharp" />
<PackageReference Include="HIC.DicomTypeTranslation" />
<PackageReference Include="HIC.FAnsiSql" />
Expand Down
11 changes: 10 additions & 1 deletion IsIdentifiable/Rules/AllowListRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ namespace IsIdentifiable.Rules;
/// <summary>
/// Expanded <see cref="RegexRule"/> which works only for <see cref="RuleAction.Ignore"/>. Should be run after main rules have picked up failures. This class is designed to perform final checks on failures and discard based on <see cref="RegexRule.IfPatternRegex"/> and/or <see cref="IfPartPatternRegex"/>
/// </summary>
public class AllowlistRule : RegexRule
public record AllowlistRule : RegexRule
{
/// <inheritdoc />
public virtual bool Equals(AllowlistRule? other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return base.Equals(other) && _ifPartPatternString == other._ifPartPatternString;
}

public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), _ifPartPatternString);

/// <summary>
/// Combination of <see cref="IfPartPattern"/> and <see cref="CaseSensitive"/>. Use this to validate
Expand Down
16 changes: 12 additions & 4 deletions IsIdentifiable/Rules/RegexRule.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Equ;
using IsIdentifiable.Failures;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
Expand All @@ -17,8 +15,18 @@ namespace IsIdentifiable.Rules;
/// A simple Regex based rule that allows flexible white listing or blacklisting of values
/// either in all columns or only a single column
/// </summary>
public class RegexRule : MemberwiseEquatable<RegexRule>, IRegexRule
public record RegexRule : IRegexRule
{
/// <inheritdoc/>
public virtual bool Equals(RegexRule? other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return _ifPatternString == other._ifPatternString && _caseSensitive == other._caseSensitive && Action == other.Action && IfColumn == other.IfColumn && As == other.As;
}

public override int GetHashCode() => HashCode.Combine(_ifPatternString, _caseSensitive, (int)Action, IfColumn, (int)As);

/// <inheritdoc/>
public RuleAction Action { get; set; }

Expand All @@ -32,7 +40,7 @@ public class RegexRule : MemberwiseEquatable<RegexRule>, IRegexRule
/// Combination of <see cref="IfPattern"/> and <see cref="CaseSensitive"/>. Use this to validate
/// whether the rule should be applied.
/// </summary>
[MemberwiseEqualityIgnore] // NOTE(rkm 2023-05-03) Exclude so equality comparer is valid
// [MemberwiseEqualityIgnore] // NOTE(rkm 2023-05-03) Exclude so equality comparer is valid - JAS 2025-01-13 moved to explicit Equals instead of Equ
protected Regex? IfPatternRegex;

private string? _ifPatternString;
Expand Down
1 change: 0 additions & 1 deletion PACKAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

| Package | Source Code | License | Purpose |
| --------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| [Equ](https://github.com/thedmi/Equ) | [GitHub](https://github.com/thedmi/Equ) | [MIT](https://opensource.org/licenses/MIT) | Simplifies object comparators |
| [NLog](https://nlog-project.org/) | [GitHub](https://github.com/NLog/NLog) | [BSD 3-Clause](https://github.com/NLog/NLog/blob/dev/LICENSE.txt) | Flexible user configurable logging |
| [Nunit](https://nunit.org/) | [GitHub](https://github.com/nunit/nunit) | [MIT](https://opensource.org/licenses/MIT) | Unit testing |
| CommandLineParser | [GitHub](https://github.com/commandlineparser/commandline) | [MIT](https://opensource.org/licenses/MIT) | Allows command line arguments for main client application and CLI executables |
Expand Down

0 comments on commit 0479e1a

Please sign in to comment.