dotnet / dotnet/roslynator

[Bug] `--include` flag does not handle space separated globs

Open
#1,835 0 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
C#
Stars
3.5k
Forks
294
Avg merge
2h 30m
Merged PRs (30d)
4

Description

### Product and version

CLI 1.0.0

### Rule or diagnostic ID

_No response_

### Steps to reproduce

Reproduction: https://github.com/samcarswell/roslynator-fix-include-bug-repro

```bash
roslynator analyze ./TestSolution.sln --include 'ProjectA/MyClass.cs ProjectB/AnotherClass.cs'
```

### Actual behavior

```bash
git clone https://github.com/samcarswell/roslynator-fix-include-bug-repro.git
cd roslynator-fix-include-bug-repro
roslynator analyze ./TestSolution.sln --include 'ProjectA/MyClass.cs ProjectB/AnotherClass.cs'
```

Outputs:
```
Loading solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln'...
Analyze solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln'
Analyze 'ProjectA' 1/2
Analyze 'ProjectB' 2/2
Analyzed solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln' (in 406 ms)

0 diagnostics found
```

### Expected behavior

I would expect the combined diagnostics from both files. If ran independently they produce the expected results:

```bash
roslynator analyze ./TestSolution.sln --include 'ProjectA/MyClass.cs'
```
produces:
```
Loading solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln'...
Analyze solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln'
Analyze 'ProjectA' 1/2
MyClass.cs(3,14): error CS0518: Predefined type 'System.Object' is not defined or imported
MyClass.cs(5,12): error CS0518: Predefined type 'System.String' is not defined or imported
MyClass.cs(7,16): error CS0518: Predefined type 'System.String' is not defined or imported
MyClass.cs(3,14): error CS1729: 'object' does not contain a constructor that takes 0 arguments
MyClass.cs(5,19): info CA1822: Member 'GetMessage' does not access instance data and can be marked as static
Analyze 'ProjectB' 2/2
Analyzed solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln' (in 406 ms)

1 CA1822 Mark members as static
3 CS0518
1 CS1729

5 diagnostics found
```

and

```bash
roslynator analyze ./TestSolution.sln --include 'ProjectB/AnotherClass.cs'
```

produces

```
Loading solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln'...
Analyze solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln'
Analyze 'ProjectA' 1/2
Analyze 'ProjectB' 2/2
AnotherClass.cs(3,14): error CS0518: Predefined type 'System.Object' is not defined or imported
AnotherClass.cs(5,12): error CS0518: Predefined type 'System.String' is not defined or imported
AnotherClass.cs(7,16): error CS0518: Predefined type 'System.String' is not defined or imported
AnotherClass.cs(3,14): error CS1729: 'object' does not contain a constructor that takes 0 arguments
AnotherClass.cs(5,19): info CA1822: Member 'GetMessage' does not access instance data and can be marked as static
Analyzed solution '/Users/srcarswell/workspace/github/samcarswell/roslynator-fix-include-bug-repro/TestSolution.sln' (in 407 ms)

1 CA1822 Mark members as static
3 CS0518
1 CS1729

5 diagnostics found
```

### Exception messages and stack traces

```shell

```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported command with the linked roslynator-fix-include-bug-repro project, then trace the CLI handling of the --include argument and its space-separated glob matching. Done means a single command including both paths reports the combined diagnostics shown in the issue, while each individual path continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.