Skip to content

UWPSyncGenerator: Replace indexer/collection member workaround with proper shadowing members #22984

@MartinZikmund

Description

@MartinZikmund

Context

In commit 6b30bfd (fix: Generator adjustment for indexers), a workaround was added to IsCollectionInterfaceMember in src/Uno.UWPSyncGenerator/Generator.cs to handle CsWinRT projections that use explicit interface implementations for collection members (e.g., IList<T>.this[int]) while also exposing a public member with the same signature.

The issue is that FindImplementationForInterfaceMember returns the explicit implementation, which doesn't match the public member via SymbolEqualityComparer. The current workaround falls back to loose name+kind matching for indexers and parameter-count matching for methods, which is overly broad and could suppress generation of legitimate stubs.

Current workaround (to be removed)

// Fall back to name+kind matching for indexers and common collection members.
if (member is IPropertySymbol memberProp && ifaceMember is IPropertySymbol ifaceProp
    && memberProp.IsIndexer && ifaceProp.IsIndexer)
{
    return true;
}

if (member is IMethodSymbol memberMethod && ifaceMember is IMethodSymbol ifaceMethod
    && memberMethod.Name == ifaceMethod.Name
    && memberMethod.Parameters.Length == ifaceMethod.Parameters.Length)
{
    return true;
}

Proposed fix

Instead of the loose matching workaround, the affected types (those inheriting from DependencyObjectCollection<T>) should have proper new shadowing members generated that delegate to the base class implementation. This would:

  1. Remove the need for the fuzzy matching workaround
  2. Make the generated code explicit about which members are provided
  3. Avoid accidentally suppressing stubs for unrelated members that happen to match by name/arity

Files involved

  • src/Uno.UWPSyncGenerator/Generator.csIsCollectionInterfaceMember method (around line 992)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions