This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
Merge changes from TFS - #761
Merged
Merged
Conversation
Implement EqualityComparer<T>.Default, and EqualityComparer<T>.Default correctly as well as make array IndexOf, LastIndexOf, and Sort function correctly Work 1. Helper function in EqualityComparerHelpers/ComparerHelpers to use template type loader to force the right comparer to be created when we can't know at compile time. 2. IL transform changes to ensure that the new helper functionality in the class library is kept alive to NUTC. 3. Modifications to well known type identification to allow types to be defined in well known non-corelib assemblies - Move the IL merge info csv parsing functionality out of DebugTypeRecords.cpp into a helper class that can be used by both TypeSystemHosting, and DebugTypeRecords - Infrastructure changes in STS hosting surface to allow a well known type to have an identifying type name and a compilation type name (to handle the single file case) - A table of non-CoreLib types to their known assemblies 4. Intrinsic recognition and replacement of the IL of the body of EquatableComparer<T>.get_Default and Comparer<T>.get_Default with custom IL that will call one of a variety of target methods depending on the situation. 5. Additionally, support for Array.IndexOf in an efficient fashion. Note: this uses similar tech, but can't use the general purpose EquatableComparer<T> code in all cases as that causes extraordinary bloat (measured up to 5% of file size). - Redirect calls to LowLevelEqualityComparer<T>.Equals to EqualityComparer<T>.Equals, and also do the same for get_Default in case anyone ever calls that. This allows the use of LowLevelEqualityComparer<T> to result in usage of EqualityComparer<T> - Perform fancy redirection for Array.GetComparerForReferenceTypesOnly<T>(). If T is a reference type or UniversalCanon, have this redirect to EqualityComparer<T>.get_Default, Otherwise, use the function as is. (will return null in that case) - Change the contents of the IndexOf functions to have a pair of loops. One for if GetComparerForReferenceTypesOnly returns null, and one for when it does not. - If it does not return null, call the EqualityComparer<T> code. - If it does return null, use a special function StructOnlyEquals<T>(). - Calls to that function result in calls to a pair of helper function in EqualityComparerHelpers (StructOnlyEqualsIEquatable, or StructOnlyEqualsNullable) depending on whether or not they are the right function to call. - The end result is that in optimized builds, we have the same single function compiled size characteristics that the old EqualsOnlyComparer<T>.Equals function had, but we maintain correctness as well. 6. And finally, to help out a little with file size, reference type array's now have a lazy generic reference to make their IList<T>.IndexOf and ICollection<T>.Contains functions work. 7. Redirect calls to LowLevelComparer<T>.Default to Comparer<T>.Default. This results in Array.Sort behaving correctly by using IComparable<T> when appropriate. 8. Add an optimization for Enum equality. With the current set of work, the size cost for applications appears to be roughly nil. There is an small impact on shared library size. My measurements show it to be fairly small. [tfs-changeset: 1570483]
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.