I'm working on parsing out the XML file that is generated when you pass /doc as a compiler option. We had previously been using VSDocman to handle the parsing and documentation website generation, along with custom topics. We ultimately didn't like the web site generated by VSDocman though and want to do something more robust with MVC.
It's easy enough to parse the XML file, but I'd like to also add custom topics like I can in VSDocman to the XML file. Is that not possible with the built in documentation support in Visual Studio? Will I have to create a custom XML file that manages all of that, writing it manually (or building a custom tool to generate it) and parsing it during my /doc parsing?
Microsoft itself does not define a standard format for extra documentation. Thus, you have to decide what tool to use next and then use the format it supports.
Besides, XML is so flexible that you can try to transform it from one format to another, so I assume it is not a big deal.
Related
I'm writing XML documentation for a couple of C# projects. I want to be able to parse the file that comes out into HTML suitable for posting on GitHub Pages. I've got a pretty good handle on the parsing process itself, but I need an idea of all the elements that might show up in documentation.
I thought that a DTD might be the best resource for this, does that exist? Or is this all completely free-form?
I realize there are a few tools that already exist to do this, but I want finer control over the process and honestly it's good practice anyway.
XML validation is a product of some sort of application. The documentation comments in C# are just XML. It is the application that you parse/process the comments with that determines if there are any rules for what elements are allowed. There are multiple applications that can convert XML documentation comments into documentation, and you could even build your own if needed.
As mentioned, MSDN has a list of available elements. These are standardized across most parsers. If you need to add additional elements it is fine if you have a parser that can handle them. You could even add an XSD or DTD if you wanted for that application, if supported.
To keep track of my new year resolutions I created a file daily.log in the following format.
8:40 AM 1/2/2013
begin:755am
activity:enquired about 3x3 black board;bought book [beginning html 5]
waste:facebook;
meeting:old friend;mechanic
programming:none
blogpost:[asp.net deployment]
do:buy black board
done:
end:1045pm
I am in the process of creating a simple C# console application which would ask me a few questions and fill this file accordingly. One of the future features to this tool would be to display a simple dashboard style web page for measuring the progress of resolutions among other things.
I would to like to use a data serialization or configuration file format for storing daily activity information in this manner, because mature tools are available for these formats rather than for plain text.
I never used JSON before and am wondering whether the JSON format can be used independently with C# (no javascript involved), and even if I can, whether the usage of JSON is appropriate in this case.
If not JSON, its superset YAML? or are any other alternatives that suit well for this purpose?
You can use JSON.NET in C# without using javascript. And I believe this data can be modeled in JSON format.
If your goal is to work with external tools to have them recognize and be able to work with your files, a better bet than JSON would be to use XML. This format is stricter (and you can use XML Schema to validate the format) and there are way more tools that are able to work with XML than there are for JSON.
The .NET Framework also contains extensive support for XML, in the System.Xml namespace (see http://msdn.microsoft.com/en-us/library/system.xml(v=vs.100).aspx).
That being said, there is no reason why JSON would not work with C#. I have personally used the JSON.NET library for most JSON work and it works beautifully (see http://james.newtonking.com/projects/json-net.aspx). Mind you, the data you show in your example is not valid JSON.
Good luck!
For the purposes of unit testing, I would like to validate that two xml files contain the same data, but ignore the order of the elements or attributes.
I am currently using MbUnit.Framework.Xml.XmlAssert.XmlEquals, and it seems to have a few options but I can't find any documentation. It returns false if the element order is different.
This is a c# project.
Try using Microsoft's XML Diff and Patch Tool.
In addition to the XML Diff and Patch API, you may be interested in taking a look at the Windows Forms code sample that implements the tool - XML Diff and Patch GUI Tool (The API's dll is included in this download).
A while back I was happily using xmlunit for these kinds of problems, http://xmlunit.sourceforge.net/, not sure about the .net side of it, or if it is still kept uptodate &c.
I have this XML file, and I want to deserialize it to an object. But I don't want to type its class definition. There is any tool that can create the C# code of the class for me, inferring the data types from sample data?
Yes. Out of the box, you can use xsd.exe to generate XSD files from XML. You can also use this tool to generate classes from XSD files.
The code it produces is limited, which is why there are some third party tools that have stepped in.
Two of those tools include LiquidXML (costs money) and CodeXS (free). We use CodeXS, because it is free and extensible. We have extended it quite a bit.
EDIT:
CodeXS has an online tool. Just give it an XSD. It produces your classes for you.
They also have a command-line tool (source code) which is extensible and doesn't require you to send the XSD to their web service. We use it as a pre-build step.
Liquid Technologies has a good tool for this purpose (Data binding) http://www.liquid-technologies.com/. You'll really need to define a schema though instead of letting such a tool "infer" it from sample data.
One of the benefits of Liquid that we've found is that it can also generate code for Java, C++, C#, VBA etc. All very consistent.
Check out LINQ-to-XSD
It requires that you write a schema for your XML but then it's pretty good about a direct translation to objects.
I would like to write all meta data (including advanced summary properties) for my files in a windows folder to a csv file. Is there a way to collect all the attributes? I see mp3 files have a different set of attributes compared to jpg files. (c#)
This can also be a script (vb, perl)
Update: by looking at libextractor (thank you) I can see this can be achieved by writing different plugins for different type of files. I gather this meta data is not a simple collection...
In Perl, you can use MP3::Tag or MP3::Info
If you can cope w/ VB.Net: http://www.codeproject.com/KB/vb/mp3id3v1.aspx
If you can cope w/ C++/.Net: http://www.codeproject.com/KB/audio-video/mp3fileinfo.aspx
For either (assuming the C++) is compiled to .Net, you can use Reflector to disassemble the binary and convert it to C#. Check w/ the respective authors about their licenses first (usually Code Project articles are under an open license like CPOL).
In a library? Try libextractor if your software is GPL.
Ok, after the clarification edits, I would suggest looking at the introspection available in .Net. I will warn you however that I think you will get more satisfying results if you forgo introspection and define the specific properties that you want for the file types that you expect to see.
Since scripting is valid, then if this were my problem to solve I would use Powershell since the .net introspection is baked in.
It may not be worth it to add all of the data from a jpeg file (exif data). I would hand pick what attributes I wanted from those files.