mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
C#: Address review comments. Replace GetHashValue() with MetadataTokens.GetToken().
C#: Make path IDs consistent.
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
@@ -88,7 +89,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return Tuples.metadata_handle(this, cx.assembly, handle.GetHashCode());
|
||||
yield return Tuples.metadata_handle(this, cx.assembly, MetadataTokens.GetToken(handle));
|
||||
|
||||
foreach (var c in base.Contents)
|
||||
yield return c;
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
|
||||
public File(Context cx, string path) : base(cx)
|
||||
{
|
||||
this.path = path.Replace("\\", "/");
|
||||
ShortId = new StringId(path.Replace(":", "_"));
|
||||
this.path = path;
|
||||
ShortId = new StringId(Semmle.Extraction.Entities.File.PathAsDatabaseId(path));
|
||||
}
|
||||
|
||||
public override IEnumerable<IExtractionProduct> Contents
|
||||
@@ -27,7 +27,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
var parent = cx.CreateFolder(System.IO.Path.GetDirectoryName(path));
|
||||
yield return parent;
|
||||
yield return Tuples.containerparent(parent, this);
|
||||
yield return Tuples.files(this, path, System.IO.Path.GetFileNameWithoutExtension(path), System.IO.Path.GetExtension(path).Substring(1));
|
||||
yield return Tuples.files(this, Semmle.Extraction.Entities.File.PathAsDatabaseString(path), System.IO.Path.GetFileNameWithoutExtension(path), System.IO.Path.GetExtension(path).Substring(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
public Folder(Context cx, string path) : base(cx)
|
||||
{
|
||||
this.path = path;
|
||||
ShortId = new StringId(path.Replace("\\", "/").Replace(":", "_"));
|
||||
ShortId = new StringId(Semmle.Extraction.Entities.File.PathAsDatabaseId(path));
|
||||
}
|
||||
|
||||
static readonly Id suffix = new StringId(";folder");
|
||||
@@ -33,7 +33,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
yield return parentFolder;
|
||||
yield return Tuples.containerparent(parentFolder, this);
|
||||
}
|
||||
yield return Tuples.folders(this, path, Path.GetFileName(path));
|
||||
yield return Tuples.folders(this, Semmle.Extraction.Entities.File.PathAsDatabaseString(path), Path.GetFileName(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
@@ -207,7 +208,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
Attribute.Populate(cx, pe, p.GetCustomAttributes());
|
||||
}
|
||||
|
||||
yield return Tuples.metadata_handle(this, cx.assembly, handle.GetHashCode());
|
||||
yield return Tuples.metadata_handle(this, cx.assembly, MetadataTokens.GetToken(handle));
|
||||
yield return Tuples.cil_method(this, Name, declaringType, typeSignature.ReturnType);
|
||||
yield return Tuples.cil_method_source_declaration(this, this);
|
||||
yield return Tuples.cil_method_location(this, cx.assembly);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
@@ -37,7 +38,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return Tuples.metadata_handle(this, cx.assembly, handle.GetHashCode());
|
||||
yield return Tuples.metadata_handle(this, cx.assembly, MetadataTokens.GetToken(handle));
|
||||
var sig = pd.DecodeSignature(cx.TypeSignatureDecoder, type);
|
||||
|
||||
yield return Tuples.cil_property(this, type, cx.ShortName(pd.Name), sig.ReturnType);
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace Semmle.Extraction.CIL.Entities
|
||||
/// </summary>
|
||||
public sealed class TypeDefinitionType : Type
|
||||
{
|
||||
Handle handle;
|
||||
readonly Handle handle;
|
||||
readonly TypeDefinition td;
|
||||
|
||||
public TypeDefinitionType(Context cx, TypeDefinitionHandle handle) : base(cx)
|
||||
|
||||
Reference in New Issue
Block a user