enabling XML comments in C++ in Visual Studio 2010 - visual-c++

How can one enable/achieve XML comments for C++ methods ala C# and VB in Visual Studio 2010? It appears this functionality isn't enabled/available by default.
Targeting initially managed C++ projects.

Configuration Properties -> C/C++ -> Output Files -> Generate XML Documentation Files.
You will have to manually add all your xml documentation (/// doesn't auto-create a summary template for you). Also doesn't support paramref. http://msdn.microsoft.com/en-us/library/ms173501.aspx

To auto complete xml documentation stubs when /// is typed try CppTripleSlash - xml doc comments for c++ extension. It also has some basic intellisense to complete xml tags inside doc comments.

I know this is the old one, but everywhere I have looked everyone say's NOT SUPPORTED, need 3rd party tool or similar, none which is not the true. What you need to know is that XML Documentation is supported and is available in Visual Studio 2010, and there are only two things to know about it:
Docs/Previous Versions / Visual Studio / XML Documentation / Recommended Tags for Documentation Comments:
https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/ms177227%28v%3dvs.90%29
In "C++ project properties / C/C++ / Output Files / Generate XML Documentation Files" set to "Yes (/doc)"
It will generate .xdc file for each source file containing documentation comments "///" and merge it into one .xml documentation file. And documentation works just fine later in other projects.

This is not supported in C++ for VS2010.

Related

Sandcastle, /doc, and Unmanaged C++

I work on a project that uses unmanaged visual C++ and a smattering of C#. We are trying to come up with a way to document our project, both the API reference, as well as some additional conceptual documents. Ideally, all of the documentation would live together in a .chm file that we could distribute with our product.
I was already familiar with Doxygen, as a long time C++ developer. Someone suggested that I look into Sandcastle as well, but I've run into a few snags.
From a number of other sources, including other posts on this site, it's well known that sandcastle does not support unmanaged C++. I did find a post that seems to indicate that you can still cram the C++ documentation into sandcastle, by adding the API reference as conceptual topics.
Using Visual Studio 2010, you can turn on the /doc option in the project settings for your unmanaged C++ project. This produces .XDC files which studio then compiles into an .xml file that goes along with your lib/dll/exe. Where I am stuck is that is unclear what exactly you can do with this xml file. Some pages I've found online suggest that you may be able to use this file for intellisense, but I've never seen that work in unmanaged C++. I was hopeful that I might be able to use this .xml file in Sandcastle Help File Builder somehow, but I can't find any examples of how that's done online, and every attempt I've made with SHFB has failed. It seems to only want MAML or HTML files if I want to add an existing conceptual help file.
So my question:
Is there a way to get my /doc generated .xml file into my SHFB help solution?
If not, what is the point of the /doc option for unmanaged C++?
Is there some kind of transformation I can do on my /doc generated .xml file to produce HTML or MAML which I could then import via SHFB?
Can this work, or should I just go back to Doxygen?
In theory, Sandcastle could be used to document unmanaged code but it would require a tool to produce the equivalent reflection data file that is currently produced by the MRefBuilder.exe tool for managed code assemblies. So far, nobody has done that to my knowledge.
I can't comment on the lack of IntelliSense for unmanged C++ since I don't use it anymore. At a guess, /doc is probably there for the managed code output assuming the same compiler is used but with a few extra command line options.
Using XSL to transform the XML comments to MAML is a possibility but, again, it's an option I'm not aware of anyone pursuing. My guess is that most opt to use Doxygen in this case since it's an established solution.
Eric
I have a similar situation. I need XML documentation in my C++/CLI bindings so .NET code can see them with Intellisense. But FYI, Visual Studio 2010 doesn't support XML documentation in native code:
https://msdn.microsoft.com/en-us/library/ms177226(v=vs.100).aspx
Visual Studio 2010
In Visual C++, you can add XML
documentation (triple-slash) comments to your source code and instruct
the compiler to output them to an .xml file. This file can then be
input to a process that creates documentation for the classes in your
code. The IDE for Visual C++ in this version does not support XML
comments in Intellisense.
That limitation was removed in Visual Studio 2013. However, it's still an annoying ecosystem to work with if you use templates in the native code (e.g. Boost libraries):
In the current release, code comments are not processed on templates or anything containing a template type (for example, a function taking a parameter as a template). Adding such comments will result in undefined behavior.
I found your question while searching for a way to temporarily disable the XML comment parser with a #pragma or #define when including such libraries.

Exporting DLL description - reference with Visual Studio 2012

I colleague of mine asked me to see a dll that he needs to use. So I used the Object Browser on Visual Studio 2012. Now he asked me if I can export like a text version of the dll reference (methods signatures and properties).
Is there a way to do it?
I can already see something like
short get_Param(short sNumParam)
Member of LMLib.ISWKey
on the windows dedicated to the description. I just need to put every method in a single file.
You can do it with a trick and have the IDE generate the definitions for you. Write a sliver of code in the text editor, similar to:
var obj = new LMLib.ISWKey();
Right-click ISWKey in the text editor and select "Go To Definition". You'll get a new text file with the definitions, auto-generated from the metadata.
If it is a COM interface, sure sounds like it with a name like that, then you can run Oleview.exe from the Visual Studio Command Prompt. Use File + View Typelib, select the type library of the COM server and you'll get the auto-generated IDL for the server. Prefer this approach if it is in fact a COM server, you'll get more info, including the [helpstring] attributes.
And of course, don't hesitate to ask the owner of the DLL for documentation. You paid good money for the license to use the DLL.

Visual Studio 2008 Read values from XSD file

First post. I am trying to read the values of any XSD in Visual Basic. I want the application to read back values like complextypes, elements etc. I have been looking at MSXML2 but most examples include validation against a XML file. I only want to read XSD and get information. Will xml reader be able to read a XSD file? Any help be great.
It depends a lot on what you're trying to do with this information, therefore the prerequisites you need to have in place before doing it.
For all but really trivial tasks, I recommend the use of classes in System.Xml.Schema namespace, particularly start with XmlSchema and XmlSchemaSet. This would allow you to manipulate XSDs any way you want; it would also allow you to validate the schemas before using them, if it would prove to be a requirement.
For completeness, and for what I would call very simple tasks, you may also think that XSD is just XML, so then any XML processor should allow you to load an XSD and interogate it as needed.
All of the above, since you've mentioned VS2008, would be on Visual Basic.NET. If you're still on Visual Basic and need to rely on MSXML, then I would refer you to this article on using Visual Basic and SOM.

Parsing Excel files in monotouch

Are there any good ways of parsing Excel files in monotouch? Seems like most methods to work with Excel is based on using the Excel Object Library. Doesn't seem like that's even an option in monotouch? I read that objective-c doesn't have any native support for Excel-files, so don't know if that would change anything?
You would need to either
write your own
find an obj-c library that does it and write MT bindings for it
find a open source .NET library and port it to MT
If all you want to do is display a file, you can use the existing iOS document APIs to do it.
The newest Office formats are XML based, so depending on how complex the files are, writing your own parser might be feasible to do.
I ended up just writing the middle step, a web service that fetches the Excel file, parses it and serves up the content as xml/json.

Add Visual C++ property sheets using CMake

I'm currently porting a gcc project to Visual C++. It's defined in a CMake file, and I have created a Visual C++ property sheet to aid in compatibility (GccCompat.props). Everytime the Visual C++ project files are regenerated by CMake, the property sheet has to be added manually, since I don't know how to add it automatically. So, the question is:
How can I tell CMake to add a property sheet to the generated Visual C++ solution?
This functionality has made it into the nightly build of CMake (https://gitlab.kitware.com/cmake/cmake/commit/e390991846825799e619e072a28f1da58b7c89ba), although not into a stable release yet. Theoretically, it will be in the next release, and CMake releases are made relatively frequently.
To use, you would set the VS_USER_PROPS property on a target. Eg. set_target_properties(foo PROPERTIES VS_USER_PROPS "${props_file}").
However, it doesn't appear that you can use multiple property sheets with this option, and, it replaces the default user property file ($(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props). To workaround this, property sheets can include other property sheets, so, you could make a 'master' property sheet which includes any other property sheets that you would like to use (including the default user property sheet).
This question is a little bit old but I have recently stumbled upon the same problem while integrating GStreamer into my project. GStreamer comes with a set of extremely well prepared and high quality Property Sheets and I wanted to use them instead of hacking things around in CMake.
Fortunately, this issue is only limited to Windows and Visual Studio. So here's my solution:
The idea is to use Visual Studio's .user file feature. CMake does not generate this file so it's pretty safe to generate it at configure-time. At configure time you may generate a file that has the EXACT name as your project file but ends with a .user extension.
Partial Solution:
If your project file is named my_project.vcxproj, you need to create another file next to it called my_project.vcxproj.user. According to MSDN:
A user file (.vcxproj.user) stores user-specific properties, for
example, debugging and deployment settings. The vcxproj.user file
applies to all projects for a particular user.
The contents of this file for importing property sheets is something like this:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="/path/to/sheet1.props" />
<Import Project="/path/to/sheet2.props" />
</Project>
Not flawless, but works until CMake starts supporting property sheets. The file can be created by using CMake's file command at configure-time.
Potential Caveat:
I have noticed when I add property sheets this way, sometimes they do not show in the Property Manager window (might be a bug in Visual Studio Community 2013) but they always are imported properly and dependencies are resolved correctly.
Not sure which properties you need. A few could be set directly in CMake, like in this example for multiple configurations:
set (CMAKE_CONFIGURATION_TYPES "A;B;C;D" CACHE STRING "Configurations" FORCE)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
set (CMAKE_CXX_FLAGS_${OUTPUTCONFIG} "/ZI /Od")
set (CMAKE_EXE_LINKER_FLAGS_${OUTPUTCONFIG} "/debug")
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
Apart from variables listed here, I think CMake has no possibility to attach property sheets.
in my master props file main.props:
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
then, in CMakeLists.txt:
set_target_properties(foo PROPERTIES VS_USER_PROPS "main.props")

Resources