From cace022c38b57052b393ed052f81c9b4afe08b2d Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 1 Sep 2018 20:02:54 -0500 Subject: [PATCH] Moved classes to new namespace --- IPA.Loader/IPA.Loader.csproj | 18 ++++++------ .../BeatSaber/CompositeBSPlugin.cs | 2 +- .../IPA/CompositeIPAPlugin.cs | 2 ++ .../Logging/StandardLogger.cs | 1 + .../IllusionInjector/PluginComponent.cs | 1 + IPA.Loader/IllusionInjector/PluginManager.cs | 28 ++++++++++++++++--- .../Updating/ModsaberML/Updater.cs | 1 + .../IllusionInjector/Updating/SelfPlugin.cs | 2 +- IPA.Loader/{IllusionPlugin => }/IniFile.cs | 2 +- IPA.Loader/{IllusionPlugin => }/ModPrefs.cs | 2 +- .../BeatSaber/IBeatSaberPlugin.cs | 5 ++-- .../BeatSaber/IEnhancedBeatSaberPlugin.cs | 2 +- .../BeatSaber/ModsaberModInfo.cs | 2 +- .../IGenericEnhancedPlugin.cs | 2 +- .../IPA/IEnhancedPlugin.cs | 2 +- .../IPA/IPlugin.cs | 2 +- 16 files changed, 49 insertions(+), 25 deletions(-) rename IPA.Loader/{IllusionPlugin => }/IniFile.cs (99%) rename IPA.Loader/{IllusionPlugin => }/ModPrefs.cs (99%) rename IPA.Loader/{IllusionPlugin => PluginInterfaces}/BeatSaber/IBeatSaberPlugin.cs (96%) rename IPA.Loader/{IllusionPlugin => PluginInterfaces}/BeatSaber/IEnhancedBeatSaberPlugin.cs (91%) rename IPA.Loader/{IllusionPlugin => PluginInterfaces}/BeatSaber/ModsaberModInfo.cs (94%) rename IPA.Loader/{IllusionPlugin => PluginInterfaces}/IGenericEnhancedPlugin.cs (96%) rename IPA.Loader/{IllusionPlugin => PluginInterfaces}/IPA/IEnhancedPlugin.cs (92%) rename IPA.Loader/{IllusionPlugin => PluginInterfaces}/IPA/IPlugin.cs (98%) diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj index 2d0184ad..daae1d20 100644 --- a/IPA.Loader/IPA.Loader.csproj +++ b/IPA.Loader/IPA.Loader.csproj @@ -7,7 +7,7 @@ {5AD344F0-01A0-4CA8-92E5-9D095737744D} Library Properties - IPA.Loader + IPA IPA.Loader v4.6 512 @@ -52,16 +52,16 @@ - - - - - - - + + + + + + + - + diff --git a/IPA.Loader/IllusionInjector/BeatSaber/CompositeBSPlugin.cs b/IPA.Loader/IllusionInjector/BeatSaber/CompositeBSPlugin.cs index 96d6ddf0..acff0c2e 100644 --- a/IPA.Loader/IllusionInjector/BeatSaber/CompositeBSPlugin.cs +++ b/IPA.Loader/IllusionInjector/BeatSaber/CompositeBSPlugin.cs @@ -1,5 +1,5 @@ using IllusionPlugin; -using IllusionPlugin.BeatSaber; +using IPA; using System; using System.Collections.Generic; using System.Linq; diff --git a/IPA.Loader/IllusionInjector/IPA/CompositeIPAPlugin.cs b/IPA.Loader/IllusionInjector/IPA/CompositeIPAPlugin.cs index 001677a6..f66b73a0 100644 --- a/IPA.Loader/IllusionInjector/IPA/CompositeIPAPlugin.cs +++ b/IPA.Loader/IllusionInjector/IPA/CompositeIPAPlugin.cs @@ -1,6 +1,8 @@ using IllusionPlugin; using System; using System.Collections.Generic; +using IPA; +using IPA.Old; using System.Linq; using System.Text; using UnityEngine; diff --git a/IPA.Loader/IllusionInjector/Logging/StandardLogger.cs b/IPA.Loader/IllusionInjector/Logging/StandardLogger.cs index c2c9a484..3224691e 100644 --- a/IPA.Loader/IllusionInjector/Logging/StandardLogger.cs +++ b/IPA.Loader/IllusionInjector/Logging/StandardLogger.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using IPA; using LoggerBase = IllusionPlugin.Logging.Logger; namespace IllusionInjector.Logging diff --git a/IPA.Loader/IllusionInjector/PluginComponent.cs b/IPA.Loader/IllusionInjector/PluginComponent.cs index 1f3fc9d3..86206cce 100644 --- a/IPA.Loader/IllusionInjector/PluginComponent.cs +++ b/IPA.Loader/IllusionInjector/PluginComponent.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Text; using UnityEngine; using UnityEngine.SceneManagement; +using IPA.Loader; namespace IllusionInjector { diff --git a/IPA.Loader/IllusionInjector/PluginManager.cs b/IPA.Loader/IllusionInjector/PluginManager.cs index c872e84c..4db9473e 100644 --- a/IPA.Loader/IllusionInjector/PluginManager.cs +++ b/IPA.Loader/IllusionInjector/PluginManager.cs @@ -2,7 +2,8 @@ using IllusionInjector.Updating; using IllusionInjector.Utilities; using IllusionPlugin; -using IllusionPlugin.BeatSaber; +using IPA; +using IPA.Old; using Mono.Cecil; using System; using System.Collections.Generic; @@ -16,7 +17,7 @@ using System.Text; using System.Threading.Tasks; using LoggerBase = IllusionPlugin.Logging.Logger; -namespace IllusionInjector +namespace IPA.Loader { public static class PluginManager { @@ -177,17 +178,36 @@ namespace IllusionInjector try { + #region Fix assemblies for refactor + var module = ModuleDefinition.ReadModule(file); bool modifiedModule = false; foreach (var @ref in module.AssemblyReferences) - { + { // fix assembly references if (@ref.Name == "IllusionPlugin" || @ref.Name == "IllusionInjector") { @ref.Name = "IPA.Loader"; modifiedModule = true; } } - if (modifiedModule) module.Write(file); + if (modifiedModule) + { // types don't need to be fixed if it's already referencing the new version + foreach (var @ref in module.GetTypeReferences()) + { // fix type references + if (@ref.FullName == "IllusionPlugin.IPlugin") @ref.Namespace = "IPA.Old"; //@ref.Name = ""; + if (@ref.FullName == "IllusionPlugin.IEnhancedPlugin") @ref.Namespace = "IPA.Old"; //@ref.Name = "" + if (@ref.FullName == "IllusionPlugin.IBeatSaberPlugin") @ref.Namespace = "IPA"; //@ref.Name = "" + if (@ref.FullName == "IllusionPlugin.IEnhancedBeatSaberPlugin") @ref.Namespace = "IPA"; //@ref.Name = "" + if (@ref.FullName == "IllusionPlugin.BeatSaber.ModsaberModInfo") @ref.Namespace = "IPA"; //@ref.Name = "" + if (@ref.FullName == "IllusionPlugin.IniFile") @ref.Namespace = "IPA"; //@ref.Name = "" + if (@ref.FullName == "IllusionPlugin.IModPrefs") @ref.Namespace = "IPA"; //@ref.Name = "" + if (@ref.FullName == "IllusionPlugin.ModPrefs") @ref.Namespace = "IPA"; //@ref.Name = "" + if (@ref.FullName == "IllusionInjector.PluginManager") @ref.Namespace = "IPA.Loader"; //@ref.Name = "" + } + module.Write(file); + } + + #endregion Assembly assembly = Assembly.LoadFrom(file); diff --git a/IPA.Loader/IllusionInjector/Updating/ModsaberML/Updater.cs b/IPA.Loader/IllusionInjector/Updating/ModsaberML/Updater.cs index 26a5c653..6555cbce 100644 --- a/IPA.Loader/IllusionInjector/Updating/ModsaberML/Updater.cs +++ b/IPA.Loader/IllusionInjector/Updating/ModsaberML/Updater.cs @@ -1,5 +1,6 @@ using IllusionInjector.Updating.Backup; using IllusionInjector.Utilities; +using IPA.Loader; using Ionic.Zip; using Newtonsoft.Json; using System; diff --git a/IPA.Loader/IllusionInjector/Updating/SelfPlugin.cs b/IPA.Loader/IllusionInjector/Updating/SelfPlugin.cs index b24f5642..809df0a3 100644 --- a/IPA.Loader/IllusionInjector/Updating/SelfPlugin.cs +++ b/IPA.Loader/IllusionInjector/Updating/SelfPlugin.cs @@ -1,5 +1,5 @@ using IllusionPlugin; -using IllusionPlugin.BeatSaber; +using IPA; using System; using System.Collections.Generic; using System.Linq; diff --git a/IPA.Loader/IllusionPlugin/IniFile.cs b/IPA.Loader/IniFile.cs similarity index 99% rename from IPA.Loader/IllusionPlugin/IniFile.cs rename to IPA.Loader/IniFile.cs index b8f47bce..94ff4f3f 100644 --- a/IPA.Loader/IllusionPlugin/IniFile.cs +++ b/IPA.Loader/IniFile.cs @@ -4,7 +4,7 @@ using System.IO; using System.Runtime.InteropServices; using System.Text; -namespace IllusionPlugin +namespace IPA { /// /// Create a New INI file to store or load data diff --git a/IPA.Loader/IllusionPlugin/ModPrefs.cs b/IPA.Loader/ModPrefs.cs similarity index 99% rename from IPA.Loader/IllusionPlugin/ModPrefs.cs rename to IPA.Loader/ModPrefs.cs index 198cc6aa..3657a81d 100644 --- a/IPA.Loader/IllusionPlugin/ModPrefs.cs +++ b/IPA.Loader/ModPrefs.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Reflection; using System.Text; -namespace IllusionPlugin +namespace IPA { /// /// Allows to get and set preferences for your mod. diff --git a/IPA.Loader/IllusionPlugin/BeatSaber/IBeatSaberPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs similarity index 96% rename from IPA.Loader/IllusionPlugin/BeatSaber/IBeatSaberPlugin.cs rename to IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs index a9e2753c..48dba55a 100644 --- a/IPA.Loader/IllusionPlugin/BeatSaber/IBeatSaberPlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs @@ -1,10 +1,9 @@ -using IllusionPlugin.BeatSaber; -using System; +using System; using System.Collections.Generic; using System.Text; using UnityEngine.SceneManagement; -namespace IllusionPlugin +namespace IPA { /// /// Interface for Beat Saber plugins. Every class that implements this will be loaded if the DLL is placed at diff --git a/IPA.Loader/IllusionPlugin/BeatSaber/IEnhancedBeatSaberPlugin.cs b/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs similarity index 91% rename from IPA.Loader/IllusionPlugin/BeatSaber/IEnhancedBeatSaberPlugin.cs rename to IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs index dfbd4f9f..3a31ef13 100644 --- a/IPA.Loader/IllusionPlugin/BeatSaber/IEnhancedBeatSaberPlugin.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace IllusionPlugin +namespace IPA { /// /// An enhanced version of a standard BeatSaber plugin. diff --git a/IPA.Loader/IllusionPlugin/BeatSaber/ModsaberModInfo.cs b/IPA.Loader/PluginInterfaces/BeatSaber/ModsaberModInfo.cs similarity index 94% rename from IPA.Loader/IllusionPlugin/BeatSaber/ModsaberModInfo.cs rename to IPA.Loader/PluginInterfaces/BeatSaber/ModsaberModInfo.cs index 6defe31c..ba5fb374 100644 --- a/IPA.Loader/IllusionPlugin/BeatSaber/ModsaberModInfo.cs +++ b/IPA.Loader/PluginInterfaces/BeatSaber/ModsaberModInfo.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace IllusionPlugin.BeatSaber +namespace IPA { /// /// A class to provide information about a mod on ModSaber.ML diff --git a/IPA.Loader/IllusionPlugin/IGenericEnhancedPlugin.cs b/IPA.Loader/PluginInterfaces/IGenericEnhancedPlugin.cs similarity index 96% rename from IPA.Loader/IllusionPlugin/IGenericEnhancedPlugin.cs rename to IPA.Loader/PluginInterfaces/IGenericEnhancedPlugin.cs index 80327f5c..b3c9a935 100644 --- a/IPA.Loader/IllusionPlugin/IGenericEnhancedPlugin.cs +++ b/IPA.Loader/PluginInterfaces/IGenericEnhancedPlugin.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace IllusionPlugin +namespace IPA { /// /// A generic interface for the modification for enhanced plugins. diff --git a/IPA.Loader/IllusionPlugin/IPA/IEnhancedPlugin.cs b/IPA.Loader/PluginInterfaces/IPA/IEnhancedPlugin.cs similarity index 92% rename from IPA.Loader/IllusionPlugin/IPA/IEnhancedPlugin.cs rename to IPA.Loader/PluginInterfaces/IPA/IEnhancedPlugin.cs index ac925b2e..91c0e42e 100644 --- a/IPA.Loader/IllusionPlugin/IPA/IEnhancedPlugin.cs +++ b/IPA.Loader/PluginInterfaces/IPA/IEnhancedPlugin.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace IllusionPlugin +namespace IPA.Old { /// /// An enhanced version of the standard IPA plugin. diff --git a/IPA.Loader/IllusionPlugin/IPA/IPlugin.cs b/IPA.Loader/PluginInterfaces/IPA/IPlugin.cs similarity index 98% rename from IPA.Loader/IllusionPlugin/IPA/IPlugin.cs rename to IPA.Loader/PluginInterfaces/IPA/IPlugin.cs index 0610da73..fe9adba2 100644 --- a/IPA.Loader/IllusionPlugin/IPA/IPlugin.cs +++ b/IPA.Loader/PluginInterfaces/IPA/IPlugin.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace IllusionPlugin +namespace IPA.Old { /// /// Interface for generic Illusion unity plugins. Every class that implements this will be loaded if the DLL is placed at