From 26b5db3019f627358257253499c9fec88bfdb751 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 4 Jun 2022 15:19:50 -0500 Subject: [PATCH] Used ReflectionOnly and/or public types where possible Fixes #1461 --- src/NzbDrone.Common/Composition/Extensions.cs | 2 +- src/NzbDrone.Common/Reflection/ReflectionExtensions.cs | 4 ++-- src/NzbDrone.Core/Datastore/DbFactory.cs | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Common/Composition/Extensions.cs b/src/NzbDrone.Common/Composition/Extensions.cs index 52ebd9040..7976fa9f4 100644 --- a/src/NzbDrone.Common/Composition/Extensions.cs +++ b/src/NzbDrone.Common/Composition/Extensions.cs @@ -32,7 +32,7 @@ namespace NzbDrone.Common.Composition.Extensions serviceTypeCondition: type => !type.IsInterface && !string.IsNullOrWhiteSpace(type.FullName) && !type.FullName.StartsWith("System"), reuse: Reuse.Transient); - var knownTypes = new KnownTypes(assemblies.SelectMany(x => x.GetTypes()).ToList()); + var knownTypes = new KnownTypes(assemblies.SelectMany(x => x.GetExportedTypes()).ToList()); container.RegisterInstance(knownTypes); return container; diff --git a/src/NzbDrone.Common/Reflection/ReflectionExtensions.cs b/src/NzbDrone.Common/Reflection/ReflectionExtensions.cs index b8fd7c6f5..8f016450d 100644 --- a/src/NzbDrone.Common/Reflection/ReflectionExtensions.cs +++ b/src/NzbDrone.Common/Reflection/ReflectionExtensions.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Common.Reflection 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) @@ -68,7 +68,7 @@ namespace NzbDrone.Common.Reflection 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 6ae61fe39..9fa0181d9 100644 --- a/src/NzbDrone.Core/Datastore/DbFactory.cs +++ b/src/NzbDrone.Core/Datastore/DbFactory.cs @@ -36,6 +36,7 @@ namespace NzbDrone.Core.Datastore Environment.SetEnvironmentVariable("No_Expand", "true"); Environment.SetEnvironmentVariable("No_SQLiteXmlConfigFile", "true"); Environment.SetEnvironmentVariable("No_PreLoadSQLite", "true"); + Environment.SetEnvironmentVariable("No_SQLiteFunctions", "true"); } public DbFactory(IMigrationController migrationController,