Remove remaining StringBuilder marshaling use from Corelib (#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)
commita9b57bd4fe194b30b3c6e9a85a316fc218f474be
treed5595388d53a6aed0dac4e6e408dcf794b53e144
parent5a0af055e4c39f4f49b7ff35141739dc3fda4f9f
Remove remaining StringBuilder marshaling use from Corelib (#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
17 files changed:
src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Calendar.cs
src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Locale.cs
src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.TimeZoneInfo.cs
src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Utils.cs
src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs
src/System.Private.CoreLib/shared/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs
src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.MUI.cs
src/System.Private.CoreLib/shared/Interop/Windows/User32/Interop.LoadString.cs
src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
src/System.Private.CoreLib/shared/System/Action.cs
src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs
src/System.Private.CoreLib/shared/System/Globalization/CultureData.Unix.cs
src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs
src/System.Private.CoreLib/shared/System/TimeZoneInfo.Win32.cs
src/System.Private.CoreLib/src/Microsoft/Win32/Win32Native.cs
src/System.Private.CoreLib/src/System/Environment.cs