Skip to content

Commit

Permalink
fix: refactor GetExplicitIndexer
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison committed Apr 18, 2023
1 parent 897c928 commit 82644c0
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,9 @@ private static (ITypeSymbol, ITypeSymbol)? GetEnumerableKeyValueTypes(MappingBui

private static INamedTypeSymbol? GetExplicitIndexer(MappingBuilderContext ctx)
{
if (SymbolEqualityComparer.Default.Equals(ctx.Target.OriginalDefinition, ctx.Types.IDictionaryT))
if (ctx.Target.ImplementsGeneric(ctx.Types.IDictionaryT, SetterIndexerPropertyName, out var typedInter, out var isExplicit) && !isExplicit)
return null;

// get typed version of IDictionay<>
ctx.Target.ImplementsGeneric(ctx.Types.IDictionaryT, out var typedInter);

var interfaceMethodSymbol = typedInter!.GetMembers(SetterIndexerPropertyName).OfType<IMethodSymbol>().SingleOrDefault(x => x.Parameters.Length == 2 && x.ReturnsVoid);

// if null then the method is unimplemented
// symbol implements genericInterface but has not implemented the corresponding methods
var methodInterImplementaton = ctx.Target.FindImplementationForInterfaceMember(interfaceMethodSymbol) as IMethodSymbol;

// check if methodImplementation is explicit
if (methodInterImplementaton!.ExplicitInterfaceImplementations.Any())
return typedInter;

return null;
return typedInter;
}
}

0 comments on commit 82644c0

Please sign in to comment.