mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Compare CIL entities directly by handle rather than by label.
C#: Remove IDs from the CIL extractor and make consistent with C# extractor. C#: Fix method collisions.
This commit is contained in:
@@ -332,7 +332,7 @@ namespace Semmle.Extraction.CommentProcessing
|
||||
|
||||
class CommentBlock : ICommentBlock
|
||||
{
|
||||
private List<ICommentLine> lines = new List<ICommentLine>();
|
||||
private readonly List<ICommentLine> lines = new List<ICommentLine>();
|
||||
|
||||
public IEnumerable<ICommentLine> CommentLines => lines;
|
||||
|
||||
|
||||
@@ -105,9 +105,11 @@ namespace Semmle.Extraction
|
||||
if (entity.NeedsPopulation)
|
||||
Populate(init as ISymbol, entity);
|
||||
#if DEBUG_LABELS
|
||||
var id = new StringWriter();
|
||||
entity.WriteId(id);
|
||||
CheckEntityHasUniqueLabel(id.ToString(), entity);
|
||||
using (var id = new StringWriter())
|
||||
{
|
||||
entity.WriteId(id);
|
||||
CheckEntityHasUniqueLabel(id.ToString(), entity);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -149,9 +151,11 @@ namespace Semmle.Extraction
|
||||
Populate(init as ISymbol, entity);
|
||||
|
||||
#if DEBUG_LABELS
|
||||
var id = new StringWriter();
|
||||
entity.WriteId(id);
|
||||
CheckEntityHasUniqueLabel(id.ToString(), entity);
|
||||
using (var id = new StringWriter())
|
||||
{
|
||||
entity.WriteId(id);
|
||||
CheckEntityHasUniqueLabel(id.ToString(), entity);
|
||||
}
|
||||
#endif
|
||||
|
||||
return entity;
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Semmle.Extraction.Entities
|
||||
public override void WriteId(System.IO.TextWriter trapFile)
|
||||
{
|
||||
trapFile.Write(assembly.ToString());
|
||||
if (assemblyPath is null)
|
||||
if (!(assemblyPath is null))
|
||||
{
|
||||
trapFile.Write("#file:///");
|
||||
trapFile.Write(assemblyPath.Replace("\\", "/"));
|
||||
|
||||
@@ -162,11 +162,13 @@ namespace Semmle.Extraction
|
||||
/// <returns>The debug string.</returns>
|
||||
public static string GetDebugLabel(this IEntity entity)
|
||||
{
|
||||
var writer = new StringWriter();
|
||||
writer.WriteLabel(entity.Label.Value);
|
||||
writer.Write('=');
|
||||
entity.WriteQuotedId(writer);
|
||||
return writer.ToString();
|
||||
using (var writer = new StringWriter())
|
||||
{
|
||||
writer.WriteLabel(entity.Label.Value);
|
||||
writer.Write('=');
|
||||
entity.WriteQuotedId(writer);
|
||||
return writer.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Semmle.Extraction
|
||||
|
||||
class IdTrapBuilder
|
||||
{
|
||||
readonly public List<string> Fragments = new List<string>();
|
||||
public readonly List<string> Fragments = new List<string>();
|
||||
|
||||
public void Append(object arg)
|
||||
{
|
||||
|
||||
@@ -90,6 +90,9 @@ namespace Semmle.Extraction
|
||||
CIL = !value;
|
||||
Fast = value;
|
||||
return true;
|
||||
case "brotli":
|
||||
TrapCompression = value ? TrapWriter.CompressionMode.Brotli : TrapWriter.CompressionMode.Gzip;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,11 @@ namespace Semmle.Extraction
|
||||
{
|
||||
get
|
||||
{
|
||||
var trap = new StringWriter();
|
||||
Populate(trap);
|
||||
return trap.ToString();
|
||||
using (var trap = new StringWriter())
|
||||
{
|
||||
Populate(trap);
|
||||
return trap.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,12 @@ namespace Semmle.Extraction
|
||||
return new NextParam(Writer);
|
||||
}
|
||||
|
||||
public NextParam Param(Label label)
|
||||
{
|
||||
Writer.WriteLabel(label.Value);
|
||||
return new NextParam(Writer);
|
||||
}
|
||||
|
||||
public void EndTuple()
|
||||
{
|
||||
Writer.WriteLine(')');
|
||||
|
||||
@@ -155,9 +155,11 @@ namespace Semmle.Extraction
|
||||
public override string ToString()
|
||||
{
|
||||
// Only implemented for debugging purposes
|
||||
var tsb = new StringWriter();
|
||||
EmitToTrapBuilder(tsb);
|
||||
return tsb.ToString();
|
||||
using (var writer = new StringWriter())
|
||||
{
|
||||
EmitToTrapBuilder(writer);
|
||||
return writer.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user