예제 #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);