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

Diagnostic CodeFix for CS0433: The type TypeName1 exists in both Assembly1 and Assembly2 #24099

Closed
MaStr11 opened this issue Jan 8, 2018 · 1 comment

Comments

@MaStr11
Copy link
Contributor

MaStr11 commented Jan 8, 2018

Version Used:

VS 15.5.2

Steps to Reproduce:

If a projects references two libraries with the same type defined in the same namespace CS0433 is triggered if this type is used. A code fix should be offered that

  1. adds an alias to the library reference,
  2. adds an corresponding extern alias directive to the document
  3. fully qualifies the type (additionally a type alias could be offered as in Ambiguous type codefix provider (using alias) #24022)

The fix should also be offered for warning CS0436 The type 'type' in 'assembly' conflicts with the imported type 'type2' in 'assembly'. Using the type defined in 'assembly'.

Before the fix:

Assembly1 File1.cs

namespace N1
{
    public class Ambiguous
    {
    }
}

Assembly2 File2.cs

namespace N1
{
    public class Ambiguous
    {
    }
}

TestAssembly
References Assembly1 and Assembly2
File3.cs in TestAssembly

namespace N2
{
    public class Test
    {
        void M()
        {
              new N1.Ambiguous(); //CS0433
        }
    }
}

After the fix:

TestAssembly
References Assembly1 reference is aliased with Assembly1Alias and Assembly2
File3.cs in TestAssembly

extern alias Assembly1Alias;
namespace N2
{
    public class Test
    {
        void M()
        {
              new Assembly1Alias::N1.Ambiguous(); 
        }
    }
}

Relates to #23326.

@jinujoseph jinujoseph added this to the Unknown milestone Jan 29, 2018
@CyrusNajmabadi
Copy link
Member

Closing out for lack of customer feedback on this issue.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2024
@dotnet dotnet locked as resolved and limited conversation to collaborators Oct 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants