MonoBehaviour scripts will break U# compiler when guarded by pre-processor directives while containing multiline text with a line starting with #, making world fail to compile with it
Here is minimal example that will reproduce the bug reliably:
Broken example (# in the string):
#if UNITY_EDITOR && !COMPILER_UDONSHARP
using UnityEngine;
public class MyCoolScript : MonoBehaviour{
public string text =
@"
# this will break it
";
}
#endif
will cause the following error to appear:
[<color=#FF00FF>UdonSharp</color>] Assets/MyCoolScript.cs(6,3): error CS1024: Preprocessor directive expected
Working example (no # in the string):
#if UNITY_EDITOR && !COMPILER_UDONSHARP
using UnityEngine;
public class MyCoolScript : MonoBehaviour{
public string text =
@"
this won't break it
";
}
#endif
Entire area is guarded from U# to be able to do default unity editor code, yet U# compiler seems to see
#
as a start of a pre-processor directive. Found when making presets for my in-editor annotation utility.