-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Show nullability flow analysis in Quick Info #36731
Show nullability flow analysis in Quick Info #36731
Conversation
ab3d4a8
to
c5bf0f8
Compare
Why do we think this? It should be noted that typescript supports that fine without issue: |
Enh... i think we're not giving users enough credit here. I think they'll understand immediately after 10 seconds using the feature: ok, it's telling me the info "here" (which seems to be intuitive since that's where they asked for the info). |
Going to hold off on review until design question is resolved. |
@CyrusNajmabadi We landed on this design after considering those questions, and one thing we did take as an assumption is that over time we may want to reduce the display as people do get more comfortable with it. We agreed that once people get the mental model then yes they'll figure it out easily -- but how they were going to get there in the first place was a concern. We very much consider this a "point in time" even if that point in time is just the next few point releases. This is also addressing a specific problem that we don't have notation to distinguish "this is not null" and "this is oblivious". If quick info shows "string foo", that means either "this is non-null" or "we don't know because the library you called into isn't annotated In design meetings and such we've often done things like I would have also imagined that TypeScript the concept of "types change at use" isn't new to the language -- even if the nullability concept was added later, I assume "the type of this can change" was there from the very start? |
It was new to the language. It only came in TypeSCript 2.0 when control-based-flow-analysis was added. Prior to that, there was no such concept and you'd always just see the declaration information. |
I'd err in the other direction. Just supply the accurate information about what the type is at that point. if it turns out people are confused by this (which i doubt), then we could add information in. It seems highly speculative. Honestly, i really don't think people will be confused here. :) |
c6515fd
to
5017008
Compare
5017008
to
16395ba
Compare
@@ -16,5 +16,6 @@ public static class QuickInfoSectionKinds | |||
public const string Exception = nameof(Exception); | |||
public const string Text = nameof(Text); | |||
public const string Captures = nameof(Captures); | |||
internal const string NullabilityAnalysis = nameof(NullabilityAnalysis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this internal as this is still considered a preview experience and indeed may change. Will make it public in the 16.3 branch if this PR ships in 16.2. If it first goes into 16.3 then I'll change this prior to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to add a follow up issue
8bf32a7
to
d063548
Compare
@jinujoseph To give a heads up on this one, this is one small piece the compiler team would like to have in 16.2; it's an enhancement to Quick Info to show some additional nullable information. It's written to only trigger under @333fred's feature flag for risk reduction; technically this isn't a "bugfix" but it's actually less risk than a bug fix. So looking for 16.2 M2 approval for this one. @dotnet/roslyn-ide @ryzngard code reviews? |
src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/QuickInfo/CSharpSemanticQuickInfoProvider.cs
Outdated
Show resolved
Hide resolved
d063548
to
45654b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code looks good for the current design. I'd say the benefit of this design is that it makes a noticeable visual difference that may surprise users (in a good way). Otherwise, I agree with @CyrusNajmabadi that I'm not convinced users would be confused, but I think iterative design would be useful on that front.
src/Features/CSharp/Portable/QuickInfo/CSharpSemanticQuickInfoProvider.cs
Outdated
Show resolved
Hide resolved
|
||
var typeInfo = semanticModel.GetTypeInfo(bindableParent, cancellationToken); | ||
|
||
string messageTemplate = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch expression would look good here :)
45654b1
to
04fdc92
Compare
If you mouse over a local, field, etc., and we have computed nullable flow analysis for it, we'll tell you whether the compiler thinks the item is null or not at that point.
04fdc92
to
8206135
Compare
If you mouse over a local, field, etc., and we have computed nullable flow analysis for it, we'll tell you whether the compiler thinks the item is null or not at that point.
The symbol shown on the first line is always shown with the declared nullability; we decided to keep it that way out of concerns that it differing from the declared nullability (without a clear statement of what is different) would be too confusing -- a simple, straightforward sentence more easily expresses the message, and putting 'here' in the message clarifies that it's a piece of information depending on the exact invocation point, which is somewhat a first for Quick Info.
I don't like that this is rebinding the symbol after we lost it in the quick info infrastructure. There is more cleanup I'd like to do here of the Quick Info code but that'll wait for another PR -- it went into weeds far deeper than I expected at first.
Closes #36191.