Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Nov 19, 2025

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.

: base(IDEDiagnosticIds.RemoveUnnecessaryDiscardDesignationDiagnosticId,
EnforceOnBuildValues.RemoveUnnecessaryDiscardDesignation,
option: null,
fadingOption: null,
Copy link
Member Author

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();
Copy link
Member Author

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))
Copy link
Member

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 ?

@dibarbet
Copy link
Member

dibarbet commented Nov 19, 2025

@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.

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
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@CyrusNajmabadi CyrusNajmabadi merged commit 0afca81 into dotnet:main Nov 20, 2025
25 of 26 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the fadingOptinos branch November 20, 2025 10:38
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants