What's the difference between "Suggestion" and "Refactoring Only" in VisualStudio? - visual-studio

I am building my .editorconfig for my project. I see both "Suggestion" and "Refactoring Only" for several of the options. What is the difference between these?

From the documentation
Violations of a Suggestion appear as build messages and as suggestions in the Visual Studio IDE; see the Messages section in the Error list.
The description for Silent applies to Refactoring only, as it will be saved as such in .editorconfig, e.g.:
dotnet_naming_rule.interface_should_be_begins_with_i.severity = silent
Violations of a Refactoring Only/silent rule aren't visible to the user, but the Quick Actions and Refactorings... menu shows an entry to resolve the violation (similarly as for Suggestion violations).
A closed issue on the Microsoft Visual Studio documentation on GitHub says:
Do not show anything to the user when this rule is violated. Code
generation features generate code in this style, however. Rules with
silent severity participate in cleanup and appear in the Quick Actions
and Refactorings menu.

Related

How to automate applying solutions that VS quick action offer to solve Stylecop(roslyn) code style errors

I'm introduce stylecop functionality with custom rule set in massive application that contain more than 100 projects. Roslyn compiler show errors and warnings in existing code and VS offers common fixes (quick actions). You press Ctrl+. and see fixes. It's so tedious and time-consuming operation select error, press shortcut and applying rule, when you have 100+ project.
I want to automatic apply the rules that in the list. Maybe some script that goes through error list, check that error id exist in list and apply that rule on project.
I hear about Visual Studio Extensions, can they help me? Can someone advise me how can I solve this problem?
The Visual Studio Code Cleanup (find it in the Analyze menu) has a Code Cleanup option. You can configure a profile with the Fixers you want to run and the have it blast through a complete solution.
Save the profile with the fixers you want, then choose Run Code Cleanup (Profile) on Solution.

How to make Visual Studio build to fail on ReSharper Error

How can I make my code build to fail when ReSharper detects an "Error" after code inspection?
I am using C# in Visual Studio 2017 along with ReSharper. I have set the inspection severity of Possible 'System.NullReferenceException' to show as "Error". This setting only shows a red underline for erroneous code, however the VS build still succeeds if I just ignore it. I want to make the build to fail if developer ignores such errors detected by ReSharper inspection.
I'm afraid Resharper seems to not support this option for now.
1.In my opinion, the error level in C#\Potential Code Quality Issues is something like showing a red underline to indicate where there maybe has a risk to help improve your code. And red to indicate this issue deserves attention. Actually,it's something controlled by us, we determine to make them error(red line) or warning(blue line?).
But such a potential code issue can't be recognized by msbuild (build system in vs). So the build will ignore these potential issues and succeeds.
2.For build settings in Resharper, I tried msbuild settings and compiler settings like below:
I set every element in the Potential Code Quality Issues to error. Also, i set null reference related settings like below:
After that I create a simple null reference but the build ignores that and succeeds. Same result when I use Resharper build.(Resharper options=>Tools=>Build=>Build engine) So maybe it's a negative answer :(
This isn't an ideal solution, but JetBrains provide a command line tool called InspectCode which runs their code inspections on your solution and outputs the results in XML or other formats. You could add a custom MSBuild step which runs InspectCode.exe MySolution.sln -o=output.xml, examines output.xml for errors, and fails the build if any are found.
Unfortunately InspectCode is slow and even though the analyses seem to be cached across runs it still takes a significant amount of time. For example, on my solution of 700k lines of code the tool takes 60 seconds on the second run, i.e. with a warm cache. So I don't think this is a viable solution to run on developer machines on every build. It might be acceptable in an automated build system.

Stop SSRS from Building ALL reports when Previewing

I am trying to find some sort of setting in Visual Studio that controls whether it Builds all the report in the solution before letting the user Preview a report.
Currently, I am updating an old report. When I try to preview, the Visual Studio preview goes blank white for about 10 minutes then gives a bunch of errors about issues with different reports.
The report preview failed because the report could not be built.
Unfortunately, Microsoft's MSDN is pretty much useless when searching for something (or anytime you want actual information and not theory). I've looked through every item in the Visual Studio menu but haven't found anything that sounds close to what I want.
It did not build all reports last week when I made changes to another report. I have other solutions which do not currently have the problem (it would make more sense if they did, tho). What setting did I change to make this stupid functionality?
I would recommend opening that report in Report Builder. It's a free download. You can use the 3.0 version or 2016. That way it will not be bogged down by the other reports, it has simpler error handling, and it has pretty much all the same editing capabilities. Once you're done making any changes, you can continue to manage it from within Visual Studio SSDT.
This is not intended as an answer but too long for a comment.
If a report has not been successfully built previously, it will be built when you preview any report. Once the build completes, reports are skipped unless they have been changed since the last succesful build.
Usually when you preview a report, it builds just that report and skips the others.
You can prove this by going to a 'working' solution/project, right-clicking the solution and choosing Clean Solution. This will delete the build info for all the reports, next time you preview any report, every report will be rebuilt, you can see this in the Output window.
Once this is complete, preview any report and in the Output windows you will see Skipping 'report name.rdl'. Item is up to date.
I 'think' the status of each report is held in the project user options file (*.rptpoj.user) but I don't have anything that I can read the file sensibly with so I'm not 100% certain.
You may have to create new project and copy each report in one at a time fixing them as you go, I can't think of anything else, but hopefully somebody know more than me.

Does anyone know of a code change management tool that can highlight code changes in Visual Studio?

Hey all, I am trying to find a tool that can highlight code changes in Visual Studio so they can be easily found and reviewed. Below are some requirements for what we are looking for...
Identify and use a difference highlighting tool that meets the following criteria:
• can highlight areas that need to be reviewed
• there is a place to enter comments
• retains line numbering from code
• preference for doing within IDE
Issue addressed:
Hard to see what was changed in code - changes not identified. Coders do not provide administrators diffs. No tool that does a nice job to identify differences. Daunting/time consuming to provide a good diff. When highlighting differences was provided, loss of line numbers was a substantial issue (was worse).
A lot of source control systems offer this functionality.
Check out Subversion at
http://subversion.tigris.org/
There is visual studio integration at Visual Subversion:
http://www.visualsvn.com/
We use BeyondCompare for this. The 3 pane view for merge (original, theirs, yours) and the 2 panel pane for comparison like you want is excellent.
You can use it standalone, including just looking at file trees outside visual studio, or integrate inside and with most of the version control systems as well. Take a look here for the parameters. That example is for TFS, but you can change the command line to fir any version control.

Can TFS or Visual Studio remind me about issues that have to be marked as completed before a check in

I'm actually working on a tool that need some configuration before it can be used. To save some time a hard coded some values into the text boxes of the configuration tab, so I don't have to renter them every time I do some testing or debugging.
As we're using TFS to manage our solutions I'm wondering if there is a way to mark those hard coded elements in some way so that TFS or Visual Studio 2008 will remind me to remove/replace them before I do a check in.
UPDATE:
The todo comments won't be a real solution as we're already using it to mark code segments which have to be reworked. We use it as a reminder for longterm tasks. And we have plenty of them so this might become a little bit unclear.
Some options:
write a custom checkin policy
use the existing FxCop checkin policy and write a custom rule (if you're marking TODOs with something that gets actually compiled, like an Attribute)
ditto, but via the StyleCop checkin policy (if your TODOs are source comments)
Probably not the perfect solution, but Visual Studio let's you add TODO comments that may work well enough for you.
You could write a unit test that fails when the hardcoded stuff is found. Obviously, you won't get a reminder before checking in but you do get a build failure afterwards.

Resources