Search Unity

[Solved] Can I use Microsoft.CodeAnalysis.CSharp for Editor script?

Discussion in 'Scripting' started by Kichang-Kim, May 20, 2019.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    Hi, I attempted to use Microsoft.CodeAnalysis.CSharp for my Editor script and stuck with DLL conflicting.

    Here is my attempt:

    1. Create normal .NET Framwork console application and install Microsoft.CodeAnalysis.CSharp (3.0.0) using nuget.
    2. Copy all dlls in avobe project into my Unity project.
    3. Set dll's target to Editor only.
    4. Call some Microsoft.CodeAnalysis.CSharp method in my Editor script.

    Then I get errors like this:

    I think that System.Runtime.CompilerServices.Unsafe in com.unity.collections makes conflict. Is there any solution for this issue?

    Thanks.
     
  2. Deleted User

    Deleted User

    Guest

    What version of Unity?

    Why not using Visual Studio 2017 or 2019; they are both Microsoft products.
     
  3. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    I used Unity 2019.1.2f1. Currently, I have some my own IDL compiler tool which using JSON based struct (integrated Unity editor). But I found that Roslyn has good Syntax parsing / transforming tools so I tried to use it for improving my Unity Editor toolset.

    So I want to use Roslyn as custom C# like scripting tool, not C# assembly compiler.
     
  4. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    I found that old version of Roslyn (v1.3.2) works succesfully with Unity 2019.1.2f1.
     
  5. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    MurphyMurph_21 and Djayp like this.