Skip to content

IDE0078 diagnostic shows up without the code fix in CSharp CodeStyle NuGet package #45569

@mavasani

Description

@mavasani

Version Used: Latest

Steps to Reproduce:

  1. Create a simple C# project
  2. Add a NuGet package reference to latest NuGet package from https://dotnet.myget.org/feed/roslyn/package/nuget/Microsoft.CodeAnalysis.CSharp.CodeStyle
  3. Add code that triggers IDE0078 (Use pattern matching). Refer to https://github.com/dotnet/roslyn/blob/8601701c373aa687fdf5ccbe4a24498f67433751/src/EditorFeatures/CSharpTest/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzerTests.cs.

Expected Behavior:
IDE0078 diagnostic + Code fix on Ctrl + Dot

Actual Behavior:
IDE0078 diagnostic, but no code fix is offered.

The reason is that the analyzer was correctly added to analyzers shared project that is included in both Features and CodeStyle NuGet package. However, both the code fix and tests were added to Features/EditorFeatures instead of being added to shared projects. Hence the fix is not part of CodeStyle NuGet package:

Actual locations

  1. Analyzer location:
    https://github.com/dotnet/roslyn/blob/8601701c373aa687fdf5ccbe4a24498f67433751/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs
  2. Fixer location: https://github.com/dotnet/roslyn/blob/8601701c373aa687fdf5ccbe4a24498f67433751/src/Features/CSharp/Portable/UsePatternCombinators/CSharpUsePatternCombinatorsCodeFixProvider.cs
  3. Tests location: https://github.com/dotnet/roslyn/blob/8601701c373aa687fdf5ccbe4a24498f67433751/src/EditorFeatures/CSharpTest/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzerTests.cs

Expected locations

  1. Analyzer location is fine
  2. Fixer location: https://github.com/dotnet/roslyn/tree/master/src/Analyzers/CSharp/CodeFixes
  3. Tests location: https://github.com/dotnet/roslyn/tree/master/src/Analyzers/CSharp/Tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions