diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/utils.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/utils.cs index c798bdc1c767a0..b1c1cdcaacd17c 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/utils.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/utils.cs @@ -52,10 +52,10 @@ internal static IntPtr AllocHGlobalIntPtrArray(int size) { checked { - IntPtr intPtrArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * size); + IntPtr intPtrArray = Marshal.AllocHGlobal(IntPtr.Size * size); for (int i = 0; i < size; i++) { - IntPtr tempPtr = (IntPtr)((long)intPtrArray + Marshal.SizeOf(typeof(IntPtr)) * i); + IntPtr tempPtr = (IntPtr)((long)intPtrArray + IntPtr.Size * i); Marshal.WriteIntPtr(tempPtr, IntPtr.Zero); } return intPtrArray; diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.cs index 79ed875dd6c44b..7f14b8842b879c 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.cs @@ -1298,7 +1298,7 @@ internal LdapControl[] BuildControlArray(DirectoryControlCollection controls, bo managedControls[i].ldctl_value = new berval { bv_len = byteControlValue.Length, - bv_val = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(byte)) * byteControlValue.Length) + bv_val = Marshal.AllocHGlobal(sizeof(byte) * byteControlValue.Length) }; Marshal.Copy(byteControlValue, 0, managedControls[i].ldctl_value.bv_val, managedControls[i].ldctl_value.bv_len); } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryReplicationMetaData.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryReplicationMetaData.cs index 6aa2c3c8158f36..7ad1d0285de735 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryReplicationMetaData.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryReplicationMetaData.cs @@ -65,14 +65,14 @@ internal void AddHelper(int count, IntPtr info, bool advanced) { if (advanced) { - addr = IntPtr.Add(info, Marshal.SizeOf(typeof(int)) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_ATTR_META_DATA_2))); + addr = IntPtr.Add(info, sizeof(int) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_ATTR_META_DATA_2))); AttributeMetadata managedMetaData = new AttributeMetadata(addr, true, _server, _nameTable); Add(managedMetaData.Name, managedMetaData); } else { - addr = IntPtr.Add(info, Marshal.SizeOf(typeof(int)) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_ATTR_META_DATA))); + addr = IntPtr.Add(info, sizeof(int) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_ATTR_META_DATA))); AttributeMetadata managedMetaData = new AttributeMetadata(addr, false, _server, _nameTable); Add(managedMetaData.Name, managedMetaData); diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursorCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursorCollection.cs index 033ecb6e4af7e4..10487511cbb4b2 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursorCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursorCollection.cs @@ -56,7 +56,7 @@ internal void AddHelper(string partition, object cursors, bool advanced, IntPtr { if (advanced) { - addr = IntPtr.Add(info, Marshal.SizeOf(typeof(int)) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_CURSOR_3))); + addr = IntPtr.Add(info, sizeof(int) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_CURSOR_3))); DS_REPL_CURSOR_3 cursor = new DS_REPL_CURSOR_3(); Marshal.PtrToStructure(addr, cursor); @@ -70,7 +70,7 @@ internal void AddHelper(string partition, object cursors, bool advanced, IntPtr } else { - addr = IntPtr.Add(info, Marshal.SizeOf(typeof(int)) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_CURSOR))); + addr = IntPtr.Add(info, sizeof(int) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_CURSOR))); DS_REPL_CURSOR cursor = new DS_REPL_CURSOR(); Marshal.PtrToStructure(addr, cursor); diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailureCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailureCollection.cs index bc660d99c21e62..0bc4a28ac57ec3 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailureCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailureCollection.cs @@ -53,7 +53,7 @@ internal void AddHelper(DS_REPL_KCC_DSA_FAILURES failures, IntPtr info) for (int i = 0; i < count; i++) { - addr = IntPtr.Add(info, Marshal.SizeOf(typeof(int)) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_KCC_DSA_FAILURE))); + addr = IntPtr.Add(info, sizeof(int) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_KCC_DSA_FAILURE))); ReplicationFailure managedFailure = new ReplicationFailure(addr, _server, _nameTable); diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighborCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighborCollection.cs index b14f06b02b7afe..1b4f715490ff7b 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighborCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighborCollection.cs @@ -53,7 +53,7 @@ internal void AddHelper(DS_REPL_NEIGHBORS neighbors, IntPtr info) for (int i = 0; i < count; i++) { - addr = IntPtr.Add(info, Marshal.SizeOf(typeof(int)) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_NEIGHBOR))); + addr = IntPtr.Add(info, sizeof(int) * 2 + i * Marshal.SizeOf(typeof(DS_REPL_NEIGHBOR))); ReplicationNeighbor managedNeighbor = new ReplicationNeighbor(addr, _server, _nameTable); diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameters.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameters.cs index 9ce092bc5379bb..ac864d0c17bbfb 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameters.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameters.cs @@ -57,11 +57,11 @@ internal IntPtr ConvertToMemory() int size = Marshal.SizeOf(typeof(EncoderParameter)); int length = _param.Length; - IntPtr memory = Marshal.AllocHGlobal(checked(length * size + Marshal.SizeOf(typeof(IntPtr)))); + IntPtr memory = Marshal.AllocHGlobal(checked(length * size + IntPtr.Size)); Marshal.WriteIntPtr(memory, (IntPtr)length); - long arrayOffset = checked((long)memory + Marshal.SizeOf(typeof(IntPtr))); + long arrayOffset = checked((long)memory + IntPtr.Size); for (int i = 0; i < length; i++) { @@ -86,7 +86,7 @@ internal static EncoderParameters ConvertFromMemory(IntPtr memory) EncoderParameters p = new EncoderParameters(count); int size = Marshal.SizeOf(typeof(EncoderParameter)); - long arrayOffset = (long)memory + Marshal.SizeOf(typeof(IntPtr)); + long arrayOffset = (long)memory + IntPtr.Size; for (int i = 0; i < count; i++) { diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Windows.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Windows.cs index fce1dd4ace8c14..d1da46e68e10d2 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Windows.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Windows.cs @@ -180,11 +180,11 @@ public static StringCollection InstalledPrinters // PRINTER_INFO_4 is 12 or 24 bytes in size depending on the architecture. if (IntPtr.Size == 8) { - sizeofstruct = (IntPtr.Size * 2) + (Marshal.SizeOf(typeof(int)) * 1) + Padding64Bit; + sizeofstruct = (IntPtr.Size * 2) + (sizeof(int) * 1) + Padding64Bit; } else { - sizeofstruct = (IntPtr.Size * 2) + (Marshal.SizeOf(typeof(int)) * 1); + sizeofstruct = (IntPtr.Size * 2) + (sizeof(int) * 1); } int bufferSize; @@ -454,7 +454,7 @@ public bool IsDirectPrintingSupported(ImageFormat imageFormat) HandleRef hdc = new HandleRef(dc, dc.Hdc); try { - isDirectPrintingSupported = SafeNativeMethods.ExtEscape(hdc, SafeNativeMethods.QUERYESCSUPPORT, Marshal.SizeOf(typeof(int)), ref nEscape, 0, out outData) > 0; + isDirectPrintingSupported = SafeNativeMethods.ExtEscape(hdc, SafeNativeMethods.QUERYESCSUPPORT, sizeof(int), ref nEscape, 0, out outData) > 0; } finally { @@ -495,10 +495,10 @@ public bool IsDirectPrintingSupported(Image image) HandleRef hdc = new HandleRef(dc, dc.Hdc); try { - bool querySupported = SafeNativeMethods.ExtEscape(hdc, SafeNativeMethods.QUERYESCSUPPORT, Marshal.SizeOf(typeof(int)), ref nEscape, 0, out outData) > 0; + bool querySupported = SafeNativeMethods.ExtEscape(hdc, SafeNativeMethods.QUERYESCSUPPORT, sizeof(int), ref nEscape, 0, out outData) > 0; if (querySupported) { - isDirectPrintingSupported = (SafeNativeMethods.ExtEscape(hdc, nEscape, pvImageLen, pvImage, Marshal.SizeOf(typeof(int)), out outData) > 0) + isDirectPrintingSupported = (SafeNativeMethods.ExtEscape(hdc, nEscape, pvImageLen, pvImage, sizeof(int), out outData) > 0) && (outData == 1); } }