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 845d66348 Fix for virtual method call from the constructor fixes for 
ElementType (#835)
845d66348 is described below

commit 845d66348e993fbc7d1bd77e3bb1d9c33e0854cb
Author: Laimonas Simutis <lai...@gmail.com>
AuthorDate: Fri Apr 14 10:00:13 2023 -0700

    Fix for virtual method call from the constructor fixes for ElementType 
(#835)
---
 .../Support/TagSoup/ElementType.cs                 | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/Lucene.Net.Benchmark/Support/TagSoup/ElementType.cs 
b/src/Lucene.Net.Benchmark/Support/TagSoup/ElementType.cs
index 343fa4f2f..2a14fd5d2 100644
--- a/src/Lucene.Net.Benchmark/Support/TagSoup/ElementType.cs
+++ b/src/Lucene.Net.Benchmark/Support/TagSoup/ElementType.cs
@@ -14,6 +14,7 @@
 using J2N.Text;
 using Sax.Helpers;
 using System;
+using System.Diagnostics.CodeAnalysis;
 using System.Text;
 
 namespace TagSoup
@@ -47,6 +48,8 @@ namespace TagSoup
         /// <param name="schema">
         /// The schema with which this element type will be associated
         /// </param>
+        [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 ElementType(string name, int model, int memberOf, int flags, 
Schema schema)
         {
             this.name = name;
@@ -59,6 +62,26 @@ namespace TagSoup
             localName = GetLocalName(name);
         }
 
+        /// <summary>
+        /// LUCENENET specific constructor that allows the caller to specify 
the namespace and local name
+        /// and is provided to subclasses as an alternative to <see 
cref="ElementType(string, int, int, int, Schema)"/>
+        /// in order to avoid virtual method calls.
+        /// </summary>
+        public ElementType(
+            string name, string @namespace, string localName,
+            int model, int memberOf, int flags, Schema schema
+            )
+        {
+            this.name = name;
+            Model = model;
+            MemberOf = memberOf;
+            Flags = flags;
+            atts = new Attributes();
+            this.schema = schema;
+            this.@namespace = @namespace;
+            this.localName = localName;
+        }
+
         /// <summary>
         /// Gets the name of this element type.
         /// </summary>

Reply via email to