Skip to main content
Code Review

Return to Question

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
deleted 19 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
  1. Is C# 4.0 Tuple covariantIs C# 4.0 Tuple covariant
  2. Co/Contravariance? Tuple<string, IEnumerable<string>> not satisfied with List<string>Co/Contravariance? Tuple<string, IEnumerable> not satisfied with List

So I decide to make my own implementation of an interface which subclass a tuple with a support for Covariance:

First problem : subclass and equality support Problems:

  1. Subclass and equality support

Second problem : naming convention

  1. Naming convention
  1. Is C# 4.0 Tuple covariant
  2. Co/Contravariance? Tuple<string, IEnumerable<string>> not satisfied with List<string>

So I decide to make my own implementation of an interface which subclass a tuple with a support for Covariance:

First problem : subclass and equality support

Second problem : naming convention

  1. Is C# 4.0 Tuple covariant
  2. Co/Contravariance? Tuple<string, IEnumerable> not satisfied with List

I decide to make my own implementation of an interface which subclass a tuple with a support for Covariance:

Problems:

  1. Subclass and equality support
  1. Naming convention
Tweeted twitter.com/#!/StackCodeReview/status/402512016541491200
added 481 characters in body
Source Link

First problem : subclass and equality support

Subclassing the tuple is easy and there is nothing to do, and this is my concern. Is there something am I missing? I see no reason why equalities and hashcode souldn't work as expected with classic Tuple, but maybe you will find a problem somewhere which I didn't think of.

Second problem : naming convention

  • Like the static class Tuple contains all the Create static methods, ITuple, which is not an interface, has the static builder. At what point is this weird to name a non interface with an I prefix?
  • At first, I called the ITuple interface ICovariantTuple, but found it too long, and there is no ITuple in the framework. Is this evident that ITuple is covariant?

Subclassing the tuple is easy and there is nothing to do, and this is my concern. Is there something am I missing? I see no reason why equalities and hashcode souldn't work as expected with classic Tuple, but maybe you will find a problem somewhere which I didn't think of.

First problem : subclass and equality support

Subclassing the tuple is easy and there is nothing to do, and this is my concern. Is there something am I missing? I see no reason why equalities and hashcode souldn't work as expected with classic Tuple, but maybe you will find a problem somewhere which I didn't think of.

Second problem : naming convention

  • Like the static class Tuple contains all the Create static methods, ITuple, which is not an interface, has the static builder. At what point is this weird to name a non interface with an I prefix?
  • At first, I called the ITuple interface ICovariantTuple, but found it too long, and there is no ITuple in the framework. Is this evident that ITuple is covariant?
Source Link
Loading
lang-cs

AltStyle によって変換されたページ (->オリジナル) /