Ejemplo n.º 1
0
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();

            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                new CreateSolutionFromFilterFileNoForm().Save(parsedArguments.FilterFile);
            }
        }
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();
            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                using (var form = new CreateFilterForm(parsedArguments.SolutionFile))
                {
                    form.ShowDialog();
                }
            }
        }
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();

            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                using (var form = new CreateFilterForm(parsedArguments.SolutionFile))
                {
                    form.ShowDialog();
                }
            }
        }
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();
            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                if (parsedArguments.Solutions.Length < 2)
                {
                    reporter.Handler("Two solution files should be provided, in order:\n   Old.sln\n   New.sln");
                }

                var oldSolution = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[0]), parsedArguments.IgnoreWarning);
                var newSolution = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[1]), parsedArguments.IgnoreWarning);
                var difference = newSolution.CompareTo(oldSolution)
                            ?? new NodeDifference(new ElementIdentifier("SolutionFile"), OperationOnParent.Modified, null);
                using (var form = new CompareSolutionsForm(difference))
                {
                    form.ShowDialog();
                }
            }
        }
Ejemplo n.º 5
0
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();

            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                if (parsedArguments.Solutions.Length < 2)
                {
                    reporter.Handler("Two solution files should be provided, in order:\n   Old.sln\n   New.sln");
                    return;
                }

                var oldSolution = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[0]), parsedArguments.IgnoreWarning);
                var newSolution = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[1]), parsedArguments.IgnoreWarning);
                var difference  = newSolution.CompareTo(oldSolution)
                                  ?? new NodeDifference(new ElementIdentifier("SolutionFile"), OperationOnParent.Modified, null);
                using (var form = new CompareSolutionsForm(difference))
                {
                    form.ShowDialog();
                }
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            //args = new string[] { "CompareSolutions", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Lors du Branch).sln", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Latest Branche WinFixFrs).sln" };
            //args = new string[] { "MergeSolutions", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Lors du Branch).sln", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Latest Branche WinFixFrs).sln", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Latest Main).sln", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\Results.sln" };
            //args = new string[] { "CreateFilterFileFromSolution", @"C:\DevCodePlex\SLNTools\Main\SLNTools.sln" };
            //args = new string[] { "OpenFilterFile", @"C:\DevCodePlex\SLNTools\Main\Test.slnfilter" };
            //args = new string[] { "/?" };
            //args = new string[] { "CreateFilterFileFromSolution", @"E:\SLNTools\SLNTools\Main\SLNTools.sln" };
            //args = new string[] { "MergeSolutions" };

            try
            {
                string[] commandName;
                string[] commandArguments;
                if (args.Length > 1)
                {
                    commandName = new string[1];
                    Array.ConstrainedCopy(args, 0, commandName, 0, 1);
                    commandArguments = new string[args.Length - 1];
                    Array.ConstrainedCopy(args, 1, commandArguments, 0, commandArguments.Length);
                }
                else
                {
                    commandName      = args;
                    commandArguments = new string[0];
                }

                var parsedArguments = new Arguments();

                var reporter = new MessageBoxErrorReporter
                {
                    CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType())
                };

                if (Parser.ParseArguments(commandName, parsedArguments, reporter.Handler))
                {
                    Command command;
                    switch (parsedArguments.Command)
                    {
                    case CommandList.CompareSolutions:
                        command = new CompareSolutionsCommand();
                        break;

                    case CommandList.MergeSolutions:
                        command = new MergeSolutionsCommand();
                        break;

                    case CommandList.CreateFilterFileFromSolution:
                        command = new CreateFilterFileFromSolutionCommand();
                        break;

                    case CommandList.OpenFilterFile:
                        command = new OpenFilterFileCommand();
                        break;

                    case CommandList.EditFilterFile:
                        command = new EditFilterFileCommand();
                        break;

                    case CommandList.CreateSolutionFromFilterFile:
                        command = new CreateSolutionFromFilterFileCommand();
                        break;

                    default:
                        command = null;
                        reporter.Handler("Invalid command name.");
                        break;
                    }

                    if (command != null)
                    {
                        reporter.CommandName = parsedArguments.Command.ToString();
                        command.Run(commandArguments, reporter);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 7
0
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();

            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                var filterFile = FilterFile.FromFile(parsedArguments.FilterFile);

                // Save the filtered solution. We also add a link to the original solution file in the filtered solution.
                // If we have to checkout the original solution file later on, its easier with that link.
                var filteredSolution = filterFile.Apply();

                // Add OriginalSolutionFile to the filter solution (and a warnings file if needed)
                filteredSolution.Projects.Add(CreateOriginalSolutionProject(filterFile.SourceSolution));

                filteredSolution.Save();
                if (filterFile.CopyReSharperFiles)
                {
                    var resharperGlobalFileSettingsSource = filterFile.SourceSolutionFullPath + ".DotSettings";
                    if (File.Exists(resharperGlobalFileSettingsSource))
                    {
                        File.Copy(resharperGlobalFileSettingsSource, filteredSolution.SolutionFullPath + ".DotSettings", true);
                    }

                    var resharperUserFileSettingsSource      = filterFile.SourceSolutionFullPath + ".DotSettings.user";
                    var resharperUserFileSettingsDestination = filteredSolution.SolutionFullPath + ".DotSettings.user";
                    if (File.Exists(resharperUserFileSettingsSource) && !File.Exists(resharperUserFileSettingsDestination))
                    {
                        File.Copy(resharperUserFileSettingsSource, resharperUserFileSettingsDestination);
                    }
                }

                if (!parsedArguments.CreateOnly)
                {
                    filterFile.StartFilteredSolutionWatcher(
                        filteredSolution,
                        delegate(NodeDifference difference)
                    {
                        using (var fix = new TopMostFormFix())
                        {
                            using (var form = new UpdateOriginalSolutionForm(difference, filterFile.SourceSolutionFullPath))
                            {
                                return(form.ShowDialog() == DialogResult.Yes);
                            }
                        }
                    });

                    var startTime = DateTime.Now;
                    var process   = Process.Start(filteredSolution.SolutionFullPath);

                    if (parsedArguments.Wait || filterFile.WatchForChangesOnFilteredSolution)
                    {
                        process.WaitForExit();

                        // If the process exited "too fast", we wait on the processes that were spawned by the process
                        // we started. This allow us to handle the case where the '.sln' is associated to an application like
                        // "VSLauncher.exe". That type of application only live for a short period of time because it's job
                        // is to analyse the sln file, launch the right version of "devenv.exe" (i.e. VS2002, VS2005, VS2008)
                        // and then exit.
                        // This "trick" should not be needed with others IDE like SharpDevelop.
                        if (DateTime.Now - startTime < TimeSpan.FromMinutes(1))
                        {
                            foreach (var processSpawned in ProcessEx.GetChildsOfProcess(process))
                            {
                                processSpawned.WaitForExit();
                            }
                        }
                    }

                    filterFile.StopFilteredSolutionWatcher();
                }
            }
        }
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();
            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                if (parsedArguments.Solutions.Length < 4)
                {
                    reporter.Handler("Four solution files should be provided, in order:\n   SourceBranch.sln\n   DestinationBranch.sln\n   CommonAncestror.sln\n   Result.sln");
                }

                var solutionInSourceBranch = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[0]), parsedArguments.IgnoreWarning);
                var solutionInDestinationBranch = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[1]), parsedArguments.IgnoreWarning);
                var commonAncestrorSolution = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[2]), parsedArguments.IgnoreWarning);
                var mergedSolutionName = parsedArguments.Solutions[3];

                var elementInSourceBranch = solutionInSourceBranch.ToElement();
                var elementInDestinationBranch = solutionInDestinationBranch.ToElement();
                var commonAncestrorElement = commonAncestrorSolution.ToElement();

                NodeDifference differenceInSourceBranch;
                NodeDifference differenceInDestinationBranch;
                var conflict = Conflict.Merge(
                                commonAncestrorElement,
                                elementInSourceBranch,
                                elementInDestinationBranch,
                                out differenceInSourceBranch,
                                out differenceInDestinationBranch);

                using (var form = new MergeSolutionsForm(
                            differenceInSourceBranch,
                            differenceInDestinationBranch,
                            conflict,
                            delegate(ConflictContext context, Difference differenceTypeInSourceBranch, Difference differenceTypeInDestinationBranch)
                            {
                                var resolverForm = new OperationTypeConflictResolverForm(
                                            context,
                                            differenceTypeInSourceBranch,
                                            differenceTypeInDestinationBranch);
                                resolverForm.ShowDialog();
                                return resolverForm.Result;
                            },
                            delegate(ConflictContext context, string valueInSourceBranch, string valueInDestinationBranch)
                            {
                                var resolverForm = new ValueConflictResolverForm(
                                            context,
                                            valueInSourceBranch,
                                            valueInDestinationBranch);
                                resolverForm.ShowDialog();
                                return resolverForm.Result;
                            }))
                {
                    if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        var mergedElement = (NodeElement)commonAncestrorElement.Apply(form.Result);
                        var mergedSolution = SolutionFile.FromElement(mergedElement);
                        mergedSolution.SaveAs(mergedSolutionName);
                        MergedHandled = true;
                    }
                }
            }
        }
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();
            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                var filterFile = FilterFile.FromFile(parsedArguments.FilterFile);

                // Save the filtered solution. We also add a link to the original solution file in the filtered solution.
                // If we have to checkout the original solution file later on, its easier with that link.
                var filteredSolution = filterFile.Apply();

                // Add OriginalSolutionFile to the filter solution (and a warnings file if needed)
                filteredSolution.Projects.Add(CreateOriginalSolutionProject(filterFile.SourceSolution));

                filteredSolution.Save();
                if (filterFile.CopyReSharperFiles)
                {
                    var resharperGlobalFileSettingsSource = filterFile.SourceSolutionFullPath + ".DotSettings";
                    if (File.Exists(resharperGlobalFileSettingsSource))
                    {
                        File.Copy(resharperGlobalFileSettingsSource, filteredSolution.SolutionFullPath + ".DotSettings", true);
                    }

                    var resharperUserFileSettingsSource = filterFile.SourceSolutionFullPath + ".DotSettings.user";
                    var resharperUserFileSettingsDestination = filteredSolution.SolutionFullPath + ".DotSettings.user";
                    if (File.Exists(resharperUserFileSettingsSource) && !File.Exists(resharperUserFileSettingsDestination))
                    {
                        File.Copy(resharperUserFileSettingsSource, resharperUserFileSettingsDestination);
                    }
                }

                if (!parsedArguments.CreateOnly)
                {
                    filterFile.StartFilteredSolutionWatcher(
                                filteredSolution,
                                delegate(NodeDifference difference)
                                {
                                    using (var fix = new TopMostFormFix())
                                    {
                                        using (var form = new UpdateOriginalSolutionForm(difference, filterFile.SourceSolutionFullPath))
                                        {
                                            return (form.ShowDialog() == DialogResult.Yes);
                                        }
                                    }
                                });

                    var startTime = DateTime.Now;
                    var process = Process.Start(filteredSolution.SolutionFullPath);

                    if (parsedArguments.Wait || filterFile.WatchForChangesOnFilteredSolution)
                    {
                        process.WaitForExit();

                        // If the process exited "too fast", we wait on the processes that were spawned by the process
                        // we started. This allow us to handle the case where the '.sln' is associated to an application like
                        // "VSLauncher.exe". That type of application only live for a short period of time because it's job
                        // is to analyse the sln file, launch the right version of "devenv.exe" (i.e. VS2002, VS2005, VS2008)
                        // and then exit.
                        // This "trick" should not be needed with others IDE like SharpDevelop.
                        if (DateTime.Now - startTime < TimeSpan.FromMinutes(1))
                        {
                            foreach (var processSpawned in ProcessEx.GetChildsOfProcess(process))
                            {
                                processSpawned.WaitForExit();
                            }
                        }
                    }

                    filterFile.StopFilteredSolutionWatcher();
                }
            }
        }
Ejemplo n.º 10
0
        public override void Run(string[] args, MessageBoxErrorReporter reporter)
        {
            var parsedArguments = new Arguments();

            reporter.CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType());

            if (Parser.ParseArguments(args, parsedArguments, reporter.Handler))
            {
                if (parsedArguments.Solutions.Length < 4)
                {
                    reporter.Handler("Four solution files should be provided, in order:\n   SourceBranch.sln\n   DestinationBranch.sln\n   CommonAncestror.sln\n   Result.sln");
                    return;
                }

                var solutionInSourceBranch      = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[0]), parsedArguments.IgnoreWarning);
                var solutionInDestinationBranch = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[1]), parsedArguments.IgnoreWarning);
                var commonAncestrorSolution     = CheckForWarnings(SolutionFile.FromFile(parsedArguments.Solutions[2]), parsedArguments.IgnoreWarning);
                var mergedSolutionName          = parsedArguments.Solutions[3];

                var elementInSourceBranch      = solutionInSourceBranch.ToElement();
                var elementInDestinationBranch = solutionInDestinationBranch.ToElement();
                var commonAncestrorElement     = commonAncestrorSolution.ToElement();

                NodeDifference differenceInSourceBranch;
                NodeDifference differenceInDestinationBranch;
                var            conflict = Conflict.Merge(
                    commonAncestrorElement,
                    elementInSourceBranch,
                    elementInDestinationBranch,
                    out differenceInSourceBranch,
                    out differenceInDestinationBranch);

                using (var form = new MergeSolutionsForm(
                           differenceInSourceBranch,
                           differenceInDestinationBranch,
                           conflict,
                           delegate(ConflictContext context, Difference differenceTypeInSourceBranch, Difference differenceTypeInDestinationBranch)
                {
                    var resolverForm = new OperationTypeConflictResolverForm(
                        context,
                        differenceTypeInSourceBranch,
                        differenceTypeInDestinationBranch);
                    resolverForm.ShowDialog();
                    return(resolverForm.Result);
                },
                           delegate(ConflictContext context, string valueInSourceBranch, string valueInDestinationBranch)
                {
                    var resolverForm = new ValueConflictResolverForm(
                        context,
                        valueInSourceBranch,
                        valueInDestinationBranch);
                    resolverForm.ShowDialog();
                    return(resolverForm.Result);
                }))
                {
                    if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        var mergedElement  = (NodeElement)commonAncestrorElement.Apply(form.Result);
                        var mergedSolution = SolutionFile.FromElement(mergedElement);
                        mergedSolution.SaveAs(mergedSolutionName);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            //args = new string[] { "CompareSolutions", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Lors du Branch).sln", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Latest Branche WinFixFrs).sln" };
            //args = new string[] { "MergeSolutions", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Lors du Branch).sln", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Latest Branche WinFixFrs).sln", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\All Projects (Latest Main).sln", @"C:\Dev\VSSolutionMerger.root\VSSolutionMerger\SLNTools.exe\Results.sln" };
            //args = new string[] { "CreateFilterFileFromSolution", @"C:\DevCodePlex\SLNTools\Main\SLNTools.sln" };
            //args = new string[] { "OpenFilterFile", @"C:\DevCodePlex\SLNTools\Main\Test.slnfilter" };
            //args = new string[] { "/?" };
            //args = new string[] { "CreateFilterFileFromSolution", @"E:\SLNTools\SLNTools\Main\SLNTools.sln" };
            //args = new string[] { "MergeSolutions" };

            try
            {
                string[] commandName;
                string[] commandArguments;
                if (args.Length > 1)
                {
                    commandName = new string[1];
                    Array.ConstrainedCopy(args, 0, commandName, 0, 1);
                    commandArguments = new string[args.Length - 1];
                    Array.ConstrainedCopy(args, 1, commandArguments, 0, commandArguments.Length);
                }
                else
                {
                    commandName = args;
                    commandArguments = new string[0];
                }

                var parsedArguments = new Arguments();

                var reporter = new MessageBoxErrorReporter
                            {
                                CommandUsage = Parser.ArgumentsUsage(parsedArguments.GetType())
                            };

                if (Parser.ParseArguments(commandName, parsedArguments, reporter.Handler))
                {
                    Command command;
                    switch (parsedArguments.Command)
                    {
                        case CommandList.CompareSolutions:
                            command = new CompareSolutionsCommand();
                            break;

                        case CommandList.MergeSolutions:
                            command = new MergeSolutionsCommand();
                            break;

                        case CommandList.CreateFilterFileFromSolution:
                            command = new CreateFilterFileFromSolutionCommand();
                            break;

                        case CommandList.OpenFilterFile:
                            command = new OpenFilterFileCommand();
                            break;

                        case CommandList.EditFilterFile:
                            command = new EditFilterFileCommand();
                            break;

                        default:
                            command = null;
                            reporter.Handler("Invalid command name.");
                            break;
                    }

                    if (command != null)
                    {
                        reporter.CommandName = parsedArguments.Command.ToString();
                        command.Run(commandArguments, reporter);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 12
0
 public abstract void Run(string[] args, MessageBoxErrorReporter reporter);
Ejemplo n.º 13
0
 public abstract void Run(string[] args, MessageBoxErrorReporter reporter);