DllImport is a well-known concept for most C # developers. This also leads to a relatively small area where segfault can occur. With code, unsafeyou can make random crashes much easier in places not related to the call unsafe(by manipulating memory areas outside of what you think you were touching).
This is very similar to compiler warnings - some developers do not pay attention to them, some turn "Treat warnings as errors" to "Everything." Guess which results in the code are easier to simplify?
In addition, DllImport itself is not a good idea if it can be avoided (due to possible break errors / missed errors / portability, etc.).
source
share