Introduce an analyzer that recommends replacing dictionaries where a key is a byte, sbyte, enum with simple arrays instead.
It's amazing what creeps into code bases over time. Dictionaries that have a byte or enum key show up once in a while and can generally be much more efficiently implemented with arrays. Flagging this is happening can help developers make better choices.
The simplest form of analysis just looks for dictionaries having those simple key types. You can get fancier and try to discover other opportunities for optimization. For example, if you can prove that a dictionary which has an int key only ever contains smaller keys, the analyzer could recommend switching to arrays too. For example, this might be possible around sequences that initialize frozen dictionaries.
The analyzer we have for this looks for uses of constructors of relevant collections and just flags those, as opposed to flagging every use of Dictionary<byte, xxx> in a code base.
Introduce an analyzer that recommends replacing dictionaries where a key is a byte, sbyte, enum with simple arrays instead.
It's amazing what creeps into code bases over time. Dictionaries that have a byte or enum key show up once in a while and can generally be much more efficiently implemented with arrays. Flagging this is happening can help developers make better choices.
The simplest form of analysis just looks for dictionaries having those simple key types. You can get fancier and try to discover other opportunities for optimization. For example, if you can prove that a dictionary which has an int key only ever contains smaller keys, the analyzer could recommend switching to arrays too. For example, this might be possible around sequences that initialize frozen dictionaries.
The analyzer we have for this looks for uses of constructors of relevant collections and just flags those, as opposed to flagging every use of Dictionary<byte, xxx> in a code base.