Skip to content

Conversation

@ujjwalchadha
Copy link
Contributor

No description provided.

@ujjwalchadha ujjwalchadha linked an issue Nov 2, 2020 that may be closed by this pull request
}

unsafe void global::System.Collections.Generic.ICollection<global::System.Collections.Generic.KeyValuePair<K, V>>.Clear()
void global::Windows.Foundation.Collections.IMap<K, V>.Clear()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why didn't this trigger a compile error (not implementing the interface)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been a compilation error indeed but seems to be a bug. The reason it did not complain was that Clear method was defined and present but as System.Collections.Generic.ICollection<global::System.Collections.Generic.KeyValuePair<K, V>>.Clear. This means the ICollection's Clear method was overridden, but IMap's Clear method was not.

But now when I think of it again, I see that we have 2 definitions of the Clear method so I'm not sure if this is the right way to do it because if we call the Clear method on class's default interface and not from IMap or ICollection, this might be an ambiguous call as to which Clear method to call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try to understand root cause a bit better - why we didn't get a compiler error with only one explicit interface implementation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s currently no compile errors for not implementing all the interface members in a default interface used as an IDynamicInterfaceCastable implementation. I opened an issue a bit ago to make an analyzer for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need both of these methods to ensure that there's implementations for all of the methods.

@ujjwalchadha ujjwalchadha merged commit d050500 into master Nov 3, 2020
@ujjwalchadha ujjwalchadha deleted the fix-idictionary-clear branch November 3, 2020 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IDictionary.Clear() fails with EntryPointNotFoundException

4 participants