locked
Is "Finalize" part of the Platform::Object projection in C++/CX?

    Question

  • The IntelliSense drop-down list for a variable of type "Platform::Object ^" shows Finalize() as a protected method in the list of methods on the object. Pressing F12 on Platform::Object (to bring up the Object Browser) also shows Finalize() as a member of Platform::Object.

    Is this method really part of the projection into C++, or is this just "left over" from reusing the CLR metadata format for winmd files (and/or from C++/CLI IntelliSense)?

    If it's part of the projection, what does it do, when is it called, how does it interact with ref-counting, etc.? Can I implement it in my own ref class?

    FWIW, defining a void Finalize() method in a ref class gives the following red squiggly errors in the code window: "Error: a member "Finalize" of this type is reserved within a managed class -- finalizer intended" (H file) and "Error: inherited member is not allowed" (CPP file), but the code builds and runs without errors. (The method is never actually called.)

    Wednesday, September 21, 2011 7:14 PM

Answers

  •  

    Thanks for inquiring on your observation! This question has surfaced previously and this was the response of that inquiry from the C++ team:

      Yes we are aware of this behavior and this is actually how it is designed. We even show private members in the memberlist. If you select it, you will get a red squiggles to give you feedback that you can't make the call. There are also different icons in the memberlist window that will help differentiate member accessibilities.

    -David

    Tuesday, October 25, 2011 4:38 PM
    Moderator

All replies

  • Seems to be a glitch in the intellisense. If you put a breakpoint and examine a Object^, the watch window shows you the vtable and you can see that there is no Finalize method.
    http://blog.voidnish.com
    Wednesday, September 21, 2011 9:21 PM
  •  

    Thanks for inquiring on your observation! This question has surfaced previously and this was the response of that inquiry from the C++ team:

      Yes we are aware of this behavior and this is actually how it is designed. We even show private members in the memberlist. If you select it, you will get a red squiggles to give you feedback that you can't make the call. There are also different icons in the memberlist window that will help differentiate member accessibilities.

    -David

    Tuesday, October 25, 2011 4:38 PM
    Moderator