Closed Steve-OH closed 1 month ago
Thank you for the bug report. Apologies for the inconvenience. ToString
has now changed to be non-nullable. Previously, it was taking the nullability of the base method (assumed to be Object.ToString()
), but this wasn't the case when deriving from a record, who implicitly defines it as non-nullable. You can go from nullable-in-the-base-type to non-nullable-in-the-derived-type, but not the other way round.
Since the generated ToString
is never null, it is not decorated with ?
.
Thanks again
Describe the bug
Using Vogen 5.x, I'm getting a warning:
CS8764 Nullability of return type doesn't match overridden member (possibly because of nullability attributes)
The warning arises only when the value object is a record and is derived from an abstract base record. It's caused by the generated
ToString()
override, but I don't understand exactly what's going on. It only occurs with records, not with classes.It can be fixed by adding this in the base record:
Visual Studio 2022 17.11.4 .NET 8 target ReSharper 2024.2.4 Vogen 5.0.2
Steps to reproduce
This code will produce the warning on build:
Expected behaviour
It would be nice to be able to avoid the warning without having to add the dummy
ToString()
method. I have no clue how to accomplish that, however.