C#


ROSLYN.PERFORMANCE.CA1853 : Unnecessary call to 'Dictionary.ContainsKey(key)' (C#)

See Roslyn-Detected C# Warning Classes for more information.

Summary

Do not guard 'Dictionary.Remove(key)' with 'Dictionary.ContainsKey(key)'. The former already checks whether the key exists, and will not throw if it does not.

This check corresponds to Roslyn rule CA1853. For full rule details, see the Microsoft website: CA1853.

Properties

Class Name Unnecessary call to 'Dictionary.ContainsKey(key)' (C#)
Significance reliability
Mnemonic ROSLYN.PERFORMANCE.CA1853
Categories None
Availability Available for C# only.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Unnecessary call to 'Dictionary.ContainsKey(key)' (C#)"

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.