Skip to content
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

Passing null to args for Activator.CreateInstance means no args #2111

Merged

Conversation

vitek-karas
Copy link
Member

The core already recognized empty array as no args, but null means the same thing.

This change also:

  • Fixes a bug when PublicConstructors was required but only PublicParameterlessConstructor were provided the warning message would not say what the requirement was.
  • Fixes another bug where Activator.CreateInstance(... NonPublic ) (only NonPublic binding) will not accept PublicParameterlessConstructor
  • Simplifies some of the code
  • Better matching for UnrecognizedReflectionAccessPattern and warnings in tests
  • Added tests

Fixes #2110

The core already recognized empty array as no args, but null means the same thing.

This change also:
* Fixes a bug when PublicConstructors was required but only PublicParameterlessConstructors were provided the warning message would not say what the requirement was.
* Simplifies some of the code
* Better matching for UnrecognizedReflectionAccessPattern and warnings in tests
* Added tests
@vitek-karas vitek-karas added this to the .NET 6.0 milestone Jun 24, 2021
@vitek-karas vitek-karas requested review from mateoatr and tlakollo June 24, 2021 15:18
@vitek-karas vitek-karas self-assigned this Jun 24, 2021
@vitek-karas vitek-karas requested a review from marek-safar as a code owner June 24, 2021 15:18
@vitek-karas vitek-karas merged commit c3d69fb into dotnet:main Jul 12, 2021
@vitek-karas vitek-karas deleted the FixActivatorCreateInstanceWithNull branch July 12, 2021 19:27
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…et/linker#2111)

The core already recognized empty array as no args, but null means the same thing.

This change also:
* Fixes a bug when PublicConstructors was required but only PublicParameterlessConstructors were provided the warning message would not say what the requirement was.
* Simplifies some of the code
* Better matching for UnrecognizedReflectionAccessPattern and warnings in tests
* Added tests

Commit migrated from dotnet/linker@c3d69fb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants