-
Notifications
You must be signed in to change notification settings - Fork 43
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
Preserve Analyzer Include in Unity-genereated csproj? #27
Comments
While you wait for a reply from the maintainer, maybe you could publish your gist and paste the link here. It's a start! It would be great to have an event directly in the Rider plugin where we could plug extra post-processors (to avoid having to read each project file, modify, and save them back. This gets expensive in projects with many projects due to having a lot of asmdef files). I would love to see this in Rider, but I noticed it didn't get much attention. Maybe Unity developers in general aren't aware of Roslyn analyzers yet, since there's no official support. |
Providing an event is an interesting idea, but it would require committing EditorPlugin to vcs, which we do not suggest. |
Updated 09.04.2019
|
Interesting. I'm watching the development of the Incremental Compiler, since it has an option related to analyzers, but it seems to be just a stub for now. I wonder why they don't like the idea of supporting Roslyn analyzers the same way we're all used to. Thanks for pasting the code here. I'm sure it will help others! |
So is this something you guys think we should include as part of the Analyzer code? it needs to run in the Context of Unity Editor - right now there's no good mechanism for this. |
Hey @vad710! Do you confirm that currently custom analyzers effectively can't be used in any IDE (Rider/VS), because Unity regenerates csproj thus removing the 'Analyzer Include="RoslynAnalyzers...' line?
|
Updated ruleset support |
The use of the namespace 'Editor' can cause compilation errors because 'Editor' is a class in the 'UnityEditor' namespace.
|
See: vad710/UnityEngineAnalyzer#27 This is to be able to configure the Microsoft VS project with RoslynAnalyzers. In my config I use: -StyleCop -FxCop
Update: Rider package 1.1.3+ brings support for this using csc.rsp arguments. |
Late to the party but why can't you just add your analyzer package reference with Directory.Build.props like this https://rider-support.jetbrains.com/hc/en-us/community/posts/360002398539/comments/360001394920 |
@danielakl That may actually work. Have you tried? A reference to Directory.Build.props would not be preserved, when sln is regenerated by Unity. However, I guess, it is optional, right? |
@van800 Yes, I am using it now and it seems like it works. I have only tried this with JetBrains Rider. The only issue so far is that changing the ruleset doesn't seem to apply until reloading the solution. No need to reference Directory.Build.props in the .sln or .csproj so it won't be affected by Unity regenerating. |
I have added your concern about change in Directory.Build.props is not instantly applied to this request: https://youtrack.jetbrains.com/issue/RIDER-24559#focus=streamItem-27-3948862.0-0 |
@danielakl Did you find a way to make it only showing up in Rider? I've added a |
@marcelwooga No, did not find a good way to do this. Also my solution doesn't really work when you add certain dependencies. The analyser will start to find errors in external libraries that are added as projects. |
@danielakl if you are using |
The readme.md states that it is possible to install UnityEngineAnalyzer as a nuget and everything will work. But next time Unity regenerates csproj files reference to Analyzer will be lost. Am I missing something?
Something like JetBrains/resharper-unity#577
might be useful to ensure that Analyzer Include is added to generated csproj.
I think we will not merge the PR mentioned above in Rider, but I may contribute a separate AssetPostProcessor strait to this repo or separate gist. What would be better?
The text was updated successfully, but these errors were encountered: