glTF-CSharp-Loader icon indicating copy to clipboard operation
glTF-CSharp-Loader copied to clipboard

Support for compiling with "Trim unused code"

Open BoyBaykiller opened this issue 2 years ago • 1 comments

My C# application uses glTFLoader for loading gltf models. I'd like to be able to publish the code with the "Trim unused code" compiler option as it drastically reduces binary size.

However when running the exectuable I get this exception.

Unhandled exception. Newtonsoft.Json.JsonSerializationException: Unable to find a constructor to use for type glTFLoader.Schema.Gltf. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'asset', line 2, position 10.
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader, JsonObjectContract, JsonProperty, JsonProperty, String, Boolean& )
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader, Type, JsonContract, JsonProperty, JsonContainerContract, JsonProperty, Object)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader, Type, JsonContract, JsonProperty, JsonContainerContract, JsonProperty, Object)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader, Type, Boolean)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader, Type)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader, Type)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String, Type, JsonSerializerSettings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String, JsonSerializerSettings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String)
   at glTFLoader.Interface.LoadModel(Stream)
   at glTFLoader.Interface.LoadModel(String)

This only happens when compiling with "Trim unused code".

BoyBaykiller avatar Jun 09 '23 19:06 BoyBaykiller

I've never heard of this option. If someone wants to research and provide a solution, that'll be great. Otherwise, I'm not sure what we can do with this.

bghgary avatar Jun 09 '23 20:06 bghgary