You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2020/01/30 08:15:52 UTC

[lucenenet] 03/09: Lucene.Net.Support.WeakDictionary: Removed unnecessary cast, marked class internal

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

commit 6366760dae8a0a46ee59fc044875f3ee0423a82f
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Mon Jan 27 03:15:23 2020 +0700

    Lucene.Net.Support.WeakDictionary: Removed unnecessary cast, marked class internal
---
 src/Lucene.Net.Facet/TopOrdAndFloatQueue.cs | 2 +-
 src/Lucene.Net.Facet/TopOrdAndIntQueue.cs   | 2 +-
 src/Lucene.Net/Properties/AssemblyInfo.cs   | 3 ++-
 src/Lucene.Net/Support/WeakDictionary.cs    | 6 ++----
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/Lucene.Net.Facet/TopOrdAndFloatQueue.cs b/src/Lucene.Net.Facet/TopOrdAndFloatQueue.cs
index 62fb389..72db2d8 100644
--- a/src/Lucene.Net.Facet/TopOrdAndFloatQueue.cs
+++ b/src/Lucene.Net.Facet/TopOrdAndFloatQueue.cs
@@ -55,7 +55,7 @@ namespace Lucene.Net.Facet
         {
         }
 
-        protected override bool LessThan(OrdAndValue a, OrdAndValue b)
+        protected internal override bool LessThan(OrdAndValue a, OrdAndValue b)
         {
             if (a.Value < b.Value)
             {
diff --git a/src/Lucene.Net.Facet/TopOrdAndIntQueue.cs b/src/Lucene.Net.Facet/TopOrdAndIntQueue.cs
index cb78b69..4f93a10 100644
--- a/src/Lucene.Net.Facet/TopOrdAndIntQueue.cs
+++ b/src/Lucene.Net.Facet/TopOrdAndIntQueue.cs
@@ -56,7 +56,7 @@ namespace Lucene.Net.Facet
         {
         }
 
-        protected override bool LessThan(OrdAndValue a, OrdAndValue b)
+        protected internal override bool LessThan(OrdAndValue a, OrdAndValue b)
         {
             if (a.Value < b.Value)
             {
diff --git a/src/Lucene.Net/Properties/AssemblyInfo.cs b/src/Lucene.Net/Properties/AssemblyInfo.cs
index f6c7729..f4ead0d 100644
--- a/src/Lucene.Net/Properties/AssemblyInfo.cs
+++ b/src/Lucene.Net/Properties/AssemblyInfo.cs
@@ -33,6 +33,8 @@ using System.Runtime.CompilerServices;
 // We need InternalsVisibleTo in order to prevent making everything public just for the sake of testing.
 // This has broad implications because many methods are marked "protected internal", which means other assemblies
 // must update overridden methods to match.
+[assembly: InternalsVisibleTo("Lucene.Net.Facet, PublicKey=" + AssemblyKeys.PublicKey)]
+[assembly: InternalsVisibleTo("Lucene.Net.Misc, PublicKey=" + AssemblyKeys.PublicKey)]
 [assembly: InternalsVisibleTo("Lucene.Net.Tests._A-D, PublicKey=" + AssemblyKeys.PublicKey)]
 [assembly: InternalsVisibleTo("Lucene.Net.Tests._E-I, PublicKey=" + AssemblyKeys.PublicKey)]
 [assembly: InternalsVisibleTo("Lucene.Net.Tests._J-S, PublicKey=" + AssemblyKeys.PublicKey)]
@@ -42,7 +44,6 @@ using System.Runtime.CompilerServices;
 [assembly: InternalsVisibleTo("Lucene.Net.TestFramework.MSTest, PublicKey=" + AssemblyKeys.PublicKey)]
 [assembly: InternalsVisibleTo("Lucene.Net.TestFramework.NUnit, PublicKey=" + AssemblyKeys.PublicKey)]
 [assembly: InternalsVisibleTo("Lucene.Net.TestFramework.xUnit, PublicKey=" + AssemblyKeys.PublicKey)]
-[assembly: InternalsVisibleTo("Lucene.Net.Misc, PublicKey=" + AssemblyKeys.PublicKey)]
 [assembly: InternalsVisibleTo("Lucene.Net.Tests.ICU, PublicKey=" + AssemblyKeys.PublicKey)] // For Analysis.Util.TestSegmentingTokenizerBase
 [assembly: InternalsVisibleTo("Lucene.Net.Tests.Misc, PublicKey=" + AssemblyKeys.PublicKey)]
 [assembly: InternalsVisibleTo("Lucene.Net.Tests.QueryParser, PublicKey=" + AssemblyKeys.PublicKey)]
diff --git a/src/Lucene.Net/Support/WeakDictionary.cs b/src/Lucene.Net/Support/WeakDictionary.cs
index 2aa467f..b4abc18 100644
--- a/src/Lucene.Net/Support/WeakDictionary.cs
+++ b/src/Lucene.Net/Support/WeakDictionary.cs
@@ -32,7 +32,7 @@ namespace Lucene.Net.Support
 #if FEATURE_SERIALIZABLE
     [Serializable]
 #endif
-    public sealed class WeakDictionary<TKey, TValue> : IDictionary<TKey, TValue> where TKey : class 
+    internal sealed class WeakDictionary<TKey, TValue> : IDictionary<TKey, TValue> where TKey : class 
     {
         private IDictionary<WeakKey<TKey>, TValue> _hm;
         private int _gcCollections = 0;
@@ -287,10 +287,8 @@ namespace Lucene.Net.Support
                     return true;
                 }
 
-                if (obj is WeakKey<T>)
+                if (obj is WeakKey<T> other)
                 {
-                    var other = (WeakKey<T>)obj;
-
                     var referenceTarget = reference.Target; // Careful: can be null in the mean time...
                     return referenceTarget != null && referenceTarget.Equals(other.Target);
                 }