Stub生成错误,具有过时属性Pex v0.94.51023.0

时间:2011-04-30 02:11:37

标签: pex moles

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

我正在寻找一种生成存根的方法,同时将错误参数保留为 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>

1 个答案:

答案 0 :(得分:0)

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

相关问题