.editorconfig option is not always reported correctly
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**:
Visual Studio 17.11.3
**Steps to Reproduce**:
StyleCop.Analyzers received this bug report: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3887
@AArnott experienced a malfunctioning StyleCop.Analyzers rule. While debugging this it seemed that the analyzer did not always get the correct value for the `insert_final_newline` option. The bug only occurred in the AssemblyInfo.cs file, which happens to be shared between all projects and only when compiling one specific project. The same .editorconfig file should be used for all projects.
To have a simpler way of testing this, I created a separate analyzer in this repo: https://github.com/bjornhellander/EditorConfigProblem1
It contains a single analyzer which checks that the mentioned option is true in all syntax trees. If I build the nuget package from that repo and add it to the Directory.Packages.props file in the repo that @AArnott mentions in the original issue, it triggers only on the AssemblyInfo.cs file while compiling the CodeFixes project. So the same behavior that we saw in StyleCop.Analyzers.
Hint: I also notice that this specific project does not have any files "of its own". If I add a new class inside the CodeFixes project, the diagnostic in AssemblyInfo.cs goes away.
Tagging @sharwell as well
**Expected Behavior**:
All .editorconfig options should be reported correctly in all projects.
**Actual Behavior**:
`insert_final_newline` (i have not checked any other) is not reported correctly in one of the projects.
Contributor guide
Research direction
Start by reproducing the behavior with the EditorConfigProblem1 analyzer and the referenced repository setup, focusing on AssemblyInfo.cs, the CodeFixes project, and Directory.Packages.props. Compare how insert_final_newline is reported when the project has no files of its own versus after adding a class. Done means .editorconfig options are reported consistently across all projects and syntax trees.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100