internal static SpecEvaluationBuilder AddTestFiles(this SpecEvaluationBuilder builder) { return(builder .AddFile(@"src\a.txt", "a") .AddFile(@"src\b.txt", "a") .AddFile(@"src\a.cs", "a") .AddFile(@"src\b.cs", "a") .AddFile(@"src\other", "a") .AddFile(@"src\f1\a.txt", "a") .AddFile(@"src\f1\b.txt", "a") .AddFile(@"src\f1\a.cs", "a") .AddFile(@"src\f1\b.cs", "a") .AddFile(@"src\f1\other", "a") .AddFile(@"src\f2\a.txt", "a") .AddFile(@"src\f2\b.txt", "a") .AddFile(@"src\f2\a.cs", "a") .AddFile(@"src\f2\b.cs", "a") .AddFile(@"src\f3\other", "a") .AddFile(@"src\f4\f5\a.txt", "a") .AddFile(@"src\f4\f5\b.txt", "a") .AddFile(@"src\f4\f5\a.cs", "a") .AddFile(@"src\f4\f5\b.cs", "a") .AddFile(@"src\f4\f5\other", "a") .AddFile(@"src\f4\f6\other", "a") .AddFile(@"src\f4\other", "a") .AddFile(@"src\x.cs\other\f7\a.cs", "a")); }
/// <summary> /// Adds modules to the spec builder based on a string-based dependency chain. E.g. "A -> B -> C -> D". No actual projects are added to /// the modules /// </summary> internal static SpecEvaluationBuilder AddModuleDependency(this SpecEvaluationBuilder builder, params string[] dependencyChains) { var moduleChains = dependencyChains.Select( dependencyChain => dependencyChain.Split(new[] { "->" }, StringSplitOptions.RemoveEmptyEntries).Select(name => name.Trim()).ToArray()); // Collect all direct dependencies for each module var dependencies = new MultiValueDictionary <string, string>(); foreach (var modules in moduleChains) { // We expect at least one dependency pair Contract.Assert(modules.Length >= 2); for (var i = 0; i < modules.Length - 1; i++) { dependencies.Add(modules[i], modules[i + 1]); } // We add the last module with no dependencies so the set of modules is complete dependencies.Add(modules[modules.Length - 1]); } // Add one module per module name, with the corresponding allowed dependencies foreach (var moduleWithDependencies in dependencies) { var moduleName = moduleWithDependencies.Key; builder.AddFile( I($"{moduleName}/package.config.dsc"), DsTest.CreatePackageConfig(moduleName, useImplicitReferenceSemantics: true, allowedDependencies: moduleWithDependencies.Value.ToList())); } // We always want to evaluate everything builder.RootSpec(Names.ConfigBc); return(builder); }