sdk: GenAPI incorrectly generates collection-based interface implementation

When targeting System.Collections.Immutable.1.7.1, GenAPI generates a class implementation which doesn’t implement the interface that its member explicitly attempts to implement.

This illustrates the issue:

public sealed partial class ImmutableHashSet<T> : IEnumerable, ICollection
{
    bool Generic.ICollection<T>.IsReadOnly { get { throw null; } }
}

This results in a build error:

error CS0540: 'ImmutableHashSet<T>.ICollection<T>.IsReadOnly': containing type does not implement interface 'ICollection<T>'

You can see that the generated class doesn’t implement any of the generic interfaces that it should:

public sealed class ImmutableHashSet<T> : IImmutableSet<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IHashKeyCollection<T>, ICollection<T>, ISet<T>, ICollection, IStrongEnumerable<T, ImmutableHashSet<T>.Enumerator>

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (24 by maintainers)

Most upvoted comments

Is it possible you’re missing the reference that contains the definition for IList?

Nevermind, got a repro using the latest. When not providing references the interface definition is actually omitted. When providing references I see the indexer get/set methods are not reduced to an indexer.

I tried this out on a few packages I was having troubles with earlier and it appears that the issue has been resolved.