Skip to content

Commit 4009f03

Browse files
authored
Merge pull request #14665 from michaelnebel/csharp/projectreference
C#: Update DependencyManager logic to exclude commented out references.
2 parents 9807a8e + 0bf2d77 commit 4009f03

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FileContent.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,19 @@ private void DoInitialize()
197197
}
198198
}
199199

200-
[GeneratedRegex("<PackageReference.*\\sInclude=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
200+
[GeneratedRegex("(?<!<!--.*)<PackageReference.*\\sInclude=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
201201
private static partial Regex PackageReference();
202202

203-
[GeneratedRegex("<FrameworkReference.*\\sInclude=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
203+
[GeneratedRegex("(?<!<!--.*)<FrameworkReference.*\\sInclude=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
204204
private static partial Regex FrameworkReference();
205205

206-
[GeneratedRegex("<(.*\\s)?Project.*\\sSdk=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
206+
[GeneratedRegex("(?<!<!--.*)<(.*\\s)?Project.*\\sSdk=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
207207
private static partial Regex ProjectSdk();
208208

209-
[GeneratedRegex("<Using.*\\sInclude=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
209+
[GeneratedRegex("(?<!<!--.*)<Using.*\\sInclude=\"(.*?)\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
210210
private static partial Regex CustomImplicitUsingDeclarations();
211211

212-
[GeneratedRegex("<Import.*\\sProject=\".*Microsoft\\.CSharp\\.targets\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
212+
[GeneratedRegex("(?<!<!--.*)<Import.*\\sProject=\".*Microsoft\\.CSharp\\.targets\".*/?>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
213213
private static partial Regex MicrosoftCSharpTargets();
214214
}
215215

csharp/extractor/Semmle.Extraction.Tests/FileContent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public void TestFileContent1()
4343
"<PackageReference Include=\"DotNetAnalyzers.DocumentationAnalyzers\" Version=\"1.0.0-beta.59\" PrivateAssets=\"all\" />",
4444
"<PackageReference Version=\"7.0.0\" Include=\"Microsoft.CodeAnalysis.NetAnalyzers\"PrivateAssets=\"all\" />",
4545
"<PackageReference Include=\"StyleCop.Analyzers\" Version=\"1.2.0-beta.406\">",
46+
"<!-- <PackageReference Include=\"NUnit\" Version=\"3.10.1\" /> -->",
4647
"<FrameworkReference Include=\"My.Framework\"/>"
4748
};
4849
var fileContent = new TestFileContent(lines);

csharp/ql/integration-tests/posix-only/standalone_dependencies/Assemblies.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,3 @@
169169
| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/mscorlib.dll |
170170
| /microsoft.netcore.app.ref/7.0.2/ref/net7.0/netstandard.dll |
171171
| /newtonsoft.json/12.0.1/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll |
172-
| /nunit/3.13.3/lib/netstandard2.0/nunit.framework.dll |

csharp/ql/integration-tests/windows-only/standalone_dependencies/Assemblies.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,3 @@
213213
| /microsoft.windowsdesktop.app.ref/7.0.2/ref/net7.0/WindowsBase.dll |
214214
| /microsoft.windowsdesktop.app.ref/7.0.2/ref/net7.0/WindowsFormsIntegration.dll |
215215
| /newtonsoft.json/12.0.1/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll |
216-
| /nunit/3.13.3/lib/netstandard2.0/nunit.framework.dll |

0 commit comments

Comments
 (0)