示例#1
0
        internal static CompilerVersionToMitigation[] CreateSortedVersionDictionary(PropertiesDictionary versionList)
        {
            List <CompilerVersionToMitigation> mitigatedCompilerList = new List <CompilerVersionToMitigation>();

            foreach (var key in versionList.Keys)
            {
                string[] versions       = key.Split('-').Select((s) => { return(s.Replace("*", int.MaxValue.ToString())); }).ToArray();
                var      mitigationData = new CompilerVersionToMitigation()
                {
                    MinimalSupportedVersion = new Version(versions[0]),
                    MaximumSupportedVersion = new Version(versions[1]),
                    SupportedMitigations    = (CompilerMitigations)Enum.Parse(typeof(CompilerMitigations), versionList[key].ToString()),
                };
                mitigatedCompilerList.Add(mitigationData);
            }
            mitigatedCompilerList.Sort((a, b) => a.MinimalSupportedVersion.CompareTo(b.MinimalSupportedVersion));

            ThrowIfMitigationDataIsInvalid(mitigatedCompilerList);

            return(mitigatedCompilerList.ToArray());
        }
示例#2
0
        private void AddCompilerMitigationDataToDictionary(PropertiesDictionary dictionary, CompilerVersionToMitigation data)
        {
            string start = data.MinimalSupportedVersion.ToString().Replace(int.MaxValue.ToString(), "*");
            string end   = data.MaximumSupportedVersion.ToString().Replace(int.MaxValue.ToString(), "*");
            string key   = start + " - " + end;

            dictionary.Add(key, data.SupportedMitigations.ToString());
        }