Skip to content

ILegacyGlobalOptionsWorkspaceService does not provide an implementation in the workspaces layer #66779

@sharwell

Description

@sharwell

Version Used: 4.3.0-2.final and newer

Steps to Reproduce:

  1. Create an analyzer project
  2. Attempt to test the analyzer with custom values of FormattingOptions.IndentationSize in the workspace

Expected Behavior:

The indentation is accounted for in the code fix behavior.

Actual Behavior:

There is no implementation of ILegacyGlobalOptionsWorkspaceService provided, so the code fix ends up using CodeActionOptions.DefaultProvider instead of the options defined by the user.

// TODO: avoid ILegacyGlobalOptionsWorkspaceService https://github.com/dotnet/roslyn/issues/60777
var globalOptions = document.Project.Solution.Services.GetService<ILegacyGlobalOptionsWorkspaceService>();
var fallbackOptions = globalOptions?.CleanCodeGenerationOptionsProvider ?? CodeActionOptions.DefaultProvider;

Additional Context:

This is blocking the move of StyleCop Analyzers to testing against Roslyn 4.4.0 / C# 11 in DotNetAnalyzers/StyleCopAnalyzers#3580.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEuntriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions