Skip to content

Members Using Generic Types With Different Type Parameters Are Not Implemented #351

@JasonBock

Description

@JasonBock

To Reproduce

Run the following test code:

var code =
  """
  #nullable enable
  
  using Rocks;
  using System;
  using System.Collections.Generic;
  		
  [assembly: Rock(typeof(ISourceUpdater<,>), BuildType.Create)]
  
  public interface ICacheUpdater<TObject, TKey>
    where TObject : notnull
    where TKey : notnull
  {
    void Refresh(IEnumerable<TKey> keys);
  }
  
  public interface ISourceUpdater<TObject, TKey>
    : ICacheUpdater<TObject, TKey>
    where TObject : notnull
    where TKey : notnull
  {
    void AddOrUpdate(TObject item);
    void Refresh(IEnumerable<TObject> items);
  }
  """;

Expected behavior
Mock code is generated as expected.

Actual behavior
A diagnostic is created:

// Rocks\Rocks.RockGenerator\ISourceUpdaterTObject, TKey_Rock_Create.g.cs(48,5): error CS0535: 
'ISourceUpdaterCreateExpectations<TObject, TKey>.Mock' does not implement interface member 'ICacheUpdater<TObject, TKey>.Refresh(IEnumerable<TKey>)'

Additional context
The base Refresh() method uses TKey, and the derived class uses TObject, so both should be implemented, but Rocks is getting confused and ignoring the base type.

This was found on DynamicData.ISourceUpdater<,>.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions