Stub generation failes with obsolete attribute, Pex v0.94.51023.0

强颜欢笑 提交于 2019-12-12 01:49:55

问题


I have an interface with a method marked with the obsolete attribute. The attributes error parameter is set to true to throw an exception when used. The problem is this causes the stub to not generate for the whole class. When I alter the value to false the stub generates as expected.

I’m looking for a way to generate the stub while retaining the error parameter as true.

public interface ICar
{
    void Start();

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

I’ve tried different permutations of.

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

回答1:


This is by design. When a method is marked at Obsolete(..., true), C# will not allow to instantiate an class implementing that interface.



来源:https://stackoverflow.com/questions/5839004/stub-generation-failes-with-obsolete-attribute-pex-v0-94-51023-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!