To reproduce:
public class PrivateSetProperty
{
public virtual string? Name { get; private set; }
}
public static class Test
{
public static void Go() => Rock.Create<PrivateSetProperty>();
}
It's OK to mock the getter for Name, but not the setter as it's private. Only the accessors on a property that are visible should be mocked.
This was discovered on Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.
To reproduce:
It's OK to mock the getter for
Name, but not thesetteras it'sprivate. Only the accessors on a property that are visible should be mocked.This was discovered on
Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.