Skip to content

Commit

Permalink
Mark EnumerateMetafileProc's callbackData parameter as nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoritzinsky authored and stephentoub committed Jun 24, 2022
1 parent 6321133 commit dbc543a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public void TranslateClip(float dx, float dy) { }
public void TranslateTransform(float dx, float dy) { }
public void TranslateTransform(float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order) { }
public delegate bool DrawImageAbort(System.IntPtr callbackdata);
public delegate bool EnumerateMetafileProc(System.Drawing.Imaging.EmfPlusRecordType recordType, int flags, int dataSize, System.IntPtr data, System.Drawing.Imaging.PlayRecordCallback callbackData);
public delegate bool EnumerateMetafileProc(System.Drawing.Imaging.EmfPlusRecordType recordType, int flags, int dataSize, System.IntPtr data, System.Drawing.Imaging.PlayRecordCallback? callbackData);
}
public enum GraphicsUnit
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public delegate bool EnumerateMetafileProc(
int flags,
int dataSize,
IntPtr data,
PlayRecordCallback callbackData);
PlayRecordCallback? callbackData);

#if NET7_0_OR_GREATER
[CustomTypeMarshaller(typeof(EnumerateMetafileProc), CustomTypeMarshallerKind.Value, Direction = CustomTypeMarshallerDirection.In, Features = CustomTypeMarshallerFeatures.TwoStageMarshalling | CustomTypeMarshallerFeatures.UnmanagedResources)]
Expand All @@ -120,7 +120,7 @@ private delegate Interop.BOOL EnumerateMetafileProcNative(
public EnumerateMetafileProcMarshaller(EnumerateMetafileProc? managed)
{
_managed = managed is null ? null : (recordType, flags, dataSize, data, callbackData) =>
managed(recordType, flags, dataSize, data, callbackData == IntPtr.Zero ? null! : Marshal.GetDelegateForFunctionPointer<PlayRecordCallback>(callbackData)) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE;
managed(recordType, flags, dataSize, data, callbackData == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer<PlayRecordCallback>(callbackData)) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE;
_nativeFunction = _managed is null ? null : (delegate* unmanaged<IntPtr, Interop.BOOL>)Marshal.GetFunctionPointerForDelegate(_managed);
}

Expand Down

0 comments on commit dbc543a

Please sign in to comment.