Share entity base classes between CIL and source extraction

This commit is contained in:
Tamas Vajk
2021-02-11 13:52:38 +01:00
parent e7853cc3a0
commit 67289a498f
106 changed files with 705 additions and 710 deletions

View File

@@ -0,0 +1,38 @@
using System.IO;
namespace Semmle.Extraction
{
/// <summary>
/// An entity which has a default "*" ID assigned to it.
/// </summary>
public abstract class FreshEntity : UnlabelledEntity
{
protected FreshEntity(Context cx) : base(cx)
{
}
protected abstract void Populate(TextWriter trapFile);
protected void TryPopulate()
{
Context.Try(null, null, () => Populate(Context.TrapWriter.Writer));
}
/// <summary>
/// For debugging.
/// </summary>
public string DebugContents
{
get
{
using var writer = new StringWriter();
Populate(writer);
return writer.ToString();
}
}
public override Microsoft.CodeAnalysis.Location? ReportingLocation => null;
public override TrapStackBehaviour TrapStackBehaviour { get; }
}
}