-
Notifications
You must be signed in to change notification settings - Fork 128
Fix Activator.CreateInstance case #2146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ public static void Main () | |
TestNullArgsOnKnownType (); | ||
TestNullArgsOnAnnotatedType (typeof (TestType)); | ||
TestNullArgsNonPublicOnly (typeof (TestType)); | ||
TestNullArgsNonPublicWithNonPublicAnnotation (typeof (TestType)); | ||
|
||
CreateInstanceWithGetTypeFromHierarchy.Test (); | ||
} | ||
|
@@ -532,6 +533,15 @@ private static void TestNullArgsNonPublicOnly ( | |
Activator.CreateInstance (type, BindingFlags.NonPublic | BindingFlags.Instance, null, null, CultureInfo.InvariantCulture); | ||
} | ||
|
||
[Kept] | ||
[ExpectedNoWarnings] | ||
private static void TestNullArgsNonPublicWithNonPublicAnnotation ( | ||
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor | DynamicallyAccessedMemberTypes.NonPublicConstructors), | ||
KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] Type type) | ||
{ | ||
Activator.CreateInstance (type, nonPublic: true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this test work? I assume we're trying to assert that the given type has its non-public constructors preserved, but how are we confirming that we're also not marking the other public constructors? Wasn't the problem in the PR that we were marking extra things and getting additional warnings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really - the problem is that PublicParameterlessConstructor | NonPublicConstructors was an annotation which was not considered sufficient for calling CreateInstance(type, true). Which it should be. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I may have given you the wrong impression when we chatted - this additional warning was because we tried to require (not mark) extra things on the input (which was an abstract DAMT value). But the extra requirements also would have resulted in extra things being marked for concrete input types (that just wasn't the failure mode we happened to hit). |
||
} | ||
|
||
[Kept] | ||
class CreateInstanceWithGetTypeFromHierarchy | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.