示例#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);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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();
        }