Remove remaining StringBuilder marshaling use from Corelib (dotnet/coreclr#21120)
authorStephen Toub <stoub@microsoft.com>
Tue, 20 Nov 2018 22:03:33 +0000 (17:03 -0500)
committerGitHub <noreply@github.com>
Tue, 20 Nov 2018 22:03:33 +0000 (17:03 -0500)
commita7f5ff614c64cafa3d7095615c6ba0a2e4b95285
treee42306a9dda30739d5a302684ef298772c0e199b
parenta58314ea32d4d7eabe7359612b48f50948782e9c
Remove remaining StringBuilder marshaling use from Corelib (dotnet/coreclr#21120)

* Remove remaining StringBuilder marshaling use from Corelib

- Unix globalization functions were using StringBuilder.  Replaced them with stackallocs, as the max sizes were all relatively small.
- Registry methods were declared to use StringBuilder, but these weren't actually used by corelib, and in fact, corefx isn't using StringBuilder with them either.  I've changed the definitions for now to use char[] instead (all the call sites are passing in null), and I'll fix up some corefx usage separately.
- Resource-related functions were using StringBuilder, and have been replaced with stackallocs, given reasonably small max buffer sizes.
- ExpandEnvironmentVariables was using a StringBuilder, but it's rewritten equivalent code in corefx is not.  For now I've copied the corefx function over to coreclr to replace the different implementation, but we can look at subsequently consolidating them into one.

* Address PR feedback

Commit migrated from https://github.com/dotnet/coreclr/commit/a9b57bd4fe194b30b3c6e9a85a316fc218f474be
17 files changed:
src/coreclr/src/System.Private.CoreLib/src/Microsoft/Win32/Win32Native.cs
src/coreclr/src/System.Private.CoreLib/src/System/Environment.cs
src/libraries/System.Private.CoreLib/src/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs
src/libraries/System.Private.CoreLib/src/Interop/Unix/System.Globalization.Native/Interop.Locale.cs
src/libraries/System.Private.CoreLib/src/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs
src/libraries/System.Private.CoreLib/src/Interop/Unix/System.Globalization.Native/Interop.Utils.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.MUI.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/User32/Interop.LoadString.cs
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Action.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs