# allowUnsafeCode

> Allow unsafe C# code to be compiled for predefined assemblies.

## Definition

* **Type:** Property
* **Namespace:** [UnityEditor](/engine/6000.3/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

```csharp
public static bool allowUnsafeCode { get; set; }
```

### Remarks

Enable to pass `/unsafe` to the C# compiler when compiling predefined assemblies, such as `Assembly-CSharp.dll`. This setting only affects code that isn't compiled into separate assemblies via `.asmdef` files.

Enable this only if your project requires direct pointer manipulation for extreme performance or native C++ interoperability. For general high-performance data handling, consider using `Unity.Collections` or `System.Span<T>` first.

**Warning:** Code compiled with `/unsafe` flag can bypass the .NET runtime's memory safety. An invalid memory access typically crashes the application or the Editor without a stack trace.

**Note:** For `.asmdef` assemblies, enable the **Allow 'unsafe' Code** checkbox in the [Assembly Definition Inspector](/engine/6000.3/manual/scripting/compilation-and-code-reload/script-compilation/assembly-definition-files/class-assembly-definition-importer.md) instead.
