Polyfills - STARIONGROUP/COMET-SDK-Community-Edition GitHub Wiki
Target Frameworks
The CDP4-COMET-SDK provides support for the following target frameworks:
- net462
- net47
- net471
- net472
- net48
- netstandard2.0
- netstandard2.1
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 COMET-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.