Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Cichoń authored and Tomasz Cichoń committed Nov 10, 2019
2 parents 18f9be9 + 7cd5dd3 commit 741486a
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Reactor.API/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
1 change: 1 addition & 0 deletions Reactor.API/Reactor.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
Expand Down
2 changes: 1 addition & 1 deletion Reactor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
1 change: 1 addition & 0 deletions Reactor/Reactor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
Expand Down
8 changes: 4 additions & 4 deletions Spindle/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
</configuration>

<supportedRuntime version="v2.0.50727"/></startup>
</configuration>
13 changes: 10 additions & 3 deletions Spindle/IO/ColoredOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}
13 changes: 12 additions & 1 deletion Spindle/Patches/CentrifugeInitPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "<Module>");
var moduleClass = FindModuleInitializer(targetModule);

if (moduleClass == null)
{
Expand All @@ -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 == "<Module>")
return type;
}

return null;
}
}
}
26 changes: 26 additions & 0 deletions Spindle/Platform.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
7 changes: 3 additions & 4 deletions Spindle/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> args)
Expand Down
4 changes: 2 additions & 2 deletions Spindle/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
13 changes: 12 additions & 1 deletion Spindle/Runtime/PatchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
22 changes: 11 additions & 11 deletions Spindle/Spindle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<OutputType>Exe</OutputType>
<RootNamespace>Spindle</RootNamespace>
<AssemblyName>Spindle</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -35,25 +36,23 @@
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Cecil, Version=0.11.0.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.0\lib\net40\Mono.Cecil.dll</HintPath>
<Reference Include="Mono.Cecil, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.11.0.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.0\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
<Reference Include="Mono.Cecil.Mdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.11.0.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.0\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
<Reference Include="Mono.Cecil.Pdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.11.0.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.11.0\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
<Reference Include="Mono.Cecil.Rocks, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
Expand All @@ -64,6 +63,7 @@
<Compile Include="IO\ModuleWriter.cs" />
<Compile Include="Patches\DecapsulationPatch.cs" />
<Compile Include="Patches\CentrifugeInitPatch.cs" />
<Compile Include="Platform.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Spindle/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Mono.Cecil" version="0.11.0" targetFramework="net46" />
<package id="Mono.Cecil" version="0.10.4" targetFramework="net35" />
</packages>

0 comments on commit 741486a

Please sign in to comment.