Пример #1
0
        protected override async Task <UpgradeStepInitializeResult> InitializeImplAsync(IUpgradeContext context, CancellationToken token)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var project = context.CurrentProject.Required();

            var configPaths = _configFilePaths.Select(p => Path.Combine(project.FileInfo.DirectoryName, p)).Where(p => File.Exists(p));

            Logger.LogDebug("Loading config files: {ConfigFiles}", string.Join(", ", configPaths));
            ConfigFiles = ImmutableArray.CreateRange(configPaths.Select(p => new ConfigFile(p)));
            Logger.LogDebug("Loaded {ConfigCount} config files", ConfigFiles.Length);

            await FilterSubStepsByIsApplicableAsync(context, token).ConfigureAwait(false);

            foreach (var step in SubSteps)
            {
                await step.InitializeAsync(context, token).ConfigureAwait(false);
            }

            var incompleteSubSteps = SubSteps.Count(s => !s.IsDone);

            return(incompleteSubSteps == 0
                ? new UpgradeStepInitializeResult(UpgradeStepStatus.Complete, "No config updaters need applied", BuildBreakRisk.None)
                : new UpgradeStepInitializeResult(UpgradeStepStatus.Incomplete, $"{incompleteSubSteps} config updaters need applied", SubSteps.Where(s => !s.IsDone).Max(s => s.Risk)));
        }
Пример #2
0
        protected override async Task <UpgradeStepInitializeResult> InitializeImplAsync(IUpgradeContext context, CancellationToken token)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _razorEngine = RazorProjectEngine.Create(RazorConfiguration.Default, GetRazorFileSystem(context.CurrentProject.Required()), builder =>
            {
                // Add useful "MVC View-isms" like _ViewImports support, page models, etc.
                // https://github.com/dotnet/aspnetcore/blob/main/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/RazorExtensions.cs
                RazorExtensions.Register(builder);
            });

            // Process all Razor documents initially
            // SubSteps can call ProcessRazorDocuments with specific files that have changed later to re-process specific documents
            ProcessRazorDocuments(null);

            foreach (var step in SubSteps)
            {
                await step.InitializeAsync(context, token).ConfigureAwait(false);
            }

            var incompleteSubSteps = SubSteps.Count(s => !s.IsDone);

            return(incompleteSubSteps == 0
                ? new UpgradeStepInitializeResult(UpgradeStepStatus.Complete, "No Razor updaters need applied", BuildBreakRisk.None)
                : new UpgradeStepInitializeResult(UpgradeStepStatus.Incomplete, $"{incompleteSubSteps} Razor updaters need applied", SubSteps.Where(s => !s.IsDone).Max(s => s.Risk)));
        }
Пример #3
0
        protected override Task <UpgradeStepApplyResult> ApplyImplAsync(IUpgradeContext context, CancellationToken token)
        {
            // Updates are made in sub-steps, so no changes need made in this apply step.
            // Just check that sub-steps executed correctly.
            var incompleteSubSteps = SubSteps.Count(s => !s.IsDone);

            return(incompleteSubSteps == 0
                ? Task.FromResult(new UpgradeStepApplyResult(UpgradeStepStatus.Complete, string.Empty))
                : Task.FromResult(new UpgradeStepApplyResult(UpgradeStepStatus.Incomplete, $"{incompleteSubSteps} VB updaters need applied")));
        }
Пример #4
0
        protected override Task <UpgradeStepApplyResult> ApplyImplAsync(IUpgradeContext context, CancellationToken token)
        {
            // Nothing needs applied here because the actual upgrade changes are applied by the substeps
            // (which should apply before this step).
            var incompleteSubSteps = SubSteps.Count(s => !s.IsDone);

            return(Task.FromResult(incompleteSubSteps == 0
                ? new UpgradeStepApplyResult(UpgradeStepStatus.Complete, string.Empty)
                : new UpgradeStepApplyResult(UpgradeStepStatus.Incomplete, $"{incompleteSubSteps} config updaters need applied")));
        }
        protected override Task <UpgradeStepApplyResult> ApplyImplAsync(IUpgradeContext context, CancellationToken token)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var incompleteSubSteps = SubSteps.Count(s => !s.IsDone);

            return(incompleteSubSteps == 0
                ? Task.FromResult(new UpgradeStepApplyResult(UpgradeStepStatus.Complete, string.Empty))
                : Task.FromResult(new UpgradeStepApplyResult(UpgradeStepStatus.Incomplete, $"{incompleteSubSteps} Winforms updaters need applied")));
        }
Пример #6
0
        protected override async Task <UpgradeStepInitializeResult> InitializeImplAsync(IUpgradeContext context, CancellationToken token)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            foreach (var step in SubSteps)
            {
                await step.InitializeAsync(context, token).ConfigureAwait(false);
            }

            var incompleteSubSteps = SubSteps.Count(s => !s.IsDone);

            return(incompleteSubSteps == 0
                ? new UpgradeStepInitializeResult(UpgradeStepStatus.Complete, "No VB updaters need applied", BuildBreakRisk.None)
                : new UpgradeStepInitializeResult(UpgradeStepStatus.Incomplete, $"{incompleteSubSteps} VB updaters need applied", SubSteps.Where(s => !s.IsDone).Max(s => s.Risk)));
        }