You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by la...@apache.org on 2023/04/13 20:15:14 UTC
[lucenenet] branch master updated: BREAKING: SrndTruncQuery fix for virtual call being made from constructor (#830)
This is an automated email from the ASF dual-hosted git repository.
laimis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new 746d9f3d3 BREAKING: SrndTruncQuery fix for virtual call being made from constructor (#830)
746d9f3d3 is described below
commit 746d9f3d34429e5aac661c382c856f8ecd62fce1
Author: Laimonas Simutis <la...@gmail.com>
AuthorDate: Thu Apr 13 13:15:08 2023 -0700
BREAKING: SrndTruncQuery fix for virtual call being made from constructor (#830)
---
src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs | 4 ++--
.../Surround/Query/SrndTruncQuery.cs | 15 +++++++++++++--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs b/src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs
index cbaaad9c3..ad9c6dcad 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/SimpleTerm.cs
@@ -27,9 +27,9 @@ namespace Lucene.Net.QueryParsers.Surround.Query
/// </summary>
public abstract class SimpleTerm : SrndQuery, IDistanceSubQuery, IComparable<SimpleTerm>
{
- protected SimpleTerm(bool q) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
+ protected SimpleTerm(bool quoted) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
{
- quoted = q;
+ this.quoted = quoted;
}
private readonly bool quoted; // LUCENENET: marked readonly
diff --git a/src/Lucene.Net.QueryParser/Surround/Query/SrndTruncQuery.cs b/src/Lucene.Net.QueryParser/Surround/Query/SrndTruncQuery.cs
index cf7bd42e7..349226d71 100644
--- a/src/Lucene.Net.QueryParser/Surround/Query/SrndTruncQuery.cs
+++ b/src/Lucene.Net.QueryParser/Surround/Query/SrndTruncQuery.cs
@@ -1,6 +1,7 @@
using Lucene.Net.Index;
using Lucene.Net.Util;
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Text.RegularExpressions;
@@ -28,13 +29,23 @@ namespace Lucene.Net.QueryParsers.Surround.Query
/// </summary>
public class SrndTruncQuery : SimpleTerm
{
+ [SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "This is a SonarCloud issue")]
+ [SuppressMessage("CodeQuality", "S1699:Constructors should only call non-overridable methods", Justification = "Required for continuity with Lucene's design")]
public SrndTruncQuery(string truncated, char unlimited, char mask)
- : base(false) /* not quoted */
+ : this(truncated, unlimited, mask, quoted: false) /* not quoted */
+ {
+ TruncatedToPrefixAndPattern();
+ }
+
+ // LUCENENET specific - this is for provided for subclasses to use and avoid
+ // the virtual call to TruncatedToPrefixAndPattern(), which they can do
+ // in their own constructor.
+ protected SrndTruncQuery(string truncated, char unlimited, char mask, bool quoted)
+ : base(quoted)
{
this.truncated = truncated;
this.unlimited = unlimited;
this.mask = mask;
- TruncatedToPrefixAndPattern();
}
private readonly string truncated;