resharper

d:DesignInstance with an interface type

余生颓废 提交于 2019-11-28 11:53:21
I'm binding an UI to an interface (which is implemented by several presenters, not accessible from the UI assembly). I really like d:DesignInstance in designer because it (kind of) makes xaml strongly typed using R#. Sadly, d:DesignInstance does not support interface types: "Cannot create an instance of an interface." The first thing I thought is: Ok, no problem, let's create a custom markup extension which takes a System.Type as parameter, and which ProvideValue method returns a fake instance of it (dummy implementation of this interface, generated by dynamic IL emission). This works quite

Should I *always* favour implictly typed local variables in C# 3.0?

半腔热情 提交于 2019-11-28 09:38:41
Resharper certainly thinks so, and out of the box it will nag you to convert Dooberry dooberry = new Dooberry(); to var dooberry = new Dooberry(); Is that really considered the best style? Jon Galloway It's of course a matter of style, but I agree with Dare: C# 3.0 Implicit Type Declarations: To var or not to var? . I think using var instead of an explicit type makes your code less readable.In the following code: var result = GetUserID(); What is result? An int, a string, a GUID? Yes, it matters, and no, I shouldn't have to dig through the code to know. It's especially annoying in code samples

Hitting Tab in Visual Studio selects block instead of adding indentation

泪湿孤枕 提交于 2019-11-28 09:35:07
I am using Visual Studio 2015 and ReSharper 2016.2 and I have this strange behavior, that I probably activated (accidentally). When having the cursor in a line before the first word, hitting the Tab-key indents the line correctly: When the cursor is inside of any word inside the line, hitting the Tab-key selects the word or block. But the desired behavior would be to indent at the cursor (e.g. split a word into two words, if the cursor was inside of the word Stream after the letter r): Does anyone know how this 'feature' is called? Does it come from ReSharper? Where can it be enabled or

How to stop Resharper from line breaking after return keyword for long lines?

我们两清 提交于 2019-11-28 08:55:20
When I auto format with Resharper CTRL + ALT + SHIFT + F for lines longer than max line length (in my case say it's 80 characters), I get the following: return View(new ViewModel { Identifier = identifier, Files = service.AllFiles() }); But what I really want is it not to wrap after the "return" keyword (i.e. not have the return keyword on a line all on its own), like so: return View(new ViewModel { Identifier = identifier, Files = service.AllFiles() }); Does anyone know how to "configure" Resharper to make this happen? :) Here's another example, here's what I'm seeing now: return repository

Visual Studio freezing (crashing) while loading solution

╄→尐↘猪︶ㄣ 提交于 2019-11-28 08:53:41
I've met with a strange problem. I had 7 projects in the solution. I had to add another MVC project. Now when the document (from the new project) is opened (for example HomeController.cs ) and when this project is initializing at the start, it freezes the whole IDE like this: (Some projects do not load) After that, I have to kill the process. When I open VS again and fast click on another project (which is initializing) the freezing issue is gone. I have no idea what can cause a problem like this. I've tried with and without ReSharper but I get the same result. Also, I restored default

Alphabetizing methods in Visual Studio

邮差的信 提交于 2019-11-28 08:51:41
Is there any sort of plug-in or tool available for Visual Studio 2008 to alphabetize methods? Ideally I'd like a tool that will alphabetize a selection, or specified type (i.e. only methods, not member variables), either automatically or on-demand. DavidN Resharper has a Type Members Layout, which can order members by type, accessibility and alphabetically as well. You can also take a look into Ora , which presents a pane in visual studio that is ordered (even though your source may not be). Link's dead. The following answer goes much further than the OP asks, because I believe, that sorting

How do I disable plugins from command line on visual studio?

谁说胖子不能爱 提交于 2019-11-28 08:39:41
问题 Resharper is killing me for some reason on startup, I just need to get in, is there a command line switch for load without addins? 回答1: You are probably looking for the /SafeMode command line switch: devenv.exe /SafeMode This will start Visual Studio with all add-ins disabled. 来源: https://stackoverflow.com/questions/885636/how-do-i-disable-plugins-from-command-line-on-visual-studio

Resharper suggests parameter can be of type 'BaseType'

廉价感情. 提交于 2019-11-28 08:13:43
what are the benefits of using base types in method parameters? Here's one sample: private void Foo(List<int> numbers) //R# laments: parameter can be IEnumerable. { foreach (var i in numbers) { Console.WriteLine(i); } } And here's another one public class Foo : ICloneable { public object Clone() { return MemberwiseClone(); } public Foo CopyMe(Foo other) //R# laments: parameter can be ICloneable { return (Foo)other.Clone(); } } ...where we can change the type and anything but Foo will fail at runtime. So the question: what should I do when R# suggests parameter can be of type 'X' ? PS. Just

Moq: Invalid setup on a non-overridable member: x => x.GetByTitle(“asdf”)

喜夏-厌秋 提交于 2019-11-28 07:54:04
Not sure how I can fix this, trying to do a unit test on the method "GetByTitle" Here are my definitions: public class ArticleDAO : GenericNHibernateDAO(IArticle, int>, IArticleDAO { public IArticle GetByTitle(string title) { IQuery query = Session.CreateQuery("...") return query.UniqueResult<IArticle>(); } } public interface IArticleDAO { IArticle GetByTitle(string title); } unit test: [Test] public void can_load_by_title() { _mockDaoFactory.Setup(x => x.GetArticleDao()) .Returns(_mockArticleDao.Object); _mockArticleDao.Setup(x => x.GetByTitle("some title")) .Returns(article1.Object);

Can I propagate XML documentation from an interface to its implementation?

喜欢而已 提交于 2019-11-28 07:04:27
问题 I need to propagate XML documentation from a base class to derivative(s) or from an interface to implementation(s). Can I do this using Resharper? 回答1: Yes you can. If you're yet to implement/override members, then in a derived class or interface implementation, click Alt + Ins , choose "Overriding members" or "Implement missing members". In the wizard that displays afterwards, choose members to implement/override, and make sure to select "Copy XML documentation". Alternatively, if you