Skip to content

Commit

Permalink
[netcore] Allow different enums as return type in CreateDelega… (#15787)
Browse files Browse the repository at this point in the history
* Relaxed check for return type in CreateDelegate

* fix build errors
  • Loading branch information
EgorBo authored and marek-safar committed Jul 24, 2019
1 parent 2a01e1b commit 1224943
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
15 changes: 0 additions & 15 deletions netcore/CoreFX.issues.rsp
Expand Up @@ -225,21 +225,6 @@
# When test is run, xunit claims it's not a part of the test suite
#-nomethod System.Net.Http.Functional.Tests.SocketsHttpHandler_HttpClientHandler_ClientCertificates_Test.AutomaticOrManual_DoesntFailRegardlessOfWhetherClientCertsAreAvailable

####################################################################
## System.Net.HttpListener.Tests
####################################################################

# TODO:
# System.ArgumentException : Cannot bind to the target method because its signature is not compatible with that of the delegate type.
# at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed)
# at System.Delegate.CreateDelegate(Type type, MethodInfo method, Boolean throwOnBindFailure)
# at System.Delegate.CreateDelegate(Type type, MethodInfo method)
# at System.Reflection.RuntimeMethodInfo.CreateDelegate(Type delegateType)
# at System.Net.CookieExtensions.IsRfc2965Variant(Cookie cookie)
#
# https://github.com/mono/mono/issues/15008
-noclass System.Net.Tests.HttpListenerResponseCookiesTests

####################################################################
## System.Net.Sockets.Tests
####################################################################
Expand Down
2 changes: 2 additions & 0 deletions netcore/CoreFX.issues_linux_arm64.rsp
@@ -0,0 +1,2 @@
# these tests are extremly slow on our arm64 CI
-nonamespace System.Transactions.Tests
3 changes: 3 additions & 0 deletions netcore/Makefile
Expand Up @@ -38,6 +38,9 @@ PLATFORM_AOT_PREFIX := lib
NETCORESDK_EXT = tar.gz
UNZIPCMD = tar -xvf
XUNIT_FLAGS = -notrait category=nonlinuxtests @../../../../CoreFX.issues_linux.rsp
ifeq ($(COREARCH), arm64)
XUNIT_FLAGS = $(XUNIT_FLAGS) -notrait category=nonlinuxtests @../../../../CoreFX.issues_linux_arm64.rsp

This comment has been minimized.

Copy link
@filipnavara

filipnavara Jul 24, 2019

Contributor

This recursive definition broke the ARM64 CI lane :-/

This comment has been minimized.

Copy link
@marek-safar

marek-safar Jul 24, 2019

Member

oh, @EgorBo could you please fix that

This comment has been minimized.

Copy link
@EgorBo

EgorBo Jul 24, 2019

Author Member

@filipnavara @marek-safar oops, sure - I couldn't test it because the ARM lane was broken everywhere when the PR was merged

endif
TESTS_PLATFORM = Linux.x64
DOTNET := $(shell ./init-tools.sh | tail -1)
endif
Expand Down
11 changes: 11 additions & 0 deletions netcore/System.Private.CoreLib/src/System/Delegate.cs
Expand Up @@ -339,6 +339,17 @@ static bool IsReturnTypeMatch (Type delReturnType, Type returnType)
// Delegate covariance
if (!returnType.IsValueType && delReturnType.IsAssignableFrom (returnType))
returnMatch = true;
else
{
bool isDelArgEnum = delReturnType.IsEnum;
bool isArgEnum = returnType.IsEnum;
if (isArgEnum && isDelArgEnum)
returnMatch = Enum.GetUnderlyingType (delReturnType) == Enum.GetUnderlyingType (returnType);
else if (isDelArgEnum && Enum.GetUnderlyingType (delReturnType) == returnType)
returnMatch = true;
else if (isArgEnum && Enum.GetUnderlyingType (returnType) == delReturnType)
returnMatch = true;
}
}

return returnMatch;
Expand Down

0 comments on commit 1224943

Please sign in to comment.