This comes after an analysis of LavaGang/MelonLoader#1202 .
In some Unity versions such as at least Unity-2017.4.8f1 to Unity-2018.4.24f1 (I didn't try to find the exact range of affected versions), trying to use Tomlet (and its consumers causes a crash:
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Tomlet.TomlSerializationMethods ---> System.TypeLoadException: Could not load type 'Typespec 0x1b000001'.
at (wrapper managed-to-native) System.MonoType:GetMethodsByName (string,System.Reflection.BindingFlags,bool,System.Type)
at System.MonoType.GetMethodImpl (System.String name, BindingFlags bindingAttr, System.Reflection.Binder binder, CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in <filename unknown>:0
at System.Type.GetMethod (System.String name, BindingFlags bindingAttr) [0x00000] in <filename unknown>:0
at Tomlet.TomlSerializationMethods..cctor () [0x00000] in <filename unknown>:0
The simplest reproducer I've seen so far is:
Test.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net35</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
<ItemGroup>
<!-- Same as in Overcooked: `monodis -assembly "$(pwd)/MelonLoader/net35/Tomlet.dll" | grep Version` -->
<PackageReference Include="Samboy063.Tomlet" Version="6.2.0" />
</ItemGroup>
</Project>
and Test.cs
using Tomlet;
using Tomlet.Attributes;
namespace Test {
class MyClass {
[TomlProperty("name")]
public string Username { get; set; }
}
class Test {
static void Main(string[] args)
{
var myClass = TomletMain.To<MyClass>("name=\"hello\""); //Requires a public, zero-argument constructor on MyClass.
System.Console.WriteLine(myClass.Username);
}
}
}
then dotnet build and you get a nice /path/to/bin/Debug/net35/Test.exe. You can run it with a recent mono a
nd get the expected "hello" output.
Then, let's try to run it with the mono version built-in Unity: for the Unity Mono directory (eg ~/Downloads/Unity-2017.4.8f1/Editor/Data/Mono/bin-linux64, let's invoke MONO_PATH="$(pwd)/../lib/mono/2.0/" ./mono ~/sandbox/bin/Debug/net35/Test.exe
EXPECTED: hello
GOT:
type 0x1f not handled in do_mono_metadata_parse_type on image /home/mistria/sandbox/bin/Debug/net35/Tomlet.dll
The class Typespec 0x1b000001 could not be loaded, used in
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Tomlet.TomlSerializationMethods ---> System.TypeLoadException: Could not load type 'Typespec 0x1b000001'.
at (wrapper managed-to-native) System.MonoType:GetMethodsByName (string,System.Reflection.BindingFlags,bool,System.Type)
at System.MonoType.GetMethodImpl (System.String name, BindingFlags bindingAttr, System.Reflection.Binder binder, CallingConventions callConvention, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in <filename unknown>:0
at System.Type.GetMethod (System.String name, BindingFlags bindingAttr) [0x00000] in <filename unknown>:0
at Tomlet.TomlSerializationMethods..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Tomlet.TomletMain.To (System.Type what, Tomlet.Models.TomlValue value, Tomlet.TomlSerializerOptions options) [0x00000] in <filename unknown>:0
at Tomlet.TomletMain.To (System.Type what, System.String tomlString, Tomlet.TomlSerializerOptions options) [0x00000] in <filename unknown>:0
at Tomlet.TomletMain.To[MyClass] (System.String tomlString, Tomlet.TomlSerializerOptions options) [0x00000] in <filename unknown>:0
at Test.Test.Main (System.String[] args) [0x00000] in <filename unknown>:0
This comes after an analysis of LavaGang/MelonLoader#1202 .
In some Unity versions such as at least Unity-2017.4.8f1 to Unity-2018.4.24f1 (I didn't try to find the exact range of affected versions), trying to use Tomlet (and its consumers causes a crash:
The simplest reproducer I've seen so far is:
Test.csproj
and Test.cs
then
dotnet buildand you get a nice/path/to/bin/Debug/net35/Test.exe. You can run it with a recent mono and get the expected "hello" output.
Then, let's try to run it with the mono version built-in Unity: for the Unity Mono directory (eg
~/Downloads/Unity-2017.4.8f1/Editor/Data/Mono/bin-linux64, let's invokeMONO_PATH="$(pwd)/../lib/mono/2.0/" ./mono ~/sandbox/bin/Debug/net35/Test.exeEXPECTED: hello
GOT: