Skip to content

Commit 3e2a6fc

Browse files
committed
C#: Simplify CIL.GenericContext contract
1 parent 1c2b9f9 commit 3e2a6fc

2 files changed

Lines changed: 4 additions & 29 deletions

File tree

csharp/extractor/Semmle.Extraction.CIL/Entities/TypeSignatureDecoder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Reflection.Metadata;
33
using System.Collections.Immutable;
4+
using System.Linq;
45

56
namespace Semmle.Extraction.CIL.Entities
67
{
@@ -29,10 +30,10 @@ Type IConstructedTypeProvider<Type>.GetGenericInstantiation(Type genericType, Im
2930
genericType.Construct(typeArguments);
3031

3132
Type ISignatureTypeProvider<Type, GenericContext>.GetGenericMethodParameter(GenericContext genericContext, int index) =>
32-
genericContext.GetGenericMethodParameter(index);
33+
genericContext.MethodParameters.ElementAt(index);
3334

3435
Type ISignatureTypeProvider<Type, GenericContext>.GetGenericTypeParameter(GenericContext genericContext, int index) =>
35-
genericContext.GetGenericTypeParameter(index);
36+
genericContext.TypeParameters.ElementAt(index);
3637

3738
Type ISignatureTypeProvider<Type, GenericContext>.GetModifiedType(Type modifier, Type unmodifiedType, bool isRequired) =>
3839
new ModifiedType(cx, unmodifiedType, modifier, isRequired);

csharp/extractor/Semmle.Extraction.CIL/GenericContext.cs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,8 @@ protected GenericContext(Context cx)
2323
public abstract IEnumerable<Entities.Type> TypeParameters { get; }
2424

2525
/// <summary>
26-
/// The list of generic method parameters.
26+
/// The list of generic method parameters/arguments.
2727
/// </summary>
2828
public abstract IEnumerable<Entities.Type> MethodParameters { get; }
29-
30-
/// <summary>
31-
/// Gets the `p`th type parameter.
32-
/// </summary>
33-
/// <param name="p">The index of the parameter.</param>
34-
/// <returns>
35-
/// For constructed types, the supplied type.
36-
/// For unbound types, the type parameter.
37-
/// </returns>
38-
public Entities.Type GetGenericTypeParameter(int p)
39-
{
40-
return TypeParameters.ElementAt(p);
41-
}
42-
43-
/// <summary>
44-
/// Gets the `p`th method type parameter.
45-
/// </summary>
46-
/// <param name="p">The index of the parameter.</param>
47-
/// <returns>
48-
/// For constructed types, the supplied type.
49-
/// For unbound types, the type parameter.
50-
/// </returns>
51-
public Entities.Type GetGenericMethodParameter(int p)
52-
{
53-
return MethodParameters.ElementAt(p);
54-
}
5529
}
5630
}

0 commit comments

Comments
 (0)