提交 dc6b077f 编写于 作者: M Marc Gravell

Found a few framework bugs (recorded), and fixed internal properties mapping

上级 8d65caba
......@@ -5313,18 +5313,28 @@ public DefaultTypeMap(Type type)
_properties = GetSettableProps(type);
_type = type;
}
#if DNXCORE50
static bool IsParameterMatch(ParameterInfo[] x, ParameterInfo[] y)
{
if (ReferenceEquals(x, y)) return true;
if (x == null || y == null) return false;
if (x.Length != y.Length) return false;
for (int i = 0; i < x.Length; i++)
if (x[i].ParameterType != y[i].ParameterType) return false;
return true;
}
#endif
internal static MethodInfo GetPropertySetter(PropertyInfo propertyInfo, Type type)
{
return propertyInfo.DeclaringType == type ?
propertyInfo.GetSetMethod(true) :
if (propertyInfo.DeclaringType == type) return propertyInfo.GetSetMethod(true);
#if DNXCORE50
propertyInfo.DeclaringType.GetProperty(
propertyInfo.Name, propertyInfo.PropertyType,
propertyInfo.GetIndexParameters().Select(p => p.ParameterType).ToArray()
).GetSetMethod(true);
return propertyInfo.DeclaringType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.Single(x => x.Name == propertyInfo.Name
&& x.PropertyType == propertyInfo.PropertyType
&& IsParameterMatch(x.GetIndexParameters(), propertyInfo.GetIndexParameters())
).GetSetMethod(true);
#else
propertyInfo.DeclaringType.GetProperty(
return propertyInfo.DeclaringType.GetProperty(
propertyInfo.Name,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
Type.DefaultBinder,
......
......@@ -5,7 +5,7 @@
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
"summary": "A high performance Micro-ORM",
"description": "A high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc..",
"version": "1.41-beta2",
"version": "1.41-beta3",
"compile": [ "../Dapper NET40/*.cs", "../Dapper NET45/*.cs" ],
"title": "Dapper dot net",
"tags": [ "orm", "sql", "micro-orm" ],
......
......@@ -139,7 +139,7 @@ insert Posts ([Text],CreationDate, LastChangeDate) values (replicate('x', 2000),
private static void RunTests()
{
var tester = new Tests();
int fail = 0, skip = 0, pass = 0;
int fail = 0, skip = 0, pass = 0, frameworkFail = 0;
MethodInfo[] methods = typeof(Tests).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
var activeTests = methods.Where(m => HasAttribute<ActiveTestAttribute>(m)).ToArray();
if (activeTests.Length != 0) methods = activeTests;
......@@ -152,31 +152,49 @@ private static void RunTests()
skip++;
continue;
}
bool expectFrameworkFail = HasAttribute<FrameworkFail>(method);
Console.Write("Running " + method.Name);
try
{
method.Invoke(tester, null);
Console.WriteLine(" - OK!");
pass++;
if (expectFrameworkFail)
{
Console.WriteLine(" - was expected to framework-fail, but didn't");
fail++;
failNames.Add(method.Name);
}
else
{
Console.WriteLine(" - OK!");
pass++;
}
} catch(TargetInvocationException tie)
{
fail++;
Console.WriteLine(" - " + tie.InnerException.Message);
failNames.Add(method.Name);
if(tie.InnerException is TypeInitializationException)
if (expectFrameworkFail)
{
Console.WriteLine("> " + tie.InnerException.InnerException.Message);
frameworkFail++;
}
else
{
fail++;
failNames.Add(method.Name);
if (tie.InnerException is TypeInitializationException)
{
Console.WriteLine("> " + tie.InnerException.InnerException.Message);
}
}
}catch (Exception ex)
{
fail++;
Console.WriteLine(" - " + ex.Message);
failNames.Add(method.Name);
}
}
Console.WriteLine();
Console.WriteLine("Passed: {0}, Failed: {1}, Skipped: {2}", pass, fail, skip);
Console.WriteLine("Passed: {0}, Failed: {1}, Skipped: {2}, Framework-fail: {3}", pass, fail, skip, frameworkFail);
if(fail == 0)
{
Console.WriteLine("(all tests successful)");
......@@ -197,4 +215,12 @@ public sealed class ActiveTestAttribute : Attribute {}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class SkipTestAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class FrameworkFail : Attribute {
public FrameworkFail(string url) {
this.Url = url;
}
public string Url { get; private set; }
}
}
......@@ -281,6 +281,7 @@ public void TestNoDefaultConstructorBinary()
output.ToArray().IsSequenceEqualTo(orig);
}
#endif
// http://stackoverflow.com/q/8593871
public void TestAbstractInheritance()
{
......@@ -3180,6 +3181,22 @@ enum AnotherEnum : byte
A = 2,
B = 1
}
#if DNXCORE50
[FrameworkFail("https://github.com/dotnet/corefx/issues/1613")]
#endif
public void AdoNetEnumValue()
{
using (var cmd = connection.CreateCommand())
{
cmd.CommandText = "select @foo";
cmd.Parameters.AddWithValue("@foo", AnEnum.B);
object value = cmd.ExecuteScalar();
AnEnum val = (AnEnum)value;
val.IsEqualTo(AnEnum.B);
}
}
public void LiteralReplacementEnumAndString()
{
var args = new { x = AnEnum.B, y = 123.45M, z = AnotherEnum.A };
......@@ -3191,6 +3208,9 @@ public void LiteralReplacementEnumAndString()
y.Equals(123.45M);
z.Equals(AnotherEnum.A);
}
#if DNXCORE50
[FrameworkFail("https://github.com/dotnet/corefx/issues/1613")]
#endif
public void LiteralReplacementDynamicEnumAndString()
{
var args = new DynamicParameters();
......@@ -4326,7 +4346,9 @@ public void SO29343103_UtcDates()
var delta = returned - date;
Assert.IsTrue(delta.TotalMilliseconds >= -1 && delta.TotalMilliseconds <= 1);
}
#if DNXCORE50
[FrameworkFail("https://github.com/dotnet/corefx/issues/1612")]
#endif
public void Issue261_Decimals()
{
var parameters = new DynamicParameters();
......@@ -4336,7 +4358,9 @@ public void Issue261_Decimals()
var c = parameters.Get<Decimal>("c");
c.IsEqualTo(11.884M);
}
#if DNXCORE50
[FrameworkFail("https://github.com/dotnet/corefx/issues/1612")]
#endif
public void Issue261_Decimals_ADONET_SetViaBaseClass()
{
Issue261_Decimals_ADONET(true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册