Skip to content

Commit 0104f96

Browse files
committed
C#: Remove metadata_handle part of the extractor implementation.
1 parent a6f95c5 commit 0104f96

File tree

6 files changed

+0
-52
lines changed

6 files changed

+0
-52
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/CachedSymbol.cs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -144,50 +144,5 @@ public ExpressionSyntax? ExpressionBody
144144
public override bool NeedsPopulation => Context.Defines(Symbol);
145145

146146
public Extraction.Entities.Location Location => Context.CreateLocation(ReportingLocation);
147-
148-
protected void PopulateMetadataHandle(TextWriter trapFile)
149-
{
150-
var handle = MetadataHandle;
151-
152-
if (handle.HasValue)
153-
trapFile.metadata_handle(this, Location, MetadataTokens.GetToken(handle.Value));
154-
}
155-
156-
private static System.Reflection.PropertyInfo? GetPropertyInfo(object o, string name)
157-
{
158-
return o.GetType().GetProperty(name, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty);
159-
}
160-
161-
public Handle? MetadataHandle
162-
{
163-
get
164-
{
165-
var handleProp = GetPropertyInfo(Symbol, "Handle");
166-
object handleObj = Symbol;
167-
168-
if (handleProp is null)
169-
{
170-
var underlyingSymbolProp = GetPropertyInfo(Symbol, "UnderlyingSymbol");
171-
if (underlyingSymbolProp?.GetValue(Symbol) is object underlying)
172-
{
173-
handleProp = GetPropertyInfo(underlying, "Handle");
174-
handleObj = underlying;
175-
}
176-
}
177-
178-
if (handleProp is not null)
179-
{
180-
switch (handleProp.GetValue(handleObj))
181-
{
182-
case MethodDefinitionHandle md: return md;
183-
case TypeDefinitionHandle td: return td;
184-
case PropertyDefinitionHandle pd: return pd;
185-
case FieldDefinitionHandle fd: return fd;
186-
}
187-
}
188-
189-
return null;
190-
}
191-
}
192147
}
193148
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Field.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ private Field(Context cx, IFieldSymbol init)
2626

2727
public override void Populate(TextWriter trapFile)
2828
{
29-
PopulateMetadataHandle(trapFile);
3029
PopulateAttributes();
3130
ContainingType!.PopulateGenerics();
3231
PopulateNullability(trapFile, Symbol.GetAnnotatedType());

csharp/extractor/Semmle.Extraction.CSharp/Entities/Method.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ protected void PopulateMethod(TextWriter trapFile)
360360
PopulateParameters();
361361
PopulateMethodBody(trapFile);
362362
PopulateGenerics(trapFile);
363-
PopulateMetadataHandle(trapFile);
364363
PopulateNullability(trapFile, Symbol.GetAnnotatedReturnType());
365364
}
366365

csharp/extractor/Semmle.Extraction.CSharp/Entities/Property.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public override void WriteId(EscapingTextWriter trapFile)
3434

3535
public override void Populate(TextWriter trapFile)
3636
{
37-
PopulateMetadataHandle(trapFile);
3837
PopulateAttributes();
3938
PopulateModifiers(trapFile);
4039
BindComments();

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/Type.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public Kinds.TypeKind GetTypeKind(Context cx, bool constructUnderlyingTupleType)
7777

7878
protected void PopulateType(TextWriter trapFile, bool constructUnderlyingTupleType = false)
7979
{
80-
PopulateMetadataHandle(trapFile);
8180
PopulateAttributes();
8281

8382
trapFile.Write("types(");

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ internal static void localvar_location(this TextWriter trapFile, LocalVariable v
233233
internal static void localvars(this TextWriter trapFile, LocalVariable key, VariableKind kind, string name, int @var, Type type, Expression expr) =>
234234
trapFile.WriteTuple("localvars", key, (int)kind, name, @var, type, expr);
235235

236-
public static void metadata_handle(this TextWriter trapFile, IEntity entity, Location assembly, int handleValue) =>
237-
trapFile.WriteTuple("metadata_handle", entity, assembly, handleValue);
238-
239236
internal static void method_location(this TextWriter trapFile, Method method, Location location) =>
240237
trapFile.WriteTuple("method_location", method, location);
241238

0 commit comments

Comments
 (0)