gpt4 book ai didi

c# - FxCop 警告 CA1006 是否有任何好的解决方法?

转载 作者:IT王子 更新时间:2023-10-29 04:20:36 25 4
gpt4 key购买 nike

我在使用 FxCop warning CA1006 时遇到问题, Microsoft.Design “DoNotNestGenericTypesInMemberSignatures”。具体来说,我正在设计一个 ReportCollection<T>ReadOnlyCollection<Report<T>> 继承的类, 及其 public构造函数采用 IList<Report<T>>作为参数。

修复此警告的建议不是很有用:

"To fix a violation of this rule, change the design to remove the nested type argument." There are two ways I can see so far to change the design as suggested:

  1. 构造函数internal .这在我的情况下不起作用。构造函数必须是 public因为这个集合类需要在程序集外被代码实例化。
  2. 让构造函数接受一个Report<T>[]而不是 IList<Report<T>> .这是次优的,因为外部代码应该具有使用动态大小数据结构的灵 active ,如 List<T>而不是固定大小的数组。

此时,我已经放弃并抑制了这个警告。有更好的解决方案吗?

最佳答案

我会接受 FxCop 的警告,就好像它们是来自一个极度固执的同事的建议。完全可以忽略(抑制)它建议的某些内容。

关于c# - FxCop 警告 CA1006 是否有任何好的解决方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/417634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com