Exemple #1
0
        internal static int Main(string[] args)
#pragma warning restore CA1801  // Parameter is never used
#pragma warning restore IDE0060 // Remove unused parameter
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: dotnet run TypeName");
                Console.WriteLine("    TypeName must be in the Xamarin.Forms namespace in the Xamarin.Forms assembly.");
                return(-1);
            }

            var settings = new GeneratorSettings
            {
                FileHeader    = @"// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
",
                RootNamespace = "Microsoft.MobileBlazorBindings.Elements",
            };

            var typeToGenerate = typeof(Xamarin.Forms.Element).Assembly.GetType("Xamarin.Forms." + args[0]);
            var generator      = new ComponentWrapperGenerator(settings);

            generator.GenerateComponentWrapper(typeToGenerate);

            return(0);
        }
        internal static int Main(string[] args)
        {
            // Un-comment these lines for easier debugging
            if (args.Length == 0)
            {
                args = new string[] { "TypesToGenerate.txt", @"..\out" };
            }

            if (args.Length != 2)
            {
                Console.WriteLine("Usage: dotnet run FileWithOneTypePerLine.txt ..\\OutputFolder");
                Console.WriteLine("    FileWithOneTypePerLine.txt must list types in the Xamarin.Forms[.DualScreen] namespace in the Xamarin.Forms[.DualScreen] assembly.");
                return(-1);
            }

            var listOfTypeNamesToGenerate = File.ReadAllLines(args[0]);
            var outputFolder = args[1];

            var settings = new GeneratorSettings
            {
                FileHeader    = @"// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
",
                RootNamespace = "Microsoft.MobileBlazorBindings.Elements",
            };

            // xml location is incorrect.
            // LoadXmlDocs(ComponentLocations.Select(loc => loc.XmlDocFilename).Where(loc => loc != null));
            var xmlDocs = Array.Empty <XmlDocument>();

            var namespaces = ComponentLocations.Select(l => l.NamespaceName).ToList();
            var generator  = new ComponentWrapperGenerator(settings, xmlDocs, namespaces);

            foreach (var typeNameToGenerate in listOfTypeNamesToGenerate)
            {
                if (string.IsNullOrWhiteSpace(typeNameToGenerate))
                {
                    continue;
                }
                if (IsCommentLine(typeNameToGenerate))
                {
                    Console.WriteLine($"Skipping comment: {typeNameToGenerate}");
                    Console.WriteLine();
                    continue;
                }

                if (!TryGetTypeToGenerate(typeNameToGenerate, out var typeToGenerate))
                {
                    Console.WriteLine($"WARNING: Couldn't find type {typeNameToGenerate}.");
                    Console.WriteLine();
                    continue;
                }

                generator.GenerateComponentWrapper(typeToGenerate, outputFolder);
                Console.WriteLine();
            }

            return(0);
        }
        internal static int Main(string[] args)
        {
            // Un-comment these lines for easier debugging
            //if (args.Length == 0)
            //{
            //    args = new string[] { "TypesToGenerate.txt", ".", @"..\out" };
            //}

            if (args.Length != 3)
            {
                Console.WriteLine("Usage: dotnet run FileWithOneTypePerLine.txt XmlDocsFolder ..\\OutputFolder");
                Console.WriteLine("    FileWithOneTypePerLine.txt must list types in the Xamarin.Forms namespace in the Xamarin.Forms assembly.");
                return(-1);
            }

            var listOfTypeNamesToGenerate = File.ReadAllLines(args[0]);
            var outputFolder = args[2];

            var settings = new GeneratorSettings
            {
                FileHeader    = @"// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
",
                RootNamespace = "Microsoft.MobileBlazorBindings.Elements",
            };

            var generator  = new ComponentWrapperGenerator(settings);
            var xmlDocs    = new XmlDocument();
            var xmlDocPath = Path.Combine(Directory.GetCurrentDirectory(), args[1], "Xamarin.Forms.Core.xml");

            xmlDocs.Load(xmlDocPath);

            foreach (var typeNameToGenerate in listOfTypeNamesToGenerate)
            {
                if (string.IsNullOrWhiteSpace(typeNameToGenerate))
                {
                    continue;
                }
                if (IsCommentLine(typeNameToGenerate))
                {
                    Console.WriteLine($"Skipping comment: {typeNameToGenerate}");
                    Console.WriteLine();
                    continue;
                }

                if (!TryGetTypeToGenerate(typeNameToGenerate, out var typeToGenerate))
                {
                    Console.WriteLine($"WARNING: Couldn't find type {typeNameToGenerate}.");
                    Console.WriteLine();
                    continue;
                }
                generator.GenerateComponentWrapper(typeToGenerate, xmlDocs, outputFolder);
                Console.WriteLine();
            }

            return(0);
        }
        private static void GenerateWrapperForType(string typeName, GeneratorSettings settings, string outputFolder)
        {
            var fullTypeName   = "Xamarin.Forms." + typeName;
            var typeToGenerate = typeof(Xamarin.Forms.Element).Assembly.GetType(fullTypeName);

            if (typeToGenerate == null)
            {
                Console.WriteLine($"WARNING: Couldn't find type {fullTypeName}.");
                Console.WriteLine();
                return;
            }
            var generator = new ComponentWrapperGenerator(settings);

            generator.GenerateComponentWrapper(typeToGenerate, outputFolder);
            Console.WriteLine();
        }
        internal static int Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: dotnet run FileWithOneTypePerLine.txt ..\\OutputFolder");
                Console.WriteLine("    FileWithOneTypePerLine.txt must list types in the Xamarin.Forms namespace in the Xamarin.Forms assembly.");
                return(-1);
            }

            var listOfTypeToGenerate = File.ReadAllLines(args[0]);
            var outputFolder         = args[1];

            var settings = new GeneratorSettings
            {
                FileHeader    = @"// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
",
                RootNamespace = "Microsoft.MobileBlazorBindings.Elements",
            };

            foreach (var typeToGenerate in listOfTypeToGenerate)
            {
                if (string.IsNullOrWhiteSpace(typeToGenerate))
                {
                    continue;
                }
                if (typeToGenerate[0] == '#')
                {
                    Console.WriteLine($"Skipping line: {typeToGenerate}");
                    Console.WriteLine();
                    continue;
                }

                GenerateWrapperForType(typeToGenerate, settings, outputFolder);
            }

            return(0);
        }
 public ComponentWrapperGenerator(GeneratorSettings settings, IList <XmlDocument> xmlDocs)
 {
     Settings = settings ?? throw new ArgumentNullException(nameof(settings));
     XmlDocs  = xmlDocs ?? throw new ArgumentNullException(nameof(xmlDocs));
 }
Exemple #7
0
 public ComponentWrapperGenerator(GeneratorSettings settings)
 {
     Settings = settings ?? throw new ArgumentNullException(nameof(settings));
 }