Classes with the same name as a namespace, and 'using' clauses

Hi,

I've hit a small problem with the error-checking/highlighting built into ReSharper where we have a
class in a package that 'clashes' with an existing class in another namespace, which is also being
imported. I'll explain by way of example of what I have done.

I was not happy with the implementation of the System.Uri class, and so I have written my own
implementation of it, and put it into our own namespace called Common.Uri. This seems to cause some
headaches for the C# parser, and it gets confused between The System.Uri class; (ii) The
Common.Uri namespace; and (iii) the Common.Uri.Uri class. It made it report errors such as "Type
name expected, but namespace name found", and "Argument type 'Uri' is not assignable to parameter
type 'Uri'" whereever 'Uri' was used. The code wouldn't compile in this state.

I didn't really want to fully-qualify the 'Uri' class name whereever I had used it (I hate that
kind of thing), and I found that if I created an alias at the top of the namespace for my Uri class
where I was using it, everything came right (i.e., I added "using Uri = Common.Uri.Uri;").
Everything compiled and ran correctly - BUT, the ReSharper add-in was still underlining/reporting
the errors with the 'Uri' class. Because of that, it can't resolve some of the method names on my
Uri class (for Ctrl+Space completion, etc.), as it doesn't seem to understand which one is being
used (System.Uri or Common.Uri.Uri). It seems to be ignoring the alias.

With C#, the 'norm' seems to be to import entire namespaces (e.g., 'using System.IO;') as against
importing individual classes (with an alias, e.g., using File = System.IO.File;). It would be nice
if there was a flag or something indicating whether to pull in an entire namespace or just the
indivdual classes required from it.


Has anyone else experienced this problem? Looks like a bug in the ReSharper add-in, but I noticed
that the latest EAP build (#73) that the error-checking had improved quite a bit, but it was still
getting confused where I've used an alias for the 'Uri' class.


Thanks in advance for any help anyone can give me.


Regards,
Corey.

2 comments
Comment actions Permalink

Hi, Corey,

thank you for your bug report. This problem is already known (submitted as request #794). We plan to fix it in the near future.

-- Nikolay Pultsin
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink


Good stuff! Thanks. :)

Regards,
Corey.


Nikolay Pultsin (JetBrains) wrote:

Hi, Corey,

thank you for your bug report. This problem is already known (submitted as request #794). We plan to fix it in the near future.

-- Nikolay Pultsin
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0

Please sign in to leave a comment.