ASP.NET Core – How to receive requests with XML content

Receiving requests with XML content is straightforward. You have to register the built-in XML InputFormatter (otherwise you get 415 – Unsupported Media Type errors). When a request comes in with an XML Content-Type (such as application/xml), it uses this InputFormatter to deserialize the request body XML. In this article, I’ll show step-by-step how to receive … Read more

XML doc warnings: CS1573 and CS1572

I’ll show examples of the XML documentation warnings and how to fix them. CS1573 Parameter ‘X’ has no matching param tag in the XML comment (but other parameters do) Warning CS1573 means there’s a missing <param> tag for one of the method parameters. This usually happens when you add a new parameter (or rename one … Read more

C# – Using XmlSerializer to serialize

Here’s how to serialize an object into XML using XmlSerializer: You must add the [Serializable] attribute to the class you want to serialize: Here’s an example of creating an Author object and feeding it to the serializer: This outputs the following XML: This example showed how to use XmlSerializer with all the default settings. In … Read more

How to generate XML documentation and include it in a nuget package

XML documentation comments serve two purposes: In this article I’ll show how to automatically generate an XML documentation file and how to include it in a nuget package. 1 – Write the XML documentation comments in your code I have a method called MergeInPlace() (which merges two dictionaries in-place). To explain what this is doing … Read more