{"record":{"id":"dcb479619edd8857","repo":"peass-ng/PEASS-ng","slug":"type-typeof-t-fullname-is-not-an-enum","errorCode":null,"errorMessage":"Type '{typeof(T).FullName}' is not an enum","messagePattern":"Type '(.+?)' is not an enum","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs","lineNumber":12,"sourceCode":"﻿using System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\n\nnamespace winPEAS.TaskScheduler\n{\n    internal static class EnumUtil\n    {\n        public static void CheckIsEnum<T>(bool checkHasFlags = false)\n        {\n            if (!typeof(T).IsEnum)\n                throw new ArgumentException($\"Type '{typeof(T).FullName}' is not an enum\");\n            if (checkHasFlags && !IsFlags<T>())\n                throw new ArgumentException($\"Type '{typeof(T).FullName}' doesn't have the 'Flags' attribute\");\n        }\n\n        public static bool IsFlags<T>() => Attribute.IsDefined(typeof(T), typeof(FlagsAttribute));\n\n        public static void CheckHasValue<T>(T value, string argName = null)\n        {\n            CheckIsEnum<T>();\n            if (IsFlags<T>())\n            {\n                var allFlags = 0L;\n                foreach (T flag in Enum.GetValues(typeof(T)))\n                    allFlags |= Convert.ToInt64(flag);\n                if ((allFlags & Convert.ToInt64(value)) != 0L)\n                    return;\n            }\n            else if (Enum.IsDefined(typeof(T), value))","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs#L1-L30","documentation":"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.","triggerScenarios":"Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs:12 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Instantiate the generic methods only with enum types (e.g. TaskLogonType, TaskState).","Add a where T : struct, Enum constraint to your own wrappers so misuse is caught at compile time.","Guard calls with typeof(T).IsEnum before invoking generic enum helpers."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}