NightOwl888 commented on code in PR #801:
URL: https://github.com/apache/lucenenet/pull/801#discussion_r1160921746


##########
src/Lucene.Net/Util/SentinelIntSet.cs:
##########
@@ -89,7 +89,9 @@ public SentinelInt32Set(int size, int emptyVal)
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public virtual void Clear()
+        // LUCENENET specific - S1699 - marked non-virtual because calling
+        // virtual members from the constructor is not a safe operation in .NET
+        public void Clear()

Review Comment:
   This one can be made into private `ClearInternal()` that is called by the 
constructor and this virtual `Clear()` method.



##########
src/Lucene.Net/Search/DisjunctionMaxQuery.cs:
##########
@@ -92,7 +92,9 @@ public DisjunctionMaxQuery(ICollection<Query> disjuncts, 
float tieBreakerMultipl
         /// <summary>
         /// Add a subquery to this disjunction </summary>
         /// <param name="query"> The disjunct added </param>
-        public virtual void Add(Query query)
+        // LUCENENET specific - S1699 - marked non-virtual because calling
+        // virtual members from the constructor is not a safe operation in .NET
+        public void Add(Query query)

Review Comment:
   This one can be made into private `AddInternal()` called by the constructor 
and virtual `Add()`.



##########
src/Lucene.Net.Spatial/Prefix/Tree/Cell.cs:
##########
@@ -175,7 +175,9 @@ private void B_fixLeaf()
         public virtual bool IsLeaf => m_leaf;
 
         /// <summary>Note: not supported at level 0.</summary>
-        public virtual void SetLeaf()
+        // LUCENENET specific - S1699 - marked non-virtual because calling
+        // virtual members from the constructor is not a safe operation in .NET
+        public void SetLeaf()

Review Comment:
   This one can be made into private `SetLeafInternal()` called by 
`B_fixLeaf()` and virtual `SetLeaf()`. In the subclass constructor, the user 
has access to both `m_leaf` and `IsLeaf` so they can read or set the value on 
construction after the base class. Public `SetLeaf()` calls can then run 
whatever business logic that happens when it is set.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to