Browse Source

Use AppDomain.GetLoadedAssemblies() for all platforms

Nikita Tsukanov 8 years ago
parent
commit
0977161413

+ 0 - 2
build/NetCore.props

@@ -1,6 +1,4 @@
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
-    <PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
-    <PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.0" />
   </ItemGroup>
 </Project>

+ 0 - 42
src/Avalonia.DotNetCoreRuntime/NetCoreRuntimePlatform.cs

@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.DotNet.PlatformAbstractions;
-using Microsoft.Extensions.DependencyModel;
-
-namespace Avalonia.Shared.PlatformSupport
-{
-    internal partial class StandardRuntimePlatform
-    {
-        private static readonly Lazy<Assembly[]> Assemblies = new Lazy<Assembly[]>(LoadAssemblies);
-        public Assembly[] GetLoadedAssemblies() => Assemblies.Value;
-
-        static Assembly[] LoadAssemblies()
-        {
-            var assemblies = new List<Assembly>();
-            // Mostly copy-pasted from (MIT):
-            // https://github.com/StefH/System.AppDomain.Core/blob/0b35e676c2721aa367b96e62eb52c97ee0b43a70/src/System.AppDomain.NetCoreApp/AppDomain.cs
-
-            foreach (var assemblyName in
-                DependencyContext.Default.GetRuntimeAssemblyNames(RuntimeEnvironment.GetRuntimeIdentifier()))
-            {
-                try
-                {
-                    var assembly = Assembly.Load(assemblyName);
-                    // just load all types and skip this assembly if one or more types cannot be resolved
-                    assembly.DefinedTypes.ToArray();
-                    assemblies.Add(assembly);
-                }
-                catch (Exception ex)
-                {
-                    Debug.Write(ex.Message);
-                }
-            }
-            return assemblies.ToArray();
-        }
-    }
-}

+ 1 - 6
src/Shared/PlatformSupport/StandardRuntimePlatform.cs

@@ -11,13 +11,8 @@ namespace Avalonia.Shared.PlatformSupport
 {
     internal partial class StandardRuntimePlatform : IRuntimePlatform
     {
-
-#if NETCOREAPP2_0
-        public void PostThreadPoolItem(Action cb) =>  ThreadPool.QueueUserWorkItem(_ => cb(), null);
-#else
-        public Assembly[] GetLoadedAssemblies() => AppDomain.CurrentDomain.GetAssemblies();
         public void PostThreadPoolItem(Action cb) => ThreadPool.UnsafeQueueUserWorkItem(_ => cb(), null);
-#endif
+        public Assembly[] GetLoadedAssemblies() => AppDomain.CurrentDomain.GetAssemblies();
         public IDisposable StartSystemTimer(TimeSpan interval, Action tick)
         {
             return new Timer(_ => tick(), null, interval, interval);