Skip to content

Commit c54634f

Browse files
author
Kapil Borle
committed
Enhance avoidalias setproperty method
1 parent c7a091a commit c54634f

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

Rules/AvoidAlias.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,31 @@ private void SetProperties()
6262
return;
6363
}
6464
IEnumerable<string> aliases = obj as IEnumerable<string>;
65-
if (obj == null)
65+
if (aliases == null)
6666
{
67-
return;
67+
// try with enumerable objects
68+
var enumerableObjs = obj as IEnumerable<object>;
69+
if (enumerableObjs == null)
70+
{
71+
return;
72+
}
73+
foreach (var x in enumerableObjs)
74+
{
75+
var y = x as string;
76+
if (y == null)
77+
{
78+
return;
79+
}
80+
else
81+
{
82+
whiteList.Add(y);
83+
}
84+
}
85+
}
86+
else
87+
{
88+
whiteList.AddRange(aliases);
6889
}
69-
whiteList.AddRange(aliases);
7090
}
7191

7292
/// <summary>

0 commit comments

Comments
 (0)