resharper

How to change default access modifier in Resharper (R#) to internal

不羁的心 提交于 2020-01-13 08:21:09
问题 By default Resharper creates all methods, properties, and classes as public. Does anybody know how to change it to internal instead? Thanks a lot. 回答1: As far as I know there's no way to do that out of the box in ReSharper. In many cases ReSharper goes the safest path when setting visibility to the code it generates but apparently there is some visibility heuristics in place, especially when it comes to generating type members. ReSharper provides a more general-purpose way of ensuring that

Is this a better way to fire/invoke events without a null check in C#?

可紊 提交于 2020-01-12 04:42:21
问题 Most code I have seen uses the following way to declare and invoke event firing: public class MyExample { public event Action MyEvent; // could be an event EventHandler<EventArgs>, too private void OnMyEvent() { var handler = this.MyEvent; // copy before access (to aviod race cond.) if (handler != null) { handler(); } } public void DoSomeThingsAndFireEvent() { // ... doing some things here OnMyEvent(); } } Even ReSharper generates an invoking method the way mentioned above. Why not just do it

Automated refactoring to add parameter names to method calls

心已入冬 提交于 2020-01-12 04:09:25
问题 I am in the middle of a big refactoring. I have dozens of methods, which are called via positional parameters. Now I would like to have them called via named parameters. The methods exist in several, non-inherited classes and have the same name and their signatures differ. Example: Definitions public class Foo { public static Foo Create(int count, string name) { ... } } public class Bar { public static Bar Create(string description, bool yesNo, float factor) { ... } } And the following calls

Detect Recursive calls in C# code

為{幸葍}努か 提交于 2020-01-09 12:51:32
问题 I want to find all recursive calls in my code. If I open file in Visual Studio, I get "Recursive call" icon on left side of Editor. I want to inspect whole solution for such calls. I used Resharper Command Line tools and VS's add-in Resharper - Code Inspection with no luck, this rule is not applied in their ruleset. Is there any way that i could inspect whole solution - i really don't want to open each file and check for that blue-ish "Recursive call" icon :) Edit: I am interested in single

Visualstudio 2015 + Resharper GER keybindings ctrl + alt + 1to7 (angled bracket) not working

烂漫一生 提交于 2020-01-07 05:40:08
问题 I am experiencing and odd keybinding behaviour after installing VisualStudio 2015 and Resharper on my Surface Pro 3 running Windows 8.1. Problem Usually ctrl + alt + 7 should type an "{" but it actually does nothing on any text input (VS, Notepad++, Editor). All other GER typical bindings with ctrl + alt + 1 to 7 also do not work like they should. ctrl + alt + 1 for example launches Firefox (which is first shortcut in my quicklaunch, but changing that does not launch another program). The

How do I get Resharper++ to ignore Qt moc files?

醉酒当歌 提交于 2020-01-07 03:48:46
问题 Resharper++ is parsing all the moc_ files generated by Qt. Has anyone figured out how to prevent this? 回答1: I used Third Party Code: Go to ReSharper | Options | Code Editing | Third-Party Code. In "File Masks" add "moc_*.cpp". 来源: https://stackoverflow.com/questions/44467881/how-do-i-get-resharper-to-ignore-qt-moc-files

实现INotifyPropertyChanged-是否存在更好的方法?

こ雲淡風輕ζ 提交于 2020-01-07 01:52:33
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Microsoft应该为 INotifyPropertyChanged 实现了一些简单的功能,例如在自动属性中,只需指定 {get; set; notify;} {get; set; notify;} {get; set; notify;} 我认为这样做很有意义。 还是有任何并发​​症要做? 我们自己可以在属性中实现“通知”之类的功能吗? 是否存在用于在您的类中实现 INotifyPropertyChanged 的优雅解决方案,或者唯一的方法是通过在每个属性中引发 PropertyChanged 事件。 如果不能,我们可以写一些东西来自动生成引发 PropertyChanged 事件的代码吗? #1楼 从.Net 4.5开始,终于有了一种简单的方法。 .Net 4.5引入了新的呼叫者信息属性。 private void OnPropertyChanged<T>([CallerMemberName]string caller = null) { // make sure only to call this if the value actually changes var handler = PropertyChanged; if (handler != null) { handler(this, new

为什么我需要一个IoC容器而不是直接的DI代码? [关闭]

半腔热情 提交于 2020-01-06 15:40:05
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我一直在使用 依赖注入 (DI)一段时间,在构造函数,属性或方法中注入。 我从未觉得需要使用 控制反转 (IoC)容器。 但是,我读的越多,我觉得社区使用IoC容器的压力就越大。 我使用.NET容器,如 StructureMap , NInject , Unity 和 Funq 。 我仍然没有看到IoC容器如何使我的代码受益/改进。 我也害怕在工作中开始使用容器,因为我的许多同事都会看到他们不理解的代码。 他们中的许多人可能不愿意学习新技术。 请说服我需要使用IoC容器。 当我在工作中与开发人员交谈时,我将使用这些论点。 #1楼 我是一名康复的国际奥委会成瘾者。 这些天我发现很难证明在大多数情况下使用IOC来证明其合理性。 IOC容器牺牲了编译时检查,据说可以为您提供“简单”设置,复杂的生命周期管理以及在运行时动态发现依赖关系。 我发现编译时间检查的丢失以及由此导致的运行时间魔术/异常,在绝大多数情况下都不值得花里胡哨。 在大型企业应用程序中,他们可能很难跟踪正在发生的事情。 我不购买集中化论证,因为你可以非常容易地集中静态设置,为你的应用程序使用抽象工厂,并虔诚地将对象创建推迟到抽象工厂,即做适当的DI。 为什么不这样做静态无魔法DI: interface IServiceA { } interface

Resharper Suggestion Color Issue

旧巷老猫 提交于 2020-01-06 08:21:14
问题 I have a strange bug in resharper 4.5 in VS 2005. Instead of doing the usual underline for a suggestion -- IE: telling me that a using statement is unnecessary, it is setting the background to red in the same manner as a breakpoint. Here is a screenshot. I have uninstalled and reinstalled several times, including an install of resharper 5.0 to no avail. I also went into the fonts/color section in the options and have set the Resharper options to standard squiggly underlines. I have also tried

Resharper Suggestion Color Issue

人盡茶涼 提交于 2020-01-06 08:21:06
问题 I have a strange bug in resharper 4.5 in VS 2005. Instead of doing the usual underline for a suggestion -- IE: telling me that a using statement is unnecessary, it is setting the background to red in the same manner as a breakpoint. Here is a screenshot. I have uninstalled and reinstalled several times, including an install of resharper 5.0 to no avail. I also went into the fonts/color section in the options and have set the Resharper options to standard squiggly underlines. I have also tried