HandyOrg/HandyControl · error · ArgumentNullException

enumType

Error message

enumType

What it means

Null guard in EnumDataProvider.GetValues: throws ArgumentNullException for 'enumType' when the caller passes a null Type where an enum type is required. The subsequent Enum.GetValues call would otherwise fail; this is a standard argument null check.

Solutions

  1. Pass a non-null enum Type to GetValues
  2. Check enumType for null (or use nameof arguments) before calling
  3. Validate with type.IsEnum before invoking to also catch non-enum types
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Shared/HandyControl_Shared/Data/Enum/EnumDataProvider.cs:43 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14). Data as JSON: /api/errors/829982c763afa352. Report an issue: GitHub.

Appendix: source

Thrown at src/Shared/HandyControl_Shared/Data/Enum/EnumDataProvider.cs:43

    }

    private bool _useAttributes;

    public bool UseAttributes
    {
        get => _useAttributes;
        set
        {
            _useAttributes = value;
            ObjectType = value ? typeof(EnumDataProvider) : typeof(System.Enum);
        }
    }

    public static IEnumerable<EnumItem> GetValues(Type enumType)
    {
        if (enumType == null)
        {
            throw new ArgumentNullException(nameof(enumType));
        }

        var resultList = new List<EnumItem>();

        var values = System.Enum.GetValues(enumType);
        foreach (System.Enum value in values)
        {
            var fieldInfo = enumType.GetField(value.ToString());
            if (fieldInfo == null)
            {
                continue;
            }

            if (fieldInfo.GetCustomAttributes(typeof(BrowsableAttribute), true) is BrowsableAttribute[] { Length: > 0 } browsableAttributes)
            {
                if (!browsableAttributes[0].Browsable)
                {
                    continue;

View on GitHub (pinned to 2c0875ebd6)