From af7fdea4494036a79e904579cec047697ddc2cf8 Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Sun, 10 Nov 2013 15:35:47 +0100 Subject: [PATCH] Return types must be cls-compliant CreateCLSCompliantWrappers must always change return types into cls-compliant types. The reason is that we cannot overload on return type alone, so we should always choose the compliant version. --- Source/Bind/FuncProcessor.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Bind/FuncProcessor.cs b/Source/Bind/FuncProcessor.cs index d305d687..6f9801c2 100644 --- a/Source/Bind/FuncProcessor.cs +++ b/Source/Bind/FuncProcessor.cs @@ -627,8 +627,12 @@ namespace Bind if (!f.CLSCompliant) { - Function cls = new Function(f); + // The return type must always be cls-compliant, + // since we cannot overload on return types alone. + f.ReturnType.CurrentType = GetCLSCompliantType(f.ReturnType); + // Create a cls-compliant wrapper for the parameters + Function cls = new Function(f); bool modified = false; for (int i = 0; i < f.Parameters.Count; i++) { @@ -637,8 +641,12 @@ namespace Bind modified = true; } + // Only add a cls-compliant overload if we have + // changed a parameter. if (modified) + { wrappers.AddChecked(cls); + } } } }