Skip to content

Commit

Permalink
Use return value of HashSet.Add
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup authored and dennisdoomen committed Nov 24, 2024
1 parent befceff commit 50acc9d
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/Reflectify/Reflectify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,10 @@ private void AddNormalProperties(MemberKind kind, PropertyInfo[] allProperties)
{
foreach (var property in allProperties)
{
if (!collectedPropertyNames.Contains(property.Name) && !property.IsExplicitlyImplemented() &&
HasVisibility(kind, property))
if (HasVisibility(kind, property) && !property.IsExplicitlyImplemented() &&
collectedPropertyNames.Add(property.Name))
{
selectedProperties.Add(property);
collectedPropertyNames.Add(property.Name);
}
}
}
Expand All @@ -661,10 +660,9 @@ private void AddExplicitlyImplementedProperties(MemberKind kind, PropertyInfo[]
{
var name = p.Name.Split('.').Last();

if (!collectedPropertyNames.Contains(name))
if (collectedPropertyNames.Add(name))
{
selectedProperties.Add(p);
collectedPropertyNames.Add(name);
}
}
}
Expand All @@ -681,11 +679,10 @@ private void AddInterfaceProperties(Type typeToReflect, MemberKind kind, Binding
{
foreach (var prop in interfaceType.GetProperties(flags))
{
if (!collectedPropertyNames.Contains(prop.Name) &&
(!prop.IsAbstract() || typeToReflect.IsInterface))
if ((!prop.IsAbstract() || typeToReflect.IsInterface) &&
collectedPropertyNames.Add(prop.Name))
{
selectedProperties.Add(prop);
collectedPropertyNames.Add(prop.Name);
}
}
}
Expand All @@ -703,10 +700,9 @@ private void LoadFields(Type typeToReflect, MemberKind kind)

foreach (var field in files)
{
if (!collectedFieldNames.Contains(field.Name) && HasVisibility(kind, field))
if (HasVisibility(kind, field) && collectedFieldNames.Add(field.Name))
{
selectedFields.Add(field);
collectedFieldNames.Add(field.Name);
}
}

Expand Down

0 comments on commit 50acc9d

Please sign in to comment.