根据 FxCop,为什么 ReadOnlyCollection<ReadOnlyCollection<T>> 不好?在生成不可变二维对象时有什么替代方法?

Why is ReadOnlyCollection<ReadOnlyCollection<T>> bad according to FxCop and what is the alternative when producing an immutable 2 dimensional object?

我正在修改我的所有代码以符合 FxCop,这意味着放弃大量数组和列表以支持 ReadOnlyCollection,我同意这个建议。然而,当生产 a

ReadOnlyCollection<ReadOnlyCollection<T>> 

替换二维数组或

List<List<T>> I now get the 

CA1006: Do not nest generic types in member signatures

投诉。首先,虽然它看起来很笨重,但它似乎并不复杂或难以理解,因为它本质上是一个不可变的 List<List<T>>,考虑到数组的缺点,我认为这是非常普遍的。 其次,我想不出存储二维数据且不可变的替代方案,除非我专门为此创建一个新类型。

请问这里的最佳做法是什么。难道这个 FxCop 规则在这里并不适用,应该被禁止吗?

非常感谢。

对此 post 的评论似乎也适用于此:

The warning is a general warning supposed to help you design a better and simpler public interface. In this case you get a warning about having a Expression> parameter in your method. However, for this method there is no point in simplifying the type and instead you should suppress the warning using an attribute or completely remove the rule from your ruleset.

A silly example where you probably should consider following the advice of the rule is a method like this:

public void F(Dictionary<String, List<Tuple<<String, Int32>>> dictionary);

Martin Liversage 的回答@