diff --git a/.globalconfig b/.globalconfig index d51e5cfacfa..f1511f2b5d2 100644 --- a/.globalconfig +++ b/.globalconfig @@ -558,6 +558,10 @@ dotnet_diagnostic.CA2015.severity = warning # https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2016 dotnet_diagnostic.CA2016.severity = suggestion +# CA2020: Prevent behavioral change +# https://learn.microsoft.com/en-gb/dotnet/fundamentals/code-analysis/quality-rules/ca2020 +dotnet_diagnostic.CA2020.severity = warning + # CA2100: Review SQL queries for security vulnerabilities # https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2100 dotnet_diagnostic.CA2100.severity = none diff --git a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs index 289f88c576f..c995e343db4 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/WSManNativeAPI.cs @@ -1121,7 +1121,7 @@ internal WSManOptionSet(WSManOption[] options) // Look at the structure of native WSManOptionSet.. Options is a pointer.. // In C-Style array individual elements are continuous..so I am building // continuous array elements here. - Marshal.StructureToPtr(options[index], (IntPtr)(_optionSet.options.ToInt64() + (sizeOfOption * index)), false); + Marshal.StructureToPtr(options[index], _optionSet.options + (sizeOfOption * index), false); } _data = MarshalledObject.Create(_optionSet); diff --git a/src/powershell/Program.cs b/src/powershell/Program.cs index 70346a1d1ce..1b50f40e2f8 100644 --- a/src/powershell/Program.cs +++ b/src/powershell/Program.cs @@ -116,7 +116,7 @@ private static void AttemptExecPwshLogin(string[] args) // Read the symlink to the startup executable IntPtr linkPathPtr = Marshal.AllocHGlobal(LINUX_PATH_MAX); IntPtr bufSize = ReadLink("/proc/self/exe", linkPathPtr, (UIntPtr)LINUX_PATH_MAX); - pwshPath = Marshal.PtrToStringAnsi(linkPathPtr, (int)bufSize); + pwshPath = Marshal.PtrToStringAnsi(linkPathPtr, checked((int)bufSize)); Marshal.FreeHGlobal(linkPathPtr); ArgumentNullException.ThrowIfNull(pwshPath);