C#: Address review comments. Tidy up tuple generation, consolidating code and use run-time type information instead of FirstParam/NextParam.

This commit is contained in:
Calum Grant
2019-08-28 12:21:27 +01:00
parent 40f56ff4b3
commit 7df90f13ed
10 changed files with 159 additions and 327 deletions

View File

@@ -247,7 +247,7 @@ namespace Semmle.Extraction.CIL.Entities
}
}
public bool TryGetPrimitiveTypeCode(out PrimitiveTypeCode code)
private bool TryGetPrimitiveTypeCode(out PrimitiveTypeCode code)
{
if (ContainingType == null && Namespace.Name == cx.SystemNamespace.Name)
{
@@ -314,7 +314,7 @@ namespace Semmle.Extraction.CIL.Entities
return false;
}
public bool IsPrimitiveType => TryGetPrimitiveTypeCode(out _);
protected bool IsPrimitiveType => TryGetPrimitiveTypeCode(out _);
public static Type DecodeType(GenericContext gc, TypeSpecificationHandle handle) =>
gc.cx.mdReader.GetTypeSpecification(handle).DecodeSignature(gc.cx.TypeSignatureDecoder, gc);

View File

@@ -15,7 +15,7 @@ namespace Semmle.Extraction.CIL
public T Populate<T>(T e) where T : IExtractedEntity
{
if(e.Label.Valid)
if (e.Label.Valid)
{
return e; // Already populated
}
@@ -72,7 +72,7 @@ namespace Semmle.Extraction.CIL
{
PrimitiveType e = primitiveTypes[(int)code];
if(e is null)
if (e is null)
{
e = new PrimitiveType(this, code);
e.Label = cx.GetNewLabel();
@@ -157,7 +157,7 @@ namespace Semmle.Extraction.CIL
/// <returns>The string.</returns>
public string GetString(StringHandle h) => mdReader.GetString(h);
#region Namespaces
#region Namespaces
readonly CachedFunction<StringHandle, Namespace> namespaceFactory;
@@ -197,9 +197,9 @@ namespace Semmle.Extraction.CIL
NamespaceDefinition nd = mdReader.GetNamespaceDefinition(handle);
return Populate(new Namespace(this, GetString(nd.Name), Create(nd.Parent)));
}
#endregion
#endregion
#region Locations
#region Locations
readonly CachedFunction<PDB.ISourceFile, PdbSourceFile> sourceFiles;
readonly CachedFunction<string, Folder> folders;
readonly CachedFunction<PDB.Location, PdbSourceLocation> sourceLocations;
@@ -225,7 +225,7 @@ namespace Semmle.Extraction.CIL
/// <returns>A source location entity.</returns>
public PdbSourceLocation CreateSourceLocation(PDB.Location loc) => sourceLocations[loc];
#endregion
#endregion
readonly CachedFunction<GenericContext, Handle, IExtractedEntity> genericHandleFactory;