使用英语阅读

通过


IL2067:“target parameter”参数在调用“target method”时不满足“DynamicallyAccessedMembersAttribute”要求。 方法“source method”的参数“source parameter”没有匹配的注释。 源值必须声明的要求,至少与在其分配到的目标位置上声明的要求相同

原因

目标位置通过其 DynamicallyAccessedMembersAttribute 对类型值声明一些要求。 源值上同样通过 DynamicallyAccessedMembersAttribute 声明的要求必须满足这些要求。 如有必要,源值可以声明比目标位置更多的要求。

示例

C#
void NeedsPublicConstructors([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type type)
{
    // ...
}

void TestMethod(Type type)
{
    // IL2067 Trim analysis: 'type' argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to 'NeedsPublicConstructor'. The parameter 'type' of method 'TestMethod' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
    NeedsPublicConstructors(type);
}

修正

有关指导,请参阅修复警告