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/06 16:56:19 UTC

[lucenenet] branch master updated: BREAKING: Remove virtual on a method that's being called from constructor in TernaryTree (#798)

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 3f4077a77 BREAKING: Remove virtual on a method that's being called from constructor in TernaryTree (#798)
3f4077a77 is described below

commit 3f4077a77aee94ab8ea767e04251a02814b21859
Author: Laimonas Simutis <la...@gmail.com>
AuthorDate: Thu Apr 6 09:56:13 2023 -0700

    BREAKING: Remove virtual on a method that's being called from constructor in TernaryTree (#798)
---
 .../Analysis/Compound/Hyphenation/HyphenationTree.cs             | 9 +++++++++
 .../Analysis/Compound/Hyphenation/TernaryTree.cs                 | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/HyphenationTree.cs b/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/HyphenationTree.cs
index 85786fb02..e1340e9c4 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/HyphenationTree.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/HyphenationTree.cs
@@ -32,6 +32,15 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
     /// fast lookup. It provides the provides the method to hyphenate a word.
     /// <para/>
     /// This class has been taken from the Apache FOP project (http://xmlgraphics.apache.org/fop/). They have been slightly modified. 
+    ///
+    /// Lucene.NET specific note:
+    /// If you are going to extend this class by inheriting from it, you should be aware that the
+    /// base class TernaryTree initializes its state in the constructor by calling its protected Init() method.
+    /// If your subclass needs to initialize its own state, you add your own "Initialize()" method
+    /// and call it both from the inside of your constructor and you will need to override the Balance() method
+    /// and call "Initialize()" before the call to base.Balance().
+    /// Your class can use the data that is initialized in the base class after the call to base.Balance().
+    ///
     /// </summary>
     public class HyphenationTree : TernaryTree, IPatternConsumer
     {
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/TernaryTree.cs b/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/TernaryTree.cs
index 5a0cd42b1..1f439e286 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/TernaryTree.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Compound/Hyphenation/TernaryTree.cs
@@ -125,7 +125,9 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
             Init();
         }
 
-        protected virtual void Init()
+         // LUCENENET specific - S1699 - marked non-virtual because calling
+         // virtual members from the constructor is not a safe operation in .NET
+        protected void Init()
         {
             m_root = (char)0;
             m_freenode = (char)1;