public void NullTest1() { Assert.Throws <ArgumentNullException>(() => PackagesConfigLocator.FindAndLoadConfigs(null, SlnItems.PackagesConfig).ToArray() ); Assert.Throws <ArgumentNullException>(() => PackagesConfigLocator.FindConfigs(null, SlnItems.PackagesConfig).ToArray() ); }
public void FindAndLoadTest1(string file, SlnItems items) { using Sln sln = new(file, items); IEnumerable <PackagesConfig> pkgs = PackagesConfigLocator.FindAndLoadConfigs(sln.Result, sln.Result.ResultType); Assert.Equal(sln.Result.PackagesConfigs.Count(), pkgs.Count()); int idx = 0; foreach (var config in sln.Result.PackagesConfigs) { Assert.Equal(config.Packages, pkgs.ElementAt(idx++).Packages); } }
/// <summary> /// To parse data from used stream. /// </summary> /// <param name="reader"></param> /// <param name="type">Allowed type of operations.</param> /// <returns></returns> public ISlnResult Parse(StreamReader reader, SlnItems type) { if (reader == null) { throw new ArgumentNullException(nameof(reader), MsgResource.ValueNoEmptyOrNull); } string sln = (reader.BaseStream is FileStream stream) ? stream.Name : MEM_FILE; var data = new SlnResult() { SolutionDir = sln.GetDirectoryFromFile(), ResultType = type, }; Process(new Svc(reader, data)); if (data.SolutionConfigs != null) { data.DefaultConfig = new ConfigItem( ExtractDefaultConfiguration(data.SolutionConfigs), ExtractDefaultPlatform(data.SolutionConfigs) ); } data.Properties = GlobalProperties( sln, data.DefaultConfig?.Configuration, data.DefaultConfig?.Platform ); Aliases(data); if ((type & SlnItems.Env) == SlnItems.Env) { data.Env = new IsolatedEnv(data, RawXmlProjects); if ((type & SlnItems.EnvWithMinimalProjects) == SlnItems.EnvWithMinimalProjects) { data.Env.LoadMinimalProjects(); } if ((type & SlnItems.EnvWithProjects) == SlnItems.EnvWithProjects) { data.Env.LoadProjects(); } } if ((type & SlnItems.ProjectDependenciesXml) == SlnItems.ProjectDependenciesXml) { if (data.ProjectDependencies != null && data.Env?.Projects != null) { // The following class provides additional features for project references in ISlnPDManager manner, // But we'll just activate references for existing ProjectDependencies (shallow copy) // just to eliminate miscellaneous units between VS and msbuild world: https://github.com/3F/MvsSln/issues/25 new ProjectReferences(data.ProjectDependencies, data.Env.Projects); } } data.PackagesConfigs = PackagesConfigLocator.FindAndLoadConfigs(data, type); return(data); }