Skip to content

Commit 0f71d0d

Browse files
committed
Tweaks for tests and classes
1 parent fbab1a7 commit 0f71d0d

12 files changed

+9
-332
lines changed

docs/Strategies.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var diffs = DiffBuilder
4545
.WithClassAttributeComparer()
4646
.WithBooleanAttributeComparer(BooleanAttributeComparision.Strict)
4747
.WithStyleAttributeComparer()
48-
.WithInlineAttributeIgnoreSupport()
4948
.Build();
5049
```
5150

@@ -405,14 +404,4 @@ To ignore a specific attribute during comparison, add the `:ignore` postfix to t
405404
<header>
406405
<h1 class:ignore="heading-1">Hello world</h1>
407406
</header>
408-
```
409-
410-
Activate this strategy by calling the `WithInlineAttributeIgnoreSupport()` method on a `DiffBuilder` instance, e.g.:
411-
412-
```csharp
413-
var diffs = DiffBuilder
414-
.Compare(controlHtml)
415-
.WithTest(testHtml)
416-
.WithInlineAttributeIgnoreSupport()
417-
.Build();
418407
```

src/Core/AttributeComparison.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public AttributeComparison(in AttributeComparisonSource control, in AttributeCom
1414
Control = control;
1515
Test = test;
1616
}
17-
18-
public (IElement ControlElement, IElement TestElement) GetAttributeElements()
17+
18+
public (IElement ControlElement, IElement TestElement) GetAttributeElements()
1919
=> ((IElement)Control.ElementSource.Node, (IElement)Test.ElementSource.Node);
2020

2121
#region Equals and HashCode
22-
public bool Equals(AttributeComparison other) => Control == other.Control && Test == other.Test;
22+
public bool Equals(AttributeComparison other) => Control.Equals(other.Control) && Test.Equals(other.Test);
2323
public override bool Equals(object obj) => obj is AttributeComparison other && Equals(other);
2424
public override int GetHashCode() => (Control, Test).GetHashCode();
2525
public static bool operator ==(AttributeComparison left, AttributeComparison right) => left.Equals(right);

src/Core/AttributeComparisonSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public AttributeComparisonSource(string attributeName, in ComparisonSource eleme
2929
}
3030

3131
#region Equals and HashCode
32-
public bool Equals(AttributeComparisonSource other) => Attribute == other.Attribute && ElementSource == other.ElementSource && Path.Equals(other.Path, StringComparison.Ordinal);
32+
public bool Equals(AttributeComparisonSource other) => Attribute == other.Attribute && ElementSource.Equals(other.ElementSource) && Path.Equals(other.Path, StringComparison.Ordinal);
3333
public override int GetHashCode() => (Attribute, ElementSource).GetHashCode();
3434
public override bool Equals(object obj) => obj is AttributeComparisonSource other && Equals(other);
3535
public static bool operator ==(AttributeComparisonSource left, AttributeComparisonSource right) => left.Equals(right);

src/Core/Diffs/DiffBase.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
namespace Egil.AngleSharp.Diffing.Core
55
{
66
[DebuggerDisplay("Diff={Target} {Result}")]
7-
public abstract class DiffBase<T> : IDiff, IEquatable<DiffBase<T>>
8-
where T : struct
7+
public abstract class DiffBase<T> : IDiff where T : struct
98
{
109
public T Control { get; }
1110

@@ -22,18 +21,5 @@ protected DiffBase(in T control, in T test, DiffTarget target)
2221
Result = DiffResult.Different;
2322
Target = target;
2423
}
25-
26-
public bool Equals(DiffBase<T> other) => !(other is null) && Control.Equals(other.Control) && Test.Equals(other.Test) && Result == other.Result && Target == other.Target;
27-
public override bool Equals(object obj) => obj is DiffBase<T> other && Equals(other);
28-
public override int GetHashCode() => (Control, Test, Result, Target).GetHashCode();
29-
public static bool operator ==(DiffBase<T> left, DiffBase<T> right)
30-
{
31-
if (left is null && right is null)
32-
return true;
33-
if (!(left is null))
34-
return left.Equals(right);
35-
return false;
36-
}
37-
public static bool operator !=(DiffBase<T> left, DiffBase<T> right) => !(left == right);
3824
}
3925
}

src/Core/Diffs/MissingDiffBase.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Egil.AngleSharp.Diffing.Core
44
{
5-
public abstract class MissingDiffBase<T> : IDiff, IEquatable<MissingDiffBase<T>> where T : struct
5+
public abstract class MissingDiffBase<T> : IDiff where T : struct
66
{
77
public T Control { get; }
88

@@ -16,19 +16,5 @@ protected MissingDiffBase(in T control, DiffTarget target)
1616
Result = DiffResult.Missing;
1717
Target = target;
1818
}
19-
20-
public bool Equals(MissingDiffBase<T> other) => !(other is null) && Control.Equals(other.Control) && Result == other.Result && Target == other.Target;
21-
public override bool Equals(object obj) => obj is MissingDiffBase<T> other && Equals(other);
22-
public override int GetHashCode() => (Control, Result, Target).GetHashCode();
23-
public static bool operator ==(MissingDiffBase<T> left, MissingDiffBase<T> right)
24-
{
25-
if (left is null && right is null)
26-
return true;
27-
if (!(left is null))
28-
return left.Equals(right);
29-
return false;
30-
}
31-
32-
public static bool operator !=(MissingDiffBase<T> left, MissingDiffBase<T> right) => !(left == right);
3319
}
3420
}

src/Core/Diffs/UnexpectedDiffBase.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Egil.AngleSharp.Diffing.Core
55
{
66
[DebuggerDisplay("Diff={Target} {Result}]")]
7-
public abstract class UnexpectedDiffBase<T> : IDiff, IEquatable<UnexpectedDiffBase<T>> where T : struct
7+
public abstract class UnexpectedDiffBase<T> : IDiff where T : struct
88
{
99
public T Test { get; }
1010

@@ -18,19 +18,5 @@ protected UnexpectedDiffBase(in T test, DiffTarget target)
1818
Result = DiffResult.Unexpected;
1919
Target = target;
2020
}
21-
22-
public bool Equals(UnexpectedDiffBase<T> other) => !(other is null) && Test.Equals(other.Test) && Result == other.Result && Target == other.Target;
23-
public override bool Equals(object obj) => obj is UnexpectedDiffBase<T> other && Equals(other);
24-
public override int GetHashCode() => (Test, Result, Target).GetHashCode();
25-
public static bool operator ==(UnexpectedDiffBase<T> left, UnexpectedDiffBase<T> right)
26-
{
27-
if (left is null && right is null)
28-
return true;
29-
if (!(left is null))
30-
return left.Equals(right);
31-
return false;
32-
}
33-
34-
public static bool operator !=(UnexpectedDiffBase<T> left, UnexpectedDiffBase<T> right) => !(left == right);
3521
}
3622
}

src/Strategies/AttributeStrategies/DiffingStrategyPipelineExtensions.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public static DiffingStrategyPipeline WithAttributeComparer(this DiffingStrategy
3333
{
3434
pipeline.AddMatcher(PostfixedAttributeMatcher.Match, isSpecializedMatcher: true);
3535
pipeline.AddComparer(AttributeComparer.Compare, isSpecializedComparer: false);
36+
pipeline.AddComparer(IgnoreAttributeComparer.Compare, isSpecializedComparer: true);
3637
return pipeline;
3738
}
3839

@@ -54,16 +55,6 @@ public static DiffingStrategyPipeline WithBooleanAttributeComparer(this DiffingS
5455
return pipeline;
5556
}
5657

57-
/// <summary>
58-
/// Enables ignoring attributes using the :ignore postfix for attributes during diffing.
59-
/// </summary>
60-
public static DiffingStrategyPipeline WithInlineAttributeIgnoreSupport(this DiffingStrategyPipeline pipeline)
61-
{
62-
pipeline.AddMatcher(IgnoreAttributeMatcher.Match, isSpecializedMatcher: true);
63-
pipeline.AddComparer(IgnoreAttributeComparer.Compare, isSpecializedComparer: true);
64-
return pipeline;
65-
}
66-
6758
/// <summary>
6859
/// Enables the special style attributes comparer during diffing.
6960
/// </summary>

src/Strategies/AttributeStrategies/IgnoreAttributeMatcher.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/Strategies/DiffingStrategyPipelineExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public static DiffingStrategyPipeline WithDefaultOptions(this DiffingStrategyPip
3131
.WithAttributeComparer()
3232
.WithClassAttributeComparer()
3333
.WithBooleanAttributeComparer(BooleanAttributeComparision.Strict)
34-
.WithStyleAttributeComparer()
35-
.WithInlineAttributeIgnoreSupport();
34+
.WithStyleAttributeComparer();
3635
;
3736
}
3837
}

tests/Core/Diffs/DiffBaseTest.cs

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)