/// <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; }
public Context(Extractor e, Compilation c, TrapWriter trapWriter, IExtractionScope scope, bool addAssemblyTrapPrefix) { Extractor = e; Compilation = c; this.scope = scope; TrapWriter = trapWriter; ShouldAddAssemblyTrapPrefix = addAssemblyTrapPrefix; }
/// <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(); } }
/// <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(); } } }
protected Context(Extractor extractor, TrapWriter trapWriter, bool shouldAddAssemblyTrapPrefix = false) { Extractor = extractor; TrapWriter = trapWriter; ShouldAddAssemblyTrapPrefix = shouldAddAssemblyTrapPrefix; }
public Context CreateContext(Compilation c, TrapWriter trapWriter, IExtractionScope scope) { return(new Context(this, c, trapWriter, scope)); }
/// <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);
/// <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);
public Context(Extractor e, TrapWriter trapWriter) : this(e, null, trapWriter, null, false) { }
/// <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);
public Context CreateContext(Compilation c, TrapWriter trapWriter, IExtractionScope scope, bool addAssemblyTrapPrefix) { return(new Context(this, c, trapWriter, scope, addAssemblyTrapPrefix)); }
/// <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);