Remove S.R.CS.Unsafe dependency from MetadataLoadContext (dotnet/corefx#34813)
authorSteve Harter <steveharter@users.noreply.github.com>
Fri, 25 Jan 2019 17:56:11 +0000 (11:56 -0600)
committerGitHub <noreply@github.com>
Fri, 25 Jan 2019 17:56:11 +0000 (11:56 -0600)
Commit migrated from https://github.com/dotnet/corefx/commit/ab8b458b6b48ea67fba128f7eb6b42cdb97771c0

src/libraries/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/RuntimeTypeInfo.TypeComponentsCache.cs

index 0c6add7..b378e4c 100644 (file)
     <Compile Include="System\Reflection\TypeLoading\Types\RoWrappedType.cs" />
   </ItemGroup>
   <ItemGroup>
-    <Reference Include="System.Runtime" />
-    <Reference Include="System.Runtime.CompilerServices.Unsafe" />
-    <Reference Include="System.Runtime.Extensions" />
-    <Reference Include="System.Runtime.InteropServices" />
     <Reference Include="System.Collections" />
     <Reference Include="System.Collections.Concurrent" />
     <Reference Include="System.Collections.Immutable" />
     <Reference Include="System.Memory" />
     <Reference Include="System.Reflection.Metadata" />
     <Reference Include="System.Resources.ResourceManager" />
+    <Reference Include="System.Runtime" />
+    <Reference Include="System.Runtime.Extensions" />
+    <Reference Include="System.Runtime.InteropServices" />
     <Reference Include="System.Threading" />
   </ItemGroup>
 </Project>
index 7a88fe2..71dd389 100644 (file)
@@ -6,7 +6,6 @@ using System.Collections.Concurrent;
 using System.Diagnostics;
 using System.Reflection.Runtime.BindingFlagSupport;
 using System.Threading;
-using Unsafe = System.Runtime.CompilerServices.Unsafe;
 using RuntimeTypeInfo = System.Reflection.TypeLoading.RoType;
 
 namespace System.Reflection.TypeLoading
@@ -51,8 +50,7 @@ namespace System.Reflection.TypeLoading
                     (immediateTypeOnly ? _perNameQueryCaches_CaseSensitive_ImmediateTypeOnly : _perNameQueryCaches_CaseSensitive);
 
                 object unifierAsObject = cacheArray[index];
-                Debug.Assert(unifierAsObject is PerNameQueryCache<M>);
-                PerNameQueryCache<M> unifier = Unsafe.As<PerNameQueryCache<M>>(unifierAsObject);
+                PerNameQueryCache<M> unifier = (PerNameQueryCache<M>)unifierAsObject;
                 QueriedMemberList<M> result = unifier.GetOrAdd(name);
                 return result;
             }
@@ -74,8 +72,7 @@ namespace System.Reflection.TypeLoading
                     Volatile.Write(ref _nameAgnosticQueryCaches[index], newResult);
                     return newResult;
                 }
-                Debug.Assert(result is QueriedMemberList<M>);
-                QueriedMemberList<M> list = Unsafe.As<QueriedMemberList<M>>(result);
+                QueriedMemberList<M> list = (QueriedMemberList<M>)result;
                 if (list.ImmediateTypeOnly && !immediateTypeOnly)
                 {
                     QueriedMemberList<M> newResult = QueriedMemberList<M>.Create(_type, filter: null, ignoreCase: false, immediateTypeOnly: false);