public void TestSimpleAssemblyReader()
        {
            //arrange
            Settings.ConstEnumsEnabled = true;

            var reader = new AssemblyReader();

            var a = typeof(DoThing <>).Assembly;
            var b = typeof(MYPONO).Assembly;

            reader.AddAssembly(b);
            reader.AddAssembly(a);

            //act
            var res = reader.GenerateTypingsString();

            //assert
            Assert.IsTrue(!string.IsNullOrEmpty(res));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var input       = Path.GetFullPath(args[0]);
            var output      = Path.GetFullPath(args[1]);
            var inputFolder = Path.GetDirectoryName(input);

            System.Console.WriteLine($"Input Path {input}");
            System.Console.WriteLine($"Output Path {output}");
            if (!File.Exists(input))
            {
                System.Console.Error.WriteLine($"Could Not Find input {input}");
                return;
            }

            Settings.MethodReturnTypeFormatString = "{0}";
            Assembly asm = AssemblyLoadContext.Default.LoadFromAssemblyPath(input);

            var files = Directory.GetFiles(inputFolder, "*.dll");

            foreach (var file in files)
            {
                AssemblyLoadContext.Default.LoadFromAssemblyPath(file);
            }

            var reader = new AssemblyReader();

            reader.AddAssembly(asm);

            if (File.Exists(output))
            {
                File.Delete(output);
            }
            using (var of = File.OpenWrite(output))
                using (var sw = new StreamWriter(of))
                {
                    var types = reader.GenerateTypingsString();
                    // sw.WriteLine(@"/// <reference path=""../jquery/jquery.d.ts"" />");
                    sw.WriteLine(types);
                }
            System.Console.WriteLine("...");
            System.Console.WriteLine("Completed");
        }