Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOT fails to parse Uri types #1030

Open
brmassa opened this issue Jan 15, 2025 · 1 comment
Open

AOT fails to parse Uri types #1030

brmassa opened this issue Jan 15, 2025 · 1 comment

Comments

@brmassa
Copy link

brmassa commented Jan 15, 2025

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
@EdwardCooke
Copy link
Collaborator

That makes sense because it’s not a primitive type. There’s a lot of nuances with aot and the way it works with the limitations we have. To get around it you could create a type converter that outputs the scalar value and converts the read scalar back to a url object. There’s quite a few type converter examples in the code base I can point you to if you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants