ILSpy
ILSpy copied to clipboard
XML documentation issues with C++/CLI code which uses "const"
Input code
This code is correctly decompiled, but the XML documentation is missing.
This is C++/CLI code:
/// <summary>
/// Example Class
/// </summary>
public ref class Example
{
public:
/// <summary>
/// Hello Function
/// </summary>
/// <param name="param1">Parameter 1</param>
/// <returns>value of param1</returns>
static int Hello(const int param1)
{
return param1;
}
};
Due to using the "const" keyword on the first parameter, the XML file contains something rarely seen, and this may be throwing off ILSpy:
<member name="M:Example.Hello(System.Int32!System.Runtime.CompilerServices.IsConst)">
If I remove the part !System.Runtime.CompilerServices.IsConst
, then it will output the XML documentation properly.
A preconfigured Visual Studio project to build the example is available here: https://www.dwedit.org/files/.ilspy/DummyProject4.7z
edit:
It also appears that char*
is repesented in the XML as System.SByte!System.Runtime.CompilerServices.IsSignUnspecifiedByte*
.
Erroneous output
XML documentation is missing because "!System.Runtime.CompilerServices.IsConst" is appended to the type name, and ILSpy is unable to handle that.
Details
- Product in use: ILSpy
- Version in use: 7.2.1.6856
The problem is that ILSpy uses its type system to generate ID strings and then looks up the XML doc for that ID string. In order to implement a language-agnostic ID string generation, we would have to either include all metadata in the type system, which would be a massive breaking change and affecting all of the decompiler engine, or - a more realistic approach - instead of using the type system to generate ID strings, reimplement ID string generation using System.Reflection.Metadata.