How to make forward reference cref in C++/CLI

Topics: User Forum
Aug 17, 2008 at 2:20 PM
How can I make a reference in eg. a <see cref="..."/> to a method that has not yet been declared in C++?
Consider for example the following scenario:

public enum class Color
/// <summary>
/// Red color. Used with <see cref="M:Window::SetColor" />.
/// </summary>
/// <summary>
/// Blue color. Used with <see cref="M:Window::SetColor" />.
/// </summary>

public ref class Window
/// <summary>
/// Changes the color to the one specified. See also <see cref="Color" />
/// </summary>
void SetColor(Color color);
The reference in the documentation from Window to the enum will work, but it seems the reference from the enum to the method in the class will not. And I don't see how I can create a forward declaration in C++ that would allow this?
Is there a solution to this?
Aug 17, 2008 at 7:48 PM

This is a known issue with the C++ compiler.  I'm not aware of any workarounds or fixes.  You may try asking in the Sandcastle project forums or on the MSDN Documentation forum as you'll get a wider audience for the question.



Aug 17, 2008 at 9:23 PM
I was afraid of that. Seems someone forgot it is not possible to forward declare enums... :(

Thanks for your reply anyhow... I'll try the other forums too just in case as you suggest.
Aug 19, 2008 at 3:04 PM
There is a trick you should be able to use:

The C++ compiler will prefix all invalid cref's with !: but shfb removes the prefix if you have the cppcommentfixup enabled.

Just write the full name of the reference with dots and it should work.

i.e. The c++ compiler can't find

so it converts it into

Which shfb converts back.

You will lose the compiler check that the reference exists but for forward references you don't have it anyway.

Aug 19, 2008 at 3:09 PM
Thanks.  I'd forgotten that was in there.