lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [49/50] lucenenet git commit: Lucene.Net.Core/Lucene.Net.Grouping: Fixed issues with compilation in .NET Core
Date Thu, 30 Mar 2017 18:00:44 GMT
Lucene.Net.Core/Lucene.Net.Grouping: Fixed issues with compilation in .NET Core


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/1697106c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/1697106c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/1697106c

Branch: refs/heads/api-work
Commit: 1697106c964b5fa6171b253d13b6d03133378096
Parents: 05c8b58
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Fri Mar 31 00:03:03 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Fri Mar 31 00:03:03 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Support/Arrays.cs      |  5 ++--
 src/Lucene.Net.Core/Support/Collections.cs | 37 +++++++++++++------------
 src/Lucene.Net.Core/Util/Fst/FST.cs        |  3 +-
 src/Lucene.Net.Core/Util/Fst/NodeHash.cs   |  3 +-
 src/Lucene.Net.Grouping/SearchGroup.cs     |  7 ++---
 5 files changed, 28 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1697106c/src/Lucene.Net.Core/Support/Arrays.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Arrays.cs b/src/Lucene.Net.Core/Support/Arrays.cs
index bea165d..2e08542 100644
--- a/src/Lucene.Net.Core/Support/Arrays.cs
+++ b/src/Lucene.Net.Core/Support/Arrays.cs
@@ -1,6 +1,7 @@
 ´╗┐using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Reflection;
 
 namespace Lucene.Net.Support
 {
@@ -12,7 +13,7 @@ namespace Lucene.Net.Support
                 return 0;
 
             int result = 1;
-            bool isValueType = typeof(T).IsValueType;
+            bool isValueType = typeof(T).GetTypeInfo().IsValueType;
 
             foreach (var item in a)
             {
@@ -99,7 +100,7 @@ namespace Lucene.Net.Support
             {
                 return true;
             }
-            bool isValueType = typeof(T).IsValueType;
+            bool isValueType = typeof(T).GetTypeInfo().IsValueType;
             if (!isValueType && a == null)
             {
                 return b == null;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1697106c/src/Lucene.Net.Core/Support/Collections.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Collections.cs b/src/Lucene.Net.Core/Support/Collections.cs
index 4abd26b..5e4affc 100644
--- a/src/Lucene.Net.Core/Support/Collections.cs
+++ b/src/Lucene.Net.Core/Support/Collections.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Globalization;
 using System.Linq;
+using System.Reflection;
 using System.Runtime.Serialization;
 using System.Text;
 
@@ -117,7 +118,7 @@ namespace Lucene.Net
         public static int GetHashCode<T>(IList<T> list)
         {
             int hashCode = 1;
-            bool isValueType = typeof(T).IsValueType;
+            bool isValueType = typeof(T).GetTypeInfo().IsValueType;
             foreach (T e in list)
             {
                 hashCode = 31 * hashCode +
@@ -141,7 +142,7 @@ namespace Lucene.Net
         public static int GetHashCode<T>(ISet<T> set)
         {
             int h = 0;
-            bool isValueType = typeof(T).IsValueType;
+            bool isValueType = typeof(T).GetTypeInfo().IsValueType;
             using (var i = set.GetEnumerator())
             {
                 while (i.MoveNext())
@@ -174,8 +175,8 @@ namespace Lucene.Net
         public static int GetHashCode<TKey, TValue>(IDictionary<TKey, TValue>
dictionary)
         {
             int h = 0;
-            bool keyIsValueType = typeof(TKey).IsValueType;
-            bool valueIsValueType = typeof(TValue).IsValueType;
+            bool keyIsValueType = typeof(TKey).GetTypeInfo().IsValueType;
+            bool valueIsValueType = typeof(TValue).GetTypeInfo().IsValueType;
             using (var i = dictionary.GetEnumerator())
             {
                 while (i.MoveNext())
@@ -211,7 +212,7 @@ namespace Lucene.Net
             }
 
             Type t = obj.GetType();
-            if (t.IsGenericType
+            if (t.GetTypeInfo().IsGenericType
                 && (t.ImplementsGenericInterface(typeof(IList<>))
                 || t.ImplementsGenericInterface(typeof(ISet<>))
                 || t.ImplementsGenericInterface(typeof(IDictionary<,>))))
@@ -241,7 +242,7 @@ namespace Lucene.Net
                 return true;
             }
 
-            bool isValueType = typeof(T).IsValueType;
+            bool isValueType = typeof(T).GetTypeInfo().IsValueType;
 
             if (!isValueType && listA == null)
             {
@@ -307,7 +308,7 @@ namespace Lucene.Net
                 return false;
             }
 
-            bool isValueType = typeof(T).IsValueType;
+            bool isValueType = typeof(T).GetTypeInfo().IsValueType;
 
             // same operation as containsAll()
             foreach (T eB in setB)
@@ -362,7 +363,7 @@ namespace Lucene.Net
                 return false;
             }
 
-            bool valueIsValueType = typeof(TValue).IsValueType;
+            bool valueIsValueType = typeof(TValue).GetTypeInfo().IsValueType;
 
             using (var i = dictionaryB.GetEnumerator())
             {
@@ -416,13 +417,13 @@ namespace Lucene.Net
 
             Type tA = objA.GetType();
             Type tB = objB.GetType();
-            if (tA.IsGenericType)
+            if (tA.GetTypeInfo().IsGenericType)
             {
                 bool shouldReturn = false;
 
                 if (tA.ImplementsGenericInterface(typeof(IList<>)))
                 {
-                    if (!(tB.IsGenericType && tB.ImplementsGenericInterface(typeof(IList<>))))
+                    if (!(tB.GetTypeInfo().IsGenericType && tB.ImplementsGenericInterface(typeof(IList<>))))
                     {
                         return false; // type mismatch - must be a list
                     }
@@ -430,7 +431,7 @@ namespace Lucene.Net
                 }
                 else if (tA.ImplementsGenericInterface(typeof(ISet<>)))
                 {
-                    if (!(tB.IsGenericType && tB.ImplementsGenericInterface(typeof(ISet<>))))
+                    if (!(tB.GetTypeInfo().IsGenericType && tB.ImplementsGenericInterface(typeof(ISet<>))))
                     {
                         return false; // type mismatch - must be a set
                     }
@@ -438,7 +439,7 @@ namespace Lucene.Net
                 }
                 else if (tA.ImplementsGenericInterface(typeof(IDictionary<,>)))
                 {
-                    if (!(tB.IsGenericType && tB.ImplementsGenericInterface(typeof(IDictionary<,>))))
+                    if (!(tB.GetTypeInfo().IsGenericType && tB.ImplementsGenericInterface(typeof(IDictionary<,>))))
                     {
                         return false; // type mismatch - must be a dictionary
                     }
@@ -459,8 +460,8 @@ namespace Lucene.Net
         // LUCENENET TODO: Move to a new TypeExtensions class
         private static bool ImplementsGenericInterface(this Type target, Type interfaceType)
         {
-            return target.IsGenericType && target.GetGenericTypeDefinition().GetInterfaces().Any(
-                x => x.IsGenericType && interfaceType.IsAssignableFrom(x.GetGenericTypeDefinition())
+            return target.GetTypeInfo().IsGenericType && target.GetGenericTypeDefinition().GetInterfaces().Any(
+                x => x.GetTypeInfo().IsGenericType && interfaceType.IsAssignableFrom(x.GetGenericTypeDefinition())
             );
         }
 
@@ -476,7 +477,7 @@ namespace Lucene.Net
                 return "[]";
             }
 
-            bool isValueType = typeof(T).IsValueType;
+            bool isValueType = typeof(T).GetTypeInfo().IsValueType;
             using (var it = collection.GetEnumerator())
             {
                 StringBuilder sb = new StringBuilder();
@@ -520,8 +521,8 @@ namespace Lucene.Net
                 return "{}";
             }
 
-            bool keyIsValueType = typeof(TKey).IsValueType;
-            bool valueIsValueType = typeof(TValue).IsValueType;
+            bool keyIsValueType = typeof(TKey).GetTypeInfo().IsValueType;
+            bool valueIsValueType = typeof(TValue).GetTypeInfo().IsValueType;
             using (var i = dictionary.GetEnumerator())
             {
                 StringBuilder sb = new StringBuilder();
@@ -565,7 +566,7 @@ namespace Lucene.Net
         public static string ToString(object obj)
         {
             Type t = obj.GetType();
-            if (t.IsGenericType
+            if (t.GetTypeInfo().IsGenericType
                 && (t.ImplementsGenericInterface(typeof(ICollection<>)))
                 || t.ImplementsGenericInterface(typeof(IDictionary<,>)))
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1697106c/src/Lucene.Net.Core/Util/Fst/FST.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/FST.cs b/src/Lucene.Net.Core/Util/Fst/FST.cs
index 3319bc3..46a4966 100644
--- a/src/Lucene.Net.Core/Util/Fst/FST.cs
+++ b/src/Lucene.Net.Core/Util/Fst/FST.cs
@@ -4,6 +4,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
+using System.Reflection;
 using System.Text;
 
 namespace Lucene.Net.Util.Fst
@@ -449,7 +450,7 @@ namespace Lucene.Net.Util.Fst
                     // LUCENENET NOTE: In .NET, IEnumerable will not equal another identical
IEnumerable
                     // because it checks for reference equality, not that the list contents
                     // are the same. Collections.Equals() will make that check.
-                    Debug.Assert(typeof(T).IsValueType 
+                    Debug.Assert(typeof(T).GetTypeInfo().IsValueType 
                         ? root.NextFinalOutput.Equals(asserting.NextFinalOutput) 
                         : Collections.Equals(root.NextFinalOutput, asserting.NextFinalOutput));
                     Debug.Assert(root.Node == asserting.Node);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1697106c/src/Lucene.Net.Core/Util/Fst/NodeHash.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/NodeHash.cs b/src/Lucene.Net.Core/Util/Fst/NodeHash.cs
index 207fa04..ef8672c 100644
--- a/src/Lucene.Net.Core/Util/Fst/NodeHash.cs
+++ b/src/Lucene.Net.Core/Util/Fst/NodeHash.cs
@@ -1,5 +1,6 @@
 using Lucene.Net.Support;
 using System.Diagnostics;
+using System.Reflection;
 
 namespace Lucene.Net.Util.Fst
 {
@@ -37,7 +38,7 @@ namespace Lucene.Net.Util.Fst
 
         // LUCENENET specific - optimize the Hash methods
         // by only calling Collections.GetHashCode() if the value is a reference type
-        private readonly bool tIsValueType = typeof(T).IsValueType;
+        private readonly static bool tIsValueType = typeof(T).GetTypeInfo().IsValueType;
 
         public NodeHash(FST<T> fst, FST.BytesReader input)
         {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1697106c/src/Lucene.Net.Grouping/SearchGroup.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Grouping/SearchGroup.cs b/src/Lucene.Net.Grouping/SearchGroup.cs
index f9772d9..b08d748 100644
--- a/src/Lucene.Net.Grouping/SearchGroup.cs
+++ b/src/Lucene.Net.Grouping/SearchGroup.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
 using System.Linq;
+using System.Reflection;
 
 namespace Lucene.Net.Search.Grouping
 {
@@ -182,15 +183,11 @@ namespace Lucene.Net.Search.Grouping
 
             // LUCENENET specific - store whether T is value type
             // for optimization of GetHashCode() and Equals()
-            private readonly bool groupValueIsValueType;
+            private readonly static bool groupValueIsValueType = typeof(T).GetTypeInfo().IsValueType;
 
             public MergedGroup(T groupValue)
             {
                 this.groupValue = groupValue;
-
-                // LUCENENET specific - store whether T is value type
-                // for optimization of GetHashCode() and Equals()
-                this.groupValueIsValueType = typeof(T).IsValueType;
             }
 
             // Only for assert


Mime
View raw message