-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Conversation
This change adds tests for the following System.Reflection types: - Module - Pointer - RuntimeReflectionExtensions - TypeDelegator - TypeInfo Fixes #11766
@davidwrighton PTAL |
PropertyInfo property = typeof(PointerHolder).GetProperty("Property"); | ||
property.SetValue(obj, Pointer.Box((void*)value, typeof(char*))); | ||
Assert.Equal(value, (int)obj.Property); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test that passing the parameter in as a boxed IntPtr does something. (I believe that's also supposed to work)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed the Pointer portions of these changes and they look good to me.
corefx guideline: "var" can only be used in one of these: var x = new Something() |
@@ -1,5 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like VS bumped a bunch of .csproj - please remove these from the commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
|
||
namespace System.Reflection.Tests | ||
{ | ||
public class TestType : Stream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason why TestType derives from an api type?
I'm not sure where Stream stands in the api bringup effort but if we restore new members to that have to be overridden, you'll have to update this class and the various tests that depend on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted something with a large number of methods. I will change this to a custom type.
{ | ||
var fields = TypeInfo.DeclaredFields.ToList(); | ||
Assert.Equal(2, fields.Count); | ||
Assert.Equal("StuffHappened", fields[0].Name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're taking a dependency on the order in DeclaredFields returns fields - there's no guarantee of order.
This applies to all the Type apis that enumerate members on types. It's probably better to do an order-agnostic set compare.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change this.
{ | ||
Module.GetField(null); | ||
}); | ||
Assert.Null(ex.InnerException); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may be going overboard. Checking that it throws ArgumentNullException should be sufficient.
List<CustomAttributeData> customAttributes = Module.CustomAttributes.ToList(); | ||
Assert.Equal(2, customAttributes.Count); | ||
var fooAttribute = customAttributes[0]; | ||
Assert.Equal(typeof(FooAttribute), fooAttribute.AttributeType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to preview
Another ordering dependency
|
||
public class TypeInfoTests | ||
{ | ||
public TypeInfo TypeInfo => typeof(TestType).GetTypeInfo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming this property "TypeInfo" is confusing. Might be preferable just to inline so that people can more easily read the tests in isolation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ill rename it.
@dotnet-bot test Innerloop CentOS7.1 Debug Build and Test please (Jenkins Client issue) |
[Fact] | ||
public void GetFields() | ||
{ | ||
List<FieldInfo> fields = TestModule.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be sorted by name for test to work reliably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add that
LGTM. |
@dotnet-bot test Innerloop CentOS7.1 Release Build and Test please (Build Timeout) |
* Add tests for S.Reflection types This change adds tests for the following System.Reflection types: - Module - Pointer - RuntimeReflectionExtensions - TypeDelegator - TypeInfo Fixes dotnet/corefx#11766 * Use checked in IL binary. * Add tests passing IntPtr to reflection apis * Ignore case in Module.Name check. * Ignore ordering in GetRuntimeFields() * Fixup Project Files * Remove resharper file that found its way in. * Remove some ordering dependencies * s/var/{type} * Rename TypeInfo property to TestTypeInfo * Sort fields by name for consistency Commit migrated from dotnet/corefx@f6f97c2
This change adds tests for the following System.Reflection types:
Fixes #11766