Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reference a constructor from C# XML comment?

Is it possible to reference a constructor from a C# XML comment without resorting to the explicit prefixes (like M: or T:)?

For instance, the following yields compilation warnings, because the compiler does not like ".ctor". Trying "PublishDynamicComponentAttribute.#ctor" is no good,
"PublishDynamicComponentAttribute.PublishDynamicComponentAttribute" is no good too.

/// <summary> /// Constructs a new <see cref="PublishEntityAttribute"/> instance. /// </summary> /// <seealso cref="PublishDynamicComponentAttribute..ctor(Type)"/> public PublishEntityAttribute(Type entityFactoryType) :   base(entityFactoryType) { } 

I am sure the type itself is visible.

So, I am left to use the explicit prefix M:, which removes the compiler verification, so when a type is moved/renamed the cref will be invalid.

Any suggestions?

like image 864
mark Avatar asked Jul 14 '09 08:07

mark


People also ask

Can we refer address of constructor?

We cannot refer to the addresses of constructors since we only require the address of a function to call it and they can never be called directly.

Why copy constructor take reference?

A copy constructor defines what copying means,So if we pass an object only (we will be passing the copy of that object) but to create the copy we will need a copy constructor, Hence it leads to infinite recursion. So, A copy constructor must have a reference as an argument.

How do you call a constructor in C++?

A constructor is automatically called when an object is created. It must be placed in public section of class. If we do not specify a constructor, C++ compiler generates a default constructor for object (expects no parameters and has an empty body).


1 Answers

You specify a constructor as if you are calling it, but with the types of the arguments instead of values for them:

/// <seealso cref="PublishDynamicComponentAttribute(Type)"/> 
like image 164
adrianbanks Avatar answered Oct 02 '22 22:10

adrianbanks