# CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
dotnet_diagnostic.CA1864.severity = warning
+# CA1868: Unnecessary call to 'Contains' for sets
+dotnet_diagnostic.CA1868.severity = warning
+
# CA2000: Dispose objects before losing scope
dotnet_diagnostic.CA2000.severity = none
# CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
dotnet_diagnostic.CA1864.severity = none
+# CA1868: Unnecessary call to 'Contains' for sets
+dotnet_diagnostic.CA1868.severity = none
+
# CA2000: Dispose objects before losing scope
dotnet_diagnostic.CA2000.severity = none
{
foreach (var module in allModules)
{
- if (!markedModules.Contains(module))
+ if (markedModules.Add(module))
{
- markedModules.Add(module);
if (modulesWithCctor.Contains(module.Module))
sortedModules.Add(module.Module);
break;
void IDependencyAnalyzerLogEdgeVisitor<DependencyContextType>.VisitEdge(DependencyNodeCore<DependencyContextType> nodeDepender, DependencyNodeCore<DependencyContextType> nodeDependerOther, DependencyNodeCore<DependencyContextType> nodeDependedOn, string reason)
{
var combinedNode = new Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>>(nodeDepender, nodeDependerOther);
- if (!_combinedNodesEdgeVisited.Contains(combinedNode))
+ if (_combinedNodesEdgeVisited.Add(combinedNode))
{
- _combinedNodesEdgeVisited.Add(combinedNode);
-
_xmlWrite.WriteStartElement("Link");
_xmlWrite.WriteAttributeString("Source", _nodeMappings[nodeDepender].ToString());
_xmlWrite.WriteAttributeString("Target", _nodeMappings[combinedNode].ToString());
}
else
{
- if (candidates.Contains(candidatePart))
- {
- alreadyProcessed = true;
- }
- else
- {
- candidates.Add(candidatePart);
- }
+ alreadyProcessed |= !candidates.Add(candidatePart);
}
if (!alreadyProcessed)
{
}
}
- if (!_sharedSessionClientIds.Contains(clientId))
+ if (_sharedSessionClientIds.Add(clientId))
{
- _sharedSessionClientIds.Add(clientId);
Interlocked.Increment(ref _sharedSessionRefCount);
}
}
string rootPath = Path.GetDirectoryName(lib)!;
string libName = Path.GetFileName(lib);
- if (!libDirs.Contains(rootPath))
+ if (libDirs.Add(rootPath))
{
- libDirs.Add(rootPath);
ret.Append($"-L {rootPath} ");
}
ret.Append($"-l:{libName} ");
var values = new HashSet<DynamicallyAccessedMemberTypes> (
Enum.GetValues (typeof (DynamicallyAccessedMemberTypes))
.Cast<DynamicallyAccessedMemberTypes> ());
- if (!values.Contains (DynamicallyAccessedMemberTypes.Interfaces))
- values.Add (DynamicallyAccessedMemberTypes.Interfaces);
+ values.Add (DynamicallyAccessedMemberTypes.Interfaces);
return values.ToArray ();
}