Skip to content
This repository was archived by the owner on Dec 13, 2021. It is now read-only.

Commit 9922e92

Browse files
committed
Fixed a bug in AttributedTypeResolver
It was wrongly adding a warning log saying a duplicate attribute had been added, but really the attribute didn't exist on the type.
1 parent 317072a commit 9922e92

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Our.Umbraco.Ditto/ComponentModel/ObjectResolution/AttributedTypeResolver.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,16 @@ public static AttributedTypeResolver<TAttribute> Create(IEnumerable<Type> types,
8585
private bool TryAddAttributedType(Type type, out TAttribute attribute, bool inherit)
8686
{
8787
attribute = type.GetCustomAttribute<TAttribute>(inherit);
88-
if (attribute != null && _attributedTypeLookup.ContainsKey(type) == false)
88+
if (attribute != null)
8989
{
90-
return _attributedTypeLookup.TryAdd(type, attribute);
91-
}
92-
else
93-
{
94-
LogHelper.Warn<AttributedTypeResolver<TAttribute>>($"Duplicate '{typeof(TAttribute)}' attribute found in type: '{type}'");
90+
if (_attributedTypeLookup.ContainsKey(type) == false)
91+
{
92+
return _attributedTypeLookup.TryAdd(type, attribute);
93+
}
94+
else
95+
{
96+
LogHelper.Warn<AttributedTypeResolver<TAttribute>>($"Duplicate '{typeof(TAttribute)}' attribute found in type: '{type}'");
97+
}
9598
}
9699

97100
return false;

0 commit comments

Comments
 (0)