1

I'm developping in Visual Studio for Dynamics 365. I need to extend a class named with _Extension final name. Below the details:

class MyParentClass_Extension
{
    str doSomething(int arg) 
   {
       // ...
   }
}

I would like to create a child class:

[ExtensionOf(classStr(MyParentClass_Extension))]
final class My ChildClass_Extension_Extension
{
    str doSomething(int arg) 
    {
        // Part 1
        var s = next doSomething(arg + 4);
        // Part 2
        return s;
    }
}

I retrive a compile error. There is any way to extend a class like mine?

Thanks.

rjv
  • 1,058
  • 11
  • 29
ulisses
  • 1,549
  • 3
  • 37
  • 85
  • Also, for the purposes of people who might be finding this q&a through google, would you be able to update the question with a copy&paste of the exact error message? – rjv Sep 06 '19 at 18:17

2 Answers2

2

You will have to be running Platform Update 26 or later. It is only possible to extend extension classes once you are on PU26 or a later platform.

Under "Extensibility Enhancements" in the link I provided above, you will find a link the third wave of extensibility enhancements. In here you will notice they have added the ability to extend extensions.

To answer your question: You are likely receiving the compile error because you are running a platform update prior to PU26.

rjv
  • 1,058
  • 11
  • 29
1

What I understand by your code, there are a total of 3 classes:

  1. MyParentClass
  2. MyParentClass_Extension which extends MyParentClass
  3. MyParentClass_Extension_Extension which extends MyParentClass_Extension

Now when you create an extension you always set it as final which means that you can not extend this class further. In your case what I believe you already set final for MyParentClass_Extension class and the next child class MyParentClass_Extension_extension is trying to extend MyParentClass_Extension which is final. That's why you are getting an error.

B. Go
  • 1,436
  • 4
  • 15
  • 22