Skip to content

Commit a238509

Browse files
authored
Merge branch 'main' into napalys/ES2023-array-protype-with
2 parents 1304ab7 + 63bc1ef commit a238509

File tree

93 files changed

+629
-904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+629
-904
lines changed

csharp/CSharp.sln

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ VisualStudioVersion = 15.0.27130.2036
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Semmle.Util", "extractor\Semmle.Util\Semmle.Util.csproj", "{CDD7AD69-0FD8-40F0-A9DA-F1077A2A85D6}"
66
EndProject
7-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Semmle.Extraction", "extractor\Semmle.Extraction\Semmle.Extraction.csproj", "{81EAAD75-4BE1-44E4-91DF-20778216DB64}"
8-
EndProject
97
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Semmle.Extraction.CSharp", "extractor\Semmle.Extraction.CSharp\Semmle.Extraction.CSharp.csproj", "{C4D62DA0-B64B-440B-86DC-AB52318CB8BF}"
108
EndProject
119
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Semmle.Extraction.CSharp.DependencyFetching", "extractor\Semmle.Extraction.CSharp.DependencyFetching\Semmle.Extraction.CSharp.DependencyFetching.csproj", "{541D1AC5-E42C-4AB2-A1A4-C2355CE2A2EF}"

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ codeql_csharp_library(
1414
nowarn = ["CA1822"],
1515
visibility = ["//csharp:__subpackages__"],
1616
deps = [
17-
"//csharp/extractor/Semmle.Extraction",
17+
"//csharp/extractor/Semmle.Extraction.CSharp",
1818
"//csharp/extractor/Semmle.Util",
1919
],
2020
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
1515
internal class NugetExeWrapper : IDisposable
1616
{
1717
private readonly string? nugetExe;
18-
private readonly Util.Logging.ILogger logger;
18+
private readonly Semmle.Util.Logging.ILogger logger;
1919

2020
public int PackageCount => fileProvider.PackagesConfigs.Count;
2121

@@ -33,7 +33,7 @@ internal class NugetExeWrapper : IDisposable
3333
/// <summary>
3434
/// Create the package manager for a specified source tree.
3535
/// </summary>
36-
public NugetExeWrapper(FileProvider fileProvider, TemporaryDirectory packageDirectory, Util.Logging.ILogger logger)
36+
public NugetExeWrapper(FileProvider fileProvider, TemporaryDirectory packageDirectory, Semmle.Util.Logging.ILogger logger)
3737
{
3838
this.fileProvider = fileProvider;
3939
this.packageDirectory = packageDirectory;

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/Semmle.Extraction.CSharp.DependencyFetching.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<ProjectReference Include="..\Semmle.Util\Semmle.Util.csproj" />
8-
<ProjectReference Include="..\Semmle.Extraction\Semmle.Extraction.csproj" />
8+
<ProjectReference Include="..\Semmle.Extraction.CSharp\Semmle.Extraction.CSharp.csproj" />
99

1010
<InternalsVisibleTo Include="Semmle.Extraction.Tests" />
1111
</ItemGroup>

csharp/extractor/Semmle.Extraction.CSharp/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ load(
66
codeql_csharp_library(
77
name = "Semmle.Extraction.CSharp",
88
srcs = glob([
9+
"CodeAnalysisExtensions/**/*.cs",
910
"Comments/**/*.cs",
1011
"Entities/**/*.cs",
1112
"Extractor/**/*.cs",
1213
"Kinds/**/*.cs",
1314
"Populators/**/*.cs",
15+
"Trap/**/*.cs",
1416
"*.cs",
1517
]),
1618
allow_unsafe_blocks = True,
1719
visibility = ["//csharp:__subpackages__"],
1820
deps = [
19-
"//csharp/extractor/Semmle.Extraction",
2021
"//csharp/extractor/Semmle.Extraction.CSharp.Util",
2122
"//csharp/extractor/Semmle.Util",
2223
"@paket.main//basic.compilerlog.util",

csharp/extractor/Semmle.Extraction.CSharp/CachedEntityFactory.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

csharp/extractor/Semmle.Extraction/LocationExtensions.cs renamed to csharp/extractor/Semmle.Extraction.CSharp/CodeAnalysisExtensions/LocationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Linq;
44
using Microsoft.CodeAnalysis;
55

6-
namespace Semmle.Extraction
6+
namespace Semmle.Extraction.CSharp
77
{
88
public static class LocationExtensions
99
{

csharp/extractor/Semmle.Extraction.CSharp/Comments/CommentBlock.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class CommentBlock
1212

1313
public IEnumerable<CommentLine> CommentLines => lines;
1414

15-
public Location Location { get; private set; }
15+
public Microsoft.CodeAnalysis.Location Location { get; private set; }
1616

1717
public CommentBlock(CommentLine firstLine)
1818
{
@@ -49,7 +49,7 @@ public void AddCommentLine(CommentLine line)
4949
{
5050
Location = !lines.Any()
5151
? line.Location
52-
: Location.Create(
52+
: Microsoft.CodeAnalysis.Location.Create(
5353
line.Location.SourceTree!,
5454
new TextSpan(Location.SourceSpan.Start, line.Location.SourceSpan.End - Location.SourceSpan.Start));
5555

csharp/extractor/Semmle.Extraction.CSharp/Comments/CommentProcessor.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public void AddComment(CommentLine comment)
1919
}
2020

2121
// Comments sorted by location.
22-
private readonly SortedDictionary<Location, CommentLine> comments = new SortedDictionary<Location, CommentLine>(new LocationComparer());
22+
private readonly SortedDictionary<Microsoft.CodeAnalysis.Location, CommentLine> comments = new SortedDictionary<Microsoft.CodeAnalysis.Location, CommentLine>(new LocationComparer());
2323

2424
// Program elements sorted by location.
25-
private readonly SortedDictionary<Location, Label> elements = new SortedDictionary<Location, Label>(new LocationComparer());
25+
private readonly SortedDictionary<Microsoft.CodeAnalysis.Location, Label> elements = new SortedDictionary<Microsoft.CodeAnalysis.Location, Label>(new LocationComparer());
2626

2727
private readonly Dictionary<Label, Key> duplicationGuardKeys = new Dictionary<Label, Key>();
2828

@@ -33,9 +33,9 @@ public void AddComment(CommentLine comment)
3333
return null;
3434
}
3535

36-
private class LocationComparer : IComparer<Location>
36+
private class LocationComparer : IComparer<Microsoft.CodeAnalysis.Location>
3737
{
38-
public int Compare(Location? l1, Location? l2) => CommentProcessor.Compare(l1, l2);
38+
public int Compare(Microsoft.CodeAnalysis.Location? l1, Microsoft.CodeAnalysis.Location? l2) => CommentProcessor.Compare(l1, l2);
3939
}
4040

4141
/// <summary>
@@ -44,7 +44,7 @@ private class LocationComparer : IComparer<Location>
4444
/// <param name="l1">First location</param>
4545
/// <param name="l2">Second location</param>
4646
/// <returns>&lt;0 if l1 before l2, &gt;0 if l1 after l2, else 0.</returns>
47-
private static int Compare(Location? l1, Location? l2)
47+
private static int Compare(Microsoft.CodeAnalysis.Location? l1, Microsoft.CodeAnalysis.Location? l2)
4848
{
4949
if (object.ReferenceEquals(l1, l2))
5050
return 0;
@@ -68,7 +68,7 @@ private static int Compare(Location? l1, Location? l2)
6868
/// <param name="elementLabel">The label of the element in the trap file.</param>
6969
/// <param name="duplicationGuardKey">The duplication guard key of the element, if any.</param>
7070
/// <param name="loc">The location of the element.</param>
71-
public void AddElement(Label elementLabel, Key? duplicationGuardKey, Location? loc)
71+
public void AddElement(Label elementLabel, Key? duplicationGuardKey, Microsoft.CodeAnalysis.Location? loc)
7272
{
7373
if (loc is not null && loc.IsInSource)
7474
elements[loc] = elementLabel;
@@ -78,7 +78,7 @@ public void AddElement(Label elementLabel, Key? duplicationGuardKey, Location? l
7878

7979
// Ensure that commentBlock and element refer to the same file
8080
// which can happen when processing multiple files.
81-
private static void EnsureSameFile(Comments.CommentBlock commentBlock, ref KeyValuePair<Location, Label>? element)
81+
private static void EnsureSameFile(Comments.CommentBlock commentBlock, ref KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? element)
8282
{
8383
if (element is not null && element.Value.Key.SourceTree != commentBlock.Location.SourceTree)
8484
element = null;
@@ -96,9 +96,9 @@ private static void EnsureSameFile(Comments.CommentBlock commentBlock, ref KeyVa
9696
/// <param name="callback">Output binding information.</param>
9797
private void GenerateBindings(
9898
Comments.CommentBlock commentBlock,
99-
KeyValuePair<Location, Label>? previousElement,
100-
KeyValuePair<Location, Label>? nextElement,
101-
KeyValuePair<Location, Label>? parentElement,
99+
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? previousElement,
100+
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? nextElement,
101+
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? parentElement,
102102
CommentBindingCallback callback
103103
)
104104
{
@@ -125,7 +125,7 @@ CommentBindingCallback callback
125125
}
126126

127127
// Heuristic to decide which is the "best" element associated with the comment.
128-
KeyValuePair<Location, Label>? bestElement;
128+
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? bestElement;
129129

130130
if (previousElement is not null && previousElement.Value.Key.EndLine() == commentBlock.Location.StartLine())
131131
{
@@ -180,14 +180,14 @@ CommentBindingCallback callback
180180
private class ElementStack
181181
{
182182
// Invariant: the top of the stack must be contained by items below it.
183-
private readonly Stack<KeyValuePair<Location, Label>> elementStack = new Stack<KeyValuePair<Location, Label>>();
183+
private readonly Stack<KeyValuePair<Microsoft.CodeAnalysis.Location, Label>> elementStack = new();
184184

185185
/// <summary>
186186
/// Add a new element to the stack.
187187
/// </summary>
188188
/// The stack is maintained.
189189
/// <param name="value">The new element to push.</param>
190-
public void Push(KeyValuePair<Location, Label> value)
190+
public void Push(KeyValuePair<Microsoft.CodeAnalysis.Location, Label> value)
191191
{
192192
// Maintain the invariant by popping existing elements
193193
while (elementStack.Count > 0 && !elementStack.Peek().Key.Contains(value.Key))
@@ -201,15 +201,15 @@ public void Push(KeyValuePair<Location, Label> value)
201201
/// </summary>
202202
/// <param name="l">The location of the comment.</param>
203203
/// <returns>An element completely containing l, or null if none found.</returns>
204-
public KeyValuePair<Location, Label>? FindParent(Location l) =>
204+
public KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? FindParent(Microsoft.CodeAnalysis.Location l) =>
205205
elementStack.Where(v => v.Key.Contains(l)).FirstOrNull();
206206

207207
/// <summary>
208208
/// Finds the element on the stack immediately preceding the comment at l.
209209
/// </summary>
210210
/// <param name="l">The location of the comment.</param>
211211
/// <returns>The element before l, or null.</returns>
212-
public KeyValuePair<Location, Label>? FindBefore(Location l)
212+
public KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? FindBefore(Microsoft.CodeAnalysis.Location l)
213213
{
214214
return elementStack
215215
.Where(v => v.Key.SourceSpan.End < l.SourceSpan.Start)
@@ -222,7 +222,7 @@ public void Push(KeyValuePair<Location, Label> value)
222222
/// <param name="comment">The location of the comment.</param>
223223
/// <param name="next">The next element.</param>
224224
/// <returns>The next element.</returns>
225-
public KeyValuePair<Location, Label>? FindAfter(Location comment, KeyValuePair<Location, Label>? next)
225+
public KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? FindAfter(Microsoft.CodeAnalysis.Location comment, KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? next)
226226
{
227227
var p = FindParent(comment);
228228
return next.HasValue && p.HasValue && p.Value.Key.Before(next.Value.Key) ? null : next;
@@ -233,7 +233,7 @@ public void Push(KeyValuePair<Location, Label> value)
233233
private void GenerateBindings(
234234
Comments.CommentBlock block,
235235
ElementStack elementStack,
236-
KeyValuePair<Location, Label>? nextElement,
236+
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? nextElement,
237237
CommentBindingCallback cb
238238
)
239239
{
@@ -259,8 +259,8 @@ CommentBindingCallback cb
259259
/// <param name="cb">Where to send the results.</param>
260260
/// <returns>true if there are more comments to process, false otherwise.</returns>
261261
private bool GenerateBindings(
262-
IEnumerator<KeyValuePair<Location, CommentLine>> commentEnumerator,
263-
KeyValuePair<Location, Label>? nextElement,
262+
IEnumerator<KeyValuePair<Microsoft.CodeAnalysis.Location, CommentLine>> commentEnumerator,
263+
KeyValuePair<Microsoft.CodeAnalysis.Location, Label>? nextElement,
264264
ElementStack elementStack,
265265
CommentBindingCallback cb
266266
)
@@ -319,8 +319,8 @@ public void GenerateBindings(CommentBindingCallback cb)
319319

320320
var elementStack = new ElementStack();
321321

322-
using IEnumerator<KeyValuePair<Location, Label>> elementEnumerator = elements.GetEnumerator();
323-
using IEnumerator<KeyValuePair<Location, CommentLine>> commentEnumerator = comments.GetEnumerator();
322+
using IEnumerator<KeyValuePair<Microsoft.CodeAnalysis.Location, Label>> elementEnumerator = elements.GetEnumerator();
323+
using IEnumerator<KeyValuePair<Microsoft.CodeAnalysis.Location, CommentLine>> commentEnumerator = comments.GetEnumerator();
324324
if (!commentEnumerator.MoveNext())
325325
{
326326
// There are no comments to process.

0 commit comments

Comments
 (0)