Skip to content

Commit ddb50b8

Browse files
committed
C#: Improve regular expressions and fix lowercase issue.
1 parent ca7fa2e commit ddb50b8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ private static bool IsGroupMatch(ReadOnlySpan<char> line, Regex regex, string gr
352352
foreach (var valueMatch in regex.EnumerateMatches(line))
353353
{
354354
// We can't get the group from the ValueMatch, so doing it manually:
355-
if (GetGroup(line, valueMatch, groupPrefix) == value)
355+
if (GetGroup(line, valueMatch, groupPrefix) == value.ToLowerInvariant())
356356
{
357357
return true;
358358
}
@@ -486,13 +486,13 @@ private void AnalyseSolutions(IEnumerable<string> solutions)
486486
public void Dispose() =>
487487
packageDirectory?.Dispose();
488488

489-
[GeneratedRegex("<PackageReference .*Include=\"(.*?)\".*/>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
489+
[GeneratedRegex("<PackageReference\\s+Include=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
490490
private static partial Regex PackageReference();
491491

492-
[GeneratedRegex("<FrameworkReference .*Include=\"(.*?)\".*/>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
492+
[GeneratedRegex("<FrameworkReference\\s+Include=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
493493
private static partial Regex FrameworkReference();
494494

495-
[GeneratedRegex("<Project .*Sdk=\"(.*?)\".*/>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
495+
[GeneratedRegex("<Project\\s+Sdk=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
496496
private static partial Regex ProjectSdk();
497497

498498
}

0 commit comments

Comments
 (0)