mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
Merge pull request #13588 from github/koesie10/update-csharp-external-api-name
C#: Fix external API name for nested types
This commit is contained in:
@@ -50,7 +50,7 @@ class ExternalApi extends DotNet::Callable {
|
||||
bindingset[this]
|
||||
private string getSignature() {
|
||||
result =
|
||||
this.getDeclaringType().getUnboundDeclaration() + "." + this.getName() + "(" +
|
||||
nestedName(this.getDeclaringType().getUnboundDeclaration()) + "." + this.getName() + "(" +
|
||||
parameterQualifiedTypeNamesToString(this) + ")"
|
||||
}
|
||||
|
||||
@@ -118,6 +118,21 @@ class ExternalApi extends DotNet::Callable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nested name of the declaration.
|
||||
*
|
||||
* If the declaration is not a nested type, the result is the same as \`getName()\`.
|
||||
* Otherwise the name of the nested type is prefixed with a \`+\` and appended to
|
||||
* the name of the enclosing type, which might be a nested type as well.
|
||||
*/
|
||||
private string nestedName(Declaration declaration) {
|
||||
not exists(declaration.getDeclaringType().getUnboundDeclaration()) and
|
||||
result = declaration.getName()
|
||||
or
|
||||
nestedName(declaration.getDeclaringType().getUnboundDeclaration()) + "+" + declaration.getName() =
|
||||
result
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the limit for the number of results produced by a telemetry query.
|
||||
*/
|
||||
|
||||
@@ -25,4 +25,10 @@ public class LibraryUsage
|
||||
{
|
||||
var guid1 = Guid.Parse("{12345678-1234-1234-1234-123456789012}"); // Has no flow summary
|
||||
}
|
||||
|
||||
public void M4()
|
||||
{
|
||||
var d = new Dictionary<string, object>(); // Uninteresting parameterless constructor
|
||||
var e = d.Keys.GetEnumerator().MoveNext(); // Methods on nested classes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
| System | 5 |
|
||||
| System.Collections.Generic | 2 |
|
||||
| System.Collections.Generic | 5 |
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
| System.Collections.Generic#List<>.Add(T) | 2 |
|
||||
| System.Collections.Generic#Dictionary<,>+KeyCollection.GetEnumerator() | 1 |
|
||||
| System.Collections.Generic#Dictionary<,>.get_Keys() | 1 |
|
||||
|
||||
Reference in New Issue
Block a user