private async ValueTask <HostCompilationStartAnalysisScope> GetCompilationAnalysisScopeCoreAsync( HostSessionStartAnalysisScope sessionScope, AnalyzerExecutor analyzerExecutor, AnalyzerExecutionContext analyzerExecutionContext ) { try { return(await analyzerExecutionContext .GetCompilationAnalysisScopeAsync(sessionScope, analyzerExecutor) .ConfigureAwait(false)); } catch (OperationCanceledException) { // Task to compute the scope was cancelled. // Clear the compilation scope for analyzer, so we can attempt a retry. analyzerExecutionContext.ClearCompilationScopeTask(); analyzerExecutor.CancellationToken.ThrowIfCancellationRequested(); return(await GetCompilationAnalysisScopeCoreAsync( sessionScope, analyzerExecutor, analyzerExecutionContext ) .ConfigureAwait(false)); } }
private async Task <HostSymbolStartAnalysisScope> GetSymbolAnalysisScopeCoreAsync( ISymbol symbol, ImmutableArray <SymbolStartAnalyzerAction> symbolStartActions, AnalyzerExecutor analyzerExecutor, AnalyzerExecutionContext analyzerExecutionContext ) { try { return(await analyzerExecutionContext .GetSymbolAnalysisScopeAsync(symbol, symbolStartActions, analyzerExecutor) .ConfigureAwait(false)); } catch (OperationCanceledException) { // Task to compute the scope was cancelled. // Clear the symbol scope for analyzer, so we can attempt a retry. analyzerExecutionContext.ClearSymbolScopeTask(symbol); analyzerExecutor.CancellationToken.ThrowIfCancellationRequested(); return(await GetSymbolAnalysisScopeCoreAsync( symbol, symbolStartActions, analyzerExecutor, analyzerExecutionContext ) .ConfigureAwait(false)); } }
/// <summary> /// Return <see cref="DiagnosticAnalyzer.SupportedDiagnostics"/> of given <paramref name="analyzer"/>. /// </summary> public ImmutableArray <DiagnosticDescriptor> GetSupportedDiagnosticDescriptors( DiagnosticAnalyzer analyzer, AnalyzerExecutor analyzerExecutor) { AnalyzerExecutionContext analyzerExecutionContext = _analyzerExecutionContextMap.GetOrCreateValue(analyzer); return(analyzerExecutionContext.GetOrComputeDescriptors(analyzer, analyzerExecutor)); }
private async Task <HostSessionStartAnalysisScope> GetSessionAnalysisScopeAsync( DiagnosticAnalyzer analyzer, AnalyzerExecutor analyzerExecutor) { AnalyzerExecutionContext analyzerExecutionContext = _analyzerExecutionContextMap.GetOrCreateValue(analyzer); return(await GetSessionAnalysisScopeCoreAsync(analyzer, analyzerExecutor, analyzerExecutionContext).ConfigureAwait(false)); }
static Task <HostSessionStartAnalysisScope> getSessionAnalysisScopeTaskSlow( AnalyzerExecutionContext context, AnalyzerExecutor executor ) { return(Task.Run( () => { var sessionScope = new HostSessionStartAnalysisScope(); executor.ExecuteInitializeMethod(context._analyzer, sessionScope); return sessionScope; }, executor.CancellationToken )); }
private async Task<HostCompilationStartAnalysisScope> GetCompilationAnalysisScopeCoreAsync( HostSessionStartAnalysisScope sessionScope, AnalyzerExecutor analyzerExecutor, AnalyzerExecutionContext analyzerExecutionContext) { try { return await analyzerExecutionContext.GetCompilationAnalysisScopeAsync(sessionScope, analyzerExecutor).ConfigureAwait(false); } catch (OperationCanceledException) { // Task to compute the scope was cancelled. // Clear the entry in scope map for analyzer, so we can attempt a retry. analyzerExecutionContext.ClearCompilationScopeMap(analyzerExecutor.AnalyzerOptions, analyzerExecutor.Compilation); analyzerExecutor.CancellationToken.ThrowIfCancellationRequested(); return await GetCompilationAnalysisScopeCoreAsync(sessionScope, analyzerExecutor, analyzerExecutionContext).ConfigureAwait(false); } }
private async ValueTask<HostSessionStartAnalysisScope> GetSessionAnalysisScopeCoreAsync( AnalyzerExecutor analyzerExecutor, AnalyzerExecutionContext analyzerExecutionContext) { try { var task = analyzerExecutionContext.GetSessionAnalysisScopeAsync(analyzerExecutor); return await task.ConfigureAwait(false); } catch (OperationCanceledException) { // Task to compute the scope was cancelled. // Clear the entry in scope map for analyzer, so we can attempt a retry. analyzerExecutionContext.ClearSessionScopeTask(); analyzerExecutor.CancellationToken.ThrowIfCancellationRequested(); return await GetSessionAnalysisScopeCoreAsync(analyzerExecutor, analyzerExecutionContext).ConfigureAwait(false); } }
public override Container VisitContainerBefore(Container container, AnalyzerExecutionContext executionContext) { string filePath = GetFileLocation(container); if (File.Exists(filePath)) { JObject meta = null; using (StreamReader reader = File.OpenText(filePath)) { meta = (JObject)JObject.ReadFrom(new JsonTextReader(reader)); } _meta.Add(container.Id, meta); } _container = container; return container; }
public override Photo VisitPhoto(Photo photo, AnalyzerExecutionContext executionContext) { if (photo.Tag(Constants.Namespace, Constants.HashMetadataKey) == null) { var streamFeature = Source.Feature<IPhotoStreamFeature>(); string value = null; using (var photoStream = streamFeature.GetStream(photo)) { value = CreateImageHash(photoStream); } var tag = new Tag(Constants.Namespace, Constants.HashMetadataKey, value); photo = photo.WithTag(tag); } return photo; }
private async Task<HostSessionStartAnalysisScope> GetSessionAnalysisScopeCoreAsync( DiagnosticAnalyzer analyzer, AnalyzerExecutor analyzerExecutor, AnalyzerExecutionContext analyzerExecutionContext) { try { var task = analyzerExecutionContext.GetSessionAnalysisScopeTask(analyzer, analyzerExecutor); return await task.ConfigureAwait(false); } catch (OperationCanceledException) { // Task to compute the scope was cancelled. // Clear the entry in scope map for analyzer, so we can attempt a retry. analyzerExecutionContext.ClearSessionScopeTask(); analyzerExecutor.CancellationToken.ThrowIfCancellationRequested(); return await GetSessionAnalysisScopeCoreAsync(analyzer, analyzerExecutor, analyzerExecutionContext).ConfigureAwait(false); } }
public override Container VisitContainerAfter(Container container, AnalyzerExecutionContext executionContext) { string filePath = GetFileLocation(container); var containerPath = container.Id + Path.DirectorySeparatorChar; var metaDataProperties = container.PhotoSets.Select(x => x.Photos).SelectMany(pl => pl) .Select(p => new JProperty(MakeRelativePath(containerPath, p.Id), p.Tags .Select(t => new JObject( new JProperty("ns", t.Namespace), new JProperty("name", t.Name), new JProperty("value", t.Value) )))); var result = new JObject(metaDataProperties); File.WriteAllText(filePath, result.ToString()); return container; }
internal virtual AnalyzerExecutionResult RunAnalyzer(AnalyzerExecutionContext executionContext, ProcessContext processContext) { return(Execute(executionContext)); }
/// <summary> /// Called by the platform to execute the Analyzer. /// </summary> /// <param name="executionContext">The context associated with this execution of the Analyzer.</param> /// <returns>The result of the execution.</returns> protected abstract AnalyzerExecutionResult Execute(AnalyzerExecutionContext executionContext);
internal ProcessContext(AnalyzerExecutionContext executionContext, Process process) { _executionContext = executionContext; Process = process; }
/// <summary> /// Called before a photo set's content is iterated. /// </summary> /// <param name="photoSet"></param> /// <param name="executionContext"></param> /// <returns></returns> public virtual PhotoSet VisitPhotoSetBefore(PhotoSet photoSet, AnalyzerExecutionContext executionContext) { return photoSet; }
/// <summary> /// Called when a photo is iterated. /// </summary> /// <param name="photo"></param> /// <param name="executionContext"></param> /// <returns></returns> public virtual Photo VisitPhoto(Photo photo, AnalyzerExecutionContext executionContext) { return photo; }
/// <summary> /// Called before a container's content is iterated. /// </summary> /// <param name="container"></param> /// <param name="executionContext"></param> /// <returns></returns> public virtual Container VisitContainerBefore(Container container, AnalyzerExecutionContext executionContext) { return container; }
public override Photo VisitPhoto(Photo photo, AnalyzerExecutionContext executionContext) { var key = MakeRelativePath(_container.Id + Path.DirectorySeparatorChar, photo.Id); var containerJson = _meta.Where(x => _container.Id.StartsWith(x.Key)).Select(x => x.Value).FirstOrDefault(); if (containerJson != null) { var photoJson = containerJson[key]; if (photoJson != null) { var tags = photoJson.Select(tagJson => new Tag(tagJson["ns"].ToString(), tagJson["name"].ToString(), tagJson["value"].ToString())); foreach (var tag in tags) { photo = photo.WithTag(tag); } } } return photo; }