3

Consider the following code snippet:

/// <summary>
/// Serializes this <see cref="ICollection"/>? object to a <see cref="string?"/>, skipping nulls.
/// </summary>
/// <param name="val">The value to process.</param>
/// <param name="separator">Optional separator.</param>
/// <returns><see cref="string?"/>.</returns>
public static string? SerializeToString(this ICollection? val, string? separator = null)
{
    if (val is null)
        return null;

With reference to the XML documentation, with cref="ICollection?"/>, Intellisense will not display the ?, which is why I put it after the <see /> block.

However, with <see cref="string?"/>, it will display the ?.

<see cref="MatchCollection?"/> won't display the ?.

Two of these examples are classes, one is an interface.

I noticed the ? won't display with generics, such as public A[]? MyFunc().

What am I misunderstanding here?

4
  • Would Nullable{MatchCollection} and public Nullable{A[]} MyFunc() work in the short term? Commented Apr 15, 2022 at 13:23
  • 1
    I'm sure they would. I'm just trying to wrap my mind around what is happening. I don't know if this is a bug or if I'm misunderstanding some fundamental. Commented Apr 15, 2022 at 13:25
  • 2
    It definitely seems to me like an oversight when implementing nullable reference types. (Or rather, when updating XML document generation to support NRTs). Commented Apr 15, 2022 at 13:25
  • string? will be displayed, but you cannot click it. Commented Apr 15, 2022 at 13:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.