ReSharper: Fix across solution - c#

Below I have added a screenshot to explain the issue. I am trying to fix certain warnings across solution, not just in a single file. It's really hard to fix them across solution when you're editing an old project with 1,000+ files and you've got 1000+ warnings that could simply be fixed in a matter of minutes, but I've been juggling with them for days.
Is there a way to enable ReSharper option to fix across solution? Or fix across folder even. This happens with a lot of issues, "Remove redundant initializer", "Remove case 0", and "Convert body to LINQ"

You can change the Resharper settings from Resharper Options menu.
Go to :
Resharper --> Options --> Code Inspection --> Inspection Severity.
Choose C# or VB.Net as per your project language then find "Language Usage Opportunities" and change the settings for "Convert body to LINQ" from 'Warning' to 'Hint'.
Your other problems are also can be fix in similar manner.

Related

Why does VS 2019 keep overriding my warnings setting?

Kinda stumped on this one. I'm using a library from GitHub and it's throwing tons of warnings, so I went into the project's build settings, chose 'All Configurations' and chose 0 for the warning level under 'Errors and Warnings'. This added the following to the project file:
<WarningLevel>0</WarningLevel>
Rebuilding and all the warnings went away.
Then on the next build, they came right back! Huh?
Went back into the UI and saw it was set back to 5! I checked the project file and it was still at 0 as expected.
To test, I changed the level 2 in the UI, and as expected, the project file updated to this instantly:
<WarningLevel>2</WarningLevel>
But then, a few seconds later, the UI again snapped back to 5! WTF?!?!
I looked around to see if there was any global overrides but didn't find anything, although I'm not really sure what I'm looking for.
Anyone know what's going on? It's really #$#!# annoying!
Here's my fork of the project if anyone else wants to take a look:
https://github.com/MarqueIV/WpfExtendedToolkit
(Forked from here: https://github.com/dotnetprojects/WpfExtendedToolkit)
Update
I checked out the project on a completely separate Win10 install where I also installed VS 2019 Community for the first time, and the same thing happened... it keeps 'resetting' the warning level, so it's something somewhere in the project itself I would think.
Ok, this isn't an 'answer' per se, but here's a workaround, at least for now to shut up the warnings.
In addition to WarningLevel, you have to also set the AnalysisLevel and RunAnalyzersDuringBuild by adding the following to your project.
<WarningLevel>0</WarningLevel>
<AnalysisLevel>none</AnalysisLevel>
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
That stops the warnings.
Still, there shouldn't be a case where something overrides WarningLevel which is why I'm posting this, but not marking it as the accepted answer. It isn't. It's a temporary, 'blunt-hammer' fix until they restore the behavior to the pre-.NET 5.0 way of it working. Let's hope that was an oversight and not an intentional change.

Remove and Sort Usings not working in Visual Studio 2019

On a certain solution the "Remove and Sort Usings" option does not work.
It sorts the Usings correctly, but does not remove any unnecessary ones.
The IDE is flagging the unused ones correctly, but it can't seem to remove them.
No errors or messages are displayed anywhere, it sorts and behaves like it has completed successfully, but the unnecessary Usings remain and are still flagged by Intellisense as such.
I have verified that in a different solution it does work, so it is not my VS2019 install.
And I don't have any plugins installed (like Resharper) that could conflict.
Have also tried clean and rebuild in case it needed an error-free compilation to work with.
Any ideas what could be different/special about a certain solution that would prevent the remove functionality?
I have found another thing which causes this issue.
For me, I discovered it was only happening in 1 particular project in a solution.
After comparing the non-working csproj to a working one, I determined that the difference was the Warning Level.
The non-working one was set to 1.
Resetting this to the default 4 allows the Remove and Sort Usings function to work as expected.
I found the cause, and it's an annoying one!
There is a custom ruleset specified for static analysis of the projects, and that had both CS8019 and IDE0065 (Unnecessary using directive) unselected.
On selecting these the remove unused usings command worked again.
Thanks to other answers for suggestions.
I had the same problem and figured out what was wrong. In your Tools|Options|Text Editor|C#|Advanced look for theses settings:
HTH.
Any ideas what could be different/special about a certain solution
that would prevent the remove functionality?
This is quite a strange behavior. You could try these suggestions:
1) close VS Instance, delete .vs hidden folder, bin, obj folder.
2) clean vs component caches under C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\16.0_xxxx(every this folder)\ComponentModelCache
3) use devenv /safemode to start VS IDE, open your project and then test again.
4) If your project is an old project which means that the project structure is a bit different from VS2019, please try to create a new vs2019 project and then migrate its content into the new project.
In addition, if these do not work, you can try this link's function to run Code Cleanup command with remove unused usings.

Cannot get Reharper 9.1 Move to Resource refactoring to work

I get this error message when I try to apply the Move to Reource refactoring to a string in a razor file:
"This project does not contain an available resource file"
I have tried added ressource files by adding new item, and also by adding in the project settings dialog. and building etc. All to no help. What is the problem?
I am using JetBrains ReSharper Ultimate 2015.1.1 Build 102.0.20150521.123255
ReSharper 9.1.20150521.134223
in Visual Studio 2015 rc in an ASp.NET MVC 5 project.
Any suggestions how to make this refactoring to work?
Open the .resx file with your "Managed Resource Editor" (the default), look at the top of the screen. There's a dropdown called "Access Modifier". Set it to public. Done.
Bart Van Meerbeeck's answer didn't work for me for the identical issue, though it definitely is the best answer. In MY case, however, the problem was me.
I was working in a large solution, and the file, in which I was attempting to do this refactoring, was located within a completely different project than where my Solution Explorer was scrolled to at the time. Upon realizing this, I created the resources file in the respective project, and all was well.
So, to others who may run into this, simply click your "Sync with Active Document" button in Solution Explorer, to jump to the project for which file you're editing, and you won't feel dumb like I do. :)

No intellisense in VS2010

I've got no intellisense at all in my VS2010 installation.
I've look at the answers on here, the relevant boxes in Tools->Options are selected and I've tried the "Ctrl-alt-space" shortcut that is also mentioned but nothing.
It's not even showing "Go to definition" when I right click on a variable or auto-tabbing new lines to the right place.
Any hints?
I've tried repairing my installation - I'm not sure if my attempts to install it on my second drive (which I then abandoned) have resulted in some issues but any help would be appreciated.
For the record, if anyone finds this later I had to use:
http://archive.msdn.microsoft.com/vs2010uninstall
To uninstall and then reinstall VS2010.
Have you tried:
Tools->Import and Export Settings-> select "Reset all Settings"
I was having the exact same problem in vs2008. All of my settings were correct in Tools -> Options -> Text Editor -> All languages -> Statement Completion as well.
After much searching, I decided to try to close out of every open source file, close the solution and re-open it. Then re-open the affected source file. This fixed the issue for me and intellisense/Go To Definition returned to full functionality. Unfortunately I can't back this up with hard science/any logic whatsoever, but it did the trick for me. Sorry for the anecdotal answer but thought I would share.
This article may also help: http://msdn.microsoft.com/en-us/library/ks1ka3t6(v=vs.71).aspx

Resharper: Cannot resolve symbol 'Eval' in VS2010 SP1

I just installed SP1 for VS2010, and since then I get error messages from Resharper for stuff that used to work and be ok for Resharper (5.1) before.
The error messages are "Cannot resolve symbol 'Eval'" and some other methods other than Eval.
How do I solve this?
Is there a fix?
Is there some resharper cache that I must delete/clear?
(The code compiles and runs as usual)
I would try deleting the _ReSharper.{SolutionName} directory completely if clear cache fails.
You might want to close VS2010 before you do that.
EDIT: Try this only if #Andrew Finnell solution doesn't work.
Try:
Resharper Menu -> Options -> General -> Clear Cache button
I had this problem in spades in my multi-project VS solution. Tried Julien + Andrew's solutions and they did not resolve the issue. But everything compiled just fine and worked as normal -- it was simply the "Errors in Solution" that kept showing the errors (which also showed up when you looked at the code in the right-hand-ReSharper-margin).
It turns out I had inadvertently deleted the web.config file in one of the solution's web projects during some version control operations. Who knew that thing was important?
I restored the web.config file, cleared the cache and deleted the R# cache directories and then rebuilt all of the projects individually and the issues went away.
Phew!
The solutions of #Andrew Finnell and #Julien Bérubé, alone and combined, did not fix my problem of "Cannot resolve symbol".
The comment of #bdwakefield pointing to here finally shed light on my problem.
It turns out that my "not resolved symbol" contains a web reference, and ReSharper gets lost there somehow.
By the link above it is possible to see that this is also an issue for many people, but JetBrains guys were not able to reproduce the error until now (see here).
I was having the same problem with one of my projects. I reported the issue to JetBrains and they requested a VS solution which has the problem.
So, I decided to spend a few hours trying to narrow down the problem as much as possible. I found out that the issue is related to a tool I use which strips out information from .DLLs.
If I don’t strip the .DLLs, Resharper works fine without showing any “cannot resolve symbol” errors. However, If I do strip the .dll, then ReSharper starts to show these “cannot resolve symbol” errors. In both cases, Visual Studio compiles the program and the program runs fine.
I am working with JetBrains to get the issue resolved.
In the mean time, I am able to workaround the problem by using versions of my .DLLs which do not have any information stripped out of them.

Categories

Resources