Starting with Visual Studio 2022 v17.12, unreachable/unused code is faded out:

I personally find it getting in the way when writing new methods. Unfortunately, there is no options in VS to turn it off or adjust the effect. See also setting dotnet_diagnostic.IDE0051.severity = none does not disable unused private member (IDE0051) fading edit, Fade out unused methods is now being forced and Publics are bright and Privates are dim in Visual Studio 2022 17.12.0 for more discussions.
I’ve created an extension for Visual Commander to modify the effect. VS sets unreachable code opacity to 0.6, the following code sets it to 1 (if you want, you can modify it to any intermediate value):
References:
Microsoft.VisualStudio.ComponentModelHost
Microsoft.VisualStudio.Text.Logic
Microsoft.VisualStudio.Text.UI.Wpf
C#
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Text.Classification;
public class E : VisualCommanderExt.IExtension
{
public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
SetClassificationOpacity(package as System.IServiceProvider, "UnnecessaryCodeDiagnostic", 1);
}
public void Close()
{
}
private bool SetClassificationOpacity(System.IServiceProvider serviceProvider, string classification, double opacity)
{
IComponentModel componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
IClassificationTypeRegistryService registryService = componentModel.GetService<IClassificationTypeRegistryService>();
IClassificationFormatMap classificationFormatMap = componentModel.GetService<IClassificationFormatMapService>().GetClassificationFormatMap(category: "text");
IClassificationType classificationType = registryService.GetClassificationType(classification);
if (classificationType == null)
return false;
var properties = classificationFormatMap.GetExplicitTextProperties(classificationType);
var newProperties = properties.SetForegroundOpacity(opacity);
classificationFormatMap.SetExplicitTextProperties(classificationType, newProperties);
return true;
}
}

Instead of entering the code, you can also import the extension from Unreachable code opacity.vcmd

There seems to be something missing
(0,0): error CS0006: Metadata file ‘Microsoft.VisualStudio.ComponentModelHost’ could not be found
Sorry for this problem.
This file is normally located at somewhere like C:Program FilesMicrosoft Visual Studio2022PreviewCommon7IDECommonExtensionsPlatformMefHostingMicrosoft.VisualStudio.ComponentModelHost.dll
Do you have it there?
Thank you! Despite everything, Microsoft still haven’t fixed this issue even in VS2026. Your plugin fixes it flawlessly however.
Thank you so much for posting this, works great in VS 2026. It has been driving me nuts having to either prematurely reference my private methods or setting them as public while I initially write them just to keep them from constantly fading out because I might have stopped typing for a half second. Completely infuriating, but I expect nothing less from MS these days.