Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public static void WriteIntPtr(IntPtr ptr, int ofs, IntPtr val)
#if TARGET_64BIT
WriteInt64(ptr, ofs, (long)val);
#else // 32
#pragma warning disable CA2020 // Prevent from behavioral change
#pragma warning disable CA2020 // Prevent behavioral change
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of these pragma warning disable instead? E.g. WriteInt32(ptr, ofs, (int)(nint)val);?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the method signature to:

public static void WriteIntPtr(IntPtr ptr, int ofs, nint val)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this for all Marshal methods where appropriate: #118335

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And Interlocked: #118336

WriteInt32(ptr, ofs, (int)val);
#pragma warning restore CA2020
#endif
Expand All @@ -487,7 +487,7 @@ public static void WriteIntPtr(object ptr, int ofs, IntPtr val)
#if TARGET_64BIT
WriteInt64(ptr, ofs, (long)val);
#else // 32
#pragma warning disable CA2020 // Prevent from behavioral change
#pragma warning disable CA2020 // Prevent behavioral change
WriteInt32(ptr, ofs, (int)val);
#pragma warning restore CA2020
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public static double Exchange(ref double location1, double value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IntPtr Exchange(ref IntPtr location1, IntPtr value)
{
#pragma warning disable CA2020 // Prevent from behavioral change
#pragma warning disable CA2020 // Prevent behavioral change
#if TARGET_64BIT
return (IntPtr)Interlocked.Exchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value);
#else
Expand Down Expand Up @@ -451,7 +451,7 @@ public static double CompareExchange(ref double location1, double value, double
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IntPtr CompareExchange(ref IntPtr location1, IntPtr value, IntPtr comparand)
{
#pragma warning disable CA2020 // Prevent from behavioral change
#pragma warning disable CA2020 // Prevent behavioral change
#if TARGET_64BIT
return (IntPtr)Interlocked.CompareExchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value, (long)comparand);
#else
Expand Down
Loading