dotnet / dotnet/aspnetcore

Invisible namespace for other projects under specific folder name

Open
#53,867 1 comment 0 reactions 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

I have a lib project X that contains a folder named `Requests` with a file that has a namespace `X.Api.Dtos.Requests`.

If I try to use classes from the `X.Api.Dtos.Requests` into my ASPNET project that has X as a reference, the project says the namespace cannot be resolved.

![image](https://github.com/dotnet/aspnetcore/assets/35759490/7e171b3e-daa8-4aac-85e5-b16568c6db35)
![image](https://github.com/dotnet/aspnetcore/assets/35759490/3a85b731-9353-449b-b58a-a9c036b6dd55)

But if you rename the folder `Requests` into something else, like `Request` as an example, the ASPNET project see the `X.Api.Dtos.Requests` namespace.

![image](https://github.com/dotnet/aspnetcore/assets/35759490/d3a56cd5-5d29-4acc-8365-12fbb99a4667)
![image](https://github.com/dotnet/aspnetcore/assets/35759490/324e75b6-c3f2-4e47-9500-13f6dc083509)

### Expected Behavior

The name of a folder shouldn't affect the visibility of a namespace in a project

### Steps To Reproduce

- Create an ASPNET proj
- Create a lib project
- Add the reference of the lib project to the ASPNET one
- Follow the steps in the description

### Exceptions (if any)

_No response_

### .NET Version

net6.0

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.