From 5a7b93593f826360a37973498265fc24aaa71a2d Mon Sep 17 00:00:00 2001 From: stephentoub Date: Thu, 8 Oct 2015 13:14:21 -0400 Subject: [PATCH] Add [Out] to a couple of StringBuilders in DllImports I audited all of the StringBuilders being used in P/Invokes in mscorlib. Almost all of them were correctly annotated as to their direction of needed marshaling. Two weren't. Commit migrated from https://github.com/dotnet/coreclr/commit/1d4061dd6455c5b41a8e9a012914115e29cc2008 --- src/coreclr/src/mscorlib/src/Microsoft/Win32/UnsafeNativeMethods.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/mscorlib/src/Microsoft/Win32/UnsafeNativeMethods.cs b/src/coreclr/src/mscorlib/src/Microsoft/Win32/UnsafeNativeMethods.cs index 624f8aa..fdd06e2 100644 --- a/src/coreclr/src/mscorlib/src/Microsoft/Win32/UnsafeNativeMethods.cs +++ b/src/coreclr/src/mscorlib/src/Microsoft/Win32/UnsafeNativeMethods.cs @@ -45,14 +45,14 @@ namespace Microsoft.Win32 { [MarshalAs(UnmanagedType.LPWStr)] StringBuilder language, ref int languageLength, - [MarshalAs(UnmanagedType.LPWStr)] + [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder fileMuiPath, ref int fileMuiPathLength, ref Int64 enumerator); [DllImport(Win32Native.USER32, EntryPoint="LoadStringW", SetLastError=true, CharSet=CharSet.Unicode, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)] - internal static extern int LoadString(SafeLibraryHandle handle, int id, StringBuilder buffer, int bufferLength); + internal static extern int LoadString(SafeLibraryHandle handle, int id, [Out] StringBuilder buffer, int bufferLength); [DllImport(Win32Native.KERNEL32, CharSet=System.Runtime.InteropServices.CharSet.Unicode, SetLastError=true)] internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags); -- 2.7.4