public WorkspaceEntry()

in tools/nuget2bazel/WorkspaceEntry.cs [20:108]


        public WorkspaceEntry(IDictionary<string, string> knownDependencies,
            PackageIdentity identity, string sha256, IEnumerable<PackageDependencyGroup> deps,
            IEnumerable<FrameworkSpecificGroup> libs, IEnumerable<FrameworkSpecificGroup> tools,
            IEnumerable<FrameworkSpecificGroup> references, IEnumerable<FrameworkSpecificGroup> buildFiles,
            IEnumerable<FrameworkSpecificGroup> runtimeFiles, string mainFile, string variable, bool nugetSourceCustom)
        {
            var netFrameworkTFMs = new string[]
            {
                "net45", "net451", "net452", "net46", "net461", "net462", "net47", "net471", "net472", "net48", "netstandard1.0",
                "netstandard1.1", "netstandard1.2", "netstandard1.3",
                "netstandard1.4", "netstandard1.5", "netstandard1.6", "netstandard2.0", "netstandard2.1",
            };
            var coreFrameworkTFMs = new string[]
            {
                "netcoreapp2.0", "netcoreapp2.1", "netcoreapp2.2", "netcoreapp3.0", "netcoreapp3.1", "net5.0", "net6.0"
            };
            PackageIdentity = identity;
            Sha256 = sha256;
            Variable = variable;
            NugetSourceCustom = nugetSourceCustom;
            var coreFrameworks = coreFrameworkTFMs.Select(x => NuGetFramework.Parse(x));
            var netFrameworks = netFrameworkTFMs.Select(x => NuGetFramework.Parse(x));
            var monoFramework = NuGetFramework.Parse("net70");

            Core_Files = GetFiles(coreFrameworks, libs, tools, buildFiles, runtimeFiles);
            Net_Files = GetFiles(netFrameworks, libs, tools, buildFiles, runtimeFiles);
            Mono_Files = GetFiles(monoFramework, libs, tools, buildFiles, runtimeFiles);

            var depConverted = deps.Select(x =>
                new FrameworkSpecificGroup(x.TargetFramework, x.Packages.Select(y => y.Id.ToLower())));
            Core_Deps = GetDepsCore(coreFrameworks, depConverted, knownDependencies);
            Net_Deps = GetDepsNet(netFrameworks, depConverted, knownDependencies);
            Mono_Deps = MSBuildNuGetProjectSystemUtility.GetMostCompatibleGroup(monoFramework, depConverted)?.Items?.Select(x => ToRefMono(x));

            CoreLib = new Dictionary<string, string>();
            foreach (var framework in coreFrameworks)
            {
                var lib = GetMostCompatibleItem(framework, libs, mainFile);
                if (!string.IsNullOrEmpty(lib))
                    CoreLib.Add(framework.GetShortFolderName(), lib);
            }
            CoreRef = new Dictionary<string, string>();
            foreach (var framework in coreFrameworks)
            {
                var reflib = GetMostCompatibleItem(framework, references, mainFile);
                if (!string.IsNullOrEmpty(reflib))
                    CoreRef.Add(framework.GetShortFolderName(), reflib);
            }

            NetLib = new Dictionary<string, string>();
            foreach (var framework in netFrameworks)
            {
                var lib = GetMostCompatibleItem(framework, libs, mainFile);
                if (!string.IsNullOrEmpty(lib))
                    NetLib.Add(framework.GetShortFolderName(), lib);
            }
            NetRef = new Dictionary<string, string>();
            foreach (var framework in netFrameworks)
            {
                var reflib = GetMostCompatibleItem(framework, references, mainFile);
                if (!string.IsNullOrEmpty(reflib))
                    NetRef.Add(framework.GetShortFolderName(), reflib);
            }
            MonoLib = GetMostCompatibleItem(monoFramework, libs, mainFile);
            MonoRef = GetMostCompatibleItem(monoFramework, references, mainFile);

            CoreTool = new Dictionary<string, string>();
            foreach (var framework in coreFrameworks)
            {
                var tool = GetMostCompatibleItem(framework, tools, mainFile);
                if (!string.IsNullOrEmpty(tool))
                    CoreTool.Add(framework.GetShortFolderName(), tool);
            }
            NetTool = new Dictionary<string, string>();
            foreach (var framework in netFrameworks)
            {
                var tool = GetMostCompatibleItem(framework, tools, mainFile);
                if (!string.IsNullOrEmpty(tool))
                    NetTool.Add(framework.GetShortFolderName(), tool);
            }
            MonoTool = GetMostCompatibleItem(monoFramework, tools, mainFile);

            //if (NetLib == null || !NetLib.Any())
            //    NetLib = Net_Files?.ToDictionary(key => key.Key, val => val.Value.FirstOrDefault(z => Path.GetExtension(z) == ".dll"));
            //if (CoreLib == null || !CoreLib.Any())
            //    CoreLib = Core_Files?.ToDictionary(key => key.Key, val => val.Value.FirstOrDefault(z => Path.GetExtension(z) == ".dll"));
            //if (MonoLib == null)
            //    MonoLib = Mono_Files?.FirstOrDefault(x => Path.GetExtension(x) == ".dll");
        }