-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unity support #1229
Comments
Unfortunately, it's not possible to downgrade Roslynator to Roslyn 3.8 since there is a lot new syntax (e.g. file-scoped namespace) that depends on Roslyn 4.x To me the question is why Unity references Roslyn 3.8. Roslyn is backward compatible so updating to 4.4 should not be an issue. @bdovaz Do you know why Unity uses Roslyn 3.8 and not higher version? Btw. Roslyn 4.4 was released almost year ago (https://www.nuget.org/packages/Microsoft.CodeAnalysis/4.4.0). So I would say Roslynator tries to be compatible by not immediately using newest Roslyn version. |
I think I can answer you with these links: https://github.com/Unity-Technologies/mono-unity https://github.com/Unity-Technologies/roslyn As you see, Unity has its own forks of mono and roslyn in older versions so they are anchored to that and in Roslyn it is equivalent to 3.8 from what it says in the documentation (link in my first post). I would love for Unity to use .NET 7, the latest version of Roslyn, etc.... But the reality is not like that... Meziantou has managed to use the 3.3.x version of the Roslyn packages: https://github.com/meziantou/Meziantou.Analyzer/blob/main/Directory.Build.targets And those analyzers are very powerful and very similar to Roslynator: https://github.com/meziantou/Meziantou.Analyzer/tree/main/docs You might be inspired to see how he did it. I would like to help (I have a good contribution history and I am a mantainer in several repositories) but my experience in Roslyn analyzers is practically null... |
I'm using VS Code as an external tool for Unity. I've tried to set up Roslynator (VS Code extension) on the project, but nothing is reported. Is it for the same reason mentioned in this report?
|
@Merichbier Please see #1338 |
@josefpihrt Thanks for the tips! Any idea what might going wrong ? |
Can you please do the following steps and let me know if it helps?
Related issue: dotnet/vscode-csharp#6790 |
The solution to all the problems as I said is that Roslynator would depend on 3.8 and not on 4.x because Unity is not compatible with it... But it is @josefpihrt who has to evaluate how much impact it has to make that downgrade... The Unity developer base is very large, keep that in mind. If Meziantou has managed it, I don't see why @josefpihrt won't be able to do it. |
@josefpihrt great job! It seems to be working properly: |
Unity only supports version 3.8 of Microsoft.CodeAnalysis.CSharp: https://docs.unity3d.com/Manual/roslyn-analyzers.html
Roslynator from what I see is directly using version 4.4.0 right now:
https://github.com/dotnet/roslynator/blob/7bc89125ea3793993a9e47f89872daf212bebe57/src/Directory.Build.props#L16C1-L16C1
This makes it not compatible with Unity:
Another very powerful Analyzer is Meziantou, in this case it is compatible with Unity because it offers the analyzers in different versions of Roslyn:
https://github.com/meziantou/Meziantou.Analyzer/blob/cfa7ab74ad7b31a49efcd467a585e39853f2706b/src/Meziantou.Analyzer.pack.csproj#L19
@josefpihrt would it be possible to do the same with Roslynator?
Thank you!
The text was updated successfully, but these errors were encountered: