CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

Unable to author interface that derives from both `IList` and `IList<T>`

Open evelynwu-msft opened this issue 3 weeks ago • 0 comments

When attempting to author a C#/WinRT component that contains an interface that derives from both IList and IList<T> (where T is a specific type, e.g. string, since WinRT does not support generic types), the following build errors appear:

1>------ Rebuild All started: Project: ClassLibrary3, Configuration: Debug Any CPU ------
Restored C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\ClassLibrary3.csproj (in 88 ms).
1>C:\Program Files\dotnet\sdk\8.0.400-preview.0.24305.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(311,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(199,31,199,48): error CS8646: 'IEnumerable.GetEnumerator()' is explicitly implemented more than once.
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(251,33,251,46): error CS0111: Type 'ICustomCollection' already defines a member called 'System.Collections.IEnumerable.GetEnumerator' with the same parameter types
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(170,61,170,107): error CS0246: The type or namespace name 'InterfaceTag<>' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(192,67,192,119): error CS0246: The type or namespace name 'InterfaceTag<>' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(71,27,71,48): error CS8646: 'IEnumerable.GetEnumerator()' is explicitly implemented more than once.
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(177,23,177,27): error CS0668: Two indexers have different names; the IndexerName attribute must be used with the same name on every indexer within a type
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(177,23,177,27): error CS0111: Type 'ICustomCollectionImpl' already defines a member called 'this' with the same parameter types
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(194,33,194,46): error CS0111: Type 'ICustomCollectionImpl' already defines a member called 'System.Collections.IEnumerable.GetEnumerator' with the same parameter types
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(172,20,172,25): error CS0102: The type 'ICustomCollectionImpl' already contains a definition for 'Count'
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(183,21,183,31): error CS0102: The type 'ICustomCollectionImpl' already contains a definition for 'IsReadOnly'
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(190,21,190,29): error CS0111: Type 'ICustomCollectionImpl' already defines a member called 'RemoveAt' with the same parameter types
1>C:\Users\evelynwu\source\repos\ClassLibrary3\ClassLibrary3\obj\Debug\net8.0-windows10.0.22621.0\WinRT.SourceGenerator\Generator.SourceGenerator\ClassLibrary3.cs(185,21,185,26): error CS0111: Type 'ICustomCollectionImpl' already defines a member called 'Clear' with the same parameter types
1>Done building project "ClassLibrary3.csproj" -- FAILED.

To Reproduce Min repro project for convenience.

public interface ICustomCollection : IList, IList<string>
{
}

Expected behavior This should compile without errors.

Version Info C#/WinRT: 2.1.0-prerelease.240602.1 Windows App SDK: 1.5.240607001 (for some reason WinAppDSK must be referenced or else the source generator balks at the use of IList)

evelynwu-msft avatar Jun 17 '24 07:06 evelynwu-msft