Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Merge changes from TFS - #1502

Merged
davidwrighton merged 1 commit into
dotnet:nmirrorfrom
dotnet-bot:from-tfs
Jul 12, 2016
Merged

davidwrighton merged 1 commit into
dotnet:nmirrorfrom
dotnet-bot:from-tfs

Conversation

@dotnet-bot

Copy link
Copy Markdown
Collaborator

No description provided.

… 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]
@davidwrighton
davidwrighton merged commit 4d03fd6 into dotnet:nmirror Jul 12, 2016
@dotnet-bot
dotnet-bot deleted the from-tfs branch July 12, 2016 00:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants