【问题标题】:Excluding files in assembly from being moled排除汇编中的文件被篡改
【发布时间】:2011-10-19 04:41:18
【问题描述】:

我正在使用 moles 为我的团队使用的遗留代码生成模拟类。是否可以将程序集中的某些类排除在外?对于遗留代码中的一些自动生成的类,我遇到了很多错误,我想排除这些错误。

【问题讨论】:

    标签: moles pex


    【解决方案1】:

    要在存根/mole 生成中包含和排除类型,您需要为您的程序集修改 .moles 文件。尽管参考手册的“类型过滤”部分仅描述了StubGeneration 元素,但也有MoleGeneration 元素,它的工作原理与此类似,但管理痣的生成。

    要从存根和痣生成中排除类型,请在 Remove 元素中指定类型名称,以便您的程序集的 .moles 文件如下所示:

    <Moles xmlns="http://schemas.microsoft.com/moles/2010/" Diagnostic="true">
        <Assembly Name="your_assembly" />
        <StubGeneration>
            <Types>
                <Remove FullName="Your.Type.Full.Name!" />
            </Types>
        </StubGeneration>
        <MoleGeneration>
            <Types>
                <Remove FullName="Your.Type.Full.Name!" />
            </Types>
        </MoleGeneration>
    </Moles>
    

    这里是如何只为一类Your.Type.Full.Name启用存根和痣生成:

    <Moles xmlns="http://schemas.microsoft.com/moles/2010/" Diagnostic="true">
        <Assembly Name="your_assembly" />
        <StubGeneration>
            <Types>
                <Clear />
                <Add FullName="Your.Type.Full.Name!" />
            </Types>
        </StubGeneration>
        <MoleGeneration>
            <Types>
                <Clear />
                <Add FullName="Your.Type.Full.Name!" />
            </Types>
        </MoleGeneration>
    </Moles>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多