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:
Koen Vlaswinkel
2023-06-28 11:14:29 +02:00
committed by GitHub
4 changed files with 25 additions and 2 deletions

View File

@@ -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.
*/

View File

@@ -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
}
}

View File

@@ -1,2 +1,2 @@
| System | 5 |
| System.Collections.Generic | 2 |
| System.Collections.Generic | 5 |

View File

@@ -1 +1,3 @@
| System.Collections.Generic#List<>.Add(T) | 2 |
| System.Collections.Generic#Dictionary<,>+KeyCollection.GetEnumerator() | 1 |
| System.Collections.Generic#Dictionary<,>.get_Keys() | 1 |