Konstantin Koch f081f8632a two commits were missing, both by KorsarNek:
"Removed the SupportedPlatformsImpl classes and replaced them with a new SupportedPlatforms attribute on the assembly level.
Removed a few class constructors which could cause problems when loading a game.
Made ResetElapsedTime in the game class reset to 0 instead of TimeSpan.MinValue.
Removed the restriction in the InputDeviceFactory for which InputDevices are supported.
Added a Logger for Metro which works with the current Logger implementation.
Changed that when a platform is recognized that is higher than Windows 8, it gets treated like Windows 8, not like Windows 7.
Due to the SupportedPlatforms change, the assembly loader is now faster in finding out which assemblies contains addIns. For not Metro system, it's also added that a warning gets written if an AddIn references a different ANX version than that of the running assembly.
OpenGL and DirectX have been updated to the newest versions.
XAudio system uses now the same SharpDX version as all the other systems.
ParameterBuffer for WindowsMetro gets now correctly created by considering the size constraints for constant buffers.
Fixed an erroneous finalizer in the xaudio system.
Made the metro projects convert to Windows 8.1, as Windows 8.0 is not supported by the newer SharpDX versions. It's now also necessary to use at least Visual Studio 2013 to build the Metro versions.
Made the samples work again on Windows."

"Fixed the creation of the swap chain for windows metro and removed the dependency of the Metro Rendersystem onto the Metro Platformsytem.
All occurrences of WindowHandles have been replaced with a custom WindowHandle type which should work out of the box in most cases, but does still represent a breaking change to XNA.
The ProjectConverter for Metro was adjusted so that with just changing the way the application is initialized, most projects that worked with ANX before should now work under win rt. The sample SimpleNoContent does now work out of the box for win rt, after a project conversion.
The application name for win rt apps is now a guid, the display name stayed the same though. That's to be more compliant with the way win rt apps are normally created.
The default namespace and namespace of the classes for the Sample "SimpleNoContent" is renamed from "SimpleModernUI" to "SimpleNoContent".
With the new way win rt apps are initialized for ANX, it's necessary to first create the WindowsGameHost for WinRT with a handler how to create the game instance and give that to the CoreApplication object to run it.
Also took care of a few annoying bugs when working with win rt and ANX where no InputDevices could be created on the first frame (Issue #1164 ) and that it wasn't possible to use the localfolder of the application on the first update and all the other stuff for which an instance of the Application class was necessary."
2015-03-29 13:48:33 +02:00

325 lines
8.6 KiB
C#

using ANXStatusComparer.Excludes;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANXStatusComparer.Data
{
public class BaseObject
{
#region Public
/// <summary>
/// The type of the enumeration.
/// </summary>
public Type Handle
{
get;
private set;
}
public int PercentageComplete
{
get;
private set;
}
public bool HasPercentageAttribute
{
get;
private set;
}
public Dictionary<string, BaseObjectElement> Methods
{
get;
private set;
}
public Dictionary<string, BaseObjectElement> Fields
{
get;
private set;
}
public Dictionary<string, BaseObjectElement> Properties
{
get;
private set;
}
public Dictionary<string, BaseObjectElement> Events
{
get;
private set;
}
public List<string> ParentNames
{
get;
private set;
}
#endregion
#region Constructor
/// <summary>
/// Create a new BaseObject data holder.
/// </summary>
/// <param name="setType">Type of the object.</param>
public BaseObject(Type setType)
{
Handle = setType;
Methods = new Dictionary<string, BaseObjectElement>();
Fields = new Dictionary<string, BaseObjectElement>();
Properties = new Dictionary<string, BaseObjectElement>();
Events = new Dictionary<string, BaseObjectElement>();
ParentNames = new List<string>();
if (Handle.BaseType != null)
{
ParentNames.Add(Handle.BaseType.Name);
}
foreach (Type interfaceName in Handle.GetInterfaces())
{
ParentNames.Add(interfaceName.Name);
}
HasPercentageAttribute = false;
foreach (Attribute attribute in Handle.GetCustomAttributes(false))
{
if (attribute.GetType().FullName ==
"ANX.Framework.NonXNA.Development.PercentageCompleteAttribute")
{
var property = attribute.GetType().GetProperty("Percentage");
PercentageComplete = (int)property.GetValue(attribute, null);
HasPercentageAttribute = true;
}
}
BindingFlags bindingFlags = BindingFlags.Public |
BindingFlags.Static | BindingFlags.Instance |
BindingFlags.DeclaredOnly | BindingFlags.NonPublic;
#region Find Events
foreach (EventInfo instanceEvent in Handle.GetEvents(bindingFlags))
{
MethodInfo addMethod = instanceEvent.GetAddMethod();
MethodInfo removeMethod = instanceEvent.GetRemoveMethod();
if ((addMethod != null &&
(addMethod.IsPublic || addMethod.IsFamily)) ||
(removeMethod != null &&
(removeMethod.IsPublic || removeMethod.IsFamily)))
{
string keyName = AssemblyComparer.TranslateNamespaceName(
instanceEvent.ToString());
Events.Add(keyName, new EventElement(instanceEvent, keyName));
}
}
#endregion
#region Find Fields
foreach (FieldInfo field in Handle.GetFields(bindingFlags))
{
if (field.IsPublic == false &&
field.IsFamily == false)
{
continue;
}
string keyName = AssemblyComparer.TranslateNamespaceName(
field.ToString());
Fields.Add(keyName, new FieldElement(field, keyName));
}
#endregion
#region Find Properties
foreach (PropertyInfo property in Handle.GetProperties(bindingFlags))
{
MethodInfo getMethod = property.GetGetMethod();
MethodInfo setMethod = property.GetSetMethod();
if ((getMethod != null &&
(getMethod.IsPublic || getMethod.IsFamily)) ||
(setMethod != null &&
(setMethod.IsPublic || setMethod.IsFamily)))
{
string keyName = AssemblyComparer.TranslateNamespaceName(
property.ToString());
Properties.Add(keyName, new PropertyElement(property, keyName));
}
}
#endregion
#region Find Methods
foreach (MethodInfo method in Handle.GetMethods(bindingFlags))
{
if(method.IsSpecialName &&
(method.Name.StartsWith("get_") ||
method.Name.StartsWith("set_") ||
method.Name.StartsWith("add_") ||
method.Name.StartsWith("remove_")))
{
continue;
}
if(method.IsPublic == false &&
method.IsFamily == false)
{
continue;
}
string keyName = AssemblyComparer.TranslateNamespaceName(
method.ToString());
Methods.Add(keyName, new MethodElement(method, keyName));
}
foreach (ConstructorInfo method in Handle.GetConstructors(bindingFlags))
{
if (method.IsPublic == false &&
method.IsFamily == false)
{
continue;
}
string keyName = AssemblyComparer.TranslateNamespaceName(
method.ToString());
Methods.Add(keyName, new ConstructorElement(method, keyName));
}
#endregion
}
#endregion
public override string ToString()
{
return (HasPercentageAttribute ? PercentageComplete.ToString("000") : "-?-") + "% - " + Handle.FullName;
}
#region IsCorrect
public bool IsCorrect(BaseObject otherObject, IEnumerable<Exclude> excludes,
ResultData.WrongObjectPair wrongPair)
{
bool isCorrect = true;
if (CompareLists(Methods, otherObject.Methods, excludes, wrongPair) == false)
isCorrect = false;
if (CompareLists(Events, otherObject.Events, excludes, wrongPair) == false)
isCorrect = false;
if (CompareLists(Fields, otherObject.Fields, excludes, wrongPair) == false)
isCorrect = false;
if (CompareLists(Properties, otherObject.Properties, excludes, wrongPair) == false)
isCorrect = false;
foreach(string parent in ParentNames)
{
if(otherObject.ParentNames.Contains(parent) == false)
{
wrongPair.MissingParents.Add(parent);
isCorrect = false;
}
}
if (Handle.IsPublic != otherObject.Handle.IsPublic)
{
wrongPair.WrongAccesses.Add("[IsPublic(XNA:" + Handle.IsPublic + "|ANX:" + otherObject.Handle.IsPublic + ")] ");
isCorrect = false;
}
if (Handle.IsSealed != otherObject.Handle.IsSealed)
{
wrongPair.WrongAccesses.Add("[IsSealed(XNA:" + Handle.IsSealed + "|ANX:" + otherObject.Handle.IsSealed + ")] ");
isCorrect = false;
}
if (Handle.IsAbstract != otherObject.Handle.IsAbstract)
{
wrongPair.WrongAccesses.Add("[IsAbstract(XNA:" + Handle.IsAbstract + "|ANX:" + otherObject.Handle.IsAbstract + ")] ");
isCorrect = false;
}
if (Handle.IsGenericType != otherObject.Handle.IsGenericType)
{
wrongPair.WrongAccesses.Add("[IsGenericType(XNA:" + Handle.IsGenericType + "|ANX:" +
otherObject.Handle.IsGenericType + ")] ");
isCorrect = false;
}
if (Handle.IsVisible != otherObject.Handle.IsVisible)
{
wrongPair.WrongAccesses.Add("[IsVisible(XNA:" + Handle.IsVisible + "|ANX:" + otherObject.Handle.IsVisible +
")] ");
isCorrect = false;
}
return isCorrect;
}
#endregion
#region CompareLists
private bool CompareLists(Dictionary<string, BaseObjectElement> dictXna, Dictionary<string, BaseObjectElement> dictAnx, IEnumerable<Exclude> excludes,
ResultData.WrongObjectPair wrongPair)
{
bool isCorrect = true;
foreach (var pair in dictXna)
{
string methodKey = pair.Key;
if (excludes.Any((x) => x.ShouldExclude(pair.Value)))
continue;
if (dictAnx.ContainsKey(methodKey) == false)
{
isCorrect = false;
wrongPair.XnaElements.Add(dictXna[methodKey]);
wrongPair.AnxElements.Add(null);
continue;
}
if (dictXna[methodKey].IsCorrect(dictAnx[methodKey]) == false)
{
isCorrect = false;
wrongPair.XnaElements.Add(dictXna[methodKey]);
wrongPair.AnxElements.Add(dictAnx[methodKey]);
}
}
return isCorrect;
}
#endregion
#region Tests
private class Tests
{
private class TestClass
{
public static int StaticMethod1(string value)
{
return 1;
}
public void NormalMethod() { }
protected void Protected() { }
private void Private() { }
internal void Internal() { }
}
public static void TestMethodGet()
{
Type classType = typeof (TestClass);
BindingFlags bindingFlags = BindingFlags.Public |
BindingFlags.Static | BindingFlags.Instance |
BindingFlags.DeclaredOnly | BindingFlags.NonPublic;
Console.WriteLine("Members");
Console.WriteLine("-----------------");
foreach (MemberInfo info in classType.GetMembers(bindingFlags))
{
Console.WriteLine(info.ToString());
}
}
}
#endregion
}
}