Beispiel #1
0
        internal static void Main(GlobalOptions options, ModeOptions modeOptions)
        {
            Helper.WriteVerbose("Switching to publicizer", ConsoleColor.Green);

            Helper.WriteVerbose($"Input: {modeOptions.Input}", ConsoleColor.Yellow);
            Helper.WriteVerbose($"Written output: {modeOptions.Output}", ConsoleColor.Yellow);
            var output = !string.IsNullOrEmpty(modeOptions.Output) ? modeOptions.Output : $"{Path.GetFileNameWithoutExtension(modeOptions.Input)}_publicized{Path.GetExtension(modeOptions.Input)}";

            Helper.WriteVerbose($"Final output: {output}", ConsoleColor.Yellow);

            var assembly = Helper.ReadAssembly(modeOptions.Input);

            Helper.WriteVerbose("Loading assembly as module");
            var module = ModuleDefMD.Load(assembly);

            Helper.WriteVerbose("Getting assembly types");
            foreach (var type in module.GetTypes())
            {
                Publicize(type);
            }
            Helper.WriteVerbose("Finalize publicizing");

            var publicizedDirectory = Path.GetDirectoryName(output);

            Helper.WriteVerbose($"Publicized result directory: {publicizedDirectory}");
            if (!string.IsNullOrEmpty(publicizedDirectory) && !Directory.Exists(publicizedDirectory))
            {
                Helper.WriteVerbose($"Publicized directory doesn't exist, creating...", System.ConsoleColor.Cyan);
                Directory.CreateDirectory(publicizedDirectory);
            }

            Helper.WriteLine(string.Join("\n", new[]
            {
                "Publicize result -",
                $"Publicized classes: {publicizedClasses}",
                $"Publicized methods: {publicizedMethods}",
                $"Publicized fields: {publicizedFields}",
                $"Publicized properties: {publicizedProperties}"
            }), System.ConsoleColor.Magenta);
            Helper.WriteVerbose($"Writing publicized assembly to path: {output}");

            module.Write(output);
        }
Beispiel #2
0
 public static async Task Start(GlobalOptions options) =>
 await ModeOptions.Parse(options, Environment.GetCommandLineArgs()).ConfigureAwait(false);