C#: Extract anonymous types explicitly

This commit is contained in:
Tamas Vajk
2020-11-16 10:44:30 +01:00
parent 3b16d2689d
commit fdf5cf9dd0
4 changed files with 14 additions and 1 deletions

View File

@@ -87,6 +87,11 @@ namespace Semmle.Extraction.CSharp.Entities
foreach (var l in Locations)
trapFile.type_location(this, l);
}
if (symbol.IsAnonymousType)
{
trapFile.anonymous_types(this);
}
}
private readonly Lazy<Type[]> typeArgumentsLazy;

View File

@@ -271,6 +271,11 @@ namespace Semmle.Extraction.CSharp
trapFile.WriteTuple("extend", type, super);
}
internal static void anonymous_types(this TextWriter trapFile, Type type)
{
trapFile.WriteTuple("anonymous_types", type);
}
internal static void field_location(this TextWriter trapFile, Field field, Location location)
{
trapFile.WriteTuple("field_location", field, location);

View File

@@ -746,7 +746,7 @@ class Class extends RefType, @class_type {
* ```
*/
class AnonymousClass extends Class {
AnonymousClass() { this.getName().matches("<%") }
AnonymousClass() { anonymous_types(this) }
}
/**

View File

@@ -413,6 +413,9 @@ extend(
unique int sub: @type ref,
int super: @type_or_ref ref);
anonymous_types(
unique int id: @type ref);
@interface_or_ref = @interface_type | @typeref;
implement(