peass-ng/PEASS-ng · error · ArgumentException
Type '{typeof(T).FullName}' doesn't have the 'Flags' attribu
Error message
Type '{typeof(T).FullName}' doesn't have the 'Flags' attribute What it means
CheckIsEnum<T>(checkHasFlags: true) additionally throws ArgumentException when T is an enum but lacks the [Flags] attribute. It is a validation sentinel fired by bit-manipulation helpers (like BitPosition) that require a flags-style enum, so the at-fault input is a non-flags enum type argument.
Source
Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs:14
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))
return;
throw new InvalidEnumArgumentException(argName ?? "value", Convert.ToInt32(value), typeof(T));View on GitHub (pinned to 53fb989abc)
Solutions
- Decorate the enum type with the [Flags] attribute before using it with bit-operation helpers.
- Only pass enums that are semantically bit masks (e.g. TaskRunFlags) to methods requiring flags.
- Check Attribute.IsDefined(typeof(T), typeof(FlagsAttribute)) before calling when the flags requirement is uncertain.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at winPEAS/winPEASexe/winPEAS/TaskScheduler/EnumUtil.cs:14 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/c551a46660e40e73.
Report an issue: GitHub.