Skip to content

Commit

Permalink
demonstrates a failing of the rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Iristyle committed Feb 4, 2011
1 parent 5516987 commit 064e99f
Showing 1 changed file with 21 additions and 0 deletions.
Expand Up @@ -181,6 +181,13 @@ public int GenericMethodArgument (Type type)
Type [] types = new Type [0];
return Array.IndexOf<Type> (types, type);
}

//TODO: currently a failure of the rule
//it wants us to use IReflect, but IReflect doesn't have a GetFields method with 0 parameters like Type does
public FieldInfo[] OverloadNotSupportedByInterface(Type type)
{
return type.GetFields();
}
}

public class SpecializedClass {
Expand Down Expand Up @@ -276,6 +283,13 @@ public int GenericMethodArgument (Type type)
MemberInfo [] types = new MemberInfo [0];
return Array.IndexOf<MemberInfo> (types, type);
}

//type could be IReflect
public FieldInfo[] OverloadNotSupportedByInterface(Type type)
{
//IReflect support this GetFields overload
return type.GetFields(BindingFlags.Public);
}
}

// resolve won't work when running unit test from makefiles
Expand Down Expand Up @@ -526,6 +540,13 @@ public void GenericMethodArgument ()
Assert.IsTrue(Runner.Defects [0].Text.IndexOf ("'System.Reflection.MemberInfo'") > 0);
}

[Test]
public void OverloadNotSupportedByInterface()
{
AssertRuleSuccess<GeneralizedClass>("OverloadNotSupportedByInterface");
AssertRuleFailure<SpecializedClass>("OverloadNotSupportedByInterface");
}

private bool HasMoreParametersThanAllowed (IMethodSignature method)
{
return (method.HasParameters ? method.Parameters.Count : 0) >= 1;
Expand Down

0 comments on commit 064e99f

Please sign in to comment.