Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 0558719

Browse files
committed
[Build] Add a patch to check whether we have .NET 4.6 at build time.
1 parent 8abc2ba commit 0558719

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

configure.in.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,15 @@ OFF_T_FLAGS="-define:OFF_T_$ac_cv_sizeof_off_t"
106106
AC_SUBST(OFF_T_FLAGS)
107107

108108
MONO_REQUIRED_VERSION=1.0
109+
MONO_NO_NET_4_6=4.4
109110
PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)
110111
if test "x$has_mono" = "xfalse" ; then
111112
PKG_CHECK_MODULES(MONO_DEPENDENCY, mono-2 >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)
113+
if "x$has_mono" = "xtrue" ; then
114+
PKG_CHECK_MODULES(MONO_DEPENDENCY, mono < $MONO_NO_NET_4_6, missing_net_4_6=true, missing_net_4_6=false)
115+
fi
116+
else
117+
PKG_CHECK_MODULES(MONO_DEPENDENCY, mono < $MONO_NO_NET_4_6, missing_net_4_6=true, missing_net_4_6=false)
112118
fi
113119

114120
AC_PATH_PROG(GACUTIL, gacutil, no)
@@ -224,6 +230,9 @@ AM_CONDITIONAL(ENABLE_MONOGETOPTIONS, test "x$has_mono" = "xtrue")
224230

225231
CSFLAGS="$DEBUG_FLAGS $CSDEFINES $WIN64DEFINES -unsafe"
226232

233+
if text "x$missing_net_4_6" = "xyes" ; then
234+
CSFLAGS="$CSFLAGS -define:MISSING_NET_4_6"
235+
fi
227236
PKG_CHECK_MODULES(GLIB_2_31,
228237
glib-2.0 >= 2.31,
229238
HAVE_GLIB_2_31_OR_HIGHER=yes, HAVE_GLIB_2_31_OR_HIGHER=no)

glib/Marshaller.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ static string Utf8PtrToStringFast (IntPtr ptr, int len)
8888
}
8989
}
9090

91+
#if !MISSING_NET_4_6
9192
static bool hasFastGetStringOverload = typeof (System.Text.Encoding).GetMethod ("GetString", new [] { typeof (byte*), typeof (int) }) != null;
93+
#endif
9294
public static string Utf8PtrToString (IntPtr ptr)
9395
{
9496
if (ptr == IntPtr.Zero)
9597
return null;
9698

9799
int len = (int) (uint)glibsharp_strlen (ptr);
100+
#if !MISSING_NET_4_6
98101
if (hasFastGetStringOverload)
99102
return Utf8PtrToStringFast (ptr, len);
103+
#endif
100104

101105
byte [] bytes = new byte [len];
102106
Marshal.Copy (ptr, bytes, 0, len);

0 commit comments

Comments
 (0)