I have a NuGet package that contains a series of assemblies that unfortunately all define the same type multiple times. Removing the duplicates is currently not an option as they are a product of generation. This yields a CS0433 compilation error like the following:
error CS0433: The type 'AmbiguousType' exists in both 'Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Assembly2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
I tried to address it by adding references to alias each of the assemblies like this:
<ItemGroup>
<PackageReference Include="MyPackage" Version="1.0.0"/>
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\netstandard2.0\assembly.dll</HintPath>
<Aliases>Assembly1</Aliases>
</Reference>
<Reference Include="Assembly2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\netstandard2.0\assembly.dll</HintPath>
<Aliases>Assembly2</Aliases>
</Reference>
</ItemGroup>
then in the C# code I added the following to define the common type:
extern alias Assembly1;
using AmbiguousType = Assembly1::AssemblyNamespace.AmbiguousType;
but now I get a CS0430 that alias Assembly1 has not been referenced.
Is it possible to resolve this or is this something that just can't be done?