Skip to content

Commit

Permalink
EditorConfig comments cannot follow a property value
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Mar 3, 2021
1 parent 4db9a68 commit 3b98df1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,18 @@ public void SpacesInProperties()
properties);
}

[Fact]
public void EndOfLineComments()
[Theory]
[WorkItem(44596, "https://github.com/dotnet/roslyn/issues/44596")]
[InlineData(";")]
[InlineData("#")]
public void EndOfLineComments(string commentStartCharacter)
{
var config = ParseConfigFile(@"
my_prop2 = my val2 # Comment");
var config = ParseConfigFile($@"
my_prop2 = my val2 {commentStartCharacter} Not A Comment");

var properties = config.GlobalSection.Properties;
AssertEx.SetEqual(
new[] { KeyValuePair.Create("my_prop2", "my val2") },
new[] { KeyValuePair.Create("my_prop2", $"my val2 {commentStartCharacter} Not A Comment") },
properties);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public sealed partial class AnalyzerConfig
// Matches EditorConfig section header such as "[*.{js,py}]", see https://editorconfig.org for details
private static readonly Regex s_sectionMatcher = new Regex(@"^\s*\[(([^#;]|\\#|\\;)+)\]\s*([#;].*)?$", RegexOptions.Compiled);
// Matches EditorConfig property such as "indent_style = space", see https://editorconfig.org for details
private static readonly Regex s_propertyMatcher = new Regex(@"^\s*([\w\.\-_]+)\s*[=:]\s*(.*?)\s*([#;].*)?$", RegexOptions.Compiled);
private static readonly Regex s_propertyMatcher = new Regex(@"^\s*([\w\.\-_]+)\s*[=:]\s*(.*?)\s*$", RegexOptions.Compiled);

/// <summary>
/// Key that indicates if this config is a global config
Expand Down

0 comments on commit 3b98df1

Please sign in to comment.