Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mavasani opened this issue Jun 30, 2020 · 4 comments · Fixed by #60378
Closed

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

mavasani opened this issue Jun 30, 2020 · 4 comments · Fixed by #60378
Labels
Area-IDE Bug IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Milestone

Comments

@mavasani
Copy link
Contributor

mavasani commented Jun 30, 2020

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
@mavasani mavasani added this to the 16.7.P4 milestone Jun 30, 2020
@mavasani
Copy link
Contributor Author

Tagging @alrz @CyrusNajmabadi

@mavasani
Copy link
Contributor Author

Seems IDE0078 was added with #43596

@alrz
Copy link
Member

alrz commented Jul 1, 2020

I recall the reason for this was that at the time some APIs were not available in the shared layer. (#43596 (comment))

@mavasani
Copy link
Contributor Author

mavasani commented Jul 1, 2020

@alrz Thanks for the context. Lets use this issue to track the work once the shared layer is moved to newer APIs.

@mavasani mavasani added the IDE-CodeStyle Built-in analyzers, fixes, and refactorings label Jul 15, 2020
@jinujoseph jinujoseph modified the milestones: 16.7.P4, 16.7, Backlog Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug IDE-CodeStyle Built-in analyzers, fixes, and refactorings
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants