Re: abstract class 'does not implement interface member ...'
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Jun 2007 13:31:53 -0400
Ben,
Well, that's a different story. The issue with me is that abstract
members can not implement interface members.
However, saying that a protected member can not expose an internal
member is justified, because with a protected member, the possibility exists
that the protected member will be accessed outside of the assembly, which
would violate the internal member's visibility.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message
news:entjJlErHHA.4020@xxxxxxxxxxxxxxxxxxxxxxx
"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in message news:uOKVctDrHHA.4740@xxxxxxxxxxxxxxxxxxxxxxx
Ben,
I see what you are getting at now. This is one of the things that has
always frustrated me as well. Honestly, I never saw any pitfalls to
allowing this, since abstract methods are the same as virtual methods
anyways when seen from the derived class on.
I've never understood this whole requirement about "type less visible than
...". Why can't I return an internal interface from a protected member
function, or vice versa? There are some perfectly valid combinations that
just can't be used currently. At most, the compiler should generate a
warning, definitely not an error.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message
news:Oc4kUgDrHHA.4100@xxxxxxxxxxxxxxxxxxxxxxx
"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in message news:uW%23gXcDrHHA.4984@xxxxxxxxxxxxxxxxxxxxxxx
Ben,
According to the language specification:
20.4.5 Abstract classes and interfaces
1. Like a non-abstract class, an abstract class must provide
implementations of all members of the interfaces that are listed in the
base class list of the class.
Ok, but since the interface is internal, I should be allowed to:
public interface IInvocable
{
object Operation { get; }
}
internal interface IInvocableInternals : IInvocable
{
bool OperationValidate(string args);
string ProxiedOperation { get; }
}
public abstract class InvocableInternals : IInvocableInternals
{
internal abstract string ProxiedOperation { get; }
public object Operation { get { return ProxiedOperation; } }
}
Or are you asking why the language specification is this way?
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message
news:%236aN$VDrHHA.1296@xxxxxxxxxxxxxxxxxxxxxxx
I get
C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27):
error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not
implement interface member
'UselessJunkForDissassembly.IInvocableInternals.OperationValidate(string)'
C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27):
error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not
implement interface member
'UselessJunkForDissassembly.IInvocableInternals.ProxiedOperation'
when compiling:
public interface IInvocable
{
object Operation { get; }
}
internal interface IInvocableInternals : IInvocable
{
bool OperationValidate(string args);
string ProxiedOperation { get; }
}
public abstract class InvocableInternals : IInvocableInternals
{
public object Operation { get { return ProxiedOperation; } }
}
But, I already knew the class didn't implement those functions.
That's why it is *abstract*. Please note that I've replaced all
complicated types with object or string to make a minimal
reproduction. I don't want my internal functions exposed publicly, I
can't hide InvocableInternals because public classes inherit from it,
and I don't want to use a forwarder because, I'm convinced that the
JIT wouldn't be able to inline it.
Why isn't it allowed to just implement
"IInvocableInternals.OperationValidate" in the most derived class?
.
- References:
- abstract class 'does not implement interface member ...'
- From: Ben Voigt [C++ MVP]
- Re: abstract class 'does not implement interface member ...'
- From: Nicholas Paldino [.NET/C# MVP]
- Re: abstract class 'does not implement interface member ...'
- From: Ben Voigt [C++ MVP]
- Re: abstract class 'does not implement interface member ...'
- From: Nicholas Paldino [.NET/C# MVP]
- Re: abstract class 'does not implement interface member ...'
- From: Ben Voigt [C++ MVP]
- abstract class 'does not implement interface member ...'
- Prev by Date: Re: Query on data from diffrent OleDBConnections
- Next by Date: Re: How do I inflate compressed data from an asynchronous socket?
- Previous by thread: Re: abstract class 'does not implement interface member ...'
- Next by thread: Re: abstract class 'does not implement interface member ...'
- Index(es):
Relevant Pages
|
|