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

Problem with nullable dictionary #109

Closed
rube200 opened this issue Jun 6, 2024 · 7 comments
Closed

Problem with nullable dictionary #109

rube200 opened this issue Jun 6, 2024 · 7 comments

Comments

@rube200
Copy link
Contributor

rube200 commented Jun 6, 2024

Hi, i am trying to move from YamlDotNet to VYaml, but i am getting an hard time.
Currently it forces me to manually create formatters instead of using YamlObject annotation.
When i have Dictionary<string, object?>? data; it seems to not work, i got compilling error CS8619, looking at the pre gen code it creates internal var var __Data__ = default(global::System.Collections.Generic.Dictionary<string, object>) instead of the requested type.

The problem seems to be Dictionary<string, object> instead of Dictionary<string, object?>

@rube200
Copy link
Contributor Author

rube200 commented Jun 6, 2024

Also everything works fine when a manully format it based on gen code

@hadashiA
Copy link
Owner

hadashiA commented Jun 8, 2024

I tried it at hand and the following samples worked.

[YamlObject]
public partial class DictionaryMember
{
    public Dictionary<string, object?>? Data { get; set; }
}

Can you give me the specific code that reproduces the problem?

@rube200
Copy link
Contributor Author

rube200 commented Jun 8, 2024

Did you enable nullability? We have it in error mode
I am one of maintainers of OpenMod, I am currently porting it from YamlDotNet to VYaml, if you really need I can try making an sample.

@hadashiA
Copy link
Owner

hadashiA commented Jun 10, 2024

Ah, maybe I understand the problem.

If Data is non-nullable, does that mean the following assign will give a warning?

    Data = __Data__

Ok, I've fixed in #110.

@rube200
Copy link
Contributor Author

rube200 commented Jun 10, 2024

If Data is non-nullable, does that mean the following assign will give a warning?

Yes I think that is the problem, in our case we get compilation error since we treat that warn as error.

@rube200
Copy link
Contributor Author

rube200 commented Jun 10, 2024

Also can you add HashSet/Set ? To resolvers?
It is very similar to list.

@hadashiA
Copy link
Owner

Also can you add HashSet/Set ? To resolvers?

#111 I was just working on. I'll release it soon.
I hope you'll give it a try.

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