Skip to content

Commit 84e4ba4

Browse files
authored
Merge pull request #239 from servicetitan/fix_AttributeSearchOptions
Fix AttributeSearchOptions.InheritFromAllBase flag value
2 parents bf8eb49 + 2c26dd0 commit 84e4ba4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Orm/Xtensive.Orm/Reflection/AttributeHelper.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@ private static IEnumerable<Attribute> ExtractAttributes((MemberInfo member, Type
9797
attributes = poe.GetAttributes(attributeType).ToList();
9898
}
9999
if ((options & AttributeSearchOptions.InheritFromBase) != 0
100-
&& (options & AttributeSearchOptions.InheritFromAllBase) == 0
100+
&& (options & AttributeSearchOptions.InheritRecursively) == 0
101101
&& member.GetBaseMember() is MemberInfo bm) {
102102
attributes.AddRange(GetAttributes(bm, attributeType, options));
103+
return attributes;
103104
}
104105
}
105106

106-
if ((options & AttributeSearchOptions.InheritFromAllBase) != 0
107+
if ((options & AttributeSearchOptions.InheritFromAllBase) == AttributeSearchOptions.InheritFromAllBase
107108
&& member.DeclaringType != WellKnownTypes.Object
108109
&& member.GetBaseMember() is MemberInfo bm2) {
109110
attributes.AddRange(GetAttributes(bm2, attributeType, options));

Orm/Xtensive.Orm/Reflection/AttributeSearchOptions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ public enum AttributeSearchOptions
2929
/// </summary>
3030
InheritFromBase = 1,
3131
/// <summary>
32+
/// Attributes inherit recursively.
33+
/// </summary>
34+
InheritRecursively = 2,
35+
/// <summary>
3236
/// Attributes from all the bases should be inherited.
3337
/// </summary>
34-
InheritFromAllBase = 3,
38+
InheritFromAllBase = InheritFromBase | InheritRecursively,
3539
/// <summary>
3640
/// If no attributes are found on the specified method,
3741
/// attributes from the property or event it belongs to should be inherited.

0 commit comments

Comments
 (0)