.net - Weird behavior with C++/CLI and friend assemblies -


I am writing two C ++ / CLI assemblies, in a assembly there is a base class with some internal virtual methods

When I try to override the internal virtual method, the compiler is forcing me to change the visibility level to the public.

What's going on? Why do I have to do this?

Code:

  // Assembly 1 "friend mixer" namespace Friends Component Test {Public Reef Class Base Class {Internal: Base Class () {} Virtual Zero DoSomething () {}}; } // Allow "FriendAsseblyDerived" [Assembly to look internally: :: System :: Runtime :: CompilerServices :: InternalsVisibleToAttribute ( "FriendAssemblyDerived, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100a95fe809ecc53c3a826aa32e3ab1309f2ecae4b91dc649457d704e150f3a4007a151ffe28852f947803dd1a1586c5c0ae2c9688bd76299857ee65ff7efb14905e03b33664a42e2fa1074080c3bad971623514ab6dd9fc4e4343ba7fb98884ecce45f96b71e5f1b55de88e36483274aa71c740fdfb14aacaada6ca22cb39bf9a2")]; // ---------------- // Assembly 2. "Friend Unlinked" fully named and signed #Usage "FriendAssemblyBase.dll" as_friend Namespace FriendsAssangtest {from public referee category Received: Base Class {Public: Derivative () {} void Foo () {DoSomething (); } Internal: // & lt; - Due to C3252 (Can not reduce visibility of virtual) Virtual Zero DoSomething () Override {}}; }  

Because FriendAssemblyBase in other class base Class. Do some .

Liskov replacement principle says that whatever can be done with the original class should be done with every derived class. DerivedClass.DoSomething should be visible on FriendAssemblyBase . This may be the only way that public: .


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -