@@ -37,15 +37,27 @@ private bool IsComment(string line)
3737 /// Removes the inline comment.
3838 /// </summary>
3939 /// <param name="line">The line with the inline comment to remove.</param>
40+ /// <param name="comment">Contains the removed comment or null if there is no comment.</param>
4041 /// <exception cref="ArgumentNullException"><c>line</c> is <c>null</c>.</exception>
4142 /// <returns>A string without the inline comment.</returns>
42- private string RemoveInlineComment ( string line )
43+ private string RemoveInlineComment ( string line , out string comment )
4344 {
4445 _ = line ?? throw new ArgumentNullException ( nameof ( line ) ) ;
4546 var separator = $ " { _configuration . CommentChar } ";
46- return line . Split ( new [ ] { separator } , MaxCount , StringSplitOptions . None ) [ 0 ] ;
47+ var substrings = line . Split ( new [ ] { separator } , MaxCount , StringSplitOptions . None ) ;
48+ comment = substrings . Length == 1 ? null : substrings [ 1 ] ;
49+ return substrings [ 0 ] ;
4750 }
4851
52+ /// <summary>
53+ /// Concatenates the comment with the value.
54+ /// </summary>
55+ /// <param name="value">The value of a key.</param>
56+ /// <param name="comment">The comment to concatenate with the value.</param>
57+ /// <returns>A string with the concatenated comment.</returns>
58+ private string ConcatCommentWithValue ( string value , string comment )
59+ => comment is null ? value : $ "{ value } { _configuration . CommentChar } { comment } ";
60+
4961 /// <summary>
5062 /// Removes all leading and trailing white-space characters from the current key.
5163 /// </summary>
@@ -283,5 +295,13 @@ private string GetValuesMultilines(string[] lines, ref int index, string value)
283295 ) ) ;
284296 return null ;
285297 }
298+
299+ /// <summary>
300+ /// Converts an empty string to a whitespace.
301+ /// </summary>
302+ /// <param name="value">The value to convert.</param>
303+ /// <returns>A string with the converted value.</returns>
304+ private string ConvertStringEmptyToWhitespace ( string value )
305+ => string . IsNullOrEmpty ( value ) ? " " : value ;
286306 }
287307}
0 commit comments