Beispiel #1
0
        public List <string> Compare(Structs target)
        {
            if (this.Count == 0 || target == null || target.Count == 0)
            {
                return(null);
            }

            List <string> differences = new List <string>();

            // Search structs which defined in previous release from current build
            // If it is found, compare the struct
            // If the content of same struct are differrent
            // Compare and output the different members
            foreach (KeyValuePair <string, StructObject> pair in this.infos)
            {
                if (ValidationIgnoreList
                    .ValidationIgnoreListStructs
                    .ContainsKey(pair.Key))
                {
                    // Ignore a set of STRUCTS from this validation.
                    continue;
                }

                string name = pair.Key;
                if (target.infos.ContainsKey(name))
                {
                    StructObject cur = target[name];
                    StructObject pre = pair.Value;
                    if (!pre.Equals(cur))
                    {
                        Members curMethods = ValidationHelper.ParseMemberInformation(cur.Body);
                        Members preMethods = ValidationHelper.ParseMemberInformation(pre.Body);

                        string difference = preMethods.Compare(curMethods);

                        LogHelper.Log("Differences of {0}:", name);
                        LogHelper.Log(difference);
                        differences.Add(difference);
                    }
                }
            }

            return(differences);
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            StructObject target = (StructObject)obj;

            if (target == null || this.name != target.name)
            {
                return(false);
            }

            if (this.body == target.body)
            {
                return(true);
            }

            //
            // Each line in the body belongs to a struct member.
            // The type and the variable name, should match exactly,
            // IDL compiler can sometimes add/remove space between the type
            // and the member name. This is to handle that case.
            //
            Console.WriteLine("Member's dont exactly match for {0} against the previous versions, doing additional checks", this.name);
            var thisMembers   = this.body.Split(this.newLine, StringSplitOptions.RemoveEmptyEntries);
            var targetMembers = target.body.Split(this.newLine, StringSplitOptions.RemoveEmptyEntries);

            if (thisMembers.Count() != targetMembers.Count())
            {
                return(false);
            }

            for (int i = 0; i < thisMembers.Count(); ++i)
            {
                if (Regex.Replace(thisMembers[i], @" +", "") != Regex.Replace(targetMembers[i], @" +", ""))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// Read all content of .h and parse struct name and body
        /// </summary>
        /// <param name="lines">Content of .h file</param>
        /// <returns>StructObject collection</returns>
        public static Structs ParseStructs(List <string> lines)
        {
            LogHelper.Log("Start getting structs:");
            Structs structs = new Structs();

            const string match    = "typedef struct";
            const string sFlag    = "{";
            const string notMatch = "Vtbl";
            const string endFlag  = "}";
            const char   space    = ' ';

            int i = 0;

            while (i < lines.Count)
            {
                string line = lines[i++];
                if (!line.StartsWith(match) || line.Contains(notMatch) || !lines[i].Contains(sFlag))
                {
                    continue;
                }

                StructObject so = new StructObject();
                so.Name = line.Split(space)[2];
                StringBuilder sb = new StringBuilder();

                while (++i < lines.Count && !lines[i].Contains(endFlag))
                {
                    sb.AppendLine(lines[i]);
                }

                so.Body = sb.ToString();
                structs.Add(so.Name, so);
            }

            LogHelper.Log("Completed getting structs: {0} structs.", structs.Count);

            return(structs);
        }
Beispiel #4
0
 public void Add(string name, StructObject io)
 {
     this.infos.Add(name, io);
 }