Skip to content

Properties With Mixed Visibility Are Being Mocked Incorrectly #207

@JasonBock

Description

@JasonBock

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions