Skip to content

Commit ed6eda5

Browse files
authored
[runtime] Initialize the class if needed in type_is_blittable (). (#39700)
* [runtime] Initialize the class if needed in type_is_blittable (). Fixes #39100. * Delete workarounds.
1 parent 7adab7c commit ed6eda5

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

src/libraries/Common/src/Interop/Interop.Calendar.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,8 @@ internal static partial class Globalization
1515
[DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetCalendarInfo")]
1616
internal static extern unsafe ResultCode GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType calendarDataType, char* result, int resultCapacity);
1717

18-
#if MONO
19-
// Temp workaround for pinvoke callbacks for Mono
20-
// https://github.com/dotnet/runtime/issues/39100
21-
22-
internal unsafe delegate void EnumCalendarInfoCallback(
23-
char* calendarString,
24-
IntPtr context);
25-
26-
[DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EnumCalendarInfo")]
27-
internal static extern bool EnumCalendarInfo(IntPtr callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context);
28-
#else
2918
[DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EnumCalendarInfo")]
3019
internal static extern unsafe bool EnumCalendarInfo(delegate* <char*, IntPtr, void> callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context);
31-
#endif
3220

3321
[DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")]
3422
internal static extern int GetLatestJapaneseEra();

src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -423,26 +423,12 @@ internal static bool EnumCalendarInfo(string localeName, CalendarId calendarId,
423423
return result;
424424
}
425425

426-
#if MONO
427-
private static unsafe bool EnumCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, ref IcuEnumCalendarsData callbackContext)
428-
{
429-
// Temp workaround for pinvoke callbacks for Mono
430-
// https://github.com/dotnet/runtime/issues/39100
431-
var calendarInfoCallback = new Interop.Globalization.EnumCalendarInfoCallback(EnumCalendarInfoCallback);
432-
return Interop.Globalization.EnumCalendarInfo(
433-
System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(calendarInfoCallback),
434-
localeName, calendarId, dataType, (IntPtr)Unsafe.AsPointer(ref callbackContext));
435-
}
436-
437-
[Mono.MonoPInvokeCallback(typeof(Interop.Globalization.EnumCalendarInfoCallback))]
438-
#else
439426
private static unsafe bool EnumCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, ref IcuEnumCalendarsData callbackContext)
440427
{
441428
return Interop.Globalization.EnumCalendarInfo(&EnumCalendarInfoCallback, localeName, calendarId, dataType, (IntPtr)Unsafe.AsPointer(ref callbackContext));
442429
}
443430

444431
[UnmanagedCallersOnly]
445-
#endif
446432
private static unsafe void EnumCalendarInfoCallback(char* calendarStringPtr, IntPtr context)
447433
{
448434
try

src/mono/mono/metadata/marshal.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3979,9 +3979,13 @@ type_is_blittable (MonoType *type)
39793979
case MONO_TYPE_U:
39803980
case MONO_TYPE_PTR:
39813981
case MONO_TYPE_FNPTR:
3982+
case MONO_TYPE_VOID:
39823983
return TRUE;
3983-
default:
3984-
return m_class_is_blittable (mono_class_from_mono_type_internal (type));
3984+
default: {
3985+
MonoClass *klass = mono_class_from_mono_type_internal (type);
3986+
mono_class_init_sizes (klass);
3987+
return m_class_is_blittable (klass);
3988+
}
39853989
}
39863990
}
39873991

0 commit comments

Comments
 (0)