Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Dec 12, 2024
1 parent fbb0ee1 commit 939d7bb
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 88 deletions.
4 changes: 1 addition & 3 deletions src/Lucene.Net.Benchmark/Quality/QualityQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,12 @@ public virtual int CompareTo(QualityQuery? other)
}

// LUCENENET specific - provide Equals and GetHashCode due to providing operator overrides
protected bool Equals(QualityQuery? other) => queryID == other?.queryID;

public override bool Equals(object? obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((QualityQuery)obj);
return queryID == ((QualityQuery)obj).queryID;
}

public override int GetHashCode() => queryID.GetHashCode();
Expand Down
28 changes: 16 additions & 12 deletions src/Lucene.Net.Highlighter/VectorHighlight/FieldPhraseList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,26 +471,28 @@ public override bool Equals(object obj)
}

#region Operator overrides
#nullable enable
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators

public static bool operator <(WeightedPhraseInfo left, WeightedPhraseInfo right)
public static bool operator <(WeightedPhraseInfo? left, WeightedPhraseInfo? right)
=> left is null ? right is not null : left.CompareTo(right) < 0;

public static bool operator <=(WeightedPhraseInfo left, WeightedPhraseInfo right)
public static bool operator <=(WeightedPhraseInfo? left, WeightedPhraseInfo? right)
=> left is null || left.CompareTo(right) <= 0;

public static bool operator >(WeightedPhraseInfo left, WeightedPhraseInfo right)
public static bool operator >(WeightedPhraseInfo? left, WeightedPhraseInfo? right)
=> left is not null && left.CompareTo(right) > 0;

public static bool operator >=(WeightedPhraseInfo left, WeightedPhraseInfo right)
public static bool operator >=(WeightedPhraseInfo? left, WeightedPhraseInfo? right)
=> left is null ? right is null : left.CompareTo(right) >= 0;

public static bool operator ==(WeightedPhraseInfo left, WeightedPhraseInfo right)
public static bool operator ==(WeightedPhraseInfo? left, WeightedPhraseInfo? right)
=> left?.Equals(right) ?? right is null;

public static bool operator !=(WeightedPhraseInfo left, WeightedPhraseInfo right)
public static bool operator !=(WeightedPhraseInfo? left, WeightedPhraseInfo? right)
=> !(left == right);

#nullable restore
#endregion

/// <summary>
Expand Down Expand Up @@ -567,26 +569,28 @@ public override string ToString()
}

#region Operator overrides
#nullable enable
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators

public static bool operator <(Toffs left, Toffs right)
public static bool operator <(Toffs? left, Toffs? right)
=> left is null ? right is not null : left.CompareTo(right) < 0;

public static bool operator <=(Toffs left, Toffs right)
public static bool operator <=(Toffs? left, Toffs? right)
=> left is null || left.CompareTo(right) <= 0;

public static bool operator >(Toffs left, Toffs right)
public static bool operator >(Toffs? left, Toffs? right)
=> left is not null && left.CompareTo(right) > 0;

public static bool operator >=(Toffs left, Toffs right)
public static bool operator >=(Toffs? left, Toffs? right)
=> left is null ? right is null : left.CompareTo(right) >= 0;

public static bool operator ==(Toffs left, Toffs right)
public static bool operator ==(Toffs? left, Toffs? right)
=> left?.Equals(right) ?? right is null;

public static bool operator !=(Toffs left, Toffs right)
public static bool operator !=(Toffs? left, Toffs? right)
=> !(left == right);

#nullable restore
#endregion
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/Lucene.Net.Highlighter/VectorHighlight/FieldTermStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,26 +286,28 @@ public override bool Equals(object obj)
}

#region Operator overrides
#nullable enable
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators

public static bool operator <(TermInfo left, TermInfo right)
public static bool operator <(TermInfo? left, TermInfo? right)
=> left is null ? right is not null : left.CompareTo(right) < 0;

public static bool operator <=(TermInfo left, TermInfo right)
public static bool operator <=(TermInfo? left, TermInfo? right)
=> left is null || left.CompareTo(right) <= 0;

public static bool operator >(TermInfo left, TermInfo right)
public static bool operator >(TermInfo? left, TermInfo? right)
=> left is not null && left.CompareTo(right) > 0;

public static bool operator >=(TermInfo left, TermInfo right)
public static bool operator >=(TermInfo? left, TermInfo? right)
=> left is null ? right is null : left.CompareTo(right) >= 0;

public static bool operator ==(TermInfo left, TermInfo right)
public static bool operator ==(TermInfo? left, TermInfo? right)
=> left?.Equals(right) ?? right is null;

public static bool operator !=(TermInfo left, TermInfo right)
public static bool operator !=(TermInfo? left, TermInfo? right)
=> !(left == right);

#nullable restore
#endregion
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Lucene.Net.Index;
using System;
using System.Text;
#pragma warning disable CS0660, CS0661 - CompareTo is deprecated, so skipping implementing equality members (lucenenet#683)

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net8.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net6.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

Check warning on line 5 in src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net9.0, x64, Release)

Single-line comment or end-of-line expected

namespace Lucene.Net.QueryParsers.Surround.Query
{
Expand Down Expand Up @@ -117,30 +118,32 @@ public override Search.Query MakeLuceneQueryFieldNoBoost(string fieldName, Basic
}

#region Operator overrides
#nullable enable
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators
// NOTE: The CompareTo method is marked as obsolete, but we still need to implement the comparison operators
// since this is public in 4.8. Suppressing the obsolete warning here.

#pragma warning disable CS0618 // Type or member is obsolete
public static bool operator <(SimpleTerm left, SimpleTerm right)
public static bool operator <(SimpleTerm? left, SimpleTerm? right)
=> left is null ? right is not null : left.CompareTo(right) < 0;

public static bool operator <=(SimpleTerm left, SimpleTerm right)
public static bool operator <=(SimpleTerm? left, SimpleTerm? right)
=> left is null || left.CompareTo(right) <= 0;

public static bool operator >(SimpleTerm left, SimpleTerm right)
public static bool operator >(SimpleTerm? left, SimpleTerm? right)
=> left is not null && left.CompareTo(right) > 0;

public static bool operator >=(SimpleTerm left, SimpleTerm right)
public static bool operator >=(SimpleTerm? left, SimpleTerm? right)
=> left is null ? right is null : left.CompareTo(right) >= 0;
#pragma warning restore CS0618 // Type or member is obsolete

public static bool operator ==(SimpleTerm left, SimpleTerm right)
public static bool operator ==(SimpleTerm? left, SimpleTerm? right)
=> left?.Equals(right) ?? right is null;

public static bool operator !=(SimpleTerm left, SimpleTerm right)
public static bool operator !=(SimpleTerm? left, SimpleTerm? right)
=> !(left == right);

#nullable restore
#endregion
}
}
29 changes: 21 additions & 8 deletions src/Lucene.Net.Suggest/Suggest/Fst/FSTCompletion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public sealed class Completion : IComparable<Completion>
{
/// <summary>
/// UTF-8 bytes of the suggestion </summary>
public BytesRef Utf8 { get; private set; }
public BytesRef Utf8 { get; }
/// <summary>
/// source bucket (weight) of the suggestion </summary>
public int Bucket { get; private set; }
public int Bucket { get; }

internal Completion(BytesRef key, int bucket)
{
Expand All @@ -68,27 +68,40 @@ public int CompareTo(Completion o)
return this.Utf8.CompareTo(o.Utf8);
}

// LUCENENET specific - per CS0660 and CS0661, we need to override Equals and GetHashCode
public override bool Equals(object obj) => ReferenceEquals(this, obj);

public override int GetHashCode()
{
unchecked
{
return (Utf8.GetHashCode() * 397) ^ Bucket;
}
}

#region Operator overrides
#nullable enable
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators

public static bool operator <(Completion left, Completion right)
public static bool operator <(Completion? left, Completion? right)
=> left is null ? right is not null : left.CompareTo(right) < 0;

public static bool operator <=(Completion left, Completion right)
public static bool operator <=(Completion? left, Completion? right)
=> left is null || left.CompareTo(right) <= 0;

public static bool operator >(Completion left, Completion right)
public static bool operator >(Completion? left, Completion? right)
=> left is not null && left.CompareTo(right) > 0;

public static bool operator >=(Completion left, Completion right)
public static bool operator >=(Completion? left, Completion? right)
=> left is null ? right is null : left.CompareTo(right) >= 0;

public static bool operator ==(Completion left, Completion right)
public static bool operator ==(Completion? left, Completion? right)
=> left?.Equals(right) ?? right is null;

public static bool operator !=(Completion left, Completion right)
public static bool operator !=(Completion? left, Completion? right)
=> !(left == right);

#nullable restore
#endregion
}

Expand Down
26 changes: 21 additions & 5 deletions src/Lucene.Net.Suggest/Suggest/Lookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ public sealed class LookupResult : IComparable<LookupResult>
{
/// <summary>
/// the key's text </summary>
public string Key { get; private set; }
public string Key { get; }

/// <summary>
/// Expert: custom Object to hold the result of a
/// highlighted suggestion.
/// </summary>
public object HighlightKey { get; private set; }
public object HighlightKey { get; }

/// <summary>
/// the key's weight </summary>
public long Value { get; private set; }
public long Value { get; }

/// <summary>
/// the key's payload (null if not present) </summary>
public BytesRef Payload { get; private set; }
public BytesRef Payload { get; }

/// <summary>
/// the key's contexts (null if not present) </summary>
public IEnumerable<BytesRef> Contexts { get; private set; }
public IEnumerable<BytesRef> Contexts { get; }

/// <summary>
/// Create a new result from a key+weight pair.
Expand Down Expand Up @@ -123,6 +123,22 @@ public int CompareTo(LookupResult o)
return CHARSEQUENCE_COMPARER.Compare(Key, o.Key);
}

// LUCENENET specific - per CS0660 and CS0661, we need to override Equals and GetHashCode
public override bool Equals(object obj) => ReferenceEquals(this, obj);

public override int GetHashCode()
{
unchecked
{
var hashCode = (Key != null ? Key.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (HighlightKey != null ? HighlightKey.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Value.GetHashCode();
hashCode = (hashCode * 397) ^ (Payload != null ? Payload.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Contexts != null ? Contexts.GetHashCode() : 0);
return hashCode;
}
}

#region Operator overrides
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators

Expand Down
14 changes: 8 additions & 6 deletions src/Lucene.Net/Index/IndexCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,28 @@ public virtual int CompareTo(IndexCommit commit)
}

#region Operator overrides
#nullable enable
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators

public static bool operator <(IndexCommit left, IndexCommit right)
public static bool operator <(IndexCommit? left, IndexCommit? right)
=> left is null ? right is not null : left.CompareTo(right) < 0;

public static bool operator <=(IndexCommit left, IndexCommit right)
public static bool operator <=(IndexCommit? left, IndexCommit? right)
=> left is null || left.CompareTo(right) <= 0;

public static bool operator >(IndexCommit left, IndexCommit right)
public static bool operator >(IndexCommit? left, IndexCommit? right)
=> left is not null && left.CompareTo(right) > 0;

public static bool operator >=(IndexCommit left, IndexCommit right)
public static bool operator >=(IndexCommit? left, IndexCommit? right)
=> left is null ? right is null : left.CompareTo(right) >= 0;

public static bool operator ==(IndexCommit left, IndexCommit right)
public static bool operator ==(IndexCommit? left, IndexCommit? right)
=> left?.Equals(right) ?? right is null;

public static bool operator !=(IndexCommit left, IndexCommit right)
public static bool operator !=(IndexCommit? left, IndexCommit? right)
=> !(left == right);

#nullable restore
#endregion
}
}
14 changes: 8 additions & 6 deletions src/Lucene.Net/Index/Term.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,28 @@ public override string ToString()
}

#region Operator overrides
#nullable enable
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators

public static bool operator <(Term left, Term right)
public static bool operator <(Term? left, Term? right)
=> left is null ? right is not null : left.CompareTo(right) < 0;

public static bool operator <=(Term left, Term right)
public static bool operator <=(Term? left, Term? right)
=> left is null || left.CompareTo(right) <= 0;

public static bool operator >(Term left, Term right)
public static bool operator >(Term? left, Term? right)
=> left is not null && left.CompareTo(right) > 0;

public static bool operator >=(Term left, Term right)
public static bool operator >=(Term? left, Term? right)
=> left is null ? right is null : left.CompareTo(right) >= 0;

public static bool operator ==(Term left, Term right)
public static bool operator ==(Term? left, Term? right)
=> left?.Equals(right) ?? right is null;

public static bool operator !=(Term left, Term right)
public static bool operator !=(Term? left, Term? right)
=> !(left == right);

#nullable restore
#endregion
}
}
14 changes: 8 additions & 6 deletions src/Lucene.Net/Util/Automaton/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,26 +376,28 @@ public override int GetHashCode()
}

#region Operator overrides
#nullable enable
// LUCENENET specific - per csharpsquid:S1210, IComparable<T> should override comparison operators

public static bool operator <(State left, State right)
public static bool operator <(State? left, State? right)
=> left is null ? right is not null : left.CompareTo(right) < 0;

public static bool operator <=(State left, State right)
public static bool operator <=(State? left, State? right)
=> left is null || left.CompareTo(right) <= 0;

public static bool operator >(State left, State right)
public static bool operator >(State? left, State? right)
=> left is not null && left.CompareTo(right) > 0;

public static bool operator >=(State left, State right)
public static bool operator >=(State? left, State? right)
=> left is null ? right is null : left.CompareTo(right) >= 0;

public static bool operator ==(State left, State right)
public static bool operator ==(State? left, State? right)
=> left is null ? right is null : ReferenceEquals(left, right);

public static bool operator !=(State left, State right)
public static bool operator !=(State? left, State? right)
=> !(left == right);

#nullable restore
#endregion
}
}
Loading

0 comments on commit 939d7bb

Please sign in to comment.