Josh G · @Josh_Gallagher
21 followers · 73 posts · Server techhub.social

@bitbonk A default interface implementation would result in reflection seeing the method on the interface where it would not see the extension method.

I was going to say that one instance I can think of where this would have an impact is in list initialization, where the runtime detects an "Add" method with the required signature, but I have just read that the "Add" method can also be an extension method. I never knew that.

#dotnet #apidesign #frameworkdesign #frameworkdesignguidelines

Last updated 2 years ago

bitbonk · @bitbonk
267 followers · 344 posts · Server mastodon.social

When should I favor extension methods over 8 default interface implementation?

When I have an extension method in the same assembly and namespace as the interface it extends, is there any reason to *NOT* use a default interface implementation on the interface instead?


@bot

#charp #dotnet #apidesign #frameworkdesign #frameworkdesignguildlines

Last updated 2 years ago