XML comments not showing up in IntelliSense (VS2010 Express)

Locked XML comments not showing up in IntelliSense (VS2010 Express)

  • Friday, January 06, 2012 2:46 PM
     
      Has Code

    From what I've gathered from msdn (http://msdn.microsoft.com/en-us/library/ms177226%28v=VS.100%29.aspx), it is possible to have XML formatted commentation. However, I can't seem to get the added comments to show up in the IntelliSence pop-ups. I have set the \doc option and after a build I have a .xml file in my Debug folder, where my .exe, .ilk and .pdb are also created in.

    Below I've given an exmple of what I'm trying to work with. Hovering with my mouse over "Cow::Cow(const char * nm, const char * no, double wt)" for example gives me a pop-up with the following information:

     

    Cow::Cow(const char * nm, const char * no, double wt)
    
    Cow::Cow()
    Cow::Cow(const Cow &c)

    Anyone who knows what might be the problem here?

    Cow.h

    #pragma once
    
    /// Text for class Cow
    class Cow
    {
    private:
    	char name[20];
    	char * hobby;
    	double weight;
    public:
    	Cow(void);
    
    	///<summary>This constructor takes parameters to set the 
    	/// members of the Cow class.</summary>
    	/// <param name="nm">Name as string of the cow.</param>
    	/// <param name="ho">Hobby as string of the cow.</param>
    	/// <param name="wt">Weight of the cow as a double.</param>
    	Cow(const char * nm, const char * ho, double wt);
    
    	/// <summary>Copy constructor</summary>
    	/// <param name="c">A Cow object</param>
    	Cow(const Cow &c);
    	~Cow(void);
    
    	Cow & operator=(const Cow &c);
    	void showCow(void) const; /// Show all Cow related data.
    };
    

    Cow.cpp

    #include "StdAfx.h"
    #include "Cow.h"
    #include <cstring>
    #include <iostream>
    
    Cow::Cow(void)
    {
    	name[0] = '\0';
    	hobby = new char[1];
    	hobby[0] = '\0';
    	weight = 0.0;
    }
    
    Cow::Cow(const char * nm, const char * no, double wt)
    {
    	//Set name
    	std::strncpy(name, nm,20);
    	//Set hobby
    	hobby = new char[std::strlen(no) + 1];
    	std::strcpy(hobby, no);
    	//set weight
    	weight = wt;
    }
    
    Cow::Cow(const Cow &c)
    {
    	std::strcpy(name,c.name);
    	hobby = new char[std::strlen(c.hobby)+1];
    	std::strcpy(hobby,c.hobby);
    	weight = c.weight;
    }
    
    Cow::~Cow(void)
    {
    	delete [] hobby;
    }
    
    Cow & Cow::operator=(const Cow &c)
    {
    	std::strcpy(name,c.name);
    	delete [] hobby;
    	hobby = new char[std::strlen(c.hobby)+1];
    	std::strcpy(hobby,c.hobby);
    	weight = c.weight;
    	return *this;
    }
    
    void Cow::showCow() const
    {
    	std::cout << "name: " << name << ", hobby: " << hobby << 
    		", weight: " << weight << std::endl;
    }
    
    

All Replies

  • Friday, January 06, 2012 10:08 PM
     
      Has Code

    Try doing it with only two // for the comments like the following.  That works for me.  I sometimes have to do something like:

    this->MyFunction

    to get Intellisense to get into gear and find the function syntax, but that always works even when just typing the function doesn't.

    Tom

    	//<summary>This constructor takes parameters to set the 
    	// members of the Cow class.</summary>
    	// <param name="nm">Name as string of the cow.</param>
    	// <param name="ho">Hobby as string of the cow.</param>
    	// <param name="wt">Weight of the cow as a double.</param>


  • Monday, January 09, 2012 7:52 AM
     
      Has Code

    Using the double slash ( // ) comment style in front results in the comments not getting 'built' into the .XML file. And indeed, did not solve my problem.

    Putting the XML formatted comments in the .cpp file and building the restult, actually made the comment visible by IntelliSense during autocompletion, but do so WITH <summary></summary> pieces. Secondly, the comment was only available for that particular file. For example, in the mainfile where I would use this simple Cow class, and I would try to autocomplete the constructor for Cow(const char * nm, const char * ho, double wt), I don't get to see the comment text (which off course one of the reasons I am writing them!).

     

    For those interested, the .XML file looks like this:

    <?xml version="1.0"?>
    <doc>
        <assembly>
            "Chapter12"
        </assembly>
        <members>
            <member name="M:Cow.showCow">
                <summary>Prints data members to std::cout.</summary>
            </member>
            <member name="M:Cow.#ctor(Cow!System.Runtime.CompilerServices.IsConst*!System.Runtime.CompilerServices.IsImplicitlyDereferenced)">
                <summary>Copy constructor</summary>
                <param name="c">A Cow object</param>
            </member>
            <member name="M:Cow.#ctor(System.SByte!System.Runtime.CompilerServices.IsSignUnspecifiedByte!System.Runtime.CompilerServices.IsConst*,System.SByte!System.Runtime.CompilerServices.IsSignUnspecifiedByte!System.Runtime.CompilerServices.IsConst*,System.Double)">
                <summary>This constructor takes parameters to set the 
    members of the Cow class.</summary>
                <param name="nm">Name as string of the cow.</param>
                <param name="ho">Hobby as string of the cow.</param>
                <param name="wt">Weight of the cow as a double.</param>
            </member>
        </members>
    </doc>