Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow unsafe code in jetbrains rider?

Tags:

c#

unsafe

rider

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.

like image 385
wingerse Avatar asked Aug 30 '17 20:08

wingerse


1 Answers

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.

like image 50
Rachmaninow Avatar answered Sep 25 '22 23:09

Rachmaninow