This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
Merge changes from TFS - #1502
Merged
Merged
Conversation
… default parameters mroe consistent with Desktop/CoreCLR. I added more tests for MethodInfo.Invoke on methods with default parameters and in the process uncovered several issues with the existing code. Issues found and fixed: - The default param string reader (InvokeUtils.cs) incorrectly reads 0x8001 as Int64.MinValue. In fact it's a first character of a multi-char representation of a large negative number. Added a special case of the 0x0001 which is Int64.MinValue (just like in the writer). - Fixed a bug in the writer which would write a 0 number as two 0x0000 0x0000, while the reader would only read the first one and return 0, and thus the next number read would read the second zero and return wrong data. - We wrote all UIntXX values as IntXX values. Trying to invoke a method with default parameter of type UInt32 (for example) would fail, since the invoke code will later on check that the types of parameters match, and they would not (we would use Int32 value for the default parameter). Fixed this by adding more types into the "enum" to cover the unsigned variants as well. Note that this is technically a breaking change in the format (old readers won't be able to read new data), but we should be fine with such changes in ProjectN right now. - C# compiler behavior around default values for decimal parameters is such that if the typical default parameter syntax is used (p = value), it would generate an optional parameter and add the DecimalConstantAttribute on it. Our code would only see the "optional" part and treat it as an optional parameter without a default value (And thus fail runtime, since we would try to pass Type.Missing as its value and fail the parameter type checks). Notes: - Even though we already have some existing default param invoke tests in the unit tests, it was intentional to add the new tests to the above location. This test file is the same with the CoreFX version and the intent is to check in the same changes to the CorFX repo. - I verified that the exact same tests are passing on both Desktop and CoreCLR as well (so the behaviors are consistent between the runtimes). - I am working on changing the code to not use the default param string mechanism and instead use metadata, but at least for the time being we plan to keep the default param string mechanism for delegates. These fixes are aplicable there as well. [tfs-changeset: 1617133]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.