YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

AOT fails to parse Uri types

Open brmassa opened this issue 10 months ago • 1 comments
trafficstars

Describe the bug When using AOT (Vecc.YamlDotNet.Analyzers.StaticGenerator), if the model uses Uri, it fails on any input (Unhandled exception. (Line: 4, Col: 1, Idx: 41) - (Line: 4, Col: 8, Idx: 48): Exception during deserialization).

To Reproduce

[YamlStaticContext]
public partial class YamlContext;

[YamlSerializable]
public class MyModel
{
    public Uri BaseUrl { get; set; }
    // public string BaseUrl { get; set; }           // string is OK
}

var deserializer = 
    // new DeserializerBuilder()                     // without AOT
    new StaticDeserializerBuilder(new YamlContext()) // with AOT
    .Build();

yaml = @"BaseURL: http://localhost.com";
var myModel = deserializer.Deserialize<MyModel>(yaml); // Exception

brmassa avatar Jan 15 '25 03:01 brmassa