dotnet / dotnet/roslyn

XML documentation cref to method with nullable array parameter should not produce warnings CS1584 and CS1658

Open
#74,613 0 comments 2 reactions 1 assignee Claimed by @JoeRobich View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

**Version Used**: VS 17.10.4, dotnet CLI 8.0.303, MSBuild 17.10.4+10fbfbf2e

**Steps to Reproduce**:

[sharplab.io](https://sharplab.io/#v2:CYLg1APgAgzABFATHAwnA3gWAFBz3AeiLgB4BnAVwFsqBDAJwE8A+HfQ4gFQAsBLMuP1JkApiLgBjeiIBmAXgBEAWQAUAI0YAXEQG0AugH4AlAoLMAdG3xECpApRoMWVvLAQAWOKo3b9BuD4iZEYYLnAAvjjhQA=)

```csharp
public class C {
///
/// This is .
///
public void M(byte[]? bytes) {
}
}
```

**Expected Behavior**:

No warnings / code completion generating valid cref attribute

**Actual Behavior**:

```
warning CS1584: XML comment has syntactically incorrect cref attribute 'M1(string, string[], byte, byte[]?)'
warning CS1658: ) expected. See also error CS1026.
```
caused by Visual Studio code completion generating invalid cref attribute

---

If I remove the `?` in the cref attribute the warnings disappear and the compiler can also resolve the reference (probably since the CRL signatures match).
I found #49633, which is similar or the same and was closed as "by design".

However, since Visual Studio code completion adds the `?` automatically and in [this #22626 comment by @sharwell](https://github.com/dotnet/roslyn/issues/22626#issuecomment-335494315) he classifies such behavior as problematic and in need of a fix, I decided to open this issue anyway.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.