question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GenAPI incorrectly generates collection-based interface implementation

See original GitHub issue

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>

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Comments:24 (24 by maintainers)

github_iconTop GitHub Comments

1reaction
ericstjcommented, Jul 28, 2023

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.

1reaction
MichaelSimonscommented, Apr 19, 2023

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I tell typescript that an interface is actually implemented?
Class 'FooModel' incorrectly implements interface 'FooResponse'. Property 'test' is missing in type 'FooModel' but required in type 'FooResponse ...
Read more >
what am I missing? : r/typescript
Hi everyone, I have an interface that I'm using to identify classes that interact ... Class 'Bam' incorrectly implements interface 'Foo'.
Read more >
Correct implementation of an interface
I'm running a DQL mutation to populate the database. Since the interface itself should be queryable (and has an ID), I need to...
Read more >
Interview Question - Adding Method to interface that has ...
This question doesn't really give enough information. Will the implementation for this new method be the same in all the classes? Do we...
Read more >
Explicit Interface Implementation - C# Programming Guide
A class can implement interfaces that contain a member with the same signature in C#. Explicit implementation creates a class member ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found