This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
Merge NMirror to Master - #1513
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]
…ing for MethodInstantiation and support signatures on member references. [tfs-changeset: 1617140]
Merge changes from TFS
When looking at a dump, I realized our code below doesn't really do anything:
return new InvalidCastException(String.Format(
SR.InvalidCast_Com,
comObjectDisplayName,
interfaceDisplayName,
interfaceType.GetInterfaceGuid().ToString("B").ToUpper(),
errorMessage));
Because SR.InvalidCast_Com is "InvalidCast_Com" and rest of the args get lost. Switching to SR.Format fixes this since it would concat the rest of the arguments to InvalidCast_Com so the message is still useful.
I'm adding il2ilcr to broaden the awareness - it is pretty costly to have one of those bugs since you lose valuable insight (like in the dump case we lost the HRESULT and error message in the failed QI). I did a scan in System.Private.Interop and fixed all instances.
The new error message is (ignore the apparently successful message since I forgot to change the HR when I force the error path).
0:000> du 0x01b563cc+0x8
01b563d4 "InvalidCast_ComSystem.__ComObjec"
01b56414 "t, MissingMetadataType, {F5EA435"
01b56454 "E-A7DB-37E0-B506-A9B69802CDD1}, "
01b56494 "The operation completed successf"
01b564d4 "ully. (Excep_FromHResult 0x0). F"
01b56514 "or more information, visit http:"
01b56554 "//go.microsoft.com/fwlink/?LinkI"
01b56594 "d=623485"
This is apparently much more useful than "InvalidCast_Com" :)
[tfs-changeset: 1617170]
Merge changes from TFS
Merge changes from TFS
…'s request - here's the checkin comment for that changeset: Fix TODO in InitializeFieldDefinition - this caused incorrect field offsets in explicit layout types. While investigating JIT test failures (jit\SIMD\BoxUnbox.csproj and jit\SIMD\VectorMatrix.csproj) I found that the dynamic type loader computes an incorrect size for structs with explicit layout. As it turns out, the native metadata is already wrong and doesn't contain the field offset specified in the source via the FieldOffset attribute (and present in EMCA metadata). The fix is simply to get the offset from the ECMA metadata reader. That API however returns -1 for the case where no explicit offset was specified, so that needs to be checked for. [tfs-changeset: 1617255]
Merge changes from TFS
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.