VYaml
VYaml copied to clipboard
YamlConstructor with parameter defaults gets confused between number types
Hello,
As the title says, if I have a YamlConstructor that has defaults on its parameters, build will fail if the type is any int-like type other than int that can't be implicitly converted.
E.g. uint, ulong
Example that fails:
[YamlConstructor]
public TimeAmount(
double Millis = 0,
uint Seconds = 0,
uint Minutes = 0,
uint Hours = 0,
uint Days = 0,
uint Years = 0
) {
this.Millis = Millis;
this.Seconds = Seconds;
this.Minutes = Minutes;
this.Hours = Hours;
this.Days = Days;
this.Years = Years;
}
Relevant generated code in Deserialize (compiler interprets var as Int32):
var __Millis__ = 0d;
var __Seconds__ = 0;
var __Minutes__ = 0;
var __Hours__ = 0;
var __Days__ = 0;
var __Years__ = 0;
Example that succeeds:
[YamlConstructor]
public TimeAmount(
double Millis,
uint Seconds,
uint Minutes,
uint Hours,
uint Days,
uint Years
) {
this.Millis = Millis;
this.Seconds = Seconds;
this.Minutes = Minutes;
this.Hours = Hours;
this.Days = Days;
this.Years = Years;
}
Relevant generated code in Deserialize (compiler knows because of default(uint)):
var __Millis__ = default(double);
var __Seconds__ = default(uint);
var __Minutes__ = default(uint);
var __Hours__ = default(uint);
var __Days__ = default(uint);
var __Years__ = default(uint);