Beispiel #1
0
        private static int ProcessArgs(ParseResult result)
        {
            result.ShowHelpOrErrorIfAppropriate();

            var command       = result.AppliedCommand();
            var globalOptions = result["dotnet-migrate-2019"];

            ProgramBase.ApplyVerbosity(result, globalOptions);

            Log.Verbose(result.Diagram());

            var items = command.Value <string[]>();

            var conversionOptions = new ConversionOptions
            {
                ProjectCache = new DefaultProjectCache(),
                ForceOnUnsupportedProjects = command.ValueOrDefault <bool>("force"),
                KeepAssemblyInfo           = command.ValueOrDefault <bool>("keep-assembly-info")
            };

            switch (command.Name)
            {
            case "evaluate":
            case "migrate":
                var frameworks = command.ValueOrDefault <string[]>("target-frameworks");
                if (frameworks != null)
                {
                    conversionOptions.TargetFrameworks = frameworks;
                }
                break;
            }

            var logic = new CommandLogic();

            switch (command.Name)
            {
            case "wizard":
                var diagnostics = new DiagnosticSet(Vs16DiagnosticSet.All);
                diagnostics.ExceptWith(DiagnosticSet.All);
                var sets = new WizardTransformationSets
                {
                    MigrateSet = new ChainTransformationSet(
                        new BasicSimplifyTransformationSet(Vs16TransformationSet.TargetVisualStudioVersion),
                        Vs16TransformationSet.TrueInstance),
                    ModernCleanUpSet = new BasicSimplifyTransformationSet(
                        Vs16TransformationSet.TargetVisualStudioVersion),
                    ModernizeSet = new ChainTransformationSet(
                        new BasicSimplifyTransformationSet(Vs16TransformationSet.TargetVisualStudioVersion),
                        Vs16ModernizationTransformationSet.TrueInstance),
                    Diagnostics = diagnostics
                };

                logic.ExecuteWizard(items, conversionOptions, sets);
                break;

            case "evaluate":
                logic.ExecuteEvaluate(items, conversionOptions, Vs16TransformationSet.Instance, new AnalysisOptions(Vs16DiagnosticSet.All));
                break;

            case "analyze":
                logic.ExecuteAnalyze(items, conversionOptions, new AnalysisOptions(Vs16DiagnosticSet.All));
                break;

            case "migrate":
                conversionOptions.AppendTargetFrameworkToOutputPath = !command.ValueOrDefault <bool>("old-output-path");

                var forceTransformations = command.ValueOrDefault <string[]>("force-transformations");
                if (forceTransformations != null)
                {
                    conversionOptions.ForceDefaultTransforms = forceTransformations;
                }

                logic.ExecuteMigrate(items, command.ValueOrDefault <bool>("no-backup"), conversionOptions, Vs16TransformationSet.Instance);
                break;
            }

            return(result.Execute().Code);
        }