I am having problem with understanding what FEATURE_PAL compiler directive means in .net 4.0 source code. It is used almost in every class that access unmanaged code.
PAL = Platform Adaptation Layer. It is first and foremost a detail of the CLR, insulating it from the operating system implementation. You'll indeed see it used in the Reference Source copy of the source code for the .NET 4 classes. It appears in any code that has a strong dependency on the underlying operating system implementation, bypassing such code since it cannot work on an operating system other than Windows.
You may be familiar with the use of the DEBUG and RELEASE directives to wrap blocks of code specific for testing/production code.
The .NET 4.0 framework uses the FEATURE_PAL compiler directive to execute code on newer platforms. It has to adapt to the platform by calling native methods found in native dlls. Hence the name of the feature: 'Platform adaptation layer'.
I came across this post after looking at the code for the Process class. One can image that killing a process works different on a given platform.
Think of the your code running on a newer version of Windows installed on a device that uses an ARM processor. When killing a process you need to call a method inside a native dll tailored to that platform.
So when compiling the framework for such platforms the FEATURE_PAL compiler directive is set as 'conditional compilation symbol'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With