From bf69880d5fc819038412265a4671286a987b2ce1 Mon Sep 17 00:00:00 2001 From: "a.beging@eas-solutions.de" Date: Tue, 12 May 2026 10:07:01 +0200 Subject: [PATCH] Fix GetAttributeOfType method: add check for empty member info to prevent null reference exceptions --- FoodsharingSiegen.Contracts/Helper/AttributeExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/FoodsharingSiegen.Contracts/Helper/AttributeExtensions.cs b/FoodsharingSiegen.Contracts/Helper/AttributeExtensions.cs index 4e64ee4..e3f348f 100644 --- a/FoodsharingSiegen.Contracts/Helper/AttributeExtensions.cs +++ b/FoodsharingSiegen.Contracts/Helper/AttributeExtensions.cs @@ -34,6 +34,7 @@ namespace FoodsharingSiegen.Contracts.Helper { var type = enumVal.GetType(); var memInfo = type.GetMember(enumVal.ToString()); + if (memInfo.Length == 0) return null; var attributes = memInfo[0].GetCustomAttributes(typeof(T), false); return attributes.Length > 0 ? (T)attributes[0] : null; }