diff --git a/Reactor.API/Properties/AssemblyInfo.cs b/Reactor.API/Properties/AssemblyInfo.cs index eacb136..0e15c12 100644 --- a/Reactor.API/Properties/AssemblyInfo.cs +++ b/Reactor.API/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("1.2.0")] +[assembly: AssemblyFileVersion("1.2.1")] [assembly: InternalsVisibleTo("Reactor", AllInternalsVisible = true)] diff --git a/Reactor.API/Reactor.API.csproj b/Reactor.API/Reactor.API.csproj index bfe4e20..fcfbf3c 100644 --- a/Reactor.API/Reactor.API.csproj +++ b/Reactor.API/Reactor.API.csproj @@ -32,6 +32,7 @@ prompt 4 8.0 + true diff --git a/Reactor/Properties/AssemblyInfo.cs b/Reactor/Properties/AssemblyInfo.cs index 56c8f4f..c27bd89 100644 --- a/Reactor/Properties/AssemblyInfo.cs +++ b/Reactor/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("1.2.0")] +[assembly: AssemblyFileVersion("1.2.1")] diff --git a/Reactor/Reactor.csproj b/Reactor/Reactor.csproj index ea445ae..f53e914 100644 --- a/Reactor/Reactor.csproj +++ b/Reactor/Reactor.csproj @@ -32,6 +32,7 @@ prompt 4 8.0 + true diff --git a/Spindle/App.config b/Spindle/App.config index 8324aa6..343984d 100644 --- a/Spindle/App.config +++ b/Spindle/App.config @@ -1,6 +1,6 @@ - + - - - \ No newline at end of file + + + diff --git a/Spindle/IO/ColoredOutput.cs b/Spindle/IO/ColoredOutput.cs index 13ae82a..9cf2e87 100644 --- a/Spindle/IO/ColoredOutput.cs +++ b/Spindle/IO/ColoredOutput.cs @@ -21,9 +21,16 @@ public static void WriteInformation(string message) private static void WriteColoredText(string message, ConsoleColor consoleColor) { - Console.ForegroundColor = consoleColor; - Console.WriteLine(message); - Console.ResetColor(); + if (Platform.IsMono() || Platform.IsUnix()) + { + Console.WriteLine(message); + } + else + { + Console.ForegroundColor = consoleColor; + Console.WriteLine(message); + Console.ResetColor(); + } } } } diff --git a/Spindle/Patches/CentrifugeInitPatch.cs b/Spindle/Patches/CentrifugeInitPatch.cs index 1cbdc3f..a71ab70 100644 --- a/Spindle/Patches/CentrifugeInitPatch.cs +++ b/Spindle/Patches/CentrifugeInitPatch.cs @@ -26,7 +26,7 @@ public override void Run(ModuleDefinition sourceModule, ModuleDefinition targetM ilProcessor.Append(initInstruction); ilProcessor.Append(ilProcessor.Create(OpCodes.Ret)); - var moduleClass = targetModule.Types.FirstOrDefault(t => t.Name == ""); + var moduleClass = FindModuleInitializer(targetModule); if (moduleClass == null) { @@ -43,5 +43,16 @@ public override void Run(ModuleDefinition sourceModule, ModuleDefinition targetM OnPatchFailed(this, eventArgs); } } + + private static TypeDefinition FindModuleInitializer(ModuleDefinition targetModule) + { + foreach (var type in targetModule.Types) + { + if (type.Name == "") + return type; + } + + return null; + } } } diff --git a/Spindle/Platform.cs b/Spindle/Platform.cs new file mode 100644 index 0000000..cd52772 --- /dev/null +++ b/Spindle/Platform.cs @@ -0,0 +1,26 @@ +using System; + +namespace Spindle +{ + internal class Platform + { + internal static bool IsMono() + { + var platformID = (int)Environment.OSVersion.Platform; + return platformID == 4 || platformID == 6 || platformID == 128; + } + + internal static bool IsUnix() + { + var platformID = Environment.OSVersion.Platform; + switch (platformID) + { + case PlatformID.MacOSX: + case PlatformID.Unix: + return true; + default: + return false; + } + } + } +} diff --git a/Spindle/Program.cs b/Spindle/Program.cs index 154e50f..2b55221 100644 --- a/Spindle/Program.cs +++ b/Spindle/Program.cs @@ -87,11 +87,10 @@ internal static void Main(string[] args) private static void WriteStartupHeader() { - Console.ForegroundColor = ConsoleColor.Magenta; var version = Assembly.GetExecutingAssembly().GetName().Version; - Console.WriteLine($"Centrifuge Spindle for Unity Engine. Version {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"); - Console.WriteLine("------------------------------------------"); - Console.ResetColor(); + + ColoredOutput.WriteInformation($"Centrifuge Spindle for Unity Engine. Version {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"); + ColoredOutput.WriteInformation("------------------------------------------"); } private static bool IsValidSyntax(ICollection args) diff --git a/Spindle/Properties/AssemblyInfo.cs b/Spindle/Properties/AssemblyInfo.cs index dc5fac4..bd3276d 100644 --- a/Spindle/Properties/AssemblyInfo.cs +++ b/Spindle/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0")] -[assembly: AssemblyFileVersion("2.0.0")] +[assembly: AssemblyVersion("2.1.0")] +[assembly: AssemblyFileVersion("2.1.0")] diff --git a/Spindle/Runtime/PatchHelper.cs b/Spindle/Runtime/PatchHelper.cs index 0bef015..95928bd 100644 --- a/Spindle/Runtime/PatchHelper.cs +++ b/Spindle/Runtime/PatchHelper.cs @@ -8,9 +8,20 @@ public class PatchHelper public static MethodReference ImportBootstrapMethodReference(ModuleDefinition targetModule, ModuleDefinition bootstrapModule) { var bootstrapType = bootstrapModule.GetType(Resources.CentrifugeBootstrapTypeName); - var bootstrapInitMethod = bootstrapType.Methods.Single(m => m.Name == Resources.CentrifugeInitMethodName); + var bootstrapInitMethod = FindBootstrapInitMethod(bootstrapType); return targetModule.ImportReference(bootstrapInitMethod); } + + private static MethodDefinition FindBootstrapInitMethod(TypeDefinition bootstrapType) + { + foreach (var method in bootstrapType.Methods) + { + if (method.Name == Resources.CentrifugeInitMethodName) + return method; + } + + return null; + } } } diff --git a/Spindle/Spindle.csproj b/Spindle/Spindle.csproj index 9a29a06..b6e62c6 100644 --- a/Spindle/Spindle.csproj +++ b/Spindle/Spindle.csproj @@ -8,10 +8,11 @@ Exe Spindle Spindle - v4.6 + v3.5 512 true true + AnyCPU @@ -35,25 +36,23 @@ 8.0 - - ..\packages\Mono.Cecil.0.11.0\lib\net40\Mono.Cecil.dll + + ..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.dll - - ..\packages\Mono.Cecil.0.11.0\lib\net40\Mono.Cecil.Mdb.dll + + ..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Mdb.dll - - ..\packages\Mono.Cecil.0.11.0\lib\net40\Mono.Cecil.Pdb.dll + + ..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Pdb.dll - - ..\packages\Mono.Cecil.0.11.0\lib\net40\Mono.Cecil.Rocks.dll + + ..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Rocks.dll - - @@ -64,6 +63,7 @@ + diff --git a/Spindle/packages.config b/Spindle/packages.config index f872a1a..791f6c3 100644 --- a/Spindle/packages.config +++ b/Spindle/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file