Replies: 13 comments
-
I think it's more responsible for the text editor. |
Beta Was this translation helpful? Give feedback.
-
I don't think there should be any kind of notification about this, because implicit implementation (like Why do you think this requires a notification? Why did it confuse you? |
Beta Was this translation helpful? Give feedback.
-
It confused me when I used (document as ICopy).Copy(); and I've forgotten about writing that Method and it used the main Copy.Method from the same class, it took me a while to find a problem because I tho I did it 0o (the code wasnt that simple of course) simple notification about would be just awsome, sometimes you are just tired and do stupid mistakes that is all. Thanks for the comment tho°! |
Beta Was this translation helpful? Give feedback.
-
First: if this is a suggestion for a behavioral change in VS2015, then this should go to /dotnet/roslyn. /dotnet/csharplang is for suggestions to changes in the C# language itself. Second: this suggestion for the IDE needs to be much more fleshed out. Say we did this:
Thanks much! |
Beta Was this translation helpful? Give feedback.
-
@CyrusNajmabadi Could the IDE provide a built-in support of finding "all methods implementing the interface"? I think this is useful in some scenarios. |
Beta Was this translation helpful? Give feedback.
-
Yes. FindAllReference on the interface method will list all the implementations. It even finds weird stuff like this: interface IFoo { void Foo(); }
class C { public void Foo(); }
class D : C, IFoo { }
In this case, it will find the implementation in C, even though C never actually specifies that it implements IFoo. Indeed, C.Foo only becomes an implementation due to D's implementation of IFoo. |
Beta Was this translation helpful? Give feedback.
-
For: interface IFoo
{
void Bar();
}
class Foo : IFoo
{
public void Bar() { }
void IFoo.Bar() { }
} it possibly would be nice to have something warn that both an implicit and explicit implementation of |
Beta Was this translation helpful? Give feedback.
-
@DavidArno it does sound a lot like an Analyzer to me. |
Beta Was this translation helpful? Give feedback.
-
Even then, it always binds to the explicit implementation as far as the interface is concerned. I've done some neat tricks with that in the past. 🙃 |
Beta Was this translation helpful? Give feedback.
-
Absolutely. SuccincT makes heavy use of that. The pattern expressions are created via the builder pattern; using around a dozen interfaces and explicit implementations of those interfaces to only expose valid methods depending on the context of the fluent chain. |
Beta Was this translation helpful? Give feedback.
-
ReSharper adds an icon into the margin telling you that a method implements an interface: Do you think this is good enough for you? If so, have you considered using ReSharper? Or do you think VS itself should show such an icon? |
Beta Was this translation helpful? Give feedback.
-
I've been using R# for years and never noticed it did that! 😀 |
Beta Was this translation helpful? Give feedback.
-
This is a pretty common and normal pattern. Warning in this case would break a lot of code. Note: you don't actually have an implicit implementation of 'Bar' here. You have the explicit implementation, and you have a public method with a matching signature.
Yup. There is nothing wrong with this code. If you don't want it in your domain, then it's best to write your own analyzer to catch this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, i'm kinda new here, and really like C# and VS but I've found some points where it can be improved(or I think so ^^).
Interfaces - it would be nice to have some warning or notification in VS2017 that(document as ICopy).Copy(); going to use Main Void Method if none of his own is declared.
Visual Studio have its own Notification by Debug it could be placed here.
For example a notification or warning by Visual Studio in Debuging mode(at Warnings or Notifications):
"Interface ICopy have none of its own Copy.Method and will use main method from Class.Document"
Beta Was this translation helpful? Give feedback.
All reactions