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

Source Generator not making optional attributes nullable in ReadOnly model #72

Open
Al12rs opened this issue Jul 9, 2024 · 2 comments
Assignees

Comments

@Al12rs
Copy link

Al12rs commented Jul 9, 2024

This can be seen in the NexusMods App code for Mod.cs model, specifically for the optional Version attribute:
https://github.com/Nexus-Mods/NexusMods.App/blob/727c0eecff6d2745b3e44557ee6e59f7e853a19d/src/Abstractions/NexusMods.Abstractions.Loadouts/Mods/Mod.cs#L44

The generated Version property of the ReadOnly model returns string rather than nullable string?.

           public string Version => NexusMods.Abstractions.Loadouts.Mods.Mod.Version.Get(this);
@Al12rs Al12rs added this to MVP Jul 9, 2024
@erri120
Copy link
Member

erri120 commented Jul 9, 2024

Implementation for optional attributes should probably be something like this:

return OptionalAttribute.TryGet(this, out var value) ? value : default;

@LukeNexusMods
Copy link

Effort = 3

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

No branches or pull requests

4 participants