示例#1
0
 /// <summary>
 /// Create a new context, one per source file/assembly.
 /// </summary>
 /// <param name="e">The extractor.</param>
 /// <param name="c">The Roslyn compilation.</param>
 /// <param name="extractedEntity">Name of the source/dll file.</param>
 /// <param name="scope">Defines which symbols are included in the trap file (e.g. AssemblyScope or SourceScope)</param>
 public Context(IExtractor e, Compilation c, TrapWriter trapWriter, IExtractionScope scope)
 {
     Extractor   = e;
     Compilation = c;
     Scope       = scope;
     TrapWriter  = trapWriter;
 }
示例#2
0
 public Context(Extractor e, Compilation c, TrapWriter trapWriter, IExtractionScope scope, bool addAssemblyTrapPrefix)
 {
     Extractor   = e;
     Compilation = c;
     this.scope  = scope;
     TrapWriter  = trapWriter;
     ShouldAddAssemblyTrapPrefix = addAssemblyTrapPrefix;
 }
示例#3
0
 /// <summary>
 /// Runs the given action <paramref name="a"/>, guarding for trap duplication
 /// based on key <paramref name="key"/>.
 /// </summary>
 public virtual void WithDuplicationGuard(Key key, Action a)
 {
     tagStack.Push(key);
     TrapWriter.Emit(new PushEmitter(key));
     try
     {
         a();
     }
     finally
     {
         TrapWriter.Emit(new PopEmitter());
         tagStack.Pop();
     }
 }
示例#4
0
 /// <summary>
 /// Runs the given action <paramref name="a"/>, guarding for trap duplication
 /// based on key <paramref name="key"/>.
 /// </summary>
 public void WithDuplicationGuard(Key key, Action a)
 {
     if (scope is AssemblyScope)
     {
         // No need for a duplication guard when extracting assemblies,
         // and the duplication guard could lead to method bodies being missed
         // depending on trap import order.
         a();
     }
     else
     {
         tagStack.Push(key);
         TrapWriter.Emit(new PushEmitter(key));
         try
         {
             a();
         }
         finally
         {
             TrapWriter.Emit(new PopEmitter());
             tagStack.Pop();
         }
     }
 }
示例#5
0
 protected Context(Extractor extractor, TrapWriter trapWriter, bool shouldAddAssemblyTrapPrefix = false)
 {
     Extractor  = extractor;
     TrapWriter = trapWriter;
     ShouldAddAssemblyTrapPrefix = shouldAddAssemblyTrapPrefix;
 }
示例#6
0
 public Context CreateContext(Compilation c, TrapWriter trapWriter, IExtractionScope scope)
 {
     return(new Context(this, c, trapWriter, scope));
 }
示例#7
0
文件: Layout.cs 项目: lcartey/codeql
 /// <summary>
 /// Gets the name of the trap file for a given source/assembly file.
 /// </summary>
 /// <param name="srcFile">The source file.</param>
 /// <returns>The full filepath of the trap file.</returns>
 public string GetTrapPath(ILogger logger, string srcFile) => TrapWriter.TrapPath(logger, TRAP_FOLDER, srcFile);
示例#8
0
 /// <summary>
 /// Gets the name of the trap file for this file.
 /// </summary>
 /// <returns>The full filepath of the trap file.</returns>
 public string GetTrapPath(ILogger logger, TrapWriter.CompressionMode trapCompression) =>
 TrapWriter.TrapPath(logger, Environment.GetEnvironmentVariable("CODEQL_EXTRACTOR_CSHARP_TRAP_DIR"), this, trapCompression);
示例#9
0
 public Context(Extractor e, TrapWriter trapWriter)
     : this(e, null, trapWriter, null, false)
 {
 }
示例#10
0
 /// <summary>
 /// Gets the name of the trap file for a given source/assembly file.
 /// </summary>
 /// <param name="srcFile">The source file.</param>
 /// <returns>The full filepath of the trap file.</returns>
 public string GetTrapPath(ILogger logger, string srcFile, TrapWriter.CompressionMode trapCompression) => TrapWriter.TrapPath(logger, TRAP_FOLDER, srcFile, trapCompression);
示例#11
0
 public Context CreateContext(Compilation c, TrapWriter trapWriter, IExtractionScope scope, bool addAssemblyTrapPrefix)
 {
     return(new Context(this, c, trapWriter, scope, addAssemblyTrapPrefix));
 }
示例#12
0
 /// <summary>
 /// Gets the name of the trap file for a given source/assembly file.
 /// </summary>
 /// <param name="srcFile">The source file.</param>
 /// <returns>The full filepath of the trap file.</returns>
 public string GetTrapPath(ILogger logger, PathTransformer.ITransformedPath srcFile, TrapWriter.CompressionMode trapCompression) =>
 TrapWriter.TrapPath(logger, TRAP_FOLDER, srcFile, trapCompression);