-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Bug Description
When a class implements multiple interfaces that share method names (like IEnumerable<T> and IEnumerable), the generator creates duplicate public methods with the same name, causing a compilation error. C# requires one of these to use explicit interface implementation.
Steps to Reproduce
- Create a class that implements
IList<T>via delegation (which inherits from bothIEnumerable<T>andIEnumerable):
using TimeWarp.SourceGenerators;
public partial class NuruAppBuilder : IList<ServiceDescriptor>
{
[Implements]
private ServiceCollection? ServiceCollection;
}- Build the project
Expected Behavior
The generator should detect when multiple interfaces define methods with the same name and use explicit interface implementation for the non-generic version:
// Public generic version
public IEnumerator<ServiceDescriptor> GetEnumerator()
{
return ServiceCollection.GetEnumerator();
}
// Explicit interface implementation for non-generic version
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}Actual Behavior
The generator creates two public methods with the same name:
public System.Collections.Generic.IEnumerator<ServiceDescriptor> GetEnumerator()
{
return ServiceCollection.GetEnumerator();
}
public System.Collections.IEnumerator GetEnumerator() // ERROR: Duplicate method name
{
return ServiceCollection.GetEnumerator();
}Compiler Error
error CS0111: Type 'NuruAppBuilder' already defines a member called 'GetEnumerator' with the same parameter types
Environment
- TimeWarp.SourceGenerators: 1.0.0-beta.7
- .NET: 10.0
- OS: Linux (WSL2)
Reproduction Repository
Branch: https://github.com/TimeWarpEngineering/timewarp-nuru/tree/Cramer/2025-10-16/readme-restructure
File: Source/TimeWarp.Nuru/NuruAppBuilder.cs (lines 10, 14-15)
Generated: Source/TimeWarp.Nuru/generated/timewarp-source-generators/TimeWarp.SourceGenerators.InterfaceDelegationGenerator/NuruAppBuilder.implements.g.cs (lines 45, 50)
Impact
This prevents using interface delegation for collection interfaces (IList<T>, IDictionary<K,V>, ISet<T>, etc.) because they all inherit from both generic and non-generic IEnumerable.
Related
- Issue Interface delegation only generates IList members, missing ICollection and IEnumerable #27 (missing inherited interface members) - FIXED in beta.7! ✅
- Issue Indexer generation missing parameter in interface delegation #25 (indexer generation bug) - FIXED in beta.6! ✅
Beta.7 successfully generates all inherited interface members, but hits this C# language constraint with duplicate method names.
Suggested Fix
When generating interface members, detect when multiple interfaces define methods with the same signature (same name and parameters). Make the more-derived/generic version public, and use explicit interface implementation for the base/non-generic version.