dotnet / dotnet/roslyn

Compiler misreporting CS0246: Type or namespace could not be found

Open
#78,616 1 comment 0 reactions 0 assignees View on GitHub
Area-Compilers Concept-Diagnostic Clarity
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

Repro:

1. Checkout branch https://github.com/tmat/roslyn/tree/Bug78616
In this branch the namespace of `OneOrMany` type was changed from `Roslyn.Utilities` to `Microsoft.CodeAnalysis.Collections` but imports have not been updated yet.
2. Open Roslyn.sln in VS.
3. Open `AbstractEditAndContinueAnalyzer.cs` and navigate to line 1479
![Image](https://github.com/user-attachments/assets/f0c0d6d6-fdb9-49b7-ac52-a158de659373)

The statement does not access `OneOrMany`:

```C#
map.AddRange(memberBodyMap.Forward);
```

`map` is `Dictionary`
`memberBodyMap` is `DeclarationBodyMap`
`memberBodyMap.Forward` is `IReadOnlyDictionary`

The file even contains `using Microsoft.CodeAnalysis.Collections;`.

Is the error reported correcty?

Contributor guide

Open the contributing guide

Research direction

Check out the Bug78616 branch and open Roslyn.sln in Visual Studio. Inspect AbstractEditAndContinueAnalyzer.cs around line 1479, including the types of map and memberBodyMap.Forward, and determine why the compiler reports CS0246 there despite the using directive. Done means explaining whether the diagnostic is correct and identifying the relevant compiler behavior or missing fix.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.