Reputation:
I have following code. I getting the FxCop violation. I do not know how to validate the List parameter.
public Collection<ProjectData> IsHookedConfiguredList(Collection<ProjectData> groupProjectList)
{
if (groupProjectList.Count != 0)
{
// my code
}
return hookConfiguredList;
}
I added the line if (groupProjectList.Count != 0)
But I did not rid violation.
How could I fix this?
Upvotes: 0
Views: 455
Reputation: 31282
Code Analysis wants you to check whether passed argument is null before you use it. Try this:
public Collection<ProjectData> IsHookedConfiguredList(Collection<ProjectData> groupProjectList)
{
if (groupProjectList == null)
{
throw new ArgumentNullException(nameof(groupProjectList));
}
// the code
}
Upvotes: 1