private void ParseIndentSize()
        {
            if (!_properties.TryGetValue("indent_size", out string indentSize))
            {
                return;
            }

            switch (indentSize)
            {
            case "unset":
                IndentSize = new IndentSize();
                return;

            case "tab":
                IndentSize = new IndentSize(true);
                return;

            default:
                int size;
                if (int.TryParse(indentSize, out size) && size > 0)
                {
                    IndentSize = new IndentSize(size);
                }

                return;
            }
        }
        /// <summary>
        /// Holds the editor configuration for a file, please use <see cref="EditorConfigParser.Parse"/> to get an instance
        /// </summary>
        internal FileConfiguration(Version version, string fileName, List <ConfigSection> sections)
        {
            if (version == null)
            {
                throw new ArgumentNullException(nameof(version));
            }
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentException("file should not be null or whitespace", nameof(fileName));
            }

            FileName = fileName;
            Version  = version;
            Sections = sections;

            var allProperties = sections.SelectMany(section => section);
            var properties    = new Dictionary <string, string>();

            foreach (var kv in allProperties)
            {
                properties[kv.Key] = kv.Value;
            }

            IndentStyle            = Sections.FirstOrDefault(s => s.IndentStyle.HasValue)?.IndentStyle;
            IndentSize             = Sections.LastOrDefault(s => s.IndentSize != null)?.IndentSize;
            TabWidth               = Sections.FirstOrDefault(s => s.TabWidth.HasValue)?.TabWidth;
            EndOfLine              = Sections.FirstOrDefault(s => s.EndOfLine.HasValue)?.EndOfLine;
            Charset                = Sections.FirstOrDefault(s => s.Charset.HasValue)?.Charset;
            TrimTrailingWhitespace = Sections.FirstOrDefault(s => s.TrimTrailingWhitespace.HasValue)?.TrimTrailingWhitespace;
            InsertFinalNewline     = Sections.FirstOrDefault(s => s.InsertFinalNewline.HasValue)?.InsertFinalNewline;
            MaxLineLength          = Sections.FirstOrDefault(s => s.MaxLineLength.HasValue)?.MaxLineLength;

            //default tab_width to indent_size when indent size is a number
            if (IndentSize != null && IndentSize.NumberOfColumns.HasValue)
            {
                TabWidth = IndentSize.NumberOfColumns.Value;
                properties["tab_width"] = TabWidth.Value.ToString();
            }

            // Set indent_size to "tab" if indent_size is unspecified and indent_style is set to "tab".
            if (IndentStyle.HasValue && IndentStyle == Core.IndentStyle.Tab && IndentSize == null &&
                Version >= new Version(0, 10))
            {
                IndentSize = IndentSize.Tab;
                properties["indent_size"] = "tab";
            }

            // Set tab_width to indent_size if indent_size is specified and tab_width is unspecified
            if (IndentSize != null && !TabWidth.HasValue && !IndentSize.UseTabWidth)
            {
                //only set tab_width to indent_size if indent size holds a positive integer
                if (IndentSize.NumberOfColumns.HasValue && IndentSize.NumberOfColumns.Value >= 0)
                {
                    TabWidth = IndentSize.NumberOfColumns.Value;
                    properties["tab_width"] = TabWidth.Value.ToString();
                }

                // unset carries over see:
                //  ctest . -R "unset_indent_size"
                else if (IndentSize.IsUnset)
                {
                    TabWidth = new int?();
                    properties["tab_width"] = "unset";
                }
            }

            // Set indent_size to tab_width if indent_size is "tab"
            if (IndentSize != null && TabWidth != null && IndentSize.UseTabWidth)
            {
                IndentSize = IndentSize.Columns(TabWidth.Value);
                properties["indent_size"] = TabWidth.Value.ToString();
            }

            Properties = new ReadOnlyDictionary <string, string>(properties);
        }