Re: abstract class 'does not implement interface member ...'



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?











.



Relevant Pages

  • Re: Design Problem Aggregation
    ... >Class E has a member of type A. ... As D is the base class of E and F we can add to the container ... >that interface in E and F. A and B have many member functions and I ... This is called the Interface Segregation Principle. ...
    (comp.object)
  • Re: implementing roles in OOP......
    ... > e.g. a person is a member of a network of family members and a member ... > bla bla bla ... the fact that I have two different contexts ... > I can ask the object for a reference to an interface to that role (and ...
    (comp.object)
  • Recomendation for Public Safety Use
    ... I am a member of a volunteer ambulance service and am looking for a good GPS receiver for my service's use. ... -Vehicle mounted with external antenna and hardwired power supply, but can be removed with minimal fuss and used portable with built-in antenna and battery supply. ... -Computer interface with standard communication protocol. ...
    (sci.geo.satellite-nav)
  • Re: abstract class does not implement interface member ...
    ... Like a non-abstract class, an abstract class must provide implementations ... implement interface member ... internal interface IInvocableInternals: IInvocable ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: If_bridge behaving as HUB
    ... I have a bridge setup with a number of vlan IF's as members. ... After a while traffic destined for one member IF are sent to all member IF's. ... A bridge works like a hub, forwarding traffic from one interface to ... Multicast and broadcast packets are always forwarded to all ...
    (freebsd-net)