Type-forwarding

Can someone provide a real life scenario where Type Forward is used?

+5
source share
3 answers

BCL libraries typically use the attribute TypeForwardedTowhen different versions of a frame move a type between assemblies. For example, style delegates Func<>were moved from System.Core in framework 3.5 to mscorlib in framework 4.0.

You can view the use of this world in the real world by opening System.Core.dll from 4.0 in ildasm, double-clicking the Manifest node and looking for all lines similar to the following

.class extern forwarder System.Func`1
{
  .assembly extern mscorlib
}
.class extern forwarder System.Func`2
{
  .assembly extern mscorlib
}
.class extern forwarder System.Func`3
{
  .assembly extern mscorlib
}
+7
source

From msdn :

, , Example Utility.dll. Utility.dll , Example . Utility.dll Utility.dll , , Example, , Example Utility.dll.

Utility.dll , Example, TypeForwardedToAttribute. Utility.dll, Example , . , .

+5

In general, this seems to allow for more flexibility / refactoring in your library classes. I found the MSDN blog article useful. In this article, one example shows that an existing library is split into two separate DLLs, where the application using the libraries does not take care that the type is moved to another dll in newer versions of the dll due to type redirection.

Posting MSDN Messages: Type Redirection

0
source

All Articles