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

VB -> C#: Duplicate Namespace #201

Closed
vfle opened this issue Nov 12, 2018 · 6 comments
Closed

VB -> C#: Duplicate Namespace #201

vfle opened this issue Nov 12, 2018 · 6 comments
Assignees
Labels
help wanted VB -> C# Specific to VB -> C# conversion

Comments

@vfle
Copy link

vfle commented Nov 12, 2018

Please prefix the issue title with either "C# -> VB: " or "VB -> C#: " if relevant

Input code

Namespace Child

Erroneous output

namespace Root.Namespace.Root.Namespace.Child

Expected output

namespace Root.Namespace.Child

Details

Product in use: VS extension

Version in use: 6.1

The project is a class library with a root namespace project property set. At the example above it would be Root.Namespace .
I am not sure why the second root namespace appears.

It is an easy work around on the produced code to replace the duplicates, just reporting in case something more serious is hidden.

@GrahamTheCoder GrahamTheCoder added the VB -> C# Specific to VB -> C# conversion label Nov 13, 2018
@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Nov 13, 2018

Thanks for the report. QualifyNode covers the general case of qualification. I suspect that means this special case code is actually redundant, and causing this bug by doing it again:
https://github.com/icsharpcode/CodeConverter/blob/master/ICSharpCode.CodeConverter/CSharp/NodesVisitor.cs#L106

I think the tests don't have a root namespace set, so it's hard to notice it during development and will need a slightly custom test (or a restoration of the project and solution level tests which could easily set a root namespace).

@knodel12
Copy link

@GrahamTheCoder Wondering why you removed the RootNamespace logic. It seems that all VB files that previously had no namespace now get created in C# without a namespace, regardless of the project root namespace. Is this intentional?

GrahamTheCoder added a commit that referenced this issue Nov 17, 2018
@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Nov 17, 2018

Ah ok yes, thanks for paying attention! In the case where the namespace is missing, we do indeed still need to add it, but we don't need to add on to existing ones. I'll add that bit back.

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Nov 17, 2018

I've also tried to tighten up the addition of the root namespace where relevant. Shout if you notice any more issues with it.

@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Jun 3, 2019

See repro on #318 (closed to consolidate with this)

@GrahamTheCoder
Copy link
Member

Fixed in 2483369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

3 participants