Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/Common/ISymbolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,16 @@
return true;
}

// TODO: Remove this fallback once symbol-based detection is complete
// This is a temporary safety net for cases where symbol resolution fails
// but should be replaced with comprehensive symbol-based approach
// TODO: Remove this fallback once symbol-based detection is complete.
Comment thread Dismissed
// Investigation notes:
// - Tests fail when fallback is removed, indicating symbol-based detection is incomplete
// - Current known symbols check: ICallback, ICallback<T>, ICallback<TMock,TResult>,
// IReturns, IReturns<T>, IReturns<TMock,TResult>, ISetupGetter<TMock,TProperty>,
// ISetupSetter<TMock,TProperty>, IRaiseable, IRaiseableAsync
// - Issue appears to be related to symbol resolution for Setup().Raises() chains
// - May be version-specific differences between Moq 4.8.2 and 4.18.4
// - Requires runtime debugging to identify which specific interface method symbols
// are not being matched by IsInstanceOf checks
Comment thread
rjmurillo marked this conversation as resolved.
return IsLikelyMoqRaisesMethodByName(methodSymbol);
}

Expand Down Expand Up @@ -251,7 +258,9 @@
{
return symbol.IsInstanceOf(knownSymbols.ICallbackRaises) ||
symbol.IsInstanceOf(knownSymbols.ICallback1Raises) ||
symbol.IsInstanceOf(knownSymbols.ICallback2Raises);
symbol.IsInstanceOf(knownSymbols.ICallback2Raises) ||
symbol.IsInstanceOf(knownSymbols.ISetupGetterRaises) ||
symbol.IsInstanceOf(knownSymbols.ISetupSetterRaises);
Comment thread
rjmurillo marked this conversation as resolved.
}

/// <summary>
Expand Down
20 changes: 20 additions & 0 deletions src/Common/WellKnown/MoqKnownSymbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,26 @@ internal MoqKnownSymbols(Compilation compilation)
/// </summary>
internal ImmutableArray<IMethodSymbol> ICallback2Raises => ICallback2?.GetMembers("Raises").OfType<IMethodSymbol>().ToImmutableArray() ?? ImmutableArray<IMethodSymbol>.Empty;

/// <summary>
/// Gets the interface <c>Moq.Language.ISetupGetter{TMock, TProperty}</c>.
/// </summary>
internal INamedTypeSymbol? ISetupGetter => TypeProvider.GetOrCreateTypeByMetadataName("Moq.Language.ISetupGetter`2");

/// <summary>
/// Gets the methods for <c>Moq.Language.ISetupGetter{TMock, TProperty}.Raises</c>.
/// </summary>
internal ImmutableArray<IMethodSymbol> ISetupGetterRaises => ISetupGetter?.GetMembers("Raises").OfType<IMethodSymbol>().ToImmutableArray() ?? ImmutableArray<IMethodSymbol>.Empty;

/// <summary>
/// Gets the interface <c>Moq.Language.ISetupSetter{TMock, TProperty}</c>.
/// </summary>
internal INamedTypeSymbol? ISetupSetter => TypeProvider.GetOrCreateTypeByMetadataName("Moq.Language.ISetupSetter`2");

/// <summary>
/// Gets the methods for <c>Moq.Language.ISetupSetter{TMock, TProperty}.Raises</c>.
/// </summary>
internal ImmutableArray<IMethodSymbol> ISetupSetterRaises => ISetupSetter?.GetMembers("Raises").OfType<IMethodSymbol>().ToImmutableArray() ?? ImmutableArray<IMethodSymbol>.Empty;

/// <summary>
/// Gets the methods for <c>Moq.Language.IReturns.Raises</c>.
/// </summary>
Expand Down
Loading