Пример #1
0
            public override Task EndBuildAsync(PluginLoggerBase logger, CancellationToken cancellationToken)
            {
                logger.LogMessage("MockCache: EndBuildAsync", MessageImportance.High);

                EndBuildCalled = true;

                return(Task.CompletedTask);
            }
Пример #2
0
        public override Task EndBuildAsync(PluginLoggerBase logger, CancellationToken cancellationToken)
        {
            logger.LogMessage($"{nameof(AssemblyMockCache)}: EndBuildAsync", MessageImportance.High);

            ErrorFrom(nameof(EndBuildAsync), logger);

            return(Task.CompletedTask);
        }
Пример #3
0
        public override Task BeginBuildAsync(CacheContext context, PluginLoggerBase logger, CancellationToken cancellationToken)
        {
            logger.LogMessage($"{nameof(AssemblyMockCache)}: BeginBuildAsync", MessageImportance.High);

            ThrowFrom(nameof(BeginBuildAsync));

            return(Task.CompletedTask);
        }
Пример #4
0
        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)));
        }
Пример #5
0
            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)));
            }
Пример #6
0
        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;
            }
        }
Пример #7
0
        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;
            }
        }
Пример #8
0
        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);
        }