Skip to content

Commit ee08309

Browse files
committed
Detail: assert that IsCovariantReturnTypes only gets called for return types
1 parent 6238c15 commit ee08309

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Castle.Core/DynamicProxy/Generators/MethodSignatureComparer.cs

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Castle.DynamicProxy.Generators
1616
{
1717
using System;
1818
using System.Collections.Generic;
19+
using System.Diagnostics;
1920
using System.Reflection;
2021

2122
internal class MethodSignatureComparer : IEqualityComparer<MethodInfo>
@@ -136,6 +137,9 @@ private bool EqualSignatureTypes(Type x, Type y, MethodInfo xm = null, MethodInf
136137

137138
static bool IsCovariantReturnTypes(Type x, Type y, MethodInfo xm, MethodInfo ym)
138139
{
140+
Debug.Assert((xm == null && ym == null)
141+
|| (xm != null && ym != null && x == xm.ReturnType && y == ym.ReturnType));
142+
139143
// This enables covariant method returns for .NET 5 and newer.
140144
// No need to check for runtime support, since such methods are marked with a custom attribute;
141145
// see https://github.com/dotnet/runtime/blob/main/docs/design/features/covariant-return-methods.md.

0 commit comments

Comments
 (0)