private static void CompareTypes(Type xnaType, Type fnaType, TypeResults results) { var xnaFields = xnaType.GetFields(); var fnaFields = fnaType.GetFields(); results.FieldsNotInFNA.AddRange(from f in xnaFields where AreFieldsDifferent(f, fnaFields.FirstOrDefault(f2 => f2.Name == f.Name)) orderby f.Name select f.GetSignature()); results.FieldsExtraInFNA.AddRange(from f in fnaFields where !f.Name.EndsWith("EXT") where AreFieldsDifferent(f, xnaFields.FirstOrDefault(f2 => f2.Name == f.Name)) orderby f.Name select f.GetSignature()); var xnaProperties = xnaType.GetProperties(); var fnaProperties = fnaType.GetProperties(); results.PropertiesNotInFNA.AddRange(from p in xnaProperties where ArePropertiesDifferent(p, fnaProperties.FirstOrDefault(p2 => p2.Name == p.Name)) orderby p.Name select p.GetSignature()); results.PropertiesExtraInFNA.AddRange(from p in fnaProperties where !p.Name.EndsWith("EXT") where ArePropertiesDifferent(p, xnaProperties.FirstOrDefault(p2 => p2.Name == p.Name)) orderby p.Name select p.GetSignature()); var xnaEvents = xnaType.GetEvents(); var fnaEvents = fnaType.GetEvents(); results.EventsNotInFNA.AddRange(from e in xnaEvents where AreEventsDifferent(e, fnaEvents.FirstOrDefault(e2 => e2.Name == e.Name)) orderby e.Name select e.GetSignature()); results.EventsExtraInFNA.AddRange(from e in fnaEvents where !e.Name.EndsWith("EXT") where AreEventsDifferent(e, xnaEvents.FirstOrDefault(e2 => e2.Name == e.Name)) orderby e.Name select e.GetSignature()); var xnaConstructors = xnaType.GetConstructors(); var fnaConstructors = fnaType.GetConstructors(); results.ConstructorsNotInFNA.AddRange(from c in xnaConstructors where AreMethodsDifferent(c, fnaConstructors.FirstOrDefault(m2 => !AreMethodsDifferent(c, m2))) orderby c.Name select c.GetSignature()); results.ConstructorsExtraInFNA.AddRange(from c in fnaConstructors where AreMethodsDifferent(c, xnaConstructors.FirstOrDefault(m2 => !AreMethodsDifferent(c, m2))) orderby c.Name select c.GetSignature()); var xnaMethods = xnaType.GetMethods().Where(m => !m.IsSpecialName); var fnaMethods = fnaType.GetMethods().Where(m => !m.IsSpecialName); results.MethodsNotInFNA.AddRange(from m in xnaMethods where AreMethodsDifferent(m, fnaMethods.FirstOrDefault(m2 => !AreMethodsDifferent(m, m2))) orderby m.Name select m.GetSignature()); results.MethodsExtraInFNA.AddRange(from m in fnaMethods where !m.Name.EndsWith("EXT") where AreMethodsDifferent(m, xnaMethods.FirstOrDefault(m2 => !AreMethodsDifferent(m, m2))) orderby m.Name select m.GetSignature()); }
static void Main(string[] args) { Results results = new Results(); // Gather up all the XNA types from all redist assemblies. We're not looking at content pipeline stuff. var xnaTypes = GetAllTypes( typeof(Microsoft.Xna.Framework.Vector2).Assembly, // Microsoft.Xna.Framework.dll // lol: typeof(Microsoft.Xna.Framework.GamerServices.AvatarDescription).Assembly, // Microsoft.Xna.Framework.Avatar.dll typeof(Microsoft.Xna.Framework.Game).Assembly, // Microsoft.Xna.Framework.Game.dll // FNA.NetStub: typeof(Microsoft.Xna.Framework.GamerServices.GamerServicesDispatcher).Assembly, // Microsoft.Xna.Framework.GamerServices.dll typeof(Microsoft.Xna.Framework.Graphics.GraphicsDevice).Assembly, // Microsoft.Xna.Framework.Graphics.dll typeof(Microsoft.Xna.Framework.Input.Touch.TouchCollection).Assembly, // Microsoft.Xna.Framework.Input.Touch.dll // FNA.NetStub: typeof(Microsoft.Xna.Framework.Net.PacketReader).Assembly, // Microsoft.Xna.Framework.Net.dll typeof(Microsoft.Xna.Framework.Storage.StorageContainer).Assembly, // Microsoft.Xna.Framework.Storage.dll typeof(Microsoft.Xna.Framework.Media.Video).Assembly, // Microsoft.Xna.Framework.Video.dll typeof(Microsoft.Xna.Framework.Audio.WaveBank).Assembly // Microsoft.Xna.Framework.Xact.dll ); // Gather up the FNA types. // Assuming here that you've got FNA.dll in the output directory. var fnaTypes = GetAllTypes(Assembly.LoadFrom("FNA.dll")); // Figure out if there are any types in XNA that aren't in FNA results.TypesNotInFNA.AddRange(from p in xnaTypes where !fnaTypes.ContainsKey(p.Key) orderby p.Key select p.Value.FullName); // Figure out if there are any types in FNA that aren't in XNA results.TypesExtraInFNA.AddRange(from p in fnaTypes where !xnaTypes.ContainsKey(p.Key) // Ignore any types which aren't in the Microsoft.Xna.Framework* namespaces. where p.Key.StartsWith("Microsoft.Xna.Framework") // Ignore any EXT types. where !p.Key.EndsWith("EXT") orderby p.Key select p.Value.FullName); // Get the types that are in both APIs for further comparison var matchedTypes = from p in xnaTypes where fnaTypes.ContainsKey(p.Key) orderby p.Key select new { XNAType = p.Value, FNAType = fnaTypes[p.Key] }; // Perform per-type comparisons to look for method/field/property equivalence. foreach (var pair in matchedTypes) { TypeResults typeResults = new TypeResults { TypeName = pair.XNAType.FullName }; CompareTypes(pair.XNAType, pair.FNAType, typeResults); if (!typeResults.IsEmpty()) { results.TypeComparisons.Add(typeResults); } } using (var writer = new StreamWriter("SpecMismatches.txt")) { if (results.TypesNotInFNA.Count > 0) { writer.WriteLine("Types Not In FNA:"); foreach (var t in results.TypesNotInFNA) { writer.WriteLine("\t{0}", t); } writer.WriteLine(); } if (results.TypesExtraInFNA.Count > 0) { writer.WriteLine("Types Extra In FNA:"); foreach (var t in results.TypesExtraInFNA) { writer.WriteLine("\t{0}", t); } writer.WriteLine(); } if (results.TypeComparisons.Count > 0) { writer.WriteLine("Type Comparisons:"); foreach (var t in results.TypeComparisons) { writer.WriteLine("\t{0}", t.TypeName); if (t.FieldsNotInFNA.Count > 0) { writer.WriteLine("\t\tFields Not In FNA:"); foreach (var f in t.FieldsNotInFNA) { writer.WriteLine("\t\t\t{0}", f); } } if (t.FieldsExtraInFNA.Count > 0) { writer.WriteLine("\t\tFields Extra In FNA:"); foreach (var f in t.FieldsExtraInFNA) { writer.WriteLine("\t\t\t{0}", f); } } if (t.PropertiesNotInFNA.Count > 0) { writer.WriteLine("\t\tProperties Not In FNA:"); foreach (var p in t.PropertiesNotInFNA) { writer.WriteLine("\t\t\t{0}", p); } } if (t.PropertiesExtraInFNA.Count > 0) { writer.WriteLine("\t\tProperties Extra In FNA:"); foreach (var p in t.PropertiesExtraInFNA) { writer.WriteLine("\t\t\t{0}", p); } } if (t.EventsNotInFNA.Count > 0) { writer.WriteLine("\t\tEvents Not In FNA:"); foreach (var e in t.EventsNotInFNA) { writer.WriteLine("\t\t\t{0}", e); } } if (t.EventsExtraInFNA.Count > 0) { writer.WriteLine("\t\tEvents Extra In FNA:"); foreach (var e in t.EventsExtraInFNA) { writer.WriteLine("\t\t\t{0}", e); } } if (t.ConstructorsNotInFNA.Count > 0) { writer.WriteLine("\t\tConstructors Not In FNA:"); foreach (var c in t.ConstructorsNotInFNA) { writer.WriteLine("\t\t\t{0}", c); } } if (t.ConstructorsExtraInFNA.Count > 0) { writer.WriteLine("\t\tConstructors Extra In FNA:"); foreach (var c in t.ConstructorsExtraInFNA) { writer.WriteLine("\t\t\t{0}", c); } } if (t.MethodsNotInFNA.Count > 0) { writer.WriteLine("\t\tMethods Not In FNA:"); foreach (var m in t.MethodsNotInFNA) { writer.WriteLine("\t\t\t{0}", m); } } if (t.MethodsExtraInFNA.Count > 0) { writer.WriteLine("\t\tMethods Extra In FNA:"); foreach (var m in t.MethodsExtraInFNA) { writer.WriteLine("\t\t\t{0}", m); } } writer.WriteLine(); } } } }