I’ve created a working component based on WinForms’ UserControl. I’ve overridden a couple of existing properties that generate warning CS8765.
CS8765: Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes).
This code places the warning on “set” .
/// <summary>
/// Gets or sets the font of the text
/// </summary>
[Browsable(true)]
public override Font Font
{
get => base.Font;
set
{
base.Font = value;
AdjustSize();
}
}
If I change the property’s type from “Font” to “Font?” the warning for “set” goes away, but I get a different warning on “get”.
CS8764: Nullability of return type doesn't match overridden member (possibly because of nullability attributes).
This makes sense to me because the original declaration that I’m overriding uses the non-nullable version of Font.
Without ignoring it, how do I fix my original warning?