roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

Suggestion: Add refactoring for Hashtable

Open VahidN opened this issue 5 years ago • 0 comments
trafficstars

Suppose we have an old code like this (belongs to .NET 1x):

namespace SimpleParser
{
    public class IanaEncodings
    {
        private static readonly Hashtable _map = new Hashtable();

        static IanaEncodings()
        {
            _map["CP037"] = 37;
            _map["CSIBM037"] = 37;
        }
    }
}

It would be really useful to have a refactoring for converting the Hashtable to a Dictionary to avoid the future boxings. The structure of this Dictionary should be detected from the usage of the _map here: Dictionary<string, int>

VahidN avatar Aug 19 '20 05:08 VahidN