Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The principle idea of type forwarding is very well explained in <a href="https://stackoverflow.com/questions/4553463/what-is-the-correct-way-to-use-typeforwardedtoattribute">this</a> question and <a href="http://www.codeproject.com/Articles/67999/Forwarding-a-type-from-one-assembly-to-another-Typ" rel="nofollow noreferrer">this</a> article and I'm not repeating the details here. In summary, however, the idea is to be able to reuse a library <code>A</code> <strong>without</strong> recompiling, even though it references a library <code>B</code> that <strong>is being replaced</strong> by library <code>C</code>. To that end, library <code>B</code> has to be modified such that it forwards the reference to library <code>C</code>, which is exactly what the TypeForwardedTo attribute does.</p> <p>How does this help you? Well, you could create your <code>ShimLib</code> such that it is referenced by all your projects, but uses conditional compilation and type forwarding to link it to the framework libraries if they exist. Fortunately, <a href="https://stackoverflow.com/questions/3462419/compatibility-pack-for-backporting-new-net-framework-features">someone already did</a> <a href="https://github.com/theraot/Theraot" rel="nofollow noreferrer">that for you</a> :)</p> <p><strong>Edit</strong> in response to Matt's comment: You're right, I overlooked that Theraot doesn't fall back to the original implementation. And I guess that will be very hard to achieve without recompiling. The best you can do is probably to follow <a href="https://stackoverflow.com/questions/2923210/c-sharp-conditional-compilation-and-framework-targets">this</a> strategy, i.e. to have different build configurations for the different framework versions. That way, you can conditionally compile the <code>TypeForwardedToAttribute</code>. At least, this saves you from having to duplicate code. If you <strong>really</strong> don't want to distribute different versions of your code, you might implement a bootstraper that <a href="https://stackoverflow.com/questions/6899707/way-to-determine-framework-version-without-registry">determines the framework version</a> and loads the version of your assembly that has been compiled using the build configuration for this version</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload