dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.04k stars 4.03k forks source link

'CSharpRemoveUnusedValuesCodeFixProvider' encountered an error and has been disabled. #75005

Open mitchdenny opened 1 month ago

mitchdenny commented 1 month ago

Version Used: Microsoft Visual Studio Enterprise 2022 (64-bit) - Int Preview Version 17.12.0 Preview 2.0 [35228.322.main]

Steps to Reproduce:

  1. Clone https://github.com/dotnet/aspire
  2. Launch VS using startvs.cmd
  3. Start moving around the code base and wait for error to occur.

A minimal repro, with source-code provided, is ideal. Using sharplab is preferred for compiler/language issues whenever possible.

Diagnostic Id: CSharpRemoveUnusedValuesCodeFixProvider

If this is a report about a bug in an analyzer, please include the diagnostic ID and message if possible (e.g. "IDE0030: Use coalesce expression").

Expected Behavior:

No yellow bars.

Actual Behavior:

image

Getting an exception in VS (this is one of many that I get, starting to file issues that I'm having):

System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeAssembly.get_DefinedTypes() at System.Composition.Hosting.ContainerConfiguration.<>c.b__16_0(Assembly a) at System.Linq.Enumerable.d__172.MoveNext() at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable1 types,AttributedModelProvider attributeContext) at System.Composition.Hosting.ContainerConfiguration.CreateContainer() at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.MefHostExportProvider.Create(String languageName) at System.Runtime.CompilerServices.ConditionalWeakTable2.GetValue(TKey key,CreateValueCallback createValueCallback) at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices..ctor(HostLanguageServices hostLanguageServices) at Microsoft.CodeAnalysis.Host.CodeStyleHostLanguageServices.Create(HostLanguageServices hostLanguageServices) at System.Runtime.CompilerServices.ConditionalWeakTable2.GetValue(TKey key,CreateValueCallback createValueCallback) at Microsoft.CodeAnalysis.Shared.Extensions.ProjectExtensions.GetExtendedLanguageServices(Project project) at Microsoft.CodeAnalysis.RemoveUnusedParametersAndValues.AbstractRemoveUnusedValuesCodeFixProvider11.IsForEachIterationVariableDiagnostic(Diagnostic diagnostic,Document document,CancellationToken cancellationToken) at async Microsoft.CodeAnalysis.RemoveUnusedParametersAndValues.AbstractRemoveUnusedValuesCodeFixProvider11.RegisterCodeFixesAsync[TExpressionSyntax,TStatementSyntax,TBlockSyntax,TExpressionStatementSyntax,TLocalDeclarationStatementSyntax,TVariableDeclaratorSyntax,TForEachStatementSyntax,TSwitchCaseBlockSyntax,TSwitchCaseLabelOrClauseSyntax,TCatchStatementSyntax,TCatchBlockSyntax]() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetCodeFixesAsync() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T]()

CyrusNajmabadi commented 1 month ago

@sharwell can you dupe this against the primary issue? Thanks!