示例#1
0
        private static void Main(string[] args)
        {
            var logger = new ConsoleLogger();

            if (args.Length < 3 || args.Length > 4)
            {
                logger.LogError("USAGE: <assemblyPath> <outputPath> <functionsInDependencies> <excludedFunctionName1;excludedFunctionName2;...>");
            }
            else
            {
                ParseArgs(args, out string assemblyPath, out string outputPath, out bool functionsInDependencies, out IEnumerable <string> excludedFunctionNames);
                var assemblyDir = Path.GetDirectoryName(assemblyPath);

#if NETCOREAPP2_1
                AssemblyLoadContext.Default.Resolving += (context, assemblyName) =>
                {
                    return(context.LoadFromAssemblyPath(Path.Combine(assemblyDir, assemblyName.Name + ".dll")));
                };
#else
                AppDomain.CurrentDomain.AssemblyResolve += (sender, e) =>
                {
                    return(Assembly.LoadFrom(Path.Combine(assemblyDir, e.Name + ".dll")));
                };
#endif

                var converter = new FunctionJsonConverter(logger, assemblyPath, outputPath, functionsInDependencies, excludedFunctionNames);
                if (!converter.TryRun())
                {
                    logger.LogError("Error generating functions metadata");
                }
            }
        }
示例#2
0
        private static void Main(string[] args)
        {
            var logger = new ConsoleLogger();

            if (args.Length < 3 || args.Length > 4)
            {
                logger.LogError("USAGE: <assemblyPath> <outputPath> <functionsInDependencies> <excludedFunctionName1;excludedFunctionName2;...>");
            }
            else
            {
                var assemblyPath            = args[0].Trim();
                var outputPath              = args[1].Trim();
                var functionsInDependencies = bool.Parse(args[2].Trim());

                IEnumerable <string> excludedFunctionNames = Enumerable.Empty <string>();

                if (args.Length > 2)
                {
                    var excludedFunctionNamesArg = args[2].Trim();
                    excludedFunctionNames = excludedFunctionNamesArg.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                }

                var converter = new FunctionJsonConverter(logger, assemblyPath, outputPath, functionsInDependencies, excludedFunctionNames);
                if (!converter.TryRun())
                {
                    logger.LogError("Error generating functions metadata");
                }
            }
        }
示例#3
0
        public void InvalidFunctionMethodProducesWarning(Type type, string warningMessage)
        {
            var logger    = new RecorderLogger();
            var converter = new FunctionJsonConverter(logger, ".", ".");
            var functions = converter.GenerateFunctions(new [] { type });

            functions.Should().BeEmpty();
            logger.Errors.Should().BeEmpty();
            logger.Warnings.Should().ContainSingle();
            logger.Warnings.Single().Should().Be(warningMessage);
        }
示例#4
0
        public void InvalidFunctionMethodProducesWarning(Type type, string warningMessage)
        {
            var logger    = new RecorderLogger();
            var converter = new FunctionJsonConverter(logger, ".", ".", functionsInDependencies: false);
            var functions = converter.GenerateFunctions(new[] { TestUtility.GetTypeDefinition(type) });

            functions.Should().BeEmpty();
            logger.Errors.Should().BeEmpty();
            logger.Warnings.Should().ContainSingle();
            logger.Warnings.Single().Should().Be(warningMessage);
        }
示例#5
0
        public void FunctionMethodsAreExported(string functionName, string type, string parameterName)
        {
            var logger    = new RecorderLogger();
            var converter = new FunctionJsonConverter(logger, ".", ".");
            var functions = converter.GenerateFunctions(new [] { typeof(FunctionsClass) });
            var schema    = functions.Single(e => Path.GetFileName(e.Value.outputFile.DirectoryName) == functionName).Value.schema;
            var binding   = schema.Bindings.Single();

            binding.Value <string>("type").Should().Be(type);
            binding.Value <string>("name").Should().Be(parameterName);
            logger.Errors.Should().BeEmpty();
            logger.Warnings.Should().BeEmpty();
        }
 private static void Main(string[] args)
 {
     if (args.Length != 2)
     {
         Logger.LogError("USAGE: <assemblyPath> <outputPath>");
     }
     else
     {
         var assemblyPath = args[0];
         var outputPath   = args[1];
         var converter    = new FunctionJsonConverter(assemblyPath, outputPath);
         if (!converter.TryRun())
         {
             Logger.LogError("Error generating functions metadata");
         }
     }
 }
示例#7
0
        public void FunctionMethodsAreExported(string functionName, string type, string parameterName, string bindingName, string bindingValue)
        {
            var logger    = new RecorderLogger();
            var converter = new FunctionJsonConverter(logger, ".", ".", functionsInDependencies: false);
            var functions = converter.GenerateFunctions(new[] { TestUtility.GetTypeDefinition(typeof(FunctionsClass)) });
            var schema    = functions.Single(e => Path.GetFileName(e.Value.outputFile.DirectoryName) == functionName).Value.schema;
            var binding   = schema.Bindings.Single();

            binding.Value <string>("type").Should().Be(type);
            binding.Value <string>("name").Should().Be(parameterName);
            if (bindingName != null)
            {
                binding.Value <string>(bindingName).Should().Be(bindingValue);
            }
            logger.Errors.Should().BeEmpty();
            logger.Warnings.Should().BeEmpty();
        }
        private static void Main(string[] args)
        {
            var logger = new ConsoleLogger();

            if (args.Length < 3 || args.Length > 4)
            {
                logger.LogError("USAGE: <assemblyPath> <outputPath> <functionsInDependencies> <excludedFunctionName1;excludedFunctionName2;...>");
            }
            else
            {
                var assemblyPath            = args[0].Trim();
                var outputPath              = args[1].Trim();
                var functionsInDependencies = bool.Parse(args[2].Trim());
                var assemblyDir             = Path.GetDirectoryName(assemblyPath);

#if NETCOREAPP2_1
                AssemblyLoadContext.Default.Resolving += (context, assemblyName) =>
                {
                    return(context.LoadFromAssemblyPath(Path.Combine(assemblyDir, assemblyName.Name + ".dll")));
                };
#else
                AppDomain.CurrentDomain.AssemblyResolve += (sender, e) =>
                {
                    return(Assembly.LoadFrom(Path.Combine(assemblyDir, e.Name + ".dll")));
                };
#endif
                IEnumerable <string> excludedFunctionNames = Enumerable.Empty <string>();

                if (args.Length > 2)
                {
                    var excludedFunctionNamesArg = args[2].Trim();
                    excludedFunctionNames = excludedFunctionNamesArg.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                }

                var converter = new FunctionJsonConverter(logger, assemblyPath, outputPath, functionsInDependencies, excludedFunctionNames);
                if (!converter.TryRun())
                {
                    logger.LogError("Error generating functions metadata");
                }
            }
        }