0

I'm using Resharper and currently on the free trial. I've developing a library along with a project which uses the library. When I'm in the project which uses the library and begin to call the constructor of one of my classes, it shows me a list of constructors in the code intellisense. The problem is that all of these constructors are intentionally internal or private.

  1. I do not want resharper to show me the internal constructors because it makes it appear as if my code is wrong.

  2. I thought it may be doing it to offer suggested refactorings, but it doesn't indicate in any way that certain constructors are private or internal. If I complete it with the suggested constructor it's a compile error.

How can I prevent resharper from suggesting inaccessible constructors?

edit: interestingly, if I begin to call a constructor of the class from within the library it only offers intellisense for the 2 internal constructors. If I call it from an entirely different project it offers intellisense for all three constructors (1 private, 2 internal).

edit: I just reproduced it in a simple solution with 2 projects. 1 Class library with 1 code file, 1 windows forms app with 1 code file.

Here's a picture. With this solution I'm using VS2008 because I write Compact Framework code (and it isn't support after 08). However, this test solution was created with a normal Class library and Windows Forms Application.

ReSharper Bug - Private/Protected Constructors

Alan
  • 7,875
  • 1
  • 28
  • 48
  • ReSharper should only show non-accessible members via Double Completion. Are you sure you're not invoking completion twice? If you're not, consider posting your issue at http://youtrack.jetbrains.com so we can investigate it. – Dmitri Nesteruk Mar 22 '14 at 06:07
  • @DmitriNesteruk I dunno what Double Completion is, I'm simply opening a parenthesis on a constructor. – Alan Mar 24 '14 at 21:01
  • @DmitriNesteruk I reproduced this bug (?) in a new project. Can you take a look at my screen shot? Is this a bug? – Alan Mar 24 '14 at 21:11
  • It's not a bug, it's an opportunity. If you choose an inaccessible member, ReSharper will offer you a quick fix to make it accessible. – John Saunders Mar 24 '14 at 21:13
  • @JohnSaunders But, it makes my code look broken. **It also doesn't show which are private or protected.** It makes the intellisense hard to use because I cannot decide which is a legal constructor. That's what I said in my 2nd list point.. I thought it was allowing a refactor, but surely it should tell me which are legal at that point in time? – Alan Mar 24 '14 at 21:33
  • @JohnSaunders Also.. if I complete a protected or private constructor, resharper doesn't suggest any refactor to public. It doesn't offer that as an option. – Alan Mar 24 '14 at 21:35
  • What do you mean, "it makes your code look broken"? If the constructor is not accessible, it will show in red, right? You then get to decide if that's the constructor you meant to use. If it is, then you get to change the accessibility. If it's not the one you intended to use, then change it. – John Saunders Mar 24 '14 at 21:35
  • I would have to see your code to know why it doesn't suggest changing to public. – John Saunders Mar 24 '14 at 21:35
  • @JohnSaunders It makes it hard to find the public constructors that I'm actually looking for. Why do I want to sort through a bunch of constructors, that I'm intentionally not supposed to see? – Alan Mar 24 '14 at 21:36
  • @JohnSaunders `Class1 c = new Class1("s", "o");` And ALT+ENTER offers no suggestions... just a red highlight telling me the Constructor it suggest I could use was a compile error! Isn't the point of Intellisense to tell me what is Available? Not tell me what would be legal if I modified my code?! – Alan Mar 24 '14 at 21:37
  • It _is_ available - if you change the accessibility, which is something that ReSharper will help you do. In any case, take a look at ReSharper options under "IntelliSense". I'm not sure about it, but try "Completion Behavior" and "Show import items" – John Saunders Mar 24 '14 at 21:58
  • @JohnSaunders Well, if I add a public constructor it doesn't show the private/protected constructors. That is maybe not so bad... I tried the option you suggested as well as others but couldn't find anything that made a difference. – Alan Mar 25 '14 at 13:40

0 Answers0