resharper

Resharper Rename Fields

て烟熏妆下的殇ゞ 提交于 2019-12-12 10:47:18
问题 I've been tasked with making some significant modifications to a legacy codebase that was not written using our current code style conventions. The changes are extensive enough that I'm doing some cleanup and refactoring (there was quite a bit of dead code) before getting started. One of the things that's bugging me is that the fields are following the m_FieldName naming convention whereas we now use _fieldName. Is there some way with Resharper to automatically rename all fields in the

How to add custom code analysis in ReSharper

情到浓时终转凉″ 提交于 2019-12-12 10:37:17
问题 I'm new to ReSharper. For those who uses Resharper, is there a way I can add custom code analysis rules? For example I might have a rule say All private variables should start with letter "m" . How can I add this to Resharper so if I violate this, it can shows as a warning or an error? 回答1: I know the question is old, but for all folks coming from google like me: Resharper -> Options -> Code inspections -> Custom Patterns There you can create your own rules for highlighting patterns or

Intellisense with MVC4 Style Bundling

谁都会走 提交于 2019-12-12 10:31:43
问题 So far I can't find a question or fix for this. I'm sure it's something simple I'm missing. I have a style bundle with a bunch of minified CSS, and I am decorating HTML elements with the classes inside. Everything is working great. Intellisense and ReSharper however are both bugging me about the CSS the classes being unknown. I'm guessing this is because they cannot peek inside the bundles. Question: Is there a way to fix this? <!-- Style Bundles in HEAD tag--> @Styles.Render("~/bundle/style

Why does Resharper complain when I compare a double to zero?

ε祈祈猫儿з 提交于 2019-12-12 10:29:10
问题 If I do double d = 0; if (d == 0) { ... } Resharper complains at the comparison d == 0 about "Comparison of floating point number with equality operator. Possible loss of precision while rounding values." Why? It cannot be difficult to represent exact zero as a double or a float can it? I understand such a warning would be relevant if I compared to some other value such as 0.2 for which there is no exact binary representation. 回答1: Resharper does not analyze how the double variable got its

Resharper suggestion: check for reference equality instead

时光怂恿深爱的人放手 提交于 2019-12-12 10:29:00
问题 I don't understand why Resharper suggest me to "check for reference equality instead" in this code: if ( typeToTranslate.Equals( typeof(string) ) ) { //do something } Why this should be better: typeToTranslate == typeof(string) ------------EDIT------------ This is the method stub: protected IType TranslateType(Type typeToTranslate) { if (typeToTranslate == null) throw new ArgumentNullException("typeToTranslate"); //do some stuff if (typeToTranslate.Equals(typeof(string))) { //do some stuff }

Can I “fix” wrong Resharper annotations?

谁说胖子不能爱 提交于 2019-12-12 09:52:36
问题 I love Resharper, but sometimes it gives incorrect warnings, probably because the built-in annotations for BCL types are wrong. For instance, in this code: private static string GetDescription(T value) { Type type = typeof(T); string name = Enum.GetName(type, value); if (name != null) { ... It gives me a warning on the if statement: "Expression is always true". But Enum.GetName can return null: string name = Enum.GetName(typeof(DayOfWeek), (DayOfWeek)42); // null I assume this is because

How to resolve Resharper's “unused property” warning on properties solely for Display/Value Members?

我只是一个虾纸丫 提交于 2019-12-12 09:33:06
问题 I have defined two properties "Name" and "ID" for an object which I use for the DisplayMember and ValueMember of a ComboBox with a BindingList datasource. I recently installed Resharper to evaluate it. Resharper is giving me warnings on the object that the two properties are unused. Sample code: BindingList<ClassSample> SampleList = new BindingList<ClassSample>(); // populate SampleList cmbSampleSelector.DisplayMember = "Name"; cmdSampleSelector.ValueMember = "ID"; cmbSampleSelector

How to turn off ReSharper's “Find All Usages”

我与影子孤独终老i 提交于 2019-12-12 09:28:47
问题 I am giving ReSharper for C# a whirl. I have found that I prefer Visual Studio's simpler "Find All References" over ReSharper's more detailed "Find All Usages". "Find All References" finds everything I need 95+% of the time. Does anyone know of a way to turn off "Find All Usages" and revert back the VS's implementation? 回答1: Unfortunately not there is no way to turn it off with out turning the whole thing off. Sorry, it takes a bit of getting used. 回答2: To restore the original VS 'Find All

Creating an interface from a huge class using resharper

心不动则不痛 提交于 2019-12-12 08:39:25
问题 I have a very big class with lots of methods, is it possible to build an interface from this class using Resharper? 回答1: Yes. My shortcut is Ctrl + Shift + R to bring up the refactoring options. Doing this on the class name allows you to" Extract Interface..." Optionally, you can choose from the menu > ReSharper > Refactor > Extract Interface... 回答2: Uh, maybe I'm missing something here (I've never used resharper) but you can extract an interface from a class using the standard VS IDE

Resharper not running new unit tests

允我心安 提交于 2019-12-12 08:17:35
问题 When I create new NUnit unit tests in my test project, the ReSharper Unit Test Runner detects them but they remain grey and are not run. This behaviour occurs whether I try to run the tests individually or all together. If I close and reopen the solution, the new tests are detected and run correctly. The behaviour only occurs if I build the solution using visual studio before I run the tests. If I let resharper trigger the build the tests are detected correctly. I am using: Visual Studio 2010