I have a .NET library ( Products.SDK) that should be compatible with both the .NET Framework 4.5 and the .NET Standard 1.4.
Products.SDK
(Later I will also create a NuGet package from this library)
My question is:
How to write code in this library? Given that both structures use different libraries / dependencies?
Will I have two separate projects with the same solution?
Products.SDK.sln
Will I have only one project and use preprocessor directives #ifto define different classes inside the library?
#if
namespace Products.SDK { #if NETSTANDARD1_3 public class ProductsApi { public string ApiUrl { get; set; } } #else public class ProductsApi { public string ApiUrl { get; set; } } #endif }
If parameter # 1 is correct, how can I make sure both projects are compiled using the same name / namespace ( Products.SDK)
, №2 , , .
PS:
.csproj
<PropertyGroup> <TargetFrameworks>netstandard1.4;net45</TargetFrameworks> </PropertyGroup>
- #if , . , , .
My Noda Time , - .
API , . , API , , net45. - :
net45
, . , X netstandard1.4 B, Y net45 A - Z, .NET 4.7, , X Y .
, . , , , net45, , netstandard, net45. ( , TypeInfo netstandard, , Type net45. TypeInfo .)
TypeInfo
Type
Source: https://habr.com/ru/post/1684200/More articles:Push new node in firebase, if not - objective-cRandom unsuccessful conversion timestamp with new date () - javascriptHow to remove elem and the next popup? - javascriptCreate an electronic menu in TypeScript? - typescriptWhy did I come across this Golang code? - goAngular object change detection - angularjava.io.IOException: Unable to combine AudioSampleEntry when merging video using Mp4Parser - androidWhy Thread Does Not Release Lock When Link Changes - javaC ++ Eigen3 matrix weird behavior - c ++Python Zeep - How to use sequence -> selection - pythonAll Articles