roslyn How to add "#define VAR" on top of C# document
<p>I'd like to edit a C# document using roslyn adding a #define trivia on top of it.</p>

<p>For example let's say I have the following</p>

<pre><code>namespace MyNameSpace {
 &lt;classes&gt;
}
</code></pre>

<p>I'd like to make it</p>

<pre><code>#define X
namespace MyNameSpace {
 &lt;classes&gt;
}
</code></pre>

<p>I tried the following:</p>

<pre><code>DocumentEditor editor = &lt;get document editor&gt;
var compilationUnit = SyntaxFactory.ParseCompilationUnit("#defin X");
                var defineXTrivia = compilationUnit.GetFirstDirective();
                editor.InsertBefore(editor.OriginalRoot, defineXTrivia);
</code></pre>