How to run unsafe code in "visual studio code"?
In the .csproj
file, just add
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
to any <PropertyGroup>
block.
No need to add anything to task.json
.
unsafe (C# Compiler Options)
To set this compiler option in the Visual Studio development environment Open the project's Properties page.
Click the Build property page.
Select the Allow Unsafe Code check box.
To add this option in a csproj file Open the .csproj file for a project, and add the following elements:
XML
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Usage
Method level
unsafe static void FastCopy(byte[] src, byte[] dst, int count)
{
// Unsafe context: can use pointers here.
}
Inline Block
...
unsafe
{
// Unsafe context: can use pointers here.
}
Class Level
public unsafe class Blah {}