This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
Merge NMirror to Master - #1544
Merged
Merged
Conversation
I'm going to be moving files between System.Private.Reflection and System.Private.CoreLib. Since VS is going to insist on updating the whitespace in the project files, I'm just going to go ahead and take care of that now so it doesn't obscure the real changes. [tfs-changeset: 1618180]
Merge Master to NMirror
Merge changes from TFS
https://github.com/dotnet/corefx/issues/9805 This prepares the Reflection codebase for the upcoming type hierarchy restoration (Type derives from MemberInfo - TypeInfo derives from Type.) Where we started at: - RuntimeType and RuntimeTypeInfo are separate object instances. - RuntimeTypeInfo delegates to RuntimeType for all apis that Type and TypeInfo share. Where we want to end up: - RuntimeType gone. All its functionality migrated to RuntimeTypeInfo. - RuntimeTypeInfo implements TypeInfo which implements Type. - AsType() and GetTypeInfo() reduced to "return this;" Where we are as of this commit: - RuntimeType and RuntimeTypeInfo are still separate object instances (blocked on parallel work to bring the Reflection surface area into Corelib.) - All RuntimeType functionality migrated to RuntimeTypeInfo. - RuntimeType reduced to a trivial shell that delegates everything to RuntimeTypeInfo. The one (and only) instantiated RuntimeType subclass is now RuntimeTypeTemporary which lives up in S.P.R.Core. - The RuntimeType abstract class has been cored out but still remains as this is a widely used exchange type and removing it will be a big task on its own. - Creating a Type always creates a RuntimeTypeInfo first, then returns the AsType(). - AsType() and GetTypeInfo() are a lot faster (basically "return this._someField;") - TypeInfos are now unified so people can use reference equality to test semantic equality. As before, we unify them by interning them into hash tables but hold them with weak pointers so abandoned types don't stay around forever. - Types have the same guarantee (as their lifetime is exactly that of the associated TypeInfo.) Other architectural changes as of this commit: ReflectionCoreNonPortable (the original "internal type factory api") has been gutted down to its essentials (obtaining a Type from a RuntimeTypeHandle, and creating a TypeLoadException (as the constructor it uses is still internal - this will probably change as a result of the big api restoration.) Everything else lives up in S.P.R.Core now. We kept all the EEType dissection and MdArray detection inside S.P.R.CoreLib but once we've decided the flavor we want, we thunk up to S.P.R.Core to do the actual Type creation. All its other functionality has been moved up to S.P.R.Core (TypeUnifier.cs, which is the new "internal type factory api.") Existing calls to ReflectionCoreNonPortable have been replaced by calls to TypeUnifier extension methods. We've simplified the RuntimeType hierarchy (in the interest of having less to port over and that some of the rationales for the original design no longer apply.) - No more EE and InspectionOnly variants for everything. The base RuntimeTypeInfo class keeps track of the type handle (this is set to default(RuntimeTypeHandle) for types without EETypes.) - As a result, that ugly ShadowInspectionOnlyNamedType hack is gone (yay!) - This does mean that converting a RuntimeTypeHandle to a Type does more work upfront than it used to whereas the old designed deferred "analyzing" the EEType as long as possible. Since we're now in a world when we can assume the mapping tables always succced for extracting the components of constructed types, some of the original rationale for the more complex lazy design has gone away. On the plus side, it means fewer "did we do this lazy work? If not do it now" checks on the actual api calls. One new RuntimeAugments api exposed from CoreLib (getting the last resort ToString() value from a RuntimeTypeHandle, for metadata-blocked Type.ToString()) "One" new RuntimeAugmentsCallback api exposed from S.P.R.Core for implementing Type.GetTypeFromHandle() (this "api" is actually 5 methods for the various type flavors - the EEType dissection and analysis still lives in CoreLib. It was too ugly to create a cross-assembly interface for.) Code Trends: - RuntimeType is on its way out so newly written code is based around RuntimeTypeInfo. This does require some extra AsType()/GetRuntimeTypeInfo() calls when interfacing with the old code. As more of the codebase becomes RuntimeTypeInfo based, these seams will go away. - ReflectionCoreNonPortable calls now discouraged in favor of the TypeUnifier extension methods. [tfs-changeset: 1618197]
Merge changes from TFS
https://github.com/dotnet/corefx/issues/9805 Remove RuntimeType type from S.P.CoreLib. It is now internal to S.P.R.Core. Tasks which used to require RuntimeType: - Checking if a type is implemented by the framework Now, call the extension method Type.IsRuntimeImplemented() (which simply checks for a private interface IRuntimeImplementedTYpe.) - Setting the RuntimeType's DebugName. We can live without it for the few weeks between now and the time Type and TypeInfo merge into the same object. RuntimeTypeTemporary holds a reference to its TypeInfo which maintains its own DebugName anyway. - Getting the typehandle w/out triggering an MME Introduced GetTypeHandleIfAvailable callback to S.P.R.Core - Array.CreateInstance() replacing an exception if the passed in element type is an open type. This code path was effectively unreachable anyway since MakeArrayType() works just fine on open types and has for a long time now. The following call to TypeHandle will throw the desired exception. - Using a Type as a key in a ConcurrentUnifier (which requires the key to implement IEquatable<>) Introduced a TypeUnificationKey wrapper. - An interop extension to detect if a Type can be reflected on. Moved the code to a callback to S.P.R.Core Other changes: - Removed obsolete/unused Corelib/R.Core interop methods for real now that apicompat has been silenced. - Disabled the IL transform that injects GetTypeInfo() into RuntimeType since RuntimeType is no longer where it expects to find it (and the transform is no longer needed since our new RuntimeType implements it the normal way.) [tfs-changeset: 1618263]
https://github.com/dotnet/corefx/issues/9805 Remove RuntimeType type from S.P.CoreLib. It is now internal to S.P.R.Core. Tasks which used to require RuntimeType: - Checking if a type is implemented by the framework Now, call the extension method Type.IsRuntimeImplemented() (which simply checks for a private interface IRuntimeImplementedTYpe.) - Setting the RuntimeType's DebugName. We can live without it for the few weeks between now and the time Type and TypeInfo merge into the same object. RuntimeTypeTemporary holds a reference to its TypeInfo which maintains its own DebugName anyway. - Getting the typehandle w/out triggering an MME Introduced GetTypeHandleIfAvailable callback to S.P.R.Core - Array.CreateInstance() replacing an exception if the passed in element type is an open type. This code path was effectively unreachable anyway since MakeArrayType() works just fine on open types and has for a long time now. The following call to TypeHandle will throw the desired exception. - Using a Type as a key in a ConcurrentUnifier (which requires the key to implement IEquatable<>) Introduced a TypeUnificationKey wrapper. - An interop extension to detect if a Type can be reflected on. Moved the code to a callback to S.P.R.Core Other changes: - Removed obsolete/unused Corelib/R.Core interop methods for real now that apicompat has been silenced. - Disabled the IL transform that injects GetTypeInfo() into RuntimeType since RuntimeType is no longer where it expects to find it (and the transform is no longer needed since our new RuntimeType implements it the normal way.) [tfs-changeset: 1618263]
Member
Author
|
@dotnet-bot test this please |
https://github.com/dotnet/corefx/issues/9805 Preparing Reflection to make it easy to remove RuntimeType. The actual switch is going to be a mostly automated "mass-replace RuntimeType with RuntimeTypeInfo, add GetTypeInfo() calls as necessary and don't think about things too much." Based on lessons learned by a few trial runs of this, this commit preps the codebase ahead of time to minimize the number of things we have to think about. Some of the code changes may look strange (as in adding extra conversions from Type/TypeInfo) but that's because we're optimizing for where we're going rather than where we are. In particular, calls to RuntimeTypeInfo.RuntimeType and CastToType() will become a "return this" and will be removed entirely. - Consolidate the Type->TypeInfo conversion helpers (get rid of the non-generic GetRuntimeInfo() extension method as it doesn't add much.) - Remove code where we cast to or do "is/as" checks against RuntimeType or RuntimeTypeInfo. - Preemptively imported the necessary namespaces (S.R.R.General/S.R.R.TypeInfo) on the various files so I don't have to do this during the big switch. - Synced up RuntimeTypeInfo's internal surface area with RuntimeType's. We can remove some of these after the switch since they are a bit redundant. - Added ICloneable to RuntimeTypeInfo because ummm... it was added to RuntimeType as part of the api syncup. [tfs-changeset: 1618386]
https://github.com/dotnet/corefx/issues/9805 Preparing Reflection to make it easy to remove RuntimeType. The actual switch is going to be a mostly automated "mass-replace RuntimeType with RuntimeTypeInfo, add GetTypeInfo() calls as necessary and don't think about things too much." Based on lessons learned by a few trial runs of this, this commit preps the codebase ahead of time to minimize the number of things we have to think about. Some of the code changes may look strange (as in adding extra conversions from Type/TypeInfo) but that's because we're optimizing for where we're going rather than where we are. In particular, calls to RuntimeTypeInfo.RuntimeType and CastToType() will become a "return this" and will be removed entirely. - Consolidate the Type->TypeInfo conversion helpers (get rid of the non-generic GetRuntimeInfo() extension method as it doesn't add much.) - Remove code where we cast to or do "is/as" checks against RuntimeType or RuntimeTypeInfo. - Preemptively imported the necessary namespaces (S.R.R.General/S.R.R.TypeInfo) on the various files so I don't have to do this during the big switch. - Synced up RuntimeTypeInfo's internal surface area with RuntimeType's. We can remove some of these after the switch since they are a bit redundant. - Added ICloneable to RuntimeTypeInfo because ummm... it was added to RuntimeType as part of the api syncup. [tfs-changeset: 1618386]
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.