peass-ng/PEASS-ng · error · ArgumentException

Type '{typeof(T).FullName}' is not an enum

Error message

Type '{typeof(T).FullName}' is not an enum

What it means

CheckIsEnum<T> is a generic validation helper that throws ArgumentException when the type parameter T is not an enum type. It fires whenever a TaskScheduler helper (e.g. enum extension methods) is invoked with a non-enum generic argument, meaning the caller misused the generic API.

Source

Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs:12

using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace winPEAS.TaskScheduler
{
    internal static class EnumUtil
    {
        public static void CheckIsEnum<T>(bool checkHasFlags = false)
        {
            if (!typeof(T).IsEnum)
                throw new ArgumentException($"Type '{typeof(T).FullName}' is not an enum");
            if (checkHasFlags && !IsFlags<T>())
                throw new ArgumentException($"Type '{typeof(T).FullName}' doesn't have the 'Flags' attribute");
        }

        public static bool IsFlags<T>() => Attribute.IsDefined(typeof(T), typeof(FlagsAttribute));

        public static void CheckHasValue<T>(T value, string argName = null)
        {
            CheckIsEnum<T>();
            if (IsFlags<T>())
            {
                var allFlags = 0L;
                foreach (T flag in Enum.GetValues(typeof(T)))
                    allFlags |= Convert.ToInt64(flag);
                if ((allFlags & Convert.ToInt64(value)) != 0L)
                    return;
            }
            else if (Enum.IsDefined(typeof(T), value))

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Instantiate the generic methods only with enum types (e.g. TaskLogonType, TaskState).
  2. Add a where T : struct, Enum constraint to your own wrappers so misuse is caught at compile time.
  3. Guard calls with typeof(T).IsEnum before invoking generic enum helpers.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs:12 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/dcb479619edd8857. Report an issue: GitHub.