Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to import Microsoft.CodeAnalysis into my project?

Discussion in 'Experimental Scripting Previews' started by pointcache, Dec 29, 2018.

  1. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    577
    I took a look at Immediate Window package and went through ALL the files and assemblies in Library and whatever i could find, i can't find a place where Microsoft.CodeAnalysis in imported, and have no idea how do i use it.
    I assumed at first that if i import immediate window i will have project wide access to Microsoft.CodeAnalysis,
    wrong ofc, now im trying to replicate what unity did to get access to that lib. Can anyone point to how would i import it?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    I have no idea if there is official support for this, I haven't kept up to date, but I've been using Analyzers for months with a little code to add them manually to the project.

    I put up a package here: https://github.com/tertle/com.bovinelabs.analyzers
    Just pull into the /Packages/com.bovinelabs.analyzers/ directory (I need to figure out a way to

    I specifically use StyleCop with a slightly modified ruleset but you should be able to use any analyzer by placing it in the RoslynAnalyzers folder and it'll automatically be added to all projects in your solution. Note it only works with visual studios atm though it's pretty easy to change for rider as I used to do that.

    ** This will also set your project c# version to 7.3 to get rid of ide warnings so you need to use a unity version that supports this or just uncomment the single line.

    -edit-

    at the moment only supports that specific folder. i'm going to make it more clean shortly so it can be pulled as a dependency into the packagecache.
     
    Last edited: Dec 29, 2018
  3. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    577
    Nevermind i got the dlls from nugets. All works.