Mercury support for project level imported namespaces?

A problem I have encountered while converting a project from VB.NET to Mercury is that Mercury does not seem to support project-level Imported namespaces. This feature allows me to identify imported namespaces at the project-level, so I don’t need to do it in each individual file. From what I can tell, this is a VB.NET-only feature and is not supported by C#.

Because my original project took advantage of this feature, when I convert my project to Mercury, my project reports many Unknown type errors. I can obviously fix these my adding an Imports statement to each file, but it would be preferable if there was a way for Mercury to support this without requiring additional changes.

–Avonelle

Thanks, logged as bugs://85560

We support that, check the (slightly oddly named for a VB perspective) “DefaultUses” project setting or, if you’re in Fire/Water, the Project|Manage Namespaces sheet.

We even convert <Imports> project tags to DefaultUses, in the .vbproj importer.

bugs://85560 got closed with status nochangereq.

That’s good to know. Hmmmm…I wonder why that didn’t happen for this particular project when switching it to Mercury? I think I did it on the latest version, but maybe I’m wrong about that.

–Avonelle

I just tried a test project, and I’m getting the same results. In my .vbproj file, there is this:

  <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="Samples.Types" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Data" />
    <Import Include="System.Diagnostics" />
    <Import Include="System.Linq" />
    <Import Include="System.Xml.Linq" />
    <Import Include="System.Threading.Tasks" />
  </ItemGroup>

In the resulting section, I get this:

    `<DefaultUses>Microsoft.VisualBasic;Samples.Types;System;System.Collections;System.Collections.Generic;System.Data;System.Diagnostics;System.Linq;System.Xml.Linq;System.Threading.Tasks;RemObjects.Elements.Mercury</DefaultUses>`

For some reason it seems to be skipping the Samples.Types Import when it converts to Mercury.

–Avonelle

Can you send me the .vbproj and .elements files, so I can have a check what happened? I don’t neeed the source.

Yes, here’s the files from my test project where I was able to replicate this behavior.

LibRefs.zip (2.7 KB)

–Avonelle

1 Like

Will have a look tomorrow, thanx!

Sorry, didn’t get around to it own Sunday…

But, maybe I’m mission something, I see tis in the imported project:

    <DefaultUses>Microsoft.VisualBasic;Samples.Types;System;System.Collections;System.Collections.Generic;System.Data;System.Diagnostics;System.Linq;System.Xml.Linq;System.Threading.Tasks;RemObjects.Elements.Mercury</DefaultUses>

and it seems to match

  <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="Samples.Types" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Data" />
    <Import Include="System.Diagnostics" />
    <Import Include="System.Linq" />
    <Import Include="System.Xml.Linq" />
    <Import Include="System.Threading.Tasks" />
  </ItemGroup>

so all seems to be working correctly?

Let’s close it. I can’t remember why, but yesterday morning I was doing something else that made me question the order of events for this, and made me think that this was my fault. I was going to provide a follow-up but I forgot - sorry about that.

–Avonelle

2 Likes

no worries; glad it’s working for you now.