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/05/04 14:00:18 UTC

[lucenenet] branch master updated: add comments and supress attributes for AddCategory in DirectoryTaxonomyWriter (#849)

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 33b40ab10 add comments and supress attributes for AddCategory in DirectoryTaxonomyWriter (#849)
33b40ab10 is described below

commit 33b40ab102aa28d47b4fce89c12e62b01e3f7439
Author: Laimonas Simutis <la...@gmail.com>
AuthorDate: Thu May 4 07:00:13 2023 -0700

    add comments and supress attributes for AddCategory in DirectoryTaxonomyWriter (#849)
---
 .../Taxonomy/Directory/DirectoryTaxonomyWriter.cs            | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/Lucene.Net.Facet/Taxonomy/Directory/DirectoryTaxonomyWriter.cs b/src/Lucene.Net.Facet/Taxonomy/Directory/DirectoryTaxonomyWriter.cs
index a11ec2e48..37189a01b 100644
--- a/src/Lucene.Net.Facet/Taxonomy/Directory/DirectoryTaxonomyWriter.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/Directory/DirectoryTaxonomyWriter.cs
@@ -10,6 +10,7 @@ using Lucene.Net.Support.Threading;
 using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 using System.IO;
 
 namespace Lucene.Net.Facet.Taxonomy.Directory
@@ -188,6 +189,10 @@ namespace Lucene.Net.Facet.Taxonomy.Directory
         /// <summary>
         /// Construct a Taxonomy writer.
         /// </summary>
+        /// <para />
+        /// NOTE to inheritors: This constructor in some cases can call AddCategory to add the root category
+        /// (e.g. if the index is empty). Therefore, if you override the AddCategory method, you should be aware
+        /// that it will be called from this constructor and some of your state might not be fully initialized at that time.
         /// <param name="directory">
         ///    The <see cref="Store.Directory"/> in which to store the taxonomy. Note that
         ///    the taxonomy is written directly to that directory (not to a
@@ -218,6 +223,8 @@ namespace Lucene.Net.Facet.Taxonomy.Directory
         /// <exception cref="IOException">
         ///     if another error occurred. </exception>
         /// <exception cref="ArgumentNullException"> if <paramref name="indexWriterFactory"/> is <c>null</c> </exception>
+        [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 DirectoryTaxonomyWriter(DirectoryTaxonomyIndexWriterFactory indexWriterFactory, Directory directory,
             OpenMode openMode, ITaxonomyWriterCache cache)
         {
@@ -517,6 +524,11 @@ namespace Lucene.Net.Facet.Taxonomy.Directory
             }
         }
 
+        /// <summary>
+        /// NOTE to inheritors: This method can be called from the constructor to add the root category
+        /// (e.g. if the index is empty). Therefore, if you override the AddCategory method, you should be aware
+        /// that it will be called before your state is fully initialized.
+        /// </summary>
         public virtual int AddCategory(FacetLabel categoryPath)
         {
             EnsureOpen();