To reproduce:
var code =
"""
using Rocks;
#nullable enable
public interface IReadOnlyNavigationBase
{
IReadOnlyNavigationBase? Inverse { get; }
}
public interface IReadOnlySkipNavigation
: IReadOnlyNavigationBase
{
new IReadOnlySkipNavigation Inverse { get; }
IReadOnlyNavigationBase IReadOnlyNavigationBase.Inverse
{
get => Inverse;
}
}
public interface IConventionSkipNavigation
: IReadOnlySkipNavigation
{
new IConventionSkipNavigation? Inverse
{
get => (IConventionSkipNavigation?)((IReadOnlySkipNavigation)this).Inverse;
}
}
public static class Test
{
public static void Go() => Rock.Create<IConventionSkipNavigation>();
}
""";
This leads to the following error:
// Rocks\Rocks.RockCreateGenerator\IConventionSkipNavigation_Rock_Create.g.cs(119,12): error CS8603: Possible null reference return.
The problem is here in the generated code:
IReadOnlySkipNavigation IReadOnlySkipNavigation.Inverse
{
get => ((IConventionSkipNavigation)this.mock).Inverse;
}
I think this is because the return for IConventionSkipNavigation.Inverse is nullable, but the one for IReadOnlySkipNavigation.Inverse is not. Adding a ! should fix the return.
This was found on Microsoft.EntityFrameworkCore.Metadata.IConventionSkipNavigation.
To reproduce:
This leads to the following error:
The problem is here in the generated code:
I think this is because the return for
IConventionSkipNavigation.Inverseis nullable, but the one forIReadOnlySkipNavigation.Inverseis not. Adding a!should fix the return.This was found on
Microsoft.EntityFrameworkCore.Metadata.IConventionSkipNavigation.