Esempio n. 1
0
            public virtual Core.FileConfiguration.AsyncGenerator Parse(string content)
            {
                var config = _realConfigurator.Parse(content);

                foreach (var testProject in config.Projects.Where(o => o.FilePath == "AsyncGenerator.Tests.csproj"))
                {
                    testProject.FilePath = Path.GetFullPath(Path.Combine(GetBaseDirectory(), "..", "..", "..", "AsyncGenerator.Tests.csproj"));
                }
                return(config);
            }
Esempio n. 2
0
        internal AsyncCodeConfiguration ConfigureFromStream(Stream stream, IFileConfigurator fileConfigurator, string basePath = null)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (fileConfigurator == null)
            {
                throw new ArgumentNullException(nameof(fileConfigurator));
            }

            basePath = basePath ?? GetExecutingDirectory();
            Core.FileConfiguration.AsyncGenerator configuration;
            using (var reader = new StreamReader(stream))
            {
                configuration = fileConfigurator.Parse(reader.ReadToEnd());
            }

            Assembly assembly = null;

            if (!string.IsNullOrEmpty(configuration.CSharpScript))
            {
                assembly = SourceCodeCompiler.Compile(configuration.CSharpScript);
            }

            if (!string.IsNullOrEmpty(configuration.Solution.FilePath))
            {
                var filePath = Path.GetFullPath(Path.Combine(basePath, configuration.Solution.FilePath));
                ConfigureSolution(filePath, o => fileConfigurator.Configure(configuration, configuration.Solution, o, assembly));
            }
            foreach (var project in configuration.Projects)
            {
                var filePath = Path.GetFullPath(Path.Combine(basePath, project.FilePath));
                ConfigureProject(filePath, o => fileConfigurator.Configure(configuration, project, o, assembly));
            }

            return(this);
        }