public void Execute(RewriteContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            foreach (var step in _steps)
                step.Execute(context);
        }
        static int Main(string[] args)
        {
            var help                          = false;
            var targetModule                  = "";
            var targetModuleOutput            = "";
            var supportModule                 = "";
            var supportModulePartialNamespace = "";
            var frameworkPath                 = "";
            var projectLockFile               = "";
            var additionalReference           = "";
            var platformPath                  = "";
            var systemNamespace               = "";
            var strongNamedReferences         = "";
            var winmdReferences               = "";
            var symbolFormat                  = DebugSymbolFormat.None;
            var alt    = new Dictionary <string, IList <string> >();
            var ignore = new Dictionary <string, IList <string> >();

            var set = new OptionSet
            {
                { "target=", "The target module to rewrite.", t => targetModule = t },
                { "output=", "Where to write the rewritten target module. Default is write over.", o => targetModuleOutput = o },
                { "support=", "The support module containing the replacement API.", s => supportModule = s },
                { "supportpartialns=", "Namespace in the support module that implements partial types.", s => supportModulePartialNamespace = s },
                { "framework=", "A comma separated list of the directories of the target framework. Reference rewriter will assume that it will not process files in those directories",
                  f => frameworkPath = f },
                { "lock=", "Path to project.lock.json file.", l => projectLockFile = l },
                { "additionalreferences=", "A comma separated list of the directories to reference additionally. Reference rewriter will assume that it will process files in those directories",
                  ar => additionalReference = ar },
                { "platform=", "Path to platform assembly.", p => platformPath = p },
                { "system=", "The support namespace for System.", s => systemNamespace = s },
                { "snrefs=", "A comma separated list of assembly names that retain their strong names.", s => strongNamedReferences = s },
                { "winmdrefs=", "A comma separated list of assembly names that should be redirected to winmd references.", s => winmdReferences = s },
                { "dbg=", "File format of the debug symbols. Either none, mdb or pdb.", d => symbolFormat = SymbolFormat(d) },
                { "alt=", "A semicolon separated list of alternative namespace and assembly mappings.", a => AltFormat(alt, a) },
                { "ignore=", "A semicolon separated list of assembly qualified type names that should not be resolved.", i => IgnoreFormat(ignore, i) },

                { "?|h|help", h => help = true },
            };

            try
            {
                set.Parse(args);
            }
            catch (OptionException)
            {
                Usage(set);
                return(3);
            }

            if (help || new[] { targetModule, supportModule, systemNamespace }.Any(string.IsNullOrWhiteSpace) || new[] { frameworkPath, projectLockFile }.All(string.IsNullOrWhiteSpace))
            {
                Usage(set);
                return(2);
            }

            try
            {
                var operation = RewriteOperation.Create(
                    ns => ns.StartsWith("System")
                                                ? systemNamespace + ns.Substring("System".Length)
                                                : ns);

                var frameworkPaths             = frameworkPath.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var additionalReferences       = additionalReference.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var strongNamedReferencesArray = strongNamedReferences.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var winmdReferencesArray       = winmdReferences.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                var context = RewriteContext.For(targetModule, symbolFormat, supportModule, supportModulePartialNamespace, frameworkPaths, projectLockFile, additionalReferences, platformPath, strongNamedReferencesArray, winmdReferencesArray, alt, ignore);

                operation.Execute(context);

                if (context.RewriteTarget)
                {
                    context.Save(string.IsNullOrEmpty(targetModuleOutput) ? targetModule : targetModuleOutput);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Catastrophic failure while running rrw: {0}", e);
                return(1);
            }

            return(0);
        }