Allow unsafe code in jetbrains rider?
Asked Answered
L

1

8

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.

Lyell answered 30/8, 2017 at 20:29 Comment(3)
Possible duplicate of Unsafe Code Compilation error in .Net Core even after setting allowunsafe flag to true in project.jsonPatrilineal
I think it is a bug in a Rider =)Pentose
Would you mind opening a feature request for this one at youtrack.jetbrains.com/issues/RIDER#newIssue ?Radferd
I
4

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.

Initiate answered 19/12, 2020 at 10:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.