private static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .ReadFrom.AppSettings() .CreateLogger(); var options = new CommandLineOptions(); // allow app to be debugged in visual studio. if (Debugger.IsAttached) { // args = "--help ".Split(' '); args = "--platform=essentials".Split(' '); // args = new[] // { // "--platform=none", // @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Xamarin.iOS.dll" // }; } // Parse in 'strict mode'; i.e. success or quit if (Parser.Default.ParseArgumentsStrict(args, options)) { try { if (!string.IsNullOrWhiteSpace(options.Template)) { _mustacheTemplate = options.Template; Log.Debug("Using {template} instead of the default template.", _mustacheTemplate); } if (!string.IsNullOrWhiteSpace(options.ReferenceAssemblies)) { _referenceAssembliesLocation = options.ReferenceAssemblies; Log.Debug($"Using {_referenceAssembliesLocation} instead of the default reference assemblies location."); } IPlatform platform = null; switch (options.Platform) { case AutoPlatform.None: if (!options.Assemblies.Any()) { throw new Exception("Assemblies to be used for manual generation were not specified."); } platform = new Bespoke(); platform.Assemblies = options.Assemblies; if (PlatformHelper.IsRunningOnMono()) { platform.CecilSearchDirectories = platform.Assemblies.Select(Path.GetDirectoryName).Distinct().ToList(); } else { platform.CecilSearchDirectories.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5"); } break; case AutoPlatform.Android: platform = new Android(_referenceAssembliesLocation); break; case AutoPlatform.iOS: platform = new iOS(_referenceAssembliesLocation); break; case AutoPlatform.Mac: platform = new Mac(_referenceAssembliesLocation); break; case AutoPlatform.TVOS: platform = new TVOS(_referenceAssembliesLocation); break; case AutoPlatform.WPF: platform = new WPF(); break; case AutoPlatform.XamForms: platform = new XamForms(); break; case AutoPlatform.Tizen: platform = new Tizen(); break; case AutoPlatform.UWP: platform = new UWP(); break; case AutoPlatform.Winforms: platform = new Winforms(); break; case AutoPlatform.Essentials: platform = new Essentials(); _mustacheTemplate = "XamarinEssentialsTemplate.mustache"; break; default: throw new ArgumentOutOfRangeException(); } ExtractEventsFromAssemblies(platform); Environment.Exit((int)ExitCode.Success); } catch (Exception ex) { Log.Fatal(ex.ToString()); if (Debugger.IsAttached) { Debugger.Break(); } } } Environment.Exit((int)ExitCode.Error); }
public static async Task Main(string[] args) { Log.Logger = new LoggerConfiguration() .ReadFrom.AppSettings() .CreateLogger(); // allow app to be debugged in visual studio. if (Debugger.IsAttached) { args = "--platform=essentials --output-path=test.txt".Split(' '); } await new Parser(parserSettings => parserSettings.CaseInsensitiveEnumValues = true).ParseArguments <CommandLineOptions>(args).MapResult( async options => { try { if (!string.IsNullOrWhiteSpace(options.Template)) { _mustacheTemplate = options.Template; Log.Debug("Using {template} instead of the default template.", _mustacheTemplate); } if (!string.IsNullOrWhiteSpace(options.ReferenceAssemblies)) { _referenceAssembliesLocation = options.ReferenceAssemblies; Log.Debug($"Using {_referenceAssembliesLocation} instead of the default reference assemblies location."); } IPlatform platform = null; switch (options.Platform) { case AutoPlatform.None: if (options.Assemblies.Any() == false) { throw new Exception("Assemblies to be used for manual generation were not specified."); } platform = new Bespoke(); platform.Assemblies.AddRange(options.Assemblies); if (PlatformHelper.IsRunningOnMono()) { platform.CecilSearchDirectories.AddRange(platform.Assemblies.Select(Path.GetDirectoryName).Distinct().ToList()); } else { platform.CecilSearchDirectories.Add(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5"); } break; case AutoPlatform.Android: platform = new Android(_referenceAssembliesLocation); break; case AutoPlatform.iOS: platform = new iOS(_referenceAssembliesLocation); break; case AutoPlatform.Mac: platform = new Mac(_referenceAssembliesLocation); break; case AutoPlatform.TVOS: platform = new TVOS(_referenceAssembliesLocation); break; case AutoPlatform.WPF: platform = new WPF(); break; case AutoPlatform.XamForms: platform = new XamForms(); break; case AutoPlatform.Tizen4: platform = new Tizen(); break; case AutoPlatform.UWP: platform = new UWP(); break; case AutoPlatform.Winforms: platform = new Winforms(); break; case AutoPlatform.Essentials: platform = new Essentials(); _mustacheTemplate = "XamarinEssentialsTemplate.mustache"; break; default: throw new ArgumentException($"Platform not {options.Platform} supported"); } await ExtractEventsFromAssemblies(options.OutputPath, platform).ConfigureAwait(false); Environment.Exit((int)ExitCode.Success); } catch (Exception ex) { Log.Fatal(ex.ToString()); if (Debugger.IsAttached) { Debugger.Break(); } } Environment.Exit((int)ExitCode.Error); }, _ => Task.CompletedTask).ConfigureAwait(false); }