Nexus-Mods / NexusMods.MnemonicDB

A simple, fast, and type-safe in-process temporal database for .NET applications.
https://nexus-mods.github.io/NexusMods.MnemonicDB/
GNU General Public License v3.0
4 stars 0 forks source link

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

Open Al12rs opened 2 months ago

Al12rs commented 2 months ago

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);
erri120 commented 2 months ago

Implementation for optional attributes should probably be something like this:

return OptionalAttribute.TryGet(this, out var value) ? value : default;
LukeNexusMods commented 4 weeks ago

Effort = 3