Skip to content

[TUnit.Mocks] Mock() fails for IDocumentStore (RavenDB.Client): asymmetric-accessor member CS0535/CS0548/CS0551 #6491

Closed

Description

@samtrion

Description

T.Mock() fails to compile when T is Raven.Client.Documents.IDocumentStore (from RavenDB.Client 7.2.5). The generated mock implementation does not correctly handle a nested interface member, Raven.Client.Json.Serialization.ISessionBlittableJsonConverter.MissingProperties, resulting in 9 compiler errors.

Repro

<PackageReference Include="RavenDB.Client" Version="7.2.5" />
<PackageReference Include="TUnit.Mocks" Version="1.61.38" />
using Raven.Client.Documents;
using TUnit.Mocks;

var store = IDocumentStore.Mock();

Confirmed minimal, isolated repro (single-file console app, no other mocked types in the compilation) — this is not usage-order-dependent or masked by other errors.

Environment

  • TUnit.Mocks: 1.61.38 (latest at time of filing)
  • RavenDB.Client: 7.2.5
  • TFM: net10.0
  • LangVersion: preview (C# 14)
  • OS: Windows 11

Actual errors

...MockGenerator\Raven_Client_Json_Serialization_ISessionBlittableJsonConverter_MockImplFactory.g.cs(7,64):
  error CS0535: 'ISessionBlittableJsonConverterMockImpl' does not implement interface member
  'ISessionBlittableJsonConverter.MissingProperties.get'

...MockImplFactory.g.cs(7,64):
  error CS0535: 'ISessionBlittableJsonConverterMockImpl' does not implement interface member
  'ISessionBlittableJsonConverter.MissingProperties.set'

...MockImplFactory.g.cs(76,133):
  error CS0548: 'ISessionBlittableJsonConverterMockImpl.MissingProperties': property or indexer
  must have at least one accessor

...Raven_Client_Json_Serialization_ISessionBlittableJsonConverter_Mock.g.cs(49,197):
  error CS0122: 'ISessionBlittableJsonConverter.MissingProperties' is inaccessible due to its
  protection level

...Mock.g.cs(7,160):
  error CS0535: 'ISessionBlittableJsonConverterMock' does not implement interface member
  'ISessionBlittableJsonConverter.MissingProperties.get'

...Mock.g.cs(7,160):
  error CS0535: 'ISessionBlittableJsonConverterMock' does not implement interface member
  'ISessionBlittableJsonConverter.MissingProperties.set'

...Mock.g.cs(49,197):
  error CS0548: 'ISessionBlittableJsonConverterMock.ISessionBlittableJsonConverter.MissingProperties':
  property or indexer must have at least one accessor

...Mock.g.cs(49,197):
  error CS0551: Explicit interface implementation
  'ISessionBlittableJsonConverterMock.ISessionBlittableJsonConverter.MissingProperties' is missing
  accessor 'ISessionBlittableJsonConverter.MissingProperties.get'

...Mock.g.cs(49,197):
  error CS0551: Explicit interface implementation
  'ISessionBlittableJsonConverterMock.ISessionBlittableJsonConverter.MissingProperties' is missing
  accessor 'ISessionBlittableJsonConverter.MissingProperties.set'

Suspected cause

ISessionBlittableJsonConverter.MissingProperties appears to be a member with mismatched/asymmetric accessor accessibility (e.g. one accessor is internal/non-public while the other is public, or the property is declared with only one accessor at a differing visibility than the generator assumes). The generator emits both a get and set accessor for this member regardless, producing a member that does not satisfy the interface contract and is also inaccessible from the generated assembly.

Impact

Any type whose interface graph transitively includes this member (in this case reached via IDocumentStore → ... → ISessionBlittableJsonConverter) cannot be mocked with T.Mock() at all — there's no per-member opt-out to work around it from the calling code.

Context

Found while migrating an OSS health-checks library (dailydevops/healthchecks) from NSubstitute to TUnit.Mocks across ~65 test files. Isolated with a minimal single-file repro to rule out cross-file interference.

Activity

  1. added a commit that references this issue on Jul 28, 2026
    73e6fda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions