-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Simplify and fix fading options. #81346
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
| : base(IDEDiagnosticIds.RemoveUnnecessaryDiscardDesignationDiagnosticId, | ||
| EnforceOnBuildValues.RemoveUnnecessaryDiscardDesignation, | ||
| option: null, | ||
| fadingOption: 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.
i always disliked how these options were being handled. now is a good opportunity to rip it all out since it broke anyways.
| { IDEDiagnosticIds.RemoveUnreachableCodeDiagnosticId, FadingOptions.FadeOutUnreachableCode }, | ||
| { IDEDiagnosticIds.RemoveUnnecessaryImportsDiagnosticId, FadingOptions.FadeOutUnusedImports }, | ||
| { IDEDiagnosticIds.RemoveUnnecessaryImportsGeneratedCodeDiagnosticId, FadingOptions.FadeOutUnusedImports }, | ||
| }.ToImmutableDictionary(); |
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.
the end result of all that goo was populating a dictionary with these values. So..................................................... just populate the dictionary once, in the place where it is read.
Maybe there's a cleaner way to do this. But i can't think of anything, so here we go.
|
|
||
| // DiagnosticId supports fading, check if the corresponding VS option is turned on. | ||
| if (!SupportsFadingOption(diagnosticData, globalOptionService)) | ||
| if (s_diagnosticToFadingOption.TryGetValue(diagnosticData.Id, out var fadingOption)) |
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.
Would logging or a Debug.Assert here help us avoid regressions? Perhaps if the Id begins with IDE ?
unfortunately i dont think there is currently an easy way to test this. would need to setup the infrastructure to allow the lsp tests to spawn and use the remote process. |
| public static readonly PerLanguageOption2<bool> FadeOutUnusedMembers = new("dotnet_fade_out_unused_members", defaultValue: true); | ||
| public static readonly PerLanguageOption2<bool> FadeOutUnreachableCode = new("dotnet_fade_out_unreachable_code", defaultValue: true); | ||
|
|
||
| // When adding a new fading option, be sure to update ProtocolConversions.ConvertDiagnostic |
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.
should we just define the map here instead?
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.
Will do!
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.
Done!
Have validated this fixes things.
@dibarbet i looked into a pull diagnostics test that actually used the remote workspace... and i gave up. if you can think of a cheap way to write a test that hits this and actually goes through the remote codepath (so it would fail prior to this fix and work after the fix) lmk.