dotnet / dotnet/roslyn

C#: Autosuggest in XMLDOCS suggests signatures that will not match after insertion when using nullable annotations with generics

Open
#78,052 0 comments 0 reactions 0 assignees View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/C:-Autosuggest-in-XMLDOCS-suggests-sign/10885507)._

---
[severity:It's more difficult to complete my work]
Whenever you use a `cref="..."` attribute (be it inside a `<see ...>`/`<seealso ...` or `<inheritdoc ...>` tag in XMLDOCS you can get autosuggest suggestions that will **not** be recognized after insertion.

# Steps to reproduce:

1. Create a new C# project, be sure that `Nullable` is enabled.
2. Add any class.
3. Add a method and some xml documentation
```cs
/// <summary>
/// Foo
/// </summary>
public static void Foo<T>(T? foo) { }
```
4. Add _another_ method
```cs
public static void Bar() { }
```
5. Now try to inherit the second methods documentation from the first via `<inheritdoc cref="..." />`. As soon as you open the `cref` tag you will get an autosuggestion list.

![Screenshot 2025-04-05 155140.png](https://aka.ms/dc/image?name=Bae5c2ccbda5a421ab64da6323e280868638794586066547965_20250405-160324-Screenshot_2025-04-05_155140.png&tid=ae5c2ccbda5a421ab64da6323e280868638794586066547965)

6. **Pick** the "Foo" suggestion:
![Screenshot 2025-04-05 155218.png](https://aka.ms/dc/image?name=Bb0722e92d8a04243ab020d820b4ef807638794586690009159_20250405-160427-Screenshot_2025-04-05_155218.png&tid=b0722e92d8a04243ab020d820b4ef807638794586690009159)

# Observation(s):
- _Note how the inserted signature inside the `cref` attribute is **white** and not **yellow** - yellow would mean a resolved signature, white is not_.
- _Note how the Intellisense documentation for the inheriting method is empty_:
![Screenshot 2025-04-05 155226.png](https://aka.ms/dc/image?name=Bc44198643d5f4196859f78c1ec27cacd638794588660621736_20250405-160744-Screenshot_2025-04-05_155226.png&tid=c44198643d5f4196859f78c1ec27cacd638794588660621736)
- Enabling the "Documentation file" option for the project will fail to create documentation for the documentation inheriting method:
![image.png](https://aka.ms/dc/image?name=B56ce8931f9454e918184f1e2ca802334638794593310636039_20250405-161529-image.png&tid=56ce8931f9454e918184f1e2ca802334638794593310636039)

## Workaround:
You have to **manually** remove all `?` annotations inside the cref attribute for Intellisense to correctly resolve the referenced signature:
![Screenshot 2025-04-05 155241.png](https://aka.ms/dc/image?name=Be218f14e5d2e409e9b0cc21909d3b943638794590000660651_20250405-160958-Screenshot_2025-04-05_155241.png&tid=e218f14e5d2e409e9b0cc21909d3b943638794590000660651)

# Observed behaviour:
Code (xmldoc) completion suggestions produce signatures that cannot be resolved by Intellisense or the xmldoc compiler.

# Expected behaviour:
Code (xmldoc) completion suggestions should poduce signatures that can later be resolved by Intellisense/xmldoc compiler.

### Regression?
I *think* this might be a regression, but I'm not sure. I only particularly noticed this behaviour in the latest Version (17.13.5) of Visual Studio.

---
### Original Comments

#### Feedback Bot on 4/7/2025, 00:24 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

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.