More corelib cleanup (dotnet/coreclr#26993)
authorStephen Toub <stoub@microsoft.com>
Thu, 3 Oct 2019 19:28:18 +0000 (15:28 -0400)
committerGitHub <noreply@github.com>
Thu, 3 Oct 2019 19:28:18 +0000 (15:28 -0400)
commita83da8a16ec41f97f6f8a0cb73a0689fcf2a5eac
tree72240d2ff4aedf997d7ea04a5dddd441d1dc8387
parentc814c9ede3ee9cc076d2fa98ef2ecdb1a3387859
More corelib cleanup (dotnet/coreclr#26993)

* Make relevant types static (mostly Interop)

* Fix a few stray semicolons

* Remove unnecessary locals

Some can be removed entirely, some can be replaced by discards.

* Remove unnecessary usings

* Move Unix-specific helper method to TimeZoneInfo.Unix.cs

* Remove duplicated code

* Remove duplicative checks

* Remove [ThreadStatic] initialization

These are all the default values and wouldn't be necessary for any static, but inline initialization for [ThreadStatic]s is particularly unuseful (and in non-default cases problematic) because the fields are only set to these values on the initializing thread.

* Fix methods whose return value is never used

* Use string.IsNullOrEmpty

* Remove unnecessary field initialization

All ctors overwrite these values.

* Address PR feedback

Commit migrated from https://github.com/dotnet/coreclr/commit/c203e048817b0a3233773cc52d79bf665f1bd8a4
169 files changed:
src/coreclr/src/System.Private.CoreLib/src/Interop/Windows/OleAut32/Interop.VariantClear.cs
src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/RuntimeEventSourceHelper.Unix.cs
src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/RuntimeEventSourceHelper.Windows.cs
src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs
src/coreclr/src/System.Private.CoreLib/src/System/GC.cs
src/coreclr/src/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs
src/coreclr/src/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.cs
src/coreclr/src/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Variant.cs
src/coreclr/src/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
src/coreclr/src/System.Private.CoreLib/src/System/Utf8Extensions.cs
src/libraries/System.Private.CoreLib/src/Interop/Unix/Interop.Errors.cs
src/libraries/System.Private.CoreLib/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.ActivityControl.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EVENT_INFO_CLASS.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EtwEnableCallback.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EventRegister.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EventSetInformation.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EventTraceGuidsEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EventUnregister.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegCloseKey.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegCreateKeyEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegDeleteKeyEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegDeleteValue.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegFlushKey.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegOpenKeyEx.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/Advapi32/Interop.RegSetValueEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Advapi32/Interop.RegistryConstants.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.GetRandomBytes.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/BCrypt/Interop.NTSTATUS.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Interop.BOOL.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Interop.BOOLEAN.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Interop.Errors.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CREATEFILE2_EXTENDED_PARAMETERS.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CancelIoEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CloseHandle.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CreateFile.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.CreateFile2.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FILE_INFO_BY_HANDLE_CLASS.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FILE_TIME.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FileAttributes.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FileTimeToSystemTime.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FileTypes.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FindClose.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FlushFileBuffers.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FreeEnvironmentStrings.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.FreeLibrary.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GET_FILEEX_INFO_LEVELS.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetCPInfo.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetCurrentProcessId.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetCurrentProcess_IntPtr.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetEnvironmentStrings.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetFileAttributesEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetFileType_SafeHandle.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetLogicalDrives.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetProcessInformation.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetProcessMemoryInfo.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetStdHandle.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetSystemTime.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetSystemTimeAsFileTime.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetSystemTimePreciseAsFileTime.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetSystemTimes.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GetVersionExW.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.HandleTypes.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.IsWow64Process_IntPtr.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.LoadLibraryEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.LocalAlloc.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.LockFile.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.MAX_PATH.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.MEMORYSTATUSEX.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.MEMORY_BASIC_INFORMATION.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.MultiByteToWideChar.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.OSVERSIONINFOEX.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.QueryUnbiasedInterruptTime.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_IntPtr.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.ReadFile_SafeHandle_NativeOverlapped.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SECURITY_ATTRIBUTES.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SYSTEM_INFO.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SecurityOptions.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SetEndOfFile.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SetFilePointerEx.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SetThreadErrorMode.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.SystemTimeToFileTime.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.TzSpecificLocalTimeToSystemTime.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.VerSetConditionMask.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.VerifyVersionExW.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.VirtualAlloc.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.VirtualFree.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.WIN32_FILE_ATTRIBUTE_DATA.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.WIN32_FIND_DATA.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.WideCharToMultiByte.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_IntPtr.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Kernel32/Interop.WriteFile_SafeHandle_NativeOverlapped.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Normaliz/Interop.Idna.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Normaliz/Interop.Normalization.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/NtDll/Interop.NtQueryInformationFile.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/NtDll/Interop.NtQuerySystemInformation.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Ole32/Interop.CoTaskMemAlloc.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/OleAut32/Interop.SysAllocStringByteLen.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/OleAut32/Interop.SysFreeString.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/OleAut32/Interop.SysStringLen.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/User32/Interop.Constants.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/User32/Interop.LoadString.cs
src/libraries/System.Private.CoreLib/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs
src/libraries/System.Private.CoreLib/src/System/AttributeUsageAttribute.cs
src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs
src/libraries/System.Private.CoreLib/src/System/ComponentModel/DefaultValueAttribute.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendarHelper.cs
src/libraries/System.Private.CoreLib/src/System/IO/BinaryReader.cs
src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Windows.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationInfo.cs
src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Text/TrimType.cs
src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.WhiteSpace.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TplEventSource.cs
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs
src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs