roslyn-code-analysis

Roslyn Code Action: How to check if preview or real execution?

眉间皱痕 提交于 2019-11-30 09:28:10
问题 I am currently experimenting with Roslyn and Code Actions, more specific Code Refactorings. It feels kind of easy, but I have a difficulty I cannot solve. Code actions are executed once against a dummy workspace as a "preview" option, so that you can see the actual changes before you click the action and execute it against the real workspace. Now I am dealing with some things Roslyn can't really do (yet), so I am doing some changes via EnvDTE . I know, it's bad, but I couldn't find another

Enabling Microsoft's Code Analysis on .NET Core Projects

一曲冷凌霜 提交于 2019-11-30 04:28:34
Our team uses the Code Analysis feature with a custom ruleset to cause our build to fail if we forget to do things like null checks on method arguments. However, now as we create a new .NET Core project, it doesn't look like Code Analysis is a feature of these new projects. There is no UI for it in the Project Properties area, and adding a custom ruleset to the project as recommended here only appears to affect StyleCop Analyzers (the SAxxxx rules). Is there any way to enable Code Analysis ( CAxxxx ) rules in a .NET Core project? Update Apparently the right way to do this is to install the

Getting type from a symbol in roslyn

喜夏-厌秋 提交于 2019-11-30 04:06:15
问题 What is the best general purpose way to get a System.Type from Microsoft.CodeAnalysis.ISymbol for different types of symbols ? (e.g. class declarations, variable, properties, etc) I want to be able to do various checks on the type e.g. as checking if the type implements any interface or is cast-able to any interface, just like one can check on System.Type. The problem I am having is that most of the concrete classes used to represent the symbol are internal (see http://source.roslyn.io/) and

Roslyn Code Action: How to check if preview or real execution?

前提是你 提交于 2019-11-29 16:18:15
I am currently experimenting with Roslyn and Code Actions, more specific Code Refactorings. It feels kind of easy, but I have a difficulty I cannot solve. Code actions are executed once against a dummy workspace as a "preview" option, so that you can see the actual changes before you click the action and execute it against the real workspace. Now I am dealing with some things Roslyn can't really do (yet), so I am doing some changes via EnvDTE . I know, it's bad, but I couldn't find another way. So the issue here is: When I hover over my code action, the code gets executed as preview, and it

VS Project References Broken On Case Sensitivity of GUID

橙三吉。 提交于 2019-11-28 08:09:14
Since upgrading to VS 2015, my team has experienced random quirky things which I'm sure are being worked out at Microsoft right now. One pretty annoying one is that we seem to lose project references, especially after branching. I began to work on a new branch of our solution yesterday only to find out that types were unrecognized and namespace usings were being cited as unnecessary (because they were for the types that had suddenly become unrecognized). The references in the project did not show any icons indicating a problem with the reference, but just to see if it would work, I removed and

VS Project References Broken On Case Sensitivity of GUID

可紊 提交于 2019-11-27 02:05:33
问题 Since upgrading to VS 2015, my team has experienced random quirky things which I'm sure are being worked out at Microsoft right now. One pretty annoying one is that we seem to lose project references, especially after branching. I began to work on a new branch of our solution yesterday only to find out that types were unrecognized and namespace usings were being cited as unnecessary (because they were for the types that had suddenly become unrecognized). The references in the project did not