Browse Source

Reformat code

ghorsington 4 years ago
parent
commit
3190bfce17

+ 4 - 4
BepInEx.Patcher/ILRepack.targets

@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
+
 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Target Name="ILRepacker" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
 
@@ -13,11 +14,10 @@
       InputAssemblies="@(InputAssemblies)"
       TargetKind="Exe"
       TargetPlatformVersion="v2"
-      OutputFile="$(OutputPath)\$(AssemblyName).exe"
-    />
+      OutputFile="$(OutputPath)\$(AssemblyName).exe" />
 
     <Delete Files="@(InputAssemblies)" />
     <Delete Files="$(OutputPath)\BepInEx.Bootstrap.dll" />
 
   </Target>
-</Project>
+</Project>

+ 1 - 1
BepInEx.Patcher/Program.cs

@@ -32,7 +32,7 @@ namespace BepInEx.Patcher
 			if (File.Exists(path))
 				return path;
 			return Path.Combine(managedDir, "UnityEngine.dll");
-        }
+		}
 
 		static void Main(string[] args)
 		{

+ 1 - 0
BepInEx.Patcher/packages.config

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
+
 <packages>
   <package id="ILRepack" version="2.0.16" targetFramework="net35" />
   <package id="ILRepack.Lib.MSBuild.Task" version="2.0.16.1" targetFramework="net35" />

+ 0 - 1
BepInEx.Preloader/Logger/PreloaderLogWriter.cs

@@ -56,7 +56,6 @@ namespace BepInEx.Preloader
 
 		public void Dispose()
 		{
-
 			if (LoggerSource != null)
 			{
 				Console.SetOut(StandardOut);

+ 5 - 5
BepInEx.Preloader/Preloader.cs

@@ -63,13 +63,13 @@ namespace BepInEx.Preloader
 				{
 					if (!Utility.CLRSupportsDynamicAssemblies || ConfigShimHarmony.Value)
 						HarmonyDetourBridge.Init();
-                }, out var harmonyBridgeException);
+				}, out var harmonyBridgeException);
 
 				TryDo(() =>
 				{
 					if (ConfigApplyRuntimePatches.Value)
 						UnityPatches.Apply();
-                }, out var runtimePatchException);
+				}, out var runtimePatchException);
 
 				Logger.Sources.Add(TraceLogSource.CreateSource());
 
@@ -105,7 +105,7 @@ namespace BepInEx.Preloader
 					Logger.LogDebug(runtimePatchException);
 				}
 
-                Logger.LogMessage("Preloader started");
+				Logger.LogMessage("Preloader started");
 
 				AssemblyPatcher.AddPatcher(new PatcherPlugin
 				{
@@ -226,7 +226,7 @@ namespace BepInEx.Preloader
 
 					il.InsertBefore(ins,
 						il.Create(OpCodes.Ldnull)); // gameExePath (always null, we initialize the Paths class in Entrypoint
-                    il.InsertBefore(ins,
+					il.InsertBefore(ins,
 						il.Create(OpCodes.Ldc_I4_0)); //startConsole (always false, we already load the console in Preloader)
 					il.InsertBefore(ins,
 						il.Create(OpCodes.Call, initMethod)); // Chainloader.Initialize(string gamePath, string managedPath = null, bool startConsole = true)
@@ -291,7 +291,7 @@ namespace BepInEx.Preloader
 			"If enabled, basic Harmony functionality is patched to use MonoMod's RuntimeDetour instead.\nTry using this if Harmony does not work in a game.",
 			false);
 
-        private static readonly ConfigWrapper<bool> ConfigPreloaderCOutLogging = ConfigFile.CoreConfig.Wrap(
+		private static readonly ConfigWrapper<bool> ConfigPreloaderCOutLogging = ConfigFile.CoreConfig.Wrap(
 			"Logging",
 			"PreloaderConsoleOutRedirection",
 			"Redirects text from Console.Out during preloader patch loading to the BepInEx logging system.",

+ 1 - 0
BepInEx.Preloader/packages.config

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
+
 <packages>
   <package id="Mono.Cecil" version="0.10.3" targetFramework="net35" />
 </packages>

+ 14 - 14
BepInEx/Bootstrap/Chainloader.cs

@@ -29,23 +29,23 @@ namespace BepInEx.Bootstrap
 		public static List<BaseUnityPlugin> Plugins { get; } = new List<BaseUnityPlugin>();
 
 		/// <summary>
-        /// The GameObject that all plugins are attached to as components.
-        /// </summary>
-        public static GameObject ManagerObject { get; private set; }
+		/// The GameObject that all plugins are attached to as components.
+		/// </summary>
+		public static GameObject ManagerObject { get; private set; }
 
 
 		private static bool _loaded = false;
 		private static bool _initialized = false;
 
 		/// <summary>
-        /// Initializes BepInEx to be able to start the chainloader.
-        /// </summary>
-        public static void Initialize(string gameExePath, bool startConsole = true)
+		/// Initializes BepInEx to be able to start the chainloader.
+		/// </summary>
+		public static void Initialize(string gameExePath, bool startConsole = true)
 		{
 			if (_initialized)
 				return;
 
-            // Set vitals
+			// Set vitals
 			if (gameExePath != null)
 			{
 				// Checking for null allows a more advanced initialization workflow, where the Paths class has been initialized before calling Chainloader.Initialize
@@ -53,12 +53,12 @@ namespace BepInEx.Bootstrap
 				Paths.SetExecutablePath(gameExePath);
 			}
 
-            // Start logging
-            if (ConsoleWindow.ConfigConsoleEnabled.Value && startConsole)
+			// Start logging
+			if (ConsoleWindow.ConfigConsoleEnabled.Value && startConsole)
 			{
 				ConsoleWindow.Attach();
 				Logger.Listeners.Add(new ConsoleLogListener());
-            }
+			}
 
 			// Fix for standard output getting overwritten by UnityLogger
 			if (ConsoleWindow.StandardOut != null)
@@ -70,7 +70,7 @@ namespace BepInEx.Bootstrap
 				Console.OutputEncoding = ConsoleEncoding.GetEncoding(encoding);
 			}
 
-            Logger.Listeners.Add(new UnityLogListener());
+			Logger.Listeners.Add(new UnityLogListener());
 			Logger.Listeners.Add(new DiskLogListener());
 
 			if (!TraceLogSource.IsListening)
@@ -87,7 +87,7 @@ namespace BepInEx.Bootstrap
 
 		private static Regex allowedGuidRegex { get; } = new Regex(@"^[a-zA-Z0-9\._\-]+$");
 
-        public static PluginInfo ToPluginInfo(TypeDefinition type)
+		public static PluginInfo ToPluginInfo(TypeDefinition type)
 		{
 			if (type.IsInterface || type.IsAbstract || !type.IsSubtypeOf(typeof(BaseUnityPlugin)))
 				return null;
@@ -118,8 +118,8 @@ namespace BepInEx.Bootstrap
 				return null;
 			}
 
-            //Perform a filter for currently running process
-            var filters = BepInProcess.FromCecilType(type);
+			//Perform a filter for currently running process
+			var filters = BepInProcess.FromCecilType(type);
 
 			bool invalidProcessName = filters.Any(x => !string.Equals(x.ProcessName.Replace(".exe", ""), Paths.ProcessName, StringComparison.InvariantCultureIgnoreCase));
 

+ 1 - 1
BepInEx/Configuration/ConfigDefinition.cs

@@ -29,7 +29,7 @@
 				return false;
 
 			return string.Equals(Key, other.Key)
-			       && string.Equals(Section, other.Section);
+				   && string.Equals(Section, other.Section);
 		}
 
 		public override int GetHashCode()

+ 1 - 1
BepInEx/Configuration/TomlTypeConverter.cs

@@ -109,4 +109,4 @@ namespace BepInEx.Configuration
 			return (T)TypeConverters[typeof(T)].ConvertToObject(value);
 		}
 	}
-}
+}

+ 1 - 1
BepInEx/ConsoleUtil/ConsoleWindow.cs

@@ -25,7 +25,7 @@ namespace UnityInjector.ConsoleUtil
 			"If true, console is set to the Shift-JIS encoding, otherwise UTF-8 encoding.",
 			false);
 
-        public static bool IsAttached { get; private set; }
+		public static bool IsAttached { get; private set; }
 		private static IntPtr _cOut;
 		private static IntPtr _oOut;
 

+ 6 - 6
BepInEx/Contract/Attributes.cs

@@ -199,12 +199,12 @@ namespace BepInEx
 			=> GetAttributes<T>(plugin.GetType());
 
 
-        /// <summary>
-        /// Retrieves the dependencies of the specified plugin type.
-        /// </summary>
-        /// <param name="Plugin">The plugin type.</param>
-        /// <returns>A list of all plugin types that the specified plugin type depends upon.</returns>
-        public static IEnumerable<BepInDependency> GetDependencies(Type plugin)
+		/// <summary>
+		/// Retrieves the dependencies of the specified plugin type.
+		/// </summary>
+		/// <param name="Plugin">The plugin type.</param>
+		/// <returns>A list of all plugin types that the specified plugin type depends upon.</returns>
+		public static IEnumerable<BepInDependency> GetDependencies(Type plugin)
 		{
 			return plugin.GetCustomAttributes(typeof(BepInDependency), true).Cast<BepInDependency>();
 		}

+ 2 - 1
BepInEx/Contract/PluginInfo.cs

@@ -1,7 +1,8 @@
 using System.Collections.Generic;
 using Mono.Cecil;
 
-namespace BepInEx.Contract {
+namespace BepInEx.Contract
+{
 	public class PluginInfo
 	{
 		public BepInPlugin Metadata { get; internal set; }

+ 1 - 1
BepInEx/Logging/ConsoleLogListener.cs

@@ -16,7 +16,7 @@ namespace BepInEx.Logging
 			if (eventArgs.Level.GetHighestLevel() > DisplayedLogLevel)
 				return;
 
-			string log = $"[{eventArgs.Level, -7}:{((ILogSource)sender).SourceName, 10}] {eventArgs.Data}\r\n";
+			string log = $"[{eventArgs.Level,-7}:{((ILogSource)sender).SourceName,10}] {eventArgs.Data}\r\n";
 
 			Kon.ForegroundColor = eventArgs.Level.GetConsoleColor();
 			Console.Write(log);

+ 2 - 5
BepInEx/Logging/DiskLogListener.cs

@@ -39,12 +39,9 @@ namespace BepInEx.Logging
 			}
 
 			LogWriter = TextWriter.Synchronized(new StreamWriter(fileStream, Encoding.UTF8));
-			
 
-			FlushTimer = new Timer(o =>
-			{
-				LogWriter?.Flush();
-			}, null, 2000, 2000);
+
+			FlushTimer = new Timer(o => { LogWriter?.Flush(); }, null, 2000, 2000);
 		}
 
 		public void LogEvent(object sender, LogEventArgs eventArgs)

+ 1 - 1
BepInEx/Logging/TraceLogSource.cs

@@ -76,7 +76,7 @@ namespace BepInEx.Logging
 					level = LogLevel.Debug;
 					break;
 			}
-			
+
 			LogSource.Log(level, $"{message}".Trim());
 		}
 	}

+ 1 - 1
BepInEx/Logging/UnityLogListener.cs

@@ -27,7 +27,7 @@ namespace BepInEx.Logging
 				WriteStringToUnityLog = (Action<string>)Delegate.CreateDelegate(typeof(Action<string>), methodInfo);
 				break;
 			}
-			
+
 			if (WriteStringToUnityLog == null)
 				Logger.LogError("Unable to start Unity log writer");
 		}

+ 1 - 0
BepInEx/Logging/UnityLogSource.cs

@@ -24,6 +24,7 @@ namespace BepInEx.Logging
 		}
 
 		private bool disposed = false;
+
 		public void Dispose()
 		{
 			if (!disposed)

+ 27 - 12
BepInEx/Utility.cs

@@ -44,21 +44,30 @@ namespace BepInEx
 		/// <param name="input">The string to parse</param>
 		/// <param name="defaultValue">The value to return if parsing is unsuccessful.</param>
 		/// <returns>Boolean value of input if able to be parsed, otherwise default value.</returns>
-		public static bool SafeParseBool(string input, bool defaultValue = false) { return Boolean.TryParse(input, out bool result) ? result : defaultValue; }
+		public static bool SafeParseBool(string input, bool defaultValue = false)
+		{
+			return Boolean.TryParse(input, out bool result) ? result : defaultValue;
+		}
 
 		/// <summary>
 		/// Converts a file path into a UnityEngine.WWW format.
 		/// </summary>
 		/// <param name="path">The file path to convert.</param>
 		/// <returns>A converted file path.</returns>
-		public static string ConvertToWWWFormat(string path) { return $"file://{path.Replace('\\', '/')}"; }
+		public static string ConvertToWWWFormat(string path)
+		{
+			return $"file://{path.Replace('\\', '/')}";
+		}
 
 		/// <summary>
 		/// Indicates whether a specified string is null, empty, or consists only of white-space characters.
 		/// </summary>
 		/// <param name="self">The string to test.</param>
 		/// <returns>True if the value parameter is null or empty, or if value consists exclusively of white-space characters.</returns>
-		public static bool IsNullOrWhiteSpace(this string self) { return self == null || self.All(Char.IsWhiteSpace); }
+		public static bool IsNullOrWhiteSpace(this string self)
+		{
+			return self == null || self.All(Char.IsWhiteSpace);
+		}
 
 		public static IEnumerable<TNode> TopologicalSort<TNode>(IEnumerable<TNode> nodes, Func<TNode, IEnumerable<TNode>> dependencySelector)
 		{
@@ -155,13 +164,16 @@ namespace BepInEx
 		}
 
 		/// <summary>
-        /// Try to resolve and load the given assembly DLL.
-        /// </summary>
-        /// <param name="assemblyName">Name of the assembly, of the type <see cref="AssemblyName" />.</param>
-        /// <param name="directory">Directory to search the assembly from.</param>
-        /// <param name="assembly">The loaded assembly.</param>
-        /// <returns>True, if the assembly was found and loaded. Otherwise, false.</returns>
-        public static bool TryResolveDllAssembly(AssemblyName assemblyName, string directory, out Assembly assembly) { return TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFile, out assembly); }
+		/// Try to resolve and load the given assembly DLL.
+		/// </summary>
+		/// <param name="assemblyName">Name of the assembly, of the type <see cref="AssemblyName" />.</param>
+		/// <param name="directory">Directory to search the assembly from.</param>
+		/// <param name="assembly">The loaded assembly.</param>
+		/// <returns>True, if the assembly was found and loaded. Otherwise, false.</returns>
+		public static bool TryResolveDllAssembly(AssemblyName assemblyName, string directory, out Assembly assembly)
+		{
+			return TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFile, out assembly);
+		}
 
 		/// <summary>
 		/// Try to resolve and load the given assembly DLL.
@@ -170,7 +182,10 @@ namespace BepInEx
 		/// <param name="directory">Directory to search the assembly from.</param>
 		/// <param name="assembly">The loaded assembly.</param>
 		/// <returns>True, if the assembly was found and loaded. Otherwise, false.</returns>
-		public static bool TryResolveDllAssembly(AssemblyName assemblyName, string directory, ReaderParameters readerParameters, out AssemblyDefinition assembly) { return TryResolveDllAssembly(assemblyName, directory, s => AssemblyDefinition.ReadAssembly(s, readerParameters), out assembly); }
+		public static bool TryResolveDllAssembly(AssemblyName assemblyName, string directory, ReaderParameters readerParameters, out AssemblyDefinition assembly)
+		{
+			return TryResolveDllAssembly(assemblyName, directory, s => AssemblyDefinition.ReadAssembly(s, readerParameters), out assembly);
+		}
 
 		/// <summary>
 		/// Tries to create a file with the given name
@@ -196,5 +211,5 @@ namespace BepInEx
 				return false;
 			}
 		}
-    }
+	}
 }

+ 1 - 0
BepInEx/packages.config

@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
+
 <packages>
   <package id="Mono.Cecil" version="0.10.3" targetFramework="net35" />
 </packages>