Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullness :: Render C# code analysis attributes in tooltips #17485

Merged
merged 5 commits into from
Aug 11, 2024

Conversation

T-Gro
Copy link
Member

@T-Gro T-Gro commented Aug 2, 2024

C# offers a selection of attributes for API authors that guide the compiler in nullable flow analysis:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/nullable-analysis

F# compiler does not do flow analysis, but these attributes are a good source of contract documentation.
Even when they are processed, there is value in showing them to developers as part of QuickInfo tooltips.

As of now, the selection is filtered for all attributes coming from System.Diagnostics.CodeAnalysis namespace.

Typical APIs where this is present in BCL are added in tooltip tests (see tests in this PR).
This covers among others:

  • System.IO.* APIs
  • The TryParse pattern

Please let me know of there are styles of API design with those attributes worth testing and covering
(i.e. real world usages of those attributes beyond the already tested attribute targets - method, method return type, method parameter)

Addresses: #17402

@T-Gro T-Gro requested a review from a team as a code owner August 2, 2024 17:34
@dotnet dotnet deleted a comment from github-actions bot Aug 2, 2024
@T-Gro T-Gro self-assigned this Aug 2, 2024
@T-Gro T-Gro linked an issue Aug 2, 2024 that may be closed by this pull request
7 tasks
@psfinaki
Copy link
Member

psfinaki commented Aug 9, 2024

Looks reasonable, could you please add a couple of screenshots how tooltips look like now?

Copy link
Contributor

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/9.0.100.md

@vzarytovskii vzarytovskii merged commit ed4263f into main Aug 11, 2024
30 checks passed
@T-Gro T-Gro deleted the nullness-tooltip-csharp-codeanalysis-attributes branch September 9, 2024 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Nullness issue - show C# nullness attributes in tooltips
3 participants