From 6a393ef6a293d9e1044a7c9a1efbb6fadde7a26f Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 21 Aug 2019 20:19:05 +0200 Subject: [PATCH] Used ReflectionOnly and/or public types where possible to avoid loading related assemblies unnecessarily. --- src/NzbDrone.Api/Indexers/ReleasePushModule.cs | 2 +- src/NzbDrone.Api/Profiles/LegacyProfileModule.cs | 2 +- src/NzbDrone.Api/Wanted/LegacyMissingModule.cs | 2 +- src/NzbDrone.Common/Composition/ContainerBuilderBase.cs | 2 +- src/NzbDrone.Common/Reflection/ReflectionExtensions.cs | 4 ++-- src/NzbDrone.Core/Datastore/DbFactory.cs | 1 + src/Sonarr.Api.V3/Indexers/ReleasePushModule.cs | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Api/Indexers/ReleasePushModule.cs b/src/NzbDrone.Api/Indexers/ReleasePushModule.cs index 14fb54819..e816e22cf 100644 --- a/src/NzbDrone.Api/Indexers/ReleasePushModule.cs +++ b/src/NzbDrone.Api/Indexers/ReleasePushModule.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Api.Indexers { - class ReleasePushModule : ReleaseModuleBase + public class ReleasePushModule : ReleaseModuleBase { private readonly IMakeDownloadDecision _downloadDecisionMaker; private readonly IProcessDownloadDecisions _downloadDecisionProcessor; diff --git a/src/NzbDrone.Api/Profiles/LegacyProfileModule.cs b/src/NzbDrone.Api/Profiles/LegacyProfileModule.cs index 0e704aa43..043ee4665 100644 --- a/src/NzbDrone.Api/Profiles/LegacyProfileModule.cs +++ b/src/NzbDrone.Api/Profiles/LegacyProfileModule.cs @@ -3,7 +3,7 @@ namespace NzbDrone.Api.Profiles { - class LegacyProfileModule : NzbDroneApiModule + public class LegacyProfileModule : NzbDroneApiModule { public LegacyProfileModule() : base("qualityprofile") diff --git a/src/NzbDrone.Api/Wanted/LegacyMissingModule.cs b/src/NzbDrone.Api/Wanted/LegacyMissingModule.cs index 002ecf179..f4af13b7a 100644 --- a/src/NzbDrone.Api/Wanted/LegacyMissingModule.cs +++ b/src/NzbDrone.Api/Wanted/LegacyMissingModule.cs @@ -3,7 +3,7 @@ namespace NzbDrone.Api.Wanted { - class LegacyMissingModule : NzbDroneApiModule + public class LegacyMissingModule : NzbDroneApiModule { public LegacyMissingModule() : base("missing") { diff --git a/src/NzbDrone.Common/Composition/ContainerBuilderBase.cs b/src/NzbDrone.Common/Composition/ContainerBuilderBase.cs index 8162ab30c..20485b56b 100644 --- a/src/NzbDrone.Common/Composition/ContainerBuilderBase.cs +++ b/src/NzbDrone.Common/Composition/ContainerBuilderBase.cs @@ -23,7 +23,7 @@ protected ContainerBuilderBase(IStartupContext args, List assemblies) foreach (var assembly in assemblies) { - _loadedTypes.AddRange(Assembly.Load(assembly).GetTypes()); + _loadedTypes.AddRange(Assembly.Load(assembly).GetExportedTypes()); } Container = new Container(new TinyIoCContainer(), _loadedTypes); diff --git a/src/NzbDrone.Common/Reflection/ReflectionExtensions.cs b/src/NzbDrone.Common/Reflection/ReflectionExtensions.cs index ccbb61c82..2dba971c6 100644 --- a/src/NzbDrone.Common/Reflection/ReflectionExtensions.cs +++ b/src/NzbDrone.Common/Reflection/ReflectionExtensions.cs @@ -17,7 +17,7 @@ public static List GetSimpleProperties(this Type type) public static List ImplementationsOf(this Assembly assembly) { - return assembly.GetTypes().Where(c => typeof(T).IsAssignableFrom(c)).ToList(); + return assembly.GetExportedTypes().Where(c => typeof(T).IsAssignableFrom(c)).ToList(); } public static bool IsSimpleType(this Type type) @@ -67,7 +67,7 @@ public static T[] GetAttributes(this MemberInfo member) where T : Attribute public static Type FindTypeByName(this Assembly assembly, string name) { - return assembly.GetTypes().SingleOrDefault(c => c.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); + return assembly.GetExportedTypes().SingleOrDefault(c => c.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); } public static bool HasAttribute(this Type type) diff --git a/src/NzbDrone.Core/Datastore/DbFactory.cs b/src/NzbDrone.Core/Datastore/DbFactory.cs index a871fcd07..dcb168fce 100644 --- a/src/NzbDrone.Core/Datastore/DbFactory.cs +++ b/src/NzbDrone.Core/Datastore/DbFactory.cs @@ -40,6 +40,7 @@ private static void InitializeEnvironment() Environment.SetEnvironmentVariable("No_Expand", "true"); Environment.SetEnvironmentVariable("No_SQLiteXmlConfigFile", "true"); Environment.SetEnvironmentVariable("No_PreLoadSQLite", "true"); + Environment.SetEnvironmentVariable("No_SQLiteFunctions", "true"); } public static void RegisterDatabase(IContainer container) diff --git a/src/Sonarr.Api.V3/Indexers/ReleasePushModule.cs b/src/Sonarr.Api.V3/Indexers/ReleasePushModule.cs index 155c3d0e1..d8525cef5 100644 --- a/src/Sonarr.Api.V3/Indexers/ReleasePushModule.cs +++ b/src/Sonarr.Api.V3/Indexers/ReleasePushModule.cs @@ -12,7 +12,7 @@ namespace Sonarr.Api.V3.Indexers { - class ReleasePushModule : ReleaseModuleBase + public class ReleasePushModule : ReleaseModuleBase { private readonly IMakeDownloadDecision _downloadDecisionMaker; private readonly IProcessDownloadDecisions _downloadDecisionProcessor;