MSFakes命名约定与通用类匹配吗? [英] MSFakes Naming Convention to match Generic class?
问题描述
我有一个名为MyClass
的类和一个名为MyClass<C>
的通用版本.使用伪造品,我想生成仅MyClass<C>
而不是MyClass
的填充.我最初尝试过:
I have a class called MyClass
, and a generic version called MyClass<C>
. Using fakes, I want to generate a shim of JUST MyClass<C>
, and not MyClass
. I originally tried:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="XXXX" Version="#.##.###"/>
<ShimGeneration>
<Clear/>
<Add FullName="MyClass!"/>
</ShimGeneration>
</Fakes>
这会为MyClass
而不是MyClass<C>
生成垫片.如果我改变了!到*,它与MyClass<C>
匹配.这使我相信我需要使用一些命名约定来匹配MyClass<C>
.有谁知道这是什么/我在哪里可以找到?
This generated shims for MyClass
, but not MyClass<C>
. If I change the ! to a *, it does match MyClass<C>
. This leads me to believe there is some naming convention I need to use to match MyClass<C>
. Does anyone know what it is/where I could find out?
推荐答案
您使用重音符加上类型上的泛型类型参数的数量.例如:MyClass<T>
将为1,MyClass<T,U>
将为2,依此类推.另请参见CLI
You use the grave accent character plus the number of generic type parameters on the type. For example: MyClass<T>
would be 1, MyClass<T,U>
would be 2, etc. See also CLI specification Section 10.7.2 Type names and arity coding.
您还应该将名称空间添加为值的一部分.
You should also add your namespace as a part of the value.
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="XXXX" Version="#.##.###"/>
<ShimGeneration>
<Clear/>
<Add FullName="MyNamespace.MyClass`1!"/>
</ShimGeneration>
</Fakes>
这篇关于MSFakes命名约定与通用类匹配吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!