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

[BUG] Stubs No Longer Compiles If Namespaces Overlap #876

Closed
acgritt opened this issue Mar 30, 2020 · 10 comments · Fixed by #883
Closed

[BUG] Stubs No Longer Compiles If Namespaces Overlap #876

acgritt opened this issue Mar 30, 2020 · 10 comments · Fixed by #883

Comments

@acgritt
Copy link

acgritt commented Mar 30, 2020

Describe the bug
Using statements with names that overlap are no longer properly respected when compiling the RefitStubs.g.cs. It generates the error "The type or namespace name 'Security' does not exist in the namespace 'Project.Common' (are you missing an assembly reference?)". This was working just fine with version 5.0.23.

Steps To Reproduce

  1. Create a class that uses namespaces similar to the following:
using Common.Security;
using Project.Common;

A workaround currently is to do the following:

using Project.Common;
using SomeType = global::Common.Security;

NOTE global:: is required to make the code compile correctly.

Expected behavior
It should compile without error and without having to add global:: or using SomeType = global::Common.Security.SomeType;. Just referencing using Common.Security; should compile.

Environment

  • OS: Windows 10
  • Version: 5.1.27
  • Working Version: 5.0.23
@acgritt acgritt added the bug Something isn't working label Mar 30, 2020
@clairernovotny
Copy link
Member

What would a minimal repro be?

@clairernovotny clairernovotny added showstopper bug and removed bug Something isn't working labels Mar 31, 2020
@acgritt
Copy link
Author

acgritt commented Mar 31, 2020

@clairernovotny I can put one together today. As I haven't put one together for C# before is there a good tool for it or just create a github repo to share it and link to that?

@clairernovotny
Copy link
Member

Easiest thing to do is to create a couple of interfaces in the right namespaces that'll show the error in the unit test project and submit a PR.

@Dreamescaper
Copy link
Contributor

Dreamescaper commented Apr 1, 2020

I think we should add global:: for all usings, that are defined outside of namespace in original file.
(usings defined inside namespace declaration should be left as-is)

@clairernovotny
Copy link
Member

@Dreamescaper Can you add a PR with this fix and the changes from #881 demonstrating the issue?

@Dreamescaper
Copy link
Contributor

Yes, a bit later.

@martincostello
Copy link
Contributor

I had a similar build failure to this caused by a nested internal interface in a test class as there were some usings at the top of the stub file, and then some more nested within that.

In that scenario I was able to fix the build break by just making the test interface non-nested.

@Dreamescaper
Copy link
Contributor

@martincostello
Could you share some example to be sure that's same issue?

@martincostello
Copy link
Contributor

I’ll see if I can come up with a repro tomorrow.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants