-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expose display option to add ! on non-nullable types #40519
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
Conversation
e227aa5 to
c902e82
Compare
|
There is no need to expose this flag for PublicApiAnalyzers. Regardless of whether this flag is internal or public, the analyzer will be using the flag only via reflection. If you want to expose it for other reasons, then that's fine too. |
What makes you say that? The analyzer for shipped APIs makes a |
|
@jcouv the analyzer references an old version of the compiler package, so unless the new flag is back-ported to Roslyn 1.x, it would only be accessible via light-up (reflection). |
|
@sharwell Reflection is not the only way to use the new flag. You can cast a number to an enum type. That's what I did in WIP PR. This hard-coding is safe because the enum value is part of public API (ie. won't change). |
|
@dotnet/roslyn-compiler for review. This PR will unblock an analyzer PR (to include nullability information in shipped APIs). |
| case CodeAnalysis.NullableAnnotation.Annotated: | ||
| if (format.MiscellaneousOptions.IncludesOption(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier) && | ||
| if ((format.MiscellaneousOptions.IncludesOption(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier) || | ||
| format.MiscellaneousOptions.IncludesOption(SymbolDisplayMiscellaneousOptions.IncludeNonNullableReferenceTypeModifier)) && |
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.
Is this change needed? (It seems strange that IncludeNonNullable... implies IncludeNullable... but not the reverse. Can we separate the two completely?) #Closed
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.
I'd be okay with making the two flags independent, but I couldn't think of a scenario when we would want to print ! annotations but not ? annotations.
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.
@333fred What's your thought on the relationship of these two flags?
Previously, we asserted that we only use the ! flag when we also use the ? flag. But an assertion isn't sufficient for public APIs, obviously. We could make the flag independent, or we could throw an exception when an invalid combination of flags is produced.
333fred
left a comment
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.
![]()
|
Dankeshon I'm re-running the integration branch. It has been consistently flaky in multiple PRs for me recently. Has anyone else run into this? |
* dotnet/master: (592 commits) Improve nullable analysis of local functions (dotnet#40422) Fix race condition in CodeFixService Annotate CSharpCompilation (dotnet#40752) Revert "Merge pull request dotnet#40765 from dibarbet/revert_use_index" More feedback address feedback More refactoring and hardening of remote calls (dotnet#40395) Update PublishData.json Unskip and fix integration test Update configs for preview 2 snap Improve error message for CS0191 (dotnet#40748) Revert "Merge pull request dotnet#40410 from sharwell/use-index" PR feedback Report erroneous implicit conversions in a switch expression (dotnet#40678) Ignore dynamic vs object, etc in pattern-matching machinery. (dotnet#40677) Handle dependent slots in pattern-matching null tests. (dotnet#39625) Pass non-null arguments to avoid nullability warning Update dependencies from https://github.com/dotnet/arcade build 20200104.1 (dotnet#40749) [master] Update dependencies from dotnet/arcade (dotnet#40718) Expose display option to add ! on non-nullable types (dotnet#40519) ...
To display
!in shipped API files (WIP PR at dotnet/roslyn-analyzers#3125), we'll need to expose the previously-internal display option.