Fixed bug with CorrespondingTypeAttribute.GetAttrForEnum with default action

pull/180/head
dahall 2020-10-22 14:31:33 -06:00
parent 857e7c4703
commit 30167bc6ca
1 changed files with 1 additions and 1 deletions

View File

@ -183,7 +183,7 @@ namespace Vanara.InteropServices
protected static IEnumerable<CorrespondingTypeAttribute> GetAttrForEnum<TEnum>(TEnum value, CorrespondingAction action = (CorrespondingAction)0xf) where TEnum : System.Enum
{
var valueType = value.GetType();
var attr = valueType.GetField(value.ToString()).GetCustomAttributes<CorrespondingTypeAttribute>(false, a => a.Action.HasFlag(action));
var attr = valueType.GetField(value.ToString()).GetCustomAttributes<CorrespondingTypeAttribute>(false, a => (a.Action & action) > 0);
if (attr.Any(a => a.Action == CorrespondingAction.Exception)) throw new Exception();
//if (!attr.Any()) return new CorrespondingTypeAttribute[0];
return attr;