【问题标题】:Stub generation failes with obsolete attribute, Pex v0.94.51023.0存根生成失败,属性过时,Pex v0.94.51023.0
【发布时间】:2011-04-30 02:11:36
【问题描述】:

我有一个带有标记为过时属性的方法的接口。 attributes error 参数设置为 true 以在使用时抛出异常。问题是这会导致存根无法为整个班级生成。当我将值更改为 false 时,存根会按预期生成。

我正在寻找一种方法来生成存根,同时将 error 参数保留为 true

public interface ICar
{
    void Start();

    [Obsolete("this is obsolete Stop, stop using it", true)]
    void Stop();
}

我尝试了不同的排列方式。

<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
  <Assembly Name="My.Car.Services"/>
  <StubGeneration>
    <TypeFilter TypeName="ICar" SkipObsolete="true" />
  </StubGeneration>
</Moles>

【问题讨论】:

    标签: pex moles


    【解决方案1】:

    这是设计使然。当方法标记为 Obsolete(..., true) 时,C# 将不允许实例化实现该接口的类。

    【讨论】:

      猜你喜欢
      • 2019-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-12
      • 1970-01-01
      相关资源
      最近更新 更多