Skip to content

Polyfills

samatrhea edited this page Mar 15, 2020 · 8 revisions

Target Frameworks

The CDP4-SDK provides support for the following target frameworks:

  • net45
  • net451
  • net452
  • net46
  • net461
  • net462
  • net47
  • netstandard1.6
  • netstandard2.0

Query* methods

The Type class does not expose the same API in the different target frameworks. A polyfill class is made available to provide exentions methods on the Type class to harmonize the implementation for all the target frameworks of the CDP4-SDK.

Methods and properties that are not available using the same .NET libraries or namespaces for all the target frameworks are prefixed with the word Query. These methods are implemented in the same file. Compiler directives are used to differentiate between the implementations that are valid for the different target frameworks specified above.

An example:

NET45
public static bool QueryIsValueType(this Type type)
{
    return type.IsValueType;
}

NETSTANDARD1.6
public static bool QueryIsValueType(this Type type)
{
    return type.GetTypeInfo().IsValueType;
}

kudos to Michael Whelan for an excellent article on porting code to .NET Core.


« CDP4Common-CE Comparers  —  Documentation overview  —  CDP4Common-CE Validation »

Clone this wiki locally