Replies: 9 comments
-
Related: #288. One of the open issues there is:
|
Beta Was this translation helpful? Give feedback.
-
You are attempting to override a method declared |
Beta Was this translation helpful? Give feedback.
-
Huh? No. The interface is internal. |
Beta Was this translation helpful? Give feedback.
-
@dotMorten No. The effective accessibility is § 3.5.1
|
Beta Was this translation helpful? Give feedback.
-
That's what the doc says, but it's not really what's happening when implementing explicitly, and you can't cast to an internal interface and access the methods either (if that were to be allowed). It's not really much different than this:
MyMethod is declared public, but it effectively isn't. It's internal, because the class is internal. |
Beta Was this translation helpful? Give feedback.
-
@dotMorten Nope. You're not making a distinction between declared accessibility and effective accessibility, which the spec calls accessibility domain. § 3.5.1:
§ 3.5.2:
|
Beta Was this translation helpful? Give feedback.
-
I support this proposal but I want to point out that internal class SomeClass
{
public void MyMethod() { }
} Is not effectively the same as internal class SomeClass
{
internal void MyMethod() { }
} Because if public class DerivedClass : SomeClass
{
}
/// another dll
new DerivedClass().MyMethod(); // depends on the above implementation But well, for interface it really be another story. I want to point out that class is not a good analogy |
Beta Was this translation helpful? Give feedback.
-
@Thaina A |
Beta Was this translation helpful? Give feedback.
-
Oh right I forgot. Sorry. Then this proposal has no problem altogether |
Beta Was this translation helpful? Give feedback.
-
When you want to implement an interface on a class, you can do it implicit or explicit. Ie
However if I create an internal interface You are forced to implement interfaces explicitly.
Implementing implicitly has a lot of nice features - I don't have to always cast to the interface to use it. This becomes very useful for wrapping native interop classes. I can create an interface that ensures that all classes that wrap native objects follow a common pattern. For instance:
That way if all my classes that wrap my features from my native interop layer all expose the pointer (or similar) in a common way, and always implements IDisposable. So I can just write
However, because I'm forced to explicitly implement classes, this benefit goes away somewhat, by forcing casting on my, and it's not as discoverable from intellisense code that this is available.
Naturally if you implement an internal interface implicitly, you would be forced to use the 'internal' or a more accessible modifier on the members.
Moved over from dotnet/roslyn#3599
/CC @onovotny
Beta Was this translation helpful? Give feedback.
All reactions