UsedImplicitly是Resharper这个插件生成的东西,这个插件在项目的Properties下生成一个叫做Annotations.cs的类。属性原型是酱紫的:
/// <summary> /// Indicates that the marked symbol is used implicitly /// (e.g. via reflection, in external library), so this symbol /// will not be marked as unused (as well as by other usage inspections) /// </summary> [AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)] public sealed class UsedImplicitlyAttribute : Attribute { public UsedImplicitlyAttribute() : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) : this(useKindFlags, ImplicitUseTargetFlags.Default) { } public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) : this(ImplicitUseKindFlags.Default, targetFlags) { } public UsedImplicitlyAttribute( ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) { UseKindFlags = useKindFlags; TargetFlags = targetFlags; } public ImplicitUseKindFlags UseKindFlags { get; private set; } public ImplicitUseTargetFlags TargetFlags { get; private set; } }
Resharper有个功能是检查你代码中定义的变量是否被使用过,如果你定义的变量没有被使用过,Resharper会给你个警告,加上UsedImplicitly这个标记就表示Resharper检查时跳过这个变量,不检查该变量是否被使用过。
不明觉厉。