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

Merge changes from TFS - #1541

Merged
jkotas merged 1 commit into
dotnet:nmirrorfrom
dotnet-bot:from-tfs
Jul 18, 2016
Merged

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

Conversation

@dotnet-bot

Copy link
Copy Markdown
Collaborator

No description provided.

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]
@jkotas
jkotas merged commit 34f53e4 into dotnet:nmirror Jul 18, 2016
@dotnet-bot
dotnet-bot deleted the from-tfs branch July 18, 2016 19:07
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.

3 participants