0

我有一个带有标记为过时属性的方法的接口。attributes错误参数设置为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>
4

1 回答 1

0

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

于 2011-04-30T03:51:58.490 回答