Uh oh!
There was an error while loading. Please reload this page.
Fix: Incorrect order of checks for TypeBuilder GetConstructor and GetField method - #53645
Conversation
janvorli
commented
Jun 8, 2021
cc: @eerhardt |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
GetConstructor and GetField had the same incorrect checks order comparing to GetMethod as in the CoreCLR. To keep the consistent solution, Mono has also been adjusted.
eerhardt
commented
Jun 14, 2021
@BartoszKlonowski - looks like it is still failing on mono. |
BartoszKlonowski
commented
Jul 2, 2021
@eerhardt Unfortunately, I've tried to understand the order of checks for Mono - |
eerhardt
commented
Jul 6, 2021
@lambdageek - any thoughts on the mono checks here? Can you help @BartoszKlonowski out? |
lambdageek
commented
Jul 6, 2021
@BartoszKlonowski I think you need something like this change in Mono's GetField and GetConstructor - ie instead always throwing if the type is a generic type definition you should instead check whether the generic type definition that |
BartoszKlonowski
commented
Jul 14, 2021
@lambdageek Thank you! Can you verify if I understood your advice correctly? |
| if (type == null) | ||
| throw new ArgumentException("Type is not generic", nameof(type)); | ||
There was a problem hiding this comment.
I think this needs the same code that GetMethod has:
if(typeisTypeBuilder&&type.ContainsGenericParameters)type=type.MakeGenericType(type.GetGenericArguments());(and same for GetField)
There was a problem hiding this comment.
I've tried, but it won't build.
There was a problem hiding this comment.
Looks like you also need
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:UnrecognizedReflectionPattern",
Justification = "Type.MakeGenericType is used to create a typical instantiation")]
| return res; | ||
| } | ||
| private static bool IsValidGetMethodType(Type type) |
There was a problem hiding this comment.
Can you put this method back where it was originally declared? That will make reviewing the change much easier. Also when people look at source history, will be able to see what change was made here easily. #Closed
Uh oh!
There was an error while loading. Please reload this page.
jeffhandley
commented
Jul 23, 2021
@eerhardt Since you're the most active reviewer on this, I assigned this PR to you for follow-up/decision before the RC1 snap. |
eerhardt
commented
Jul 26, 2021
@BartoszKlonowski - I left 2 pieces of feedback above. Let me know if you will address these, or if you want me to resolve them. That way we can move this PR forward. |
eerhardt
commented
Jul 27, 2021
Looks like the tests are still failing: |
eerhardt
commented
Jul 27, 2021
Tests are still failing: Are you able to run them locally? That would give you a faster turn around to get the CI green. |
BartoszKlonowski
commented
Aug 3, 2021
@eerhardt I'm afraid I won't be able to finish this, sorry. I really appreciate your help and support, but analysing this and fixing the issue with tests would require much more time than I currently have... |
steveharter
commented
Aug 4, 2021
@eerhardt if you want to take over this PR, please do so ASAP otherwise I recommend closing. Thanks |
eerhardt
commented
Sep 7, 2021
I'll get to this PR once I am finished with my 6.0 deliverables. |
Ensure checks are consistent across GetConstructor, GetField, and GetMethod for both coreclr and mono.
Uh oh!
There was an error while loading. Please reload this page.
This pull request fixes#45988
It changes the order of checks for
GetConstructorandGetFieldmethod according to the workflow ofGetMethod.Full explanation can be found in the linked issue.
Because of reordered checks of those method, unit tests had to be adjusted.
For both
GetFieldandGetConstructorthey now check whether for not generic type the element will be created without throwing.