This is an automated email from the ASF dual-hosted git repository.

nightowl888 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 740144c4c chore: Added suppression attributes to CA1822 (#693)
740144c4c is described below

commit 740144c4c974f701a8c526729adef287ad6cf802
Author: Nikolaj Brask-Nielsen <[email protected]>
AuthorDate: Thu Oct 20 21:48:10 2022 +0200

    chore: Added suppression attributes to CA1822 (#693)
    
    * chore: Added suppression attributes
    
    * chore: Added attributes to BasicModelBE.F
    
    * Removed CA1822 comment, since we are suppressing this one
    
    Co-authored-by: Shad Storhaug <[email protected]>
---
 .../Language/MatchRatingApproachEncoder.cs                         | 7 +++++++
 .../Support/Util/LuceneTestFrameworkInitializer.cs                 | 2 ++
 src/Lucene.Net/Search/FieldCacheImpl.cs                            | 6 ++++--
 src/Lucene.Net/Search/Similarities/BasicModelBE.cs                 | 4 ++++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git 
a/src/Lucene.Net.Analysis.Phonetic/Language/MatchRatingApproachEncoder.cs 
b/src/Lucene.Net.Analysis.Phonetic/Language/MatchRatingApproachEncoder.cs
index e484e7abf..87dc0d4d5 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/MatchRatingApproachEncoder.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/MatchRatingApproachEncoder.cs
@@ -1,5 +1,6 @@
 // commons-codec version compatibility level: 1.9
 using System;
+using System.Diagnostics.CodeAnalysis;
 using System.Globalization;
 using System.Text;
 
@@ -84,6 +85,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         /// </summary>
         /// <param name="name">The name to be cleaned.</param>
         /// <returns>The cleaned name.</returns>
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "By design")]
         internal string CleanName(string name)
         {
             string upperName = LOCALE_ENGLISH.TextInfo.ToUpper(name);
@@ -135,6 +137,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         /// </summary>
         /// <param name="name">The string to get the substrings from.</param>
         /// <returns>Annexed first &amp; last 3 letters of input 
word.</returns>
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "By design")]
         internal string GetFirst3Last3(string name)
         {
             int nameLength = name.Length;
@@ -157,6 +160,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         /// </summary>
         /// <param name="sumLength">The length of 2 strings sent down.</param>
         /// <returns>The min rating value.</returns>
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "By design")]
         internal int GetMinRating(int sumLength)
         {
             int minRating; // LUCENENET: IDE0059: Remove unnecessary value 
assignment
@@ -271,6 +275,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         /// <param name="name1"></param>
         /// <param name="name2"></param>
         /// <returns></returns>
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "By design")]
         internal int LeftToRightThenRightToLeftProcessing(string name1, string 
name2)
         {
             char[] name1Char = name1.ToCharArray();
@@ -366,6 +371,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         /// </summary>
         /// <param name="name">String to have double consonants 
removed.</param>
         /// <returns>Single consonant word.</returns>
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "By design")]
         internal string RemoveDoubleConsonants(string name)
         {
             string replacedName = name.ToUpperInvariant();
@@ -385,6 +391,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         /// </summary>
         /// <param name="name">The name to have vowels removed.</param>
         /// <returns>De-voweled word.</returns>
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "By design")]
         internal string RemoveVowels(string name)
         {
             // Extract first letter
diff --git 
a/src/Lucene.Net.TestFramework/Support/Util/LuceneTestFrameworkInitializer.cs 
b/src/Lucene.Net.TestFramework/Support/Util/LuceneTestFrameworkInitializer.cs
index 167d7f517..49b520ee2 100644
--- 
a/src/Lucene.Net.TestFramework/Support/Util/LuceneTestFrameworkInitializer.cs
+++ 
b/src/Lucene.Net.TestFramework/Support/Util/LuceneTestFrameworkInitializer.cs
@@ -2,6 +2,7 @@
 using Lucene.Net.Configuration;
 using NUnit.Framework;
 using System;
+using System.Diagnostics.CodeAnalysis;
 using System.IO;
 
 namespace Lucene.Net.Util
@@ -276,6 +277,7 @@ namespace Lucene.Net.Util
         /// // tight loop with many invocations.
         /// </code>
         /// </summary>
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "By design")]
         protected Random Random => LuceneTestCase.Random;
 
         /// <summary>
diff --git a/src/Lucene.Net/Search/FieldCacheImpl.cs 
b/src/Lucene.Net/Search/FieldCacheImpl.cs
index 0fb95f5cf..b47503773 100644
--- a/src/Lucene.Net/Search/FieldCacheImpl.cs
+++ b/src/Lucene.Net/Search/FieldCacheImpl.cs
@@ -11,6 +11,7 @@ using Prism.Events;
 #endif
 using System;
 using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 using System.IO;
 using System.Runtime.CompilerServices;
 using JCG = J2N.Collections.Generic;
@@ -163,7 +164,8 @@ namespace Lucene.Net.Search
             return result.ToArray();
         }
 
-        private void AddCacheEntries<TKey, 
TValue>(IList<FieldCache.CacheEntry> result, Type cacheType, Cache<TKey, 
TValue> cache) where TKey : CacheKey // LUCENENET: CA1822: Mark members as 
static
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "False positive")]
+        private void AddCacheEntries<TKey, 
TValue>(IList<FieldCache.CacheEntry> result, Type cacheType, Cache<TKey, 
TValue> cache) where TKey : CacheKey
         {
             UninterruptableMonitor.Enter(cache.readerCache);
             try
@@ -2180,4 +2182,4 @@ namespace Lucene.Net.Search
                     : (value is SafeTextWriterWrapper ? value : new 
SafeTextWriterWrapper(value));
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/Lucene.Net/Search/Similarities/BasicModelBE.cs 
b/src/Lucene.Net/Search/Similarities/BasicModelBE.cs
index a1f7a2e56..3fed66c5e 100644
--- a/src/Lucene.Net/Search/Similarities/BasicModelBE.cs
+++ b/src/Lucene.Net/Search/Similarities/BasicModelBE.cs
@@ -1,4 +1,6 @@
 using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.CompilerServices;
 
 namespace Lucene.Net.Search.Similarities
 {
@@ -49,6 +51,8 @@ namespace Lucene.Net.Search.Similarities
 
         /// <summary>
         /// The <em>f</em> helper function defined for <em>B<sub>E</sub></em>. 
</summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        [SuppressMessage("Performance", "CA1822:Mark members as static", 
Justification = "By design")]
         private double F(double n, double m)
         {
             return (m + 0.5) * SimilarityBase.Log2(n / m) + (n - m) * 
SimilarityBase.Log2(n);

Reply via email to