Allow unsafe code in jetbrains rider?

4.1k views Asked by At

I need to write an unsafe method in C# and apparently "unsafe construct cannot be used in safe context". I went to project properties and saw a switch to allow unsafe code in Debug and Release builds.

However, it is not clickable.

enter image description here

How do I allow unsafe code for my project?

Edit: adding <AllowUnsafeBlocks>true</AllowUnsafeBlocks> to PropertyGroup tag in the csproj file does fix the problem but I was wondering if there is a way to do this in the IDE itself, since I expect IDEs to be able to do these sort of stuff.

1

There are 1 answers

0
Rachmaninow On

use Alt-Enter on the "unsafe" keyword in your code. There you will find the option to "allow unsafe code for ethis project".

I would not know how to undo thst later though. Funny that the Rider manual does not say anything about that.