#pragma warning restore CA1711 #pragma warning restore IDE0079 /// <summary> /// Gets a value indicating whether the field is private. /// </summary> /// <param name="provider">The reflection introspection provider.</param> /// <param name="field">The field to retrieve visibility for.</param> /// <returns>true if the field is private; otherwise; false.</returns> public static bool IsPrivate(this IFieldInfoIntrospectionProvider provider, FieldInfo field) => (NotNull(provider).GetAttributes(field) & FieldAttributes.FieldAccessMask) == FieldAttributes.Private;
#pragma warning disable IDE0079 // Remove unnecessary suppression. #pragma warning disable CA1711 // Replace Impl suffix. (Mirror image of reflection APIs.) /// <summary> /// Gets a value indicating whether the field has the PinvokeImpl attribute. /// </summary> /// <param name="provider">The reflection introspection provider.</param> /// <param name="field">The field to inspect.</param> /// <returns>true if the field has the PinvokeImpl attribute set; otherwise, false.</returns> public static bool IsPinvokeImpl(this IFieldInfoIntrospectionProvider provider, FieldInfo field) => (NotNull(provider).GetAttributes(field) & FieldAttributes.PinvokeImpl) > FieldAttributes.PrivateScope;
/// <summary> /// Gets a value indicating whether the field has the NotSerialized attribute. /// </summary> /// <param name="provider">The reflection introspection provider.</param> /// <param name="field">The field to inspect.</param> /// <returns>true if the field has the NotSerialized attribute set; otherwise, false.</returns> public static bool IsNotSerialized(this IFieldInfoIntrospectionProvider provider, FieldInfo field) => (NotNull(provider).GetAttributes(field) & FieldAttributes.NotSerialized) > FieldAttributes.PrivateScope;
/// <summary> /// Gets a value indicating whether the field can only be set in the body of the constructor. /// </summary> /// <param name="provider">The reflection introspection provider.</param> /// <param name="field">The field to inspect.</param> /// <returns>true if the field has the InitOnly attribute set; otherwise, false.</returns> public static bool IsInitOnly(this IFieldInfoIntrospectionProvider provider, FieldInfo field) => (NotNull(provider).GetAttributes(field) & FieldAttributes.InitOnly) > FieldAttributes.PrivateScope;
/// <summary> /// Gets a value indicating whether the potential visibility of the specified <paramref name="field"/> is described by <see cref="FieldAttributes.FamORAssem" />; that is, the field can be accessed by derived classes wherever they are, and by classes in the same assembly. /// </summary> /// <param name="provider">The reflection introspection provider.</param> /// <param name="field">The field to retrieve visibility for.</param> /// <returns>true if the visibility of the specified <paramref name="field"/> is exactly described by <see cref="FieldAttributes.FamORAssem" />; otherwise, false.</returns> public static bool IsFamilyOrAssembly(this IFieldInfoIntrospectionProvider provider, FieldInfo field) => (NotNull(provider).GetAttributes(field) & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem;
/// <summary> /// Gets a value indicating whether the field has the SpecialName attribute. /// </summary> /// <param name="provider">The reflection introspection provider.</param> /// <param name="field">The field to inspect.</param> /// <returns>true if the field has the SpecialName attribute set; otherwise, false.</returns> public static bool IsSpecialName(this IFieldInfoIntrospectionProvider provider, FieldInfo field) => (NotNull(provider).GetAttributes(field) & FieldAttributes.SpecialName) > FieldAttributes.PrivateScope;