diff --git a/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerConfigTests.cs b/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerConfigTests.cs index 1624752b3330e..7ad3a2d889460 100644 --- a/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerConfigTests.cs +++ b/src/Compilers/Core/CodeAnalysisTest/Analyzers/AnalyzerConfigTests.cs @@ -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); } diff --git a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.cs b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.cs index a1c4f920e136e..a4d67b9d708a1 100644 --- a/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.cs +++ b/src/Compilers/Core/Portable/CommandLine/AnalyzerConfig.cs @@ -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); /// /// Key that indicates if this config is a global config