コード例 #1
0
    public static bool AllowsNull(this PropertyDefinition property, NullGuardMode mode)
    {
        if (mode == NullGuardMode.Explicit)
        {
            return(ExplicitMode.AllowsNull(property));
        }

        return(property.ImplicitAllowsNull());
    }
コード例 #2
0
    public static bool AllowsNull(this ParameterDefinition parameter, MethodDefinition method, NullGuardMode mode)
    {
        if (mode == NullGuardMode.Explicit)
        {
            return(ExplicitMode.AllowsNull(parameter, method));
        }

        return(parameter.ImplicitAllowsNull());
    }
コード例 #3
0
    public static bool AllowsNull(this PropertyDefinition property, ExplicitMode explicitMode)
    {
        if (explicitMode != null)
        {
            return(explicitMode.AllowsNull(property));
        }

        return(property.ImplicitAllowsNull());
    }
コード例 #4
0
    public static bool AllowsNull(this ParameterDefinition parameter, MethodDefinition method, ExplicitMode explicitMode)
    {
        if (explicitMode != null)
        {
            return(explicitMode.AllowsNull(parameter, method));
        }

        return(parameter.ImplicitAllowsNull());
    }
コード例 #5
0
    public static bool AllowsNullReturnValue(this MethodDefinition methodDefinition, NullGuardMode mode)
    {
        if (mode == NullGuardMode.Explicit)
        {
            // ReSharper uses a *method* attribute for NotNull for the return value
            return(ExplicitMode.AllowsNull(methodDefinition));
        }

        return(methodDefinition.MethodReturnType.CustomAttributes.Any(a => a.AttributeType.Name == AllowNullAttributeTypeName) ||
               // ReSharper uses a *method* attribute for CanBeNull for the return value
               methodDefinition.CustomAttributes.Any(a => a.AttributeType.Name == CanBeNullAttributeTypeName));
    }
コード例 #6
0
    public static bool AllowsNullReturnValue(this MethodDefinition methodDefinition, ExplicitMode explicitMode)
    {
        if (explicitMode != null)
        {
            // ReSharper uses a *method* attribute for NotNull for the return value
            return(explicitMode.AllowsNull(methodDefinition));
        }

        return(methodDefinition.CustomAttributes.HasNullableReferenceType(NullableContextAttributeTypeName) ||
               methodDefinition.MethodReturnType.CustomAttributes.Any(a => a.AttributeType.Name == AllowNullAttributeTypeName) ||
               // ReSharper uses a *method* attribute for CanBeNull for the return value
               methodDefinition.CustomAttributes.Any(a => a.AttributeType.Name == CanBeNullAttributeTypeName));
    }