public override Task EndBuildAsync(PluginLoggerBase logger, CancellationToken cancellationToken) { logger.LogMessage("MockCache: EndBuildAsync", MessageImportance.High); EndBuildCalled = true; return(Task.CompletedTask); }
public override Task EndBuildAsync(PluginLoggerBase logger, CancellationToken cancellationToken) { logger.LogMessage($"{nameof(AssemblyMockCache)}: EndBuildAsync", MessageImportance.High); ErrorFrom(nameof(EndBuildAsync), logger); return(Task.CompletedTask); }
public override Task BeginBuildAsync(CacheContext context, PluginLoggerBase logger, CancellationToken cancellationToken) { logger.LogMessage($"{nameof(AssemblyMockCache)}: BeginBuildAsync", MessageImportance.High); ThrowFrom(nameof(BeginBuildAsync)); return(Task.CompletedTask); }
public override Task <CacheResult> GetCacheResultAsync( BuildRequestData buildRequest, PluginLoggerBase logger, CancellationToken cancellationToken) { logger.LogMessage($"{nameof(AssemblyMockCache)}: GetCacheResultAsync for {buildRequest.ProjectFullPath}", MessageImportance.High); ErrorFrom(nameof(GetCacheResultAsync), logger); return(Task.FromResult(CacheResult.IndicateNonCacheHit(CacheResultType.CacheNotApplicable))); }
public override Task <CacheResult> GetCacheResultAsync( BuildRequestData buildRequest, PluginLoggerBase logger, CancellationToken cancellationToken) { Requests.Enqueue(buildRequest); logger.LogMessage($"MockCache: GetCacheResultAsync for {buildRequest.ProjectFullPath}", MessageImportance.High); return (Task.FromResult( _testData?.GetExpectedCacheResultForProjectNumber(GetProjectNumber(buildRequest.ProjectFullPath)) ?? CacheResult.IndicateNonCacheHit(CacheResultType.CacheMiss))); }
private static void ErrorFrom(string errorLocation, PluginLoggerBase pluginLoggerBase) { var errorKind = Environment.GetEnvironmentVariable(errorLocation); switch (errorKind) { case "Exception": throw new Exception($"Cache plugin exception from {errorLocation}"); case "LoggedError": pluginLoggerBase?.LogError($"Cache plugin logged error from {errorLocation}"); break; } }
private static void ErrorFrom(string errorLocation, PluginLoggerBase pluginLoggerBase) { var errorKind = Environment.GetEnvironmentVariable(errorLocation); switch (errorKind) { case "Exception": pluginLoggerBase?.LogMessage($"{errorLocation} is going to throw an exception", MessageImportance.High); throw new Exception($"Cache plugin exception from {errorLocation}"); case "LoggedError": pluginLoggerBase?.LogError($"Cache plugin logged error from {errorLocation}"); break; } }
public override Task BeginBuildAsync(CacheContext context, PluginLoggerBase logger, CancellationToken cancellationToken) { logger.LogMessage($"{nameof(AssemblyMockCache)}: BeginBuildAsync", MessageImportance.High); foreach (var ep in context.GraphEntryPoints ?? Enumerable.Empty <ProjectGraphEntryPoint>()) { var globalPropertyString = ep.GlobalProperties is not null ? string.Join("\n\t", ep.GlobalProperties.Select(gp => $"{gp.Key}:{gp.Value}")) : string.Empty; logger.LogMessage($"EntryPoint: {ep.ProjectFile} \n(\n\t{globalPropertyString}\n)"); } ErrorFrom(nameof(BeginBuildAsync), logger); return(Task.CompletedTask); }