chore: remove duplication namespace declaration

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Andrew Welker 2025-07-07 10:06:59 -05:00 committed by Neil Dorin
parent 7f60dcb4cf
commit 5d90fafbd7

View file

@ -4,18 +4,15 @@ using System.Linq;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using System.Reflection; using System.Reflection;
using System.IO; using System.IO;
using Newtonsoft.Json;
using System.Reflection.PortableExecutable; using System.Reflection.PortableExecutable;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using SystemIO = System.IO;
using CrestronIO = System.IO;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using Serilog.Events; using Serilog.Events;
namespace PepperDash.Essentials;
namespace PepperDash.Essentials;
/// <summary> /// <summary>
/// Provides functionality for loading and managing plugins and assemblies in the application. /// Provides functionality for loading and managing plugins and assemblies in the application.
/// </summary> /// </summary>
@ -75,19 +72,6 @@ public static class PluginLoader
/// </summary> /// </summary>
private static string TempDirectory => PluginDirectory + Global.DirectorySeparator + "temp"; private static string TempDirectory => PluginDirectory + Global.DirectorySeparator + "temp";
/// <summary>
/// The directory to look in for .cplz plugin packages
/// </summary>
static string _pluginDirectory => Global.FilePathPrefix + "plugins";
/// <summary>
/// The directory where plugins will be moved to and loaded from
/// </summary>
static string _loadedPluginsDirectoryPath => _pluginDirectory + Global.DirectorySeparator + "loadedAssemblies";
// The temp directory where .cplz archives will be unzipped to
static string _tempDirectory => _pluginDirectory + Global.DirectorySeparator + "temp";
/// <summary> /// <summary>
/// Represents a collection of fully qualified type names that are known to be incompatible with the current /// Represents a collection of fully qualified type names that are known to be incompatible with the current
/// application or framework. /// application or framework.
@ -96,8 +80,8 @@ public static class PluginLoader
/// incompatible with the intended usage of the application. These types may represent security risks, unsupported /// incompatible with the intended usage of the application. These types may represent security risks, unsupported
/// features, or legacy APIs that should be avoided.</remarks> /// features, or legacy APIs that should be avoided.</remarks>
private static readonly HashSet<string> KnownIncompatibleTypes = private static readonly HashSet<string> KnownIncompatibleTypes =
[ [
"System.Net.ICertificatePolicy", "System.Net.ICertificatePolicy",
"System.Security.Cryptography.SHA1CryptoServiceProvider", "System.Security.Cryptography.SHA1CryptoServiceProvider",
"System.Web.HttpUtility", "System.Web.HttpUtility",
"System.Configuration.ConfigurationManager", "System.Configuration.ConfigurationManager",
@ -108,7 +92,7 @@ public static class PluginLoader
"System.Security.SecurityManager", "System.Security.SecurityManager",
"System.Security.Permissions.FileIOPermission", "System.Security.Permissions.FileIOPermission",
"System.AppDomain.CreateDomain" "System.AppDomain.CreateDomain"
]; ];
/// <summary> /// <summary>
/// Initializes static members of the <see cref="PluginLoader"/> class. /// Initializes static members of the <see cref="PluginLoader"/> class.
@ -142,7 +126,6 @@ public static class PluginLoader
Debug.LogMessage(LogEventLevel.Verbose, "Found {0} Assemblies", assemblyFiles.Length); Debug.LogMessage(LogEventLevel.Verbose, "Found {0} Assemblies", assemblyFiles.Length);
foreach (var fi in assemblyFiles.Where(fi => fi.Name.Contains("Essentials") || fi.Name.Contains("PepperDash"))) foreach (var fi in assemblyFiles.Where(fi => fi.Name.Contains("Essentials") || fi.Name.Contains("PepperDash")))
{ {
string version = string.Empty; string version = string.Empty;
@ -190,7 +173,6 @@ public static class PluginLoader
} }
} }
/// <summary> /// <summary>
/// Associates the specified assembly with the given name in the loaded assemblies collection. /// Associates the specified assembly with the given name in the loaded assemblies collection.
/// </summary> /// </summary>
@ -335,7 +317,7 @@ public static class PluginLoader
} }
return null; return null;
} }
catch (FileLoadException ex) when (ex.Message.Contains("Assembly with same name is already loaded")) catch(FileLoadException ex) when (ex.Message.Contains("Assembly with same name is already loaded"))
{ {
// Get the assembly name from the file path // Get the assembly name from the file path
string assemblyName = Path.GetFileNameWithoutExtension(filePath); string assemblyName = Path.GetFileNameWithoutExtension(filePath);
@ -356,7 +338,7 @@ public static class PluginLoader
Debug.LogMessage(LogEventLevel.Warning, "Assembly with same name already loaded but couldn't find it: {0}", filePath); Debug.LogMessage(LogEventLevel.Warning, "Assembly with same name already loaded but couldn't find it: {0}", filePath);
return null; return null;
} }
catch (Exception ex) catch(Exception ex)
{ {
string fileName = Path.GetFileName(filePath); string fileName = Path.GetFileName(filePath);
@ -730,6 +712,7 @@ public static class PluginLoader
continue; continue;
} }
foreach (var type in types) foreach (var type in types)
{ {
try try
@ -853,7 +836,7 @@ public static class PluginLoader
LoadDeviceFactories(deviceFactory); LoadDeviceFactories(deviceFactory);
if (!EssentialsPluginAssemblies.Contains(loadedAssembly)) if(!EssentialsPluginAssemblies.Contains(loadedAssembly))
EssentialsPluginAssemblies.Add(loadedAssembly); EssentialsPluginAssemblies.Add(loadedAssembly);
} }