Skip to content

Bulk codefixes are broken #14967

Closed
Closed

Description

@psfinaki

C#:

csharp.mp4

F#:

fsharp.mp4

Nothing happens in F#. This is sad.

Known workarounds

Apply codefixes one by one? Regex replace?

Additional context

Discovered during some F# session with @T-Gro

Activity

  1. added this to the Backlog milestone on Mar 23, 2023
  2. T-Gro commented on Mar 23, 2023

    @T-Gro
    Member

    Found something in the docs and we do not seem to use it centrally.

    namespace Microsoft.CodeAnalysis.CodeFixes
    
    open Microsoft.CodeAnalysis.CodeFixes
    
    
    ///<summary>
    ///            Implement this type to provide fixes for source code problems.
    ///            Remember to use <see cref="T:Microsoft.CodeAnalysis.CodeFixes.ExportCodeFixProviderAttribute" /> so the host environment can offer your fixes in a UI.
    ///            </summary>
    type CodeFixProvider =
      
      new: unit -> unit
      
      member ComputeRequestPriority: unit -> Microsoft.CodeAnalysis.CodeActions.CodeActionRequestPriority
      
      ///<summary>
      ///            Gets an optional <see cref="T:Microsoft.CodeAnalysis.CodeFixes.FixAllProvider" /> that can fix all/multiple occurrences of diagnostics fixed by this code fix provider.
      ///            Return null if the provider doesn't support fix all/multiple occurrences.
      ///            Otherwise, you can return any of the well known fix all providers from <see cref="T:Microsoft.CodeAnalysis.CodeFixes.WellKnownFixAllProviders" /> or implement your own fix all provider.
      ///            </summary>
      member GetFixAllProvider: unit -> FixAllProvider

    The unused opens uses a wellknown batch provider, which has limitation in it's remarks which causes the unused opens to not work.
    I have a feeling that the limitation might have been added later after F# implemented this codefix.. ?

    ///<summary>
    ///            Contains well known implementations of <see cref="T:Microsoft.CodeAnalysis.CodeFixes.FixAllProvider" />.
    ///            </summary>
    type WellKnownFixAllProviders =
      
      ///<summary>
      ///            Default batch fix all provider.
      ///            This provider batches all the individual diagnostic fixes across the scope of fix all action,
      ///            computes fixes in parallel and then merges all the non-conflicting fixes into a single fix all code action.
      ///            This fixer supports fixes for the following fix all scopes:
      ///            <see cref="F:Microsoft.CodeAnalysis.CodeFixes.FixAllScope.Document" />, <see cref="F:Microsoft.CodeAnalysis.CodeFixes.FixAllScope.Project" />, <see cref="F:Microsoft.CodeAnalysis.CodeFixes.FixAllScope.Solution" /><see cref="F:Microsoft.CodeAnalysis.CodeFixes.FixAllScope.ContainingMember" /> and <see cref="F:Microsoft.CodeAnalysis.CodeFixes.FixAllScope.ContainingType" />.
      ///            </summary>
      ///<remarks>
      ///            The batch fix all provider only batches operations (i.e. <see cref="T:Microsoft.CodeAnalysis.CodeActions.CodeActionOperation" />) of type
      ///            <see cref="T:Microsoft.CodeAnalysis.CodeActions.ApplyChangesOperation" /> present within the individual diagnostic fixes. Other types of
      ///            operations present within these fixes are ignored.
      ///            </remarks>
      static member BatchFixer: FixAllProvider
  3. self-assigned this
    on Mar 23, 2023
  4. 0101 commented on Mar 27, 2023

    @0101
    Contributor

    Duplicate of #14864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-LangService-CodeFixesCode fixes associated with diagnosticsArea-VS-EditorVS editor support for F# code, not covered elsewhereBug

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions