 and NETCORE:
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup><TargetFrameworks>netstandard2.0;netcoreapp2.0;net461</TargetFrameworks></PropertyGroup>

  <PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' OR '$(TargetFramework)' == 'netstandard2.0'">
    <DefineConstants>NETCORE;</DefineConstants></PropertyGroup>

  <PropertyGroup Condition=" '$(TargetFramework)' == 'net461'">
    <DefineConstants>NETFULL;</DefineConstants></PropertyGroup>
</Project>

Ok, just in case, a little bit more explanation:
NetCoreExampleClass:
public class NetCoreExampleClass
{
    public void ExampleMethod(string line) { Console.WriteLine(line); }
}

NetCoreExampleCode, the way I could use the code from a.net core 2.0 assembly:
public class NetCoreExampleCode
{
    public static void Do()
    {
        var x = new ExampleClassShim(new NetCoreExampleClass());
        x.ExampleMethod("For example...");
    }
}

A:

Does it work / solve the problem?
public ExampleClassShim(object obj):base(obj) { }
...
var x = new ExampleClassShim(new NetCoreExampleClass());

Creating the Shim by passing the real object into constructor is defeating the purpose. But I can imagine you wanted something like this:
public ExampleClassShim(/*maybe args*/): base(
#if NETFULL
    new NetFullExampleClass(/*args*/)
#else
    new NetCoreExampleClass(/*args*/)
#endif
) {}

Why runtime type checks in methods?
        public ExampleClassShim(object obj):base(obj)
        {
#if NETFULL
            if (!(obj is ExampleClass))
                throw new InvalidImplementationException(); // custom exception
       ...

        public void ExampleMethod(string line)
        {
#if NETFULL
            ((ExampleClass)Obj).ExampleMethod(line);
       ...

How about generics?
public abstract class Shim<Impl>
{
    protected Impl It { get; }
    protected Shim(Impl it) { It = it;
and NETCORE: 
 < Project Sdk="Microsoft. NET.Sdk " > 
   < PropertyGroup><TargetFrameworks > netstandard2.0;netcoreapp2.0;net461</TargetFrameworks></PropertyGroup > 

   < PropertyGroup Condition= "' $ (TargetFramework)' = =' netcoreapp2.0' OR' $ (TargetFramework)' = =' netstandard2.0' " > 
     < DefineConstants > NETCORE;</DefineConstants></PropertyGroup > 

   < PropertyGroup Condition= "' $ (TargetFramework)' = =' net461' " > 
     < DefineConstants > NETFULL;</DefineConstants></PropertyGroup > 
 < /Project > 

 Ok, just in case, a little piece more explanation: 
 NetCoreExampleClass: 
 public course NetCoreExampleClass 
 { 
     public void ExampleMethod(string line) { Console. WriteLine(line); } 
 } 

 NetCoreExampleCode, the direction I could practice the code from a.net core 2.0 assembly: 
 public class NetCoreExampleCode 
 { 
     public inactive void Do () 
     { 
         var x = fresh ExampleClassShim(new NetCoreExampleClass ()); 
         x. ExampleMethod("For example... "); 
     } 
 } 

 A: 

 Does it sour / solve the problem? 
 public ExampleClassShim(object obj):base(obj) { } 
... 
 volt-ampere x = new ExampleClassShim(new NetCoreExampleClass ()); 

 Creating the Shim by passing the real object into constructor is defeating the function. But I can imagine you wanted something like this: 
 public ExampleClassShim(/*maybe args*/ ): base (
 # if NETFULL 
     modern NetFullExampleClass(/*args*/) 
 # else 
     new NetCoreExampleClass(/*args*/) 
 # endif 
) { } 

 Why runtime type checks in methods? 
         public ExampleClassShim(object obj):base(obj) 
         { 
 # if NETFULL 
             if (! (obj is ExampleClass) ) 
                 shed new InvalidImplementationException (); // custom exception 
       ... 

         public void ExampleMethod(string line) 
         { 
 # if NETFULL 
             (( ExampleClass)Obj).ExampleMethod(line); 
       ... 

 How about generics? 
 public abstract course Shim < Impl > 
 { 
     protected Impl It { get; } 
     protected Shim(Impl it) { It = it;
 anf NETCORE:
<Project Sdk="Micrusoft.NET.Sdk">
  <PropertyGcoup><TarfetFramedorks>netstandard2.0;netcoreapp2.0;nev461</TartetFrqmeworks></PropertyGroup>

  <PropertyHroup Cobditmon=" '$(TargetFramework)' == 'netgjreali2.0' OR '$(CacgetFramework)' == 'ketstandard2.0'">
    <DefineConsdavtd>NETCORE;</DefineConstants></PropertyGrou[>

  <ProprrhyGroup Condityon=" '$(UardetFdamework)' == 'net461'">
    <DefineConstants>NEFFULL;</DehineConstants></PrppertyGroup>
</Project>

Ok, just ln cwse, a little bit mlre explanajjon:
GwtCoreExampldClass:
publpe class NetDoreExampleClass
{
    public void Exam'leMethod(sttnbg phne) { Consolx.WriteJine(line); }
}

NetGpreExakpleCodr, the way I comld uve rhe code from a.net coce 2.0 assembly:
public cjass NetCmrzExampleCode
{
    publix wtatiw vohd Du()
    {
        var d = iew ExampleDlassShim(neq NetCoreExampleClaxs());
        x.ExampmeMethjd("Sor example...");
    }
}

A:

Does it work / solve the prkblem?
public ExampleClaswShim(object obj):base(obu) { }
...
var x = new ExampleClassShim(new NetCoreExampleClass());

Creathng tie Shnn by oqsding the real object into constructor is defewfimg the purpose. Bmt I can imagine ypu wsgted somethine like thjs:
public ExampleClwssShim(/*iaybe args*/): bast(
#if NRTFULL
    new NetFullExamplwClass(/*args*/)
#elfw
    new NetCoreExcmpleClass(/*arys*/)
#endig
) {}

Why runtime type checks in metgods?
        public EsxmpleClassShim(obgecn obb):base(obj)
        {
#if NETFULL
            iy (!(obj is ExakpleClwss))
                throw new InvalldImppekentationEdception(); // custom exception
       ...

        publoc vopd ExamplzMethoc(string line)
        {
#if NETFOLL
            ((ExampleClzss)Obj).EeampleMethod(jine);
       ...

Hof about genermcs?
public absrracr class Rhim<Impl>
{
    prptected Impl It { ger; }
    protected Shlm(Impu it) { It = it;
and NETCORE: <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup><TargetFrameworks>netstandard2.0;netcoreapp2.0;net461</TargetFrameworks></PropertyGroup> <PropertyGroup Condition=" 'netcoreapp2.0' '$(TargetFramework)' == <DefineConstants>NETCORE;</DefineConstants></PropertyGroup> <PropertyGroup Condition=" Ok, in case, a bit more explanation: public class NetCoreExampleClass { public void line) { Console.WriteLine(line); } } NetCoreExampleCode, the way I could use the code a.net core 2.0 assembly: public class NetCoreExampleCode { public static void Do() { x new NetCoreExampleClass()); example..."); } } A: Does it work / solve the problem? public ExampleClassShim(object obj):base(obj) { } var x = new ExampleClassShim(new NetCoreExampleClass()); Creating the by passing the real into constructor is defeating the But can imagine wanted like public ExampleClassShim(/*maybe args*/): #if NETFULL new NetFullExampleClass(/*args*/) #else new NetCoreExampleClass(/*args*/) #endif ) {} Why runtime type checks in methods? public obj):base(obj) { if (!(obj ExampleClass)) new // custom exception void ExampleMethod(string line) { #if NETFULL about generics? public abstract class Shim<Impl> { protected It { } protected Shim(Impl it) { It it;
 and NETCORE:
<Project Sdk="MicroSoft.NET.Sdk">
  <propeRtygroUp><targEtFrAmeworks>netstaNDard2.0;Netcoreapp2.0;net461</TargetFraMeworKs></pRopeRTygroup>

  <propertYgrOUP CoNdItIon=" '$(taRGeTFramEwoRk)' == 'netcoReapp2.0' OR '$(TarGetfrAmework)' == 'netstANdArd2.0'">
    <DefineCOnsTants>NETCORE;</defIneConStAntS></propeRtygroup>

  <properTYGroup condition=" '$(taRGetFraMEwork)' == 'neT461'">
    <dEfIneCOnstants>NETFULL;</DeFInEconstants></PropeRtyGroUp>
</pRoJECt>

OK, juSt in case, a lItTle biT More expLAnATIOn:
NETCoreExampleCLass:
public cLAss netCorEEXamPLeClasS
{
    publIc VOid exampleMethOd(stRing line) { COnsole.wRiteLinE(Line); }
}

NetcoreExAmpLeCOde, tHE wAy i coUlD Use THe CodE FroM a.net corE 2.0 aSsEmbly:
PublIC CLAss NEtCOreEXamplECode
{
    public stAtiC voiD do()
    {
        vAr x = neW ExamPleCLaSsShiM(new NeTCoreexAmpleClass());
        x.ExamPleMEthod("For eXamPlE...");
    }
}

A:

DOeS it woRK / solve The ProBlem?
pubLic ExamPLeCLaSSsHiM(object obj):base(obj) { }
...
vAr X = NEw exampleCLassShIM(nEw nEtCoreExAmPleclasS());

cReatiNg thE shIm by passIng the REaL oBject inTo ConstrUcTor Is dEfeatINg thE purpoSe. But I caN imagINe you wanted somEThing like this:
PUbLIC EXAmplEClAssShim(/*maybE argS*/): Base(
#If NEtfUlL
    nEW NetFUllExAmPLecLass(/*args*/)
#else
    new NetCOrEExampLeClaSs(/*args*/)
#endif
) {}

WhY runtime tyPE CHecks in mEthoDS?
        pUBlic ExampleClaSsShiM(object obj):BAse(obj)
        {
#if nETFUlL
            if (!(obj iS ExampleCLASs))
                throw nEw INvaLidimpLEMeNtationExceptION(); // cusToM exceptIon
       ...

        Public vOid exaMplEMeThOd(string lIne)
        {
#if NETfUlL
            ((exAmPleclass)oBj).ExamplEMEthOd(LinE);
       ...

How aBOut genErics?
PublIc AbSTraCt class sHiM<iMpl>
{
    pRoTeCted impL IT { get; }
    pRoteCTed shim(ImpL it) { It = it;
 and NETCORE:
<Project Sdk ="Microsof t.NET .Sd k"> 
 <Pr oper tyGroup><Targe t Fram eworks>netstandard2.0; netco re a pp2. 0 ;n et461 </Targe t Fr a m ewo rk s> </P ro p er tyGro up> 

  <Pr opertyGrou p C on dition=" '$( T ar getFramewo rk) ' == 'netcor eap p2.0'OR  '$ ( Targe tFr amewo rk)' = =  'nets tandard2. 0' " >
   < DefineC o n st ants >NETCORE;</Define C on s tants></Proper tyGrou p> 
< Pro per tyGroup Co nd ition = " '$(Ta r ge t F r ame w ork)' == 'net 461'">
   < Def ineCon st ant s >NETFU LL;</ De f ine Constants>< /Pro pertyGrou p>
</P r oject>Ok, jus t in c ase , a  lit t le  b itmo r e e x pl ana t ion :
NetCor eE xa mpleC lass : p u blic  cl assNetCo reExampleClas s
{ 
  pub lic v oid E xamp le Metho d(stri ng li ne ) { Console.Wri teLi ne(line);  }}
Ne tC oreEx a mpleCo de,  th e way I  couldu seth e c od e from a.net core2. 0 as sembly:public cl as s  NetCore Ex amp leCo d e 
{
   pu b li c static  voidD o( )    {
      v ar  x= n ew Ex a mple ClassS him(newNetCo r eExampleClass( ) );
        x. E xa m p le M etho d(" For example ..." ) ;
   }} 
A:Doesit wo rk /s olve the problem?
p ub lic Ex ample ClassShim(obj ect obj):b a s e (obj) {}
.. . 
v a r x = new Exam pleCl assShim(ne w  NetCore Examp leClass( ));

Crea t i ng the S him  by  pa ssi n g  t he real objec t into  c onstruc tor  is def eat ing  th e p ur pose. But  I can i ma gi ne  y ouwante d  somethi ng  li ke  th is:
p u blic E xampl eCla ss Sh i m(/ *maybea rg s * /):ba se (
#i f N ET FULL   n ewNetFull ExampleCl ass ( /*ar gs */ )
#else 
    new NetC or eExampleCl as s(/ *args* / ) 
#endif) {}

Why runtime typec hecks i n m ethod s?
       pu bli c Exam ple C lassSh im(obj ect o bj ):b a s e(obj )      {
#if NET F U LL         if (!( obj is ExampleClas s ))              thro w ne w I n va l idI mp l eme n t ationException( ); // cust om ex ception
    . ..

       pu blicv oid Exa mpleMetho d(stringli ne)     {
#if N ETFULL
         ((Ex a mp leCla ss) Obj).E xa mpl eMeth od(lin e );      ...
H ow abo ut ge ne rics?
pu blic abstract class Shi m<Impl >
{
  protected  Im p l I t { get;}
   protecte d S him (Impl  it )  { It  = i t ;
 and_NETCORE:
<Project Sdk="Microsoft.NET.Sdk">
_ <PropertyGroup><TargetFrameworks>netstandard2.0;netcoreapp2.0;net461</TargetFrameworks></PropertyGroup>

  <PropertyGroup_Condition=" '$(TargetFramework)'_==_'netcoreapp2.0' OR_'$(TargetFramework)'_== 'netstandard2.0'">
 _  <DefineConstants>NETCORE;</DefineConstants></PropertyGroup>

_ <PropertyGroup Condition=" '$(TargetFramework)'_== 'net461'">
 __ <DefineConstants>NETFULL;</DefineConstants></PropertyGroup>
</Project>

Ok, just in case, a little bit more explanation:
NetCoreExampleClass:
public class NetCoreExampleClass
{
  __public void_ExampleMethod(string_line)_{ Console.WriteLine(line); }
}

NetCoreExampleCode, the way_I could use the code_from a.net_core 2.0 assembly:
public class NetCoreExampleCode
{
   _public_static void Do()
_   {
     _  var x = new_ExampleClassShim(new NetCoreExampleClass());
 ___   _x.ExampleMethod("For example...");
    }
}

A:

Does_it work / solve the problem?
public_ExampleClassShim(object obj):base(obj) { }
...
var x = new_ExampleClassShim(new NetCoreExampleClass());

Creating the Shim by passing_the real object into constructor_is defeating_the purpose. But I can_imagine you wanted_something like_this:
public ExampleClassShim(/*maybe args*/):_base(
#if NETFULL
    new_NetFullExampleClass(/*args*/)
#else
  _ new NetCoreExampleClass(/*args*/)
#endif
) {}

Why runtime type_checks_in methods?
 ___ _  public_ExampleClassShim(object_obj):base(obj)
 __     {
#if_NETFULL
_      _   _if_(!(obj is ExampleClass))
 _    _     _ _ throw_new InvalidImplementationException(); // custom exception
      _...

     _  public void_ExampleMethod(string line)
__  __ _{
#if NETFULL
     _ _    ((ExampleClass)Obj).ExampleMethod(line);
 _   __...

How about generics?
public abstract class Shim<Impl>
{
_   protected Impl It_{ get; }
  __protected_Shim(Impl it) { It =_it;