Fix StyleCop rule SA1129 ("Do not use default value type constructor") (dotnet/corefx...
authorStephen Toub <stoub@microsoft.com>
Mon, 11 Nov 2019 23:49:48 +0000 (18:49 -0500)
committerGitHub <noreply@github.com>
Mon, 11 Nov 2019 23:49:48 +0000 (18:49 -0500)
Commit migrated from https://github.com/dotnet/corefx/commit/88f40addc220c73794f962f10d288c20c416ede1

238 files changed:
src/libraries/Common/src/Interop/FreeBSD/Interop.Process.cs
src/libraries/Common/src/Interop/OSX/Interop.libproc.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaOpenPolicy.cs
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.Blobs.cs
src/libraries/Common/src/Interop/Windows/NCrypt/Interop.NCryptDeriveKeyMaterial.cs
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs
src/libraries/Common/src/Interop/Windows/SChannel/Interop.Sec_Application_Protocols.cs
src/libraries/Common/src/Interop/Windows/SspiCli/SSPISecureChannelType.cs
src/libraries/Common/src/Interop/Windows/SspiCli/SafeDeleteContext.cs
src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs
src/libraries/Common/src/System/IO/FileSystem.Attributes.Windows.cs
src/libraries/Common/src/System/Net/LazyAsyncResult.cs
src/libraries/Common/src/System/Net/NetworkInformation/HostInformationPal.Windows.cs
src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs
src/libraries/Common/src/System/Security/Cryptography/DSACng.ImportExport.cs
src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs
src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanCng.ImportExport.cs
src/libraries/Common/src/System/Security/Cryptography/ECDsaCng.ImportExport.cs
src/libraries/Common/src/System/Security/Cryptography/RSACng.ImportExport.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorHandling.cs
src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentBag.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentStack.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.HashBucket.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableHashSet_1.HashBucket.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionException.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/CompositionResult.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/Serialization/MemberRelationshipService.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/OverrideModeSetting.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SectionInformation.cs
src/libraries/System.Console/src/System/ConsolePal.Windows.cs
src/libraries/System.Data.Common/src/System/Data/Common/DbCommand.cs
src/libraries/System.Data.Common/src/System/Data/Common/DbEnumerator.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBinaryStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLByteStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLBytesStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLCharsStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDateTimeStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDecimalStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLDoubleStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLGuidStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt16Storage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt32Storage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLInt64Storage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLMoneyStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLSingleStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQLStringStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/SQLTypes/SQlBooleanStorage.cs
src/libraries/System.Data.Common/src/System/Data/DataSet.cs
src/libraries/System.Data.Common/src/System/Data/DataTable.cs
src/libraries/System.Data.Common/src/System/Data/Select.cs
src/libraries/System.Data.Common/src/System/Data/Selection.cs
src/libraries/System.Data.SqlClient/src/Interop/SNINativeMethodWrapper.Windows.cs
src/libraries/System.Data.SqlClient/src/Microsoft/SqlServer/Server/SmiMetaDataProperty.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnection.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlEnums.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.Windows.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObject.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObjectNative.cs
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogInternal.cs
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogSession.cs
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs
src/libraries/System.Diagnostics.FileVersionInfo/src/System/Diagnostics/FileVersionInfo.Windows.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/CounterSampleCalculator.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthZSet.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Context.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/interopt.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/SearchResultCollection.cs
src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphicsContext.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Font.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Font.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Font.cs
src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Image.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Image.cs
src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMap.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Metafile.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeader.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintingServices.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/SystemFonts.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/macFunctions.cs
src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContext.cs
src/libraries/System.Drawing.Common/src/misc/GDI/WindowsRegion.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/Color.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/Point.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/PointF.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/Rectangle.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/RectangleF.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/Size.cs
src/libraries/System.Drawing.Primitives/src/System/Drawing/SizeF.cs
src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/ZLibNative.cs
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs
src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs
src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Windows.cs
src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.Windows.cs
src/libraries/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedView.Windows.cs
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/Pipe.cs
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/StreamPipeReader.cs
src/libraries/System.IO.Pipelines/src/System/IO/Pipelines/StreamPipeWriter.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/AnonymousPipeServerStream.Windows.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.Windows.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Windows.cs
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Unix.cs
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs
src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/QuerySettings.cs
src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/QueryTask.cs
src/libraries/System.Linq/src/System/Linq/Concat.SpeedOpt.cs
src/libraries/System.Linq/src/System/Linq/SelectMany.SpeedOpt.cs
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpCertificateHelper.cs
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinInetProxyHelper.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/FailedProxyCache.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/MacProxy.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListener.Windows.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListenerRequest.Windows.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListenerResponse.Windows.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpResponseStream.Windows.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpResponseStreamAsyncResult.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBase.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketHttpListenerDuplexStream.cs
src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpReplyReaderFactory.cs
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPInterfaceStatistics.cs
src/libraries/System.Net.Security/src/System/Net/CertificateValidationPal.Windows.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/ReceiveMessageOverlappedAsyncResult.Windows.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Unix.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Windows.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerReadContextComplexJson.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlObjectSerializerWriteContextComplexJson.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerContext.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs
src/libraries/System.Private.Uri/src/System/Uri.cs
src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XContainer.cs
src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XElement.cs
src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XLinq.cs
src/libraries/System.Private.Xml.Linq/src/System/Xml/XPath/XNodeNavigator.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaSet.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdDateTime.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdDuration.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/IteratorDescriptor.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlILOptimizerVisitor.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlIlVisitor.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/TreeIterators.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XmlCollation.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilGenerator.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilGeneratorEnv.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XslAstAnalyzer.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltInput.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/ImmutableByteArrayInterop.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/Ecma/EcmaModule.ManifestResources.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/RuntimeTypeInfo.BindingFlags.cs
src/libraries/System.Runtime.Numerics/src/System/Globalization/FormatProvider.BigInteger.cs
src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs
src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/Duration.cs
src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/Media/Animation/KeyTime.cs
src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/Media/Animation/RepeatBehavior.cs
src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/Media/Matrix.cs
src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/Media/Media3D/Matrix3D.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/Windows/Rect.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/Windows/Size.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/Windows/UI/Color.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Privilege.cs
src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/CngKeyLite.cs
src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/ECCurve.cs
src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/ECDiffieHellmanCngPublicKey.cs
src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/CngKey.Export.cs
src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/ECDiffieHellmanCngPublicKey.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CapiHelper.DSA.Shared.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CapiHelper.Shared.cs
src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/AnyOS/ManagedPal.KeyTrans.cs
src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSigner.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/ManagedX509ExtensionProcessor.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.PrivateKey.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/ChainPal.BuildChain.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/ChainPal.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/X509Pal.PublicKey.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/Pkcs10CertificationRequestInfo.cs
src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/Win32.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/CategoriesDocument.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/ResourceCollectionInfo.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/ServiceDocument.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationCategory.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationItem.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationLink.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationPerson.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Workspace.cs
src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs
src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceController.cs
src/libraries/System.Text.Json/src/System/Text/Json/JsonHelpers.Date.cs
src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ConcurrentQueue.cs
src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/Parallel.cs
src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelLoopState.cs
src/libraries/System.Threading/src/System/Threading/Barrier.cs
src/libraries/System.Threading/src/System/Threading/CountdownEvent.cs
src/libraries/System.Threading/src/System/Threading/ReaderWriterLock.cs
src/libraries/System.Transactions.Local/src/System/Transactions/EnlistmentTraceIdentifier.cs
src/libraries/System.Transactions.Local/src/System/Transactions/TransactionState.cs
src/libraries/System.Transactions.Local/src/System/Transactions/TransactionTraceIdentifier.cs
src/libraries/System.Windows.Extensions/src/System/Drawing/FontConverter.cs

index 5713ab2..056a893 100644 (file)
@@ -396,7 +396,7 @@ internal static partial class Interop
         /// </returns>
         public static unsafe proc_stats GetThreadInfo(int pid, int tid)
         {
-            proc_stats ret = new proc_stats();
+            proc_stats ret = default;
             kinfo_proc* info = null;
             int count;
 
index e3b9376..6775b4d 100644 (file)
@@ -473,7 +473,7 @@ internal static partial class Interop
                 throw new ArgumentOutOfRangeException(nameof(pid), SR.NegativePidNotSupported);
             }
 
-            rusage_info_v3 info = new rusage_info_v3();
+            rusage_info_v3 info = default;
 
             // Get the PIDs rusage info
             int result = proc_pid_rusage(pid, RUSAGE_INFO_V3, &info);
index bf24309..5780184 100644 (file)
@@ -113,7 +113,7 @@ internal static partial class Interop
             SafeBignumHandle qx_bn, qy_bn, d_bn;
             IntPtr d_bn_not_owned;
             int qx_cb, qy_cb, d_cb;
-            ECParameters parameters = new ECParameters();
+            ECParameters parameters = default;
 
             bool refAdded = false;
             try
@@ -254,7 +254,7 @@ internal static partial class Interop
                     int cbSubgroupOrder = GetMax(order_cb, d_cb);
 
                     // Copy values to ECParameters
-                    ECParameters parameters = new ECParameters();
+                    ECParameters parameters = default;
                     parameters.Q = new ECPoint
                     {
                         X = Crypto.ExtractBignum(qx_bn, cbFieldLength),
index 4360f33..de5da0c 100644 (file)
@@ -24,7 +24,7 @@ internal static partial class Interop
             int AccessMask,
             out SafeLsaPolicyHandle PolicyHandle)
         {
-            var systemNameUnicode = new UNICODE_STRING();
+            UNICODE_STRING systemNameUnicode = default;
             if (SystemName != null)
             {
                 fixed (char* c = SystemName)
index 90981ab..dc688b0 100644 (file)
@@ -302,7 +302,7 @@ internal partial class Interop
 
             public static BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO Create()
             {
-                BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO ret = new BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO();
+                BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO ret = default;
 
                 ret.cbSize = sizeof(BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO);
 
index 2485e1d..1aebafb 100644 (file)
@@ -49,7 +49,7 @@ internal static partial class Interop
                 Span<NCryptBuffer> parameters = stackalloc NCryptBuffer[4];
                 int parameterCount = 0;
                 // We always need to marshal the hashing function
-                NCryptBuffer hashAlgorithmBuffer = new NCryptBuffer();
+                NCryptBuffer hashAlgorithmBuffer = default;
                 hashAlgorithmBuffer.cbBuffer = (hashAlgorithm.Length + 1) * sizeof(char);
                 hashAlgorithmBuffer.BufferType = BufferType.KdfHashAlgorithm;
                 hashAlgorithmBuffer.pvBuffer = hashAlgorithmString;
@@ -67,7 +67,7 @@ internal static partial class Interop
 
                         if (pHmacKey != null)
                         {
-                            NCryptBuffer hmacKeyBuffer = new NCryptBuffer();
+                            NCryptBuffer hmacKeyBuffer = default;
                             hmacKeyBuffer.cbBuffer = hmacKey.Length;
                             hmacKeyBuffer.BufferType = BufferType.KdfHmacKey;
                             hmacKeyBuffer.pvBuffer = new IntPtr(pHmacKey);
@@ -78,7 +78,7 @@ internal static partial class Interop
 
                         if (pSecretPrepend != null)
                         {
-                            NCryptBuffer secretPrependBuffer = new NCryptBuffer();
+                            NCryptBuffer secretPrependBuffer = default;
                             secretPrependBuffer.cbBuffer = secretPrepend.Length;
                             secretPrependBuffer.BufferType = BufferType.KdfSecretPrepend;
                             secretPrependBuffer.pvBuffer = new IntPtr(pSecretPrepend);
@@ -89,7 +89,7 @@ internal static partial class Interop
 
                         if (pSecretAppend != null)
                         {
-                            NCryptBuffer secretAppendBuffer = new NCryptBuffer();
+                            NCryptBuffer secretAppendBuffer = default;
                             secretAppendBuffer.cbBuffer = secretAppend.Length;
                             secretAppendBuffer.BufferType = BufferType.KdfSecretAppend;
                             secretAppendBuffer.pvBuffer = new IntPtr(pSecretAppend);
@@ -126,7 +126,7 @@ internal static partial class Interop
         {
             fixed (NCryptBuffer* pParameters = &MemoryMarshal.GetReference(parameters))
             {
-                NCryptBufferDesc parameterDesc = new NCryptBufferDesc();
+                NCryptBufferDesc parameterDesc = default;
                 parameterDesc.ulVersion = 0;
                 parameterDesc.cBuffers = parameters.Length;
                 parameterDesc.pBuffers = new IntPtr(pParameters);
@@ -225,13 +225,13 @@ internal static partial class Interop
             {
                 fixed (byte* pLabel = label, pSeed = seed)
                 {
-                    NCryptBuffer labelBuffer = new NCryptBuffer();
+                    NCryptBuffer labelBuffer = default;
                     labelBuffer.cbBuffer = label.Length;
                     labelBuffer.BufferType = BufferType.KdfTlsLabel;
                     labelBuffer.pvBuffer = new IntPtr(pLabel);
                     buffers[0] = labelBuffer;
 
-                    NCryptBuffer seedBuffer = new NCryptBuffer();
+                    NCryptBuffer seedBuffer = default;
                     seedBuffer.cbBuffer = seed.Length;
                     seedBuffer.BufferType = BufferType.KdfTlsSeed;
                     seedBuffer.pvBuffer = new IntPtr(pSeed);
index e3e5209..17f0521 100644 (file)
@@ -13,7 +13,7 @@ internal partial class Interop
 
         internal static unsafe int RtlGetVersionEx(out RTL_OSVERSIONINFOEX osvi)
         {
-            osvi = new RTL_OSVERSIONINFOEX();
+            osvi = default;
             osvi.dwOSVersionInfoSize = (uint)sizeof(RTL_OSVERSIONINFOEX);
             return RtlGetVersion(ref osvi);
         }
index ff2aec1..08407d6 100644 (file)
@@ -37,7 +37,7 @@ internal static partial class Interop
                 }
             }
 
-            Sec_Application_Protocols protocols = new Sec_Application_Protocols();
+            Sec_Application_Protocols protocols = default;
 
             int protocolListConstSize = sizeof(Sec_Application_Protocols) - sizeof(uint) /* offsetof(Sec_Application_Protocols, ProtocolExtensionType) */;
             protocols.ProtocolListsSize = (uint)(protocolListConstSize + protocolListSize);
index 134f736..13e32d4 100644 (file)
@@ -99,7 +99,7 @@ namespace System.Net
             refHandle = SafeFreeContextBufferChannelBinding.CreateEmptyHandle();
 
             // Bindings is on the stack, so there's no need for a fixed block.
-            SecPkgContext_Bindings bindings = new SecPkgContext_Bindings();
+            SecPkgContext_Bindings bindings = default;
             return SafeFreeContextBufferChannelBinding.QueryContextChannelBinding(phContext, attribute, &bindings, refHandle);
         }
 
index fd49dbe..d593155 100644 (file)
@@ -29,7 +29,7 @@ namespace System.Net.Security
 
         protected SafeDeleteContext() : base(IntPtr.Zero, true)
         {
-            _handle = new Interop.SspiCli.CredHandle();
+            _handle = default;
         }
 
         public override bool IsInvalid
index 8182e41..a32c0d4 100644 (file)
@@ -178,7 +178,7 @@ namespace System.Net.Security
 
         protected SafeFreeCredentials() : base(IntPtr.Zero, true)
         {
-            _handle = new Interop.SspiCli.CredHandle();
+            _handle = default;
         }
 
 #if TRACE_VERBOSE
index 4167fc5..be7ddee 100644 (file)
@@ -25,7 +25,7 @@ namespace System.IO
 
         private static bool DirectoryExists(string path, out int lastError)
         {
-            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = new Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA();
+            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = default;
             lastError = FillAttributeInfo(path, ref data, returnErrorOnNotFound: true);
 
             return
@@ -36,7 +36,7 @@ namespace System.IO
 
         public static bool FileExists(string fullPath)
         {
-            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = new Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA();
+            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = default;
             int errorCode = FillAttributeInfo(fullPath, ref data, returnErrorOnNotFound: true);
 
             return
@@ -96,7 +96,7 @@ namespace System.IO
                         // pagefile.sys case. As such we're probably stuck filtering out specific
                         // cases that we know we don't want to retry on.
 
-                        var findData = new Interop.Kernel32.WIN32_FIND_DATA();
+                        Interop.Kernel32.WIN32_FIND_DATA findData = default;
                         using (SafeFindHandle handle = Interop.Kernel32.FindFirstFile(path, ref findData))
                         {
                             if (handle.IsInvalid)
index 17b6af0..54847f7 100644 (file)
@@ -491,7 +491,7 @@ namespace System.Net
             // can benefit from the synchronization of _intCompleted).  That means you can get here before _result got
             // set (although rarely - once every eight hours of stress).  Handle that case with a spin-lock.
 
-            SpinWait sw = new SpinWait();
+            SpinWait sw = default;
             while (_result == DBNull.Value)
             {
                 sw.SpinOnce();
index 1e7b308..b81de34 100644 (file)
@@ -34,7 +34,7 @@ namespace System.Net.NetworkInformation
         {
             uint size = 0;
             SafeLocalAllocHandle buffer = null;
-            Interop.IpHlpApi.FIXED_INFO fixedInfo = new Interop.IpHlpApi.FIXED_INFO();
+            Interop.IpHlpApi.FIXED_INFO fixedInfo = default;
 
             // First we need to get the size of the buffer
             uint result = Interop.IpHlpApi.GetNetworkParams(SafeLocalAllocHandle.InvalidHandle, ref size);
index a900ed9..1e9485b 100644 (file)
@@ -972,7 +972,7 @@ namespace System.Net.WebSockets
         {
             Debug.Assert(_receiveBufferCount >= 2, $"Expected to at least have the first two bytes of the header.");
 
-            var header = new MessageHeader();
+            MessageHeader header = default;
             Span<byte> receiveBufferSpan = _receiveBuffer.Span;
 
             header.Fin = (receiveBufferSpan[_receiveBufferOffset] & 0x80) != 0;
index 2147bb4..3f7a4ac 100644 (file)
@@ -337,7 +337,7 @@ namespace System.Security.Cryptography
 
                 unsafe
                 {
-                    DSAParameters dsaParams = new DSAParameters();
+                    DSAParameters dsaParams = default;
 
                     fixed (byte* pDsaBlob = dsaBlob)
                     {
index 8f61160..f1e98f9 100644 (file)
@@ -226,7 +226,7 @@ namespace System.Security.Cryptography
                 {
                     BCRYPT_ECCFULLKEY_BLOB* pBcryptBlob = (BCRYPT_ECCFULLKEY_BLOB*)pEcBlob;
 
-                    var primeCurve = new ECCurve();
+                    ECCurve primeCurve = default;
                     primeCurve.CurveType = ConvertToCurveTypeEnum(pBcryptBlob->CurveType);
                     primeCurve.Hash = GetHashAlgorithmName(pBcryptBlob->CurveGenerationAlgId);
 
@@ -467,8 +467,8 @@ namespace System.Security.Cryptography
 
             using (SafeUnicodeStringHandle safeCurveName = new SafeUnicodeStringHandle(curveName))
             {
-                var desc = new Interop.BCrypt.BCryptBufferDesc();
-                var buff = new Interop.BCrypt.BCryptBuffer();
+                Interop.BCrypt.BCryptBufferDesc desc = default;
+                Interop.BCrypt.BCryptBuffer buff = default;
 
                 IntPtr descPtr = IntPtr.Zero;
                 IntPtr buffPtr = IntPtr.Zero;
index 8f0e745..ce4dae3 100644 (file)
@@ -50,7 +50,7 @@ namespace System.Security.Cryptography
 
                 try
                 {
-                    ECParameters ecparams = new ECParameters();
+                    ECParameters ecparams = default;
                     ECCng.ExportPrimeCurveParameters(ref ecparams, blob, includePrivateParameters);
                     return ecparams;
                 }
@@ -62,7 +62,7 @@ namespace System.Security.Cryptography
 
             public override ECParameters ExportParameters(bool includePrivateParameters)
             {
-                ECParameters ecparams = new ECParameters();
+                ECParameters ecparams = default;
 
                 string curveName = GetCurveName(out string oidValue);
                 byte[] blob = null;
index 0e4c31a..03814d8 100644 (file)
@@ -68,7 +68,7 @@ namespace System.Security.Cryptography
             public override ECParameters ExportExplicitParameters(bool includePrivateParameters)
             {
                 byte[] blob = ExportFullKeyBlob(includePrivateParameters);
-                ECParameters ecparams = new ECParameters();
+                ECParameters ecparams = default;
                 ECCng.ExportPrimeCurveParameters(ref ecparams, blob, includePrivateParameters);
                 return ecparams;
             }
@@ -83,7 +83,7 @@ namespace System.Security.Cryptography
             /// <returns>The key and named curve parameters used by the ECC object.</returns>
             public override ECParameters ExportParameters(bool includePrivateParameters)
             {
-                ECParameters ecparams = new ECParameters();
+                ECParameters ecparams = default;
 
                 string curveName = GetCurveName(out string oidValue);
 
index 4d72d68..79fe528 100644 (file)
@@ -294,7 +294,7 @@ namespace System.Security.Cryptography
             public override RSAParameters ExportParameters(bool includePrivateParameters)
         {
             byte[] rsaBlob = ExportKeyBlob(includePrivateParameters);
-            RSAParameters rsaParams = new RSAParameters();
+            RSAParameters rsaParams = default;
             ExportParameters(ref rsaParams, rsaBlob, includePrivateParameters);
             return rsaParams;
         }
index 2e9a9c6..e06cbc4 100644 (file)
@@ -21,7 +21,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors
             int piarg = 0;
             int cargUnique = 0;
 
-            UserStringBuilder builder = new UserStringBuilder();
+            UserStringBuilder builder = default;
 
             for (int iarg = 0; iarg < args.Length; iarg++)
             {
index a94dd3d..0dbec2d 100644 (file)
@@ -87,7 +87,7 @@ namespace Microsoft.Win32
                         s_isUserInteractive = true;
 
                         int lengthNeeded = 0;
-                        Interop.User32.USEROBJECTFLAGS flags = new Interop.User32.USEROBJECTFLAGS();
+                        Interop.User32.USEROBJECTFLAGS flags = default;
 
                         if (Interop.User32.GetUserObjectInformationW(hwinsta, Interop.User32.UOI_FLAGS, ref flags, sizeof(Interop.User32.USEROBJECTFLAGS), ref lengthNeeded))
                         {
@@ -1267,7 +1267,7 @@ namespace Microsoft.Win32
 
                 if (_windowHandle != IntPtr.Zero)
                 {
-                    Interop.User32.MSG msg = new Interop.User32.MSG();
+                    Interop.User32.MSG msg = default(Interop.User32.MSG);
 
                     bool keepRunning = true;
 
index 858fac6..6bebdc3 100644 (file)
@@ -256,7 +256,7 @@ nameof(boundedCapacity), boundedCapacity,
 #if DEBUG
             bool tryAddReturnValue =
 #endif
-            TryAddWithNoTimeValidation(item, Timeout.Infinite, new CancellationToken());
+            TryAddWithNoTimeValidation(item, Timeout.Infinite, CancellationToken.None);
 #if DEBUG
             Debug.Assert(tryAddReturnValue, "TryAdd() was expected to return true.");
 #endif
@@ -305,7 +305,7 @@ nameof(boundedCapacity), boundedCapacity,
         /// <exception cref="System.InvalidOperationException">The underlying collection didn't accept the item.</exception>
         public bool TryAdd(T item)
         {
-            return TryAddWithNoTimeValidation(item, 0, new CancellationToken());
+            return TryAddWithNoTimeValidation(item, 0, CancellationToken.None);
         }
 
         /// <summary>
@@ -329,7 +329,7 @@ nameof(boundedCapacity), boundedCapacity,
         public bool TryAdd(T item, TimeSpan timeout)
         {
             ValidateTimeout(timeout);
-            return TryAddWithNoTimeValidation(item, (int)timeout.TotalMilliseconds, new CancellationToken());
+            return TryAddWithNoTimeValidation(item, (int)timeout.TotalMilliseconds, CancellationToken.None);
         }
 
         /// <summary>
@@ -351,7 +351,7 @@ nameof(boundedCapacity), boundedCapacity,
         public bool TryAdd(T item, int millisecondsTimeout)
         {
             ValidateMillisecondsTimeout(millisecondsTimeout);
-            return TryAddWithNoTimeValidation(item, millisecondsTimeout, new CancellationToken());
+            return TryAddWithNoTimeValidation(item, millisecondsTimeout, CancellationToken.None);
         }
 
         /// <summary>
@@ -450,7 +450,7 @@ nameof(boundedCapacity), boundedCapacity,
                 // spins until all adders finish then throw IOE
                 // The idea behind to spin until all adders finish, is to avoid to return to the caller with IOE while there are still some adders have
                 // not been finished yet
-                SpinWait spinner = new SpinWait();
+                SpinWait spinner = default;
                 while (true)
                 {
                     int observedAdders = _currentAdders;
@@ -1475,7 +1475,7 @@ nameof(boundedCapacity), boundedCapacity,
             if (IsAddingCompleted)
                 return;
 
-            SpinWait spinner = new SpinWait();
+            SpinWait spinner = default;
             while (true)
             {
                 int observedAdders = _currentAdders;
index c7549f6..430b955 100644 (file)
@@ -634,7 +634,7 @@ namespace System.Collections.Concurrent
             {
                 if (queue._currentOp != (int)Operation.None)
                 {
-                    var spinner = new SpinWait();
+                    SpinWait spinner = default;
                     do { spinner.SpinOnce(); }
                     while (queue._currentOp != (int)Operation.None);
                 }
@@ -975,7 +975,7 @@ namespace System.Collections.Concurrent
                         // steal operations happening at the time.
                         if ((head - (_tailIndex - 2) >= 0) && _currentOp == (int)Operation.Add)
                         {
-                            var spinner = new SpinWait();
+                            SpinWait spinner = default;
                             do
                             {
                                 spinner.SpinOnce();
index ceb5ad7..6d5ca3a 100644 (file)
@@ -379,7 +379,7 @@ namespace System.Collections.Concurrent
         /// <param name="tail">The tail pointer to the new list</param>
         private void PushCore(Node head, Node tail)
         {
-            SpinWait spin = new SpinWait();
+            SpinWait spin = default;
 
             // Keep trying to CAS the existing head with the new node until we succeed.
             do
@@ -600,7 +600,7 @@ namespace System.Collections.Concurrent
         /// the <see cref="ConcurrentStack{T}"/>.</returns>
         private int TryPopCore(int count, out Node? poppedHead)
         {
-            SpinWait spin = new SpinWait();
+            SpinWait spin = default;
 
             // Try to CAS the head with its current next.  We stop when we succeed or
             // when we notice that the stack is empty, whichever comes first.
index fcf60ad..b6f9115 100644 (file)
@@ -791,7 +791,7 @@ namespace System.Collections.Concurrent
                             // we need to make sure all array copiers are finished
                             if (_activeCopiers > 0)
                             {
-                                SpinWait sw = new SpinWait();
+                                SpinWait sw = default;
                                 while (_activeCopiers > 0) sw.SpinOnce();
                             }
 
index c3612ff..e5603ec 100644 (file)
@@ -227,7 +227,7 @@ namespace System.Collections.Immutable
                     if (_additionalElements.IsEmpty)
                     {
                         result = OperationResult.SizeChanged;
-                        return new HashBucket();
+                        return default;
                     }
                     else
                     {
index d830c06..d4dd830 100644 (file)
@@ -215,7 +215,7 @@ namespace System.Collections.Immutable
                     if (_additionalElements.IsEmpty)
                     {
                         result = OperationResult.SizeChanged;
-                        return new HashBucket();
+                        return default;
                     }
                     else
                     {
index cf5105c..aef115d 100644 (file)
@@ -264,7 +264,7 @@ namespace System.ComponentModel.Composition
         {
             List<IEnumerable<CompositionError>> paths = new List<IEnumerable<CompositionError>>();
 
-            VisitContext context = new VisitContext();
+            VisitContext context = default;
             context.Path = new Stack<CompositionError>();
             context.LeafVisitor = path =>
             {
index b855f21..7f06572 100644 (file)
@@ -11,7 +11,7 @@ namespace System.ComponentModel.Composition
 {
     internal struct CompositionResult
     {
-        public static readonly CompositionResult SucceededResult = new CompositionResult();
+        public static readonly CompositionResult SucceededResult;
         private readonly IEnumerable<CompositionError> _errors;
 
         public CompositionResult(params CompositionError[] errors)
index 98a4b87..3ea1fac 100644 (file)
@@ -189,7 +189,7 @@ namespace System.ComponentModel.Design.Serialization
     /// </summary>
     public readonly struct MemberRelationship
     {
-        public static readonly MemberRelationship Empty = new MemberRelationship();
+        public static readonly MemberRelationship Empty;
 
         /// <summary>
         /// Creates a new member relationship.
index 38c426b..bdfdfaa 100644 (file)
@@ -244,7 +244,7 @@ namespace System.ComponentModel
                 culture = CultureInfo.CurrentCulture;
             }
 
-            _flagState = new BitVector32();
+            _flagState = default;
 
             // read only property-backend fields.
 
index 4a4013b..f6cc2e1 100644 (file)
@@ -163,7 +163,7 @@ namespace System.Configuration
         internal BaseConfigurationRecord()
         {
             // not strictly necessary, but compiler spits out a warning without this initiailization
-            _flags = new SafeBitVector32();
+            _flags = default;
         }
 
         protected abstract SimpleBitVector32 ClassFlags { get; }
index 79cb7bd..5f75185 100644 (file)
@@ -38,7 +38,7 @@ namespace System.Configuration
             // The conversion is true -> OverrideMode.Inherit
             // The conversion is false -> OverrideMode.Deny
             // This is consistent with Whidbey where true means true unless there is a false somewhere above
-            OverrideModeSetting result = new OverrideModeSetting();
+            OverrideModeSetting result = default;
 
             result.SetMode(allowOverride ? OverrideMode.Inherit : OverrideMode.Deny);
             result._mode |= XmlDefinedLegacy;
@@ -48,7 +48,7 @@ namespace System.Configuration
 
         internal static OverrideModeSetting CreateFromXmlReadValue(OverrideMode mode)
         {
-            OverrideModeSetting result = new OverrideModeSetting();
+            OverrideModeSetting result = default;
 
             result.SetMode(mode);
             result._mode |= XmlDefinedNewMode;
index ba72c52..a1a4f21 100644 (file)
@@ -62,7 +62,7 @@ namespace System.Configuration
             _flags[FlagInheritInChildApps] = true;
             _flags[FlagForceSave] = false;
 
-            _modifiedFlags = new SimpleBitVector32();
+            _modifiedFlags = default;
         }
 
         private bool IsRuntime => _flags[FlagAttached] &&
@@ -403,7 +403,7 @@ namespace System.Configuration
 
         internal void ResetModifiedFlags()
         {
-            _modifiedFlags = new SimpleBitVector32();
+            _modifiedFlags = default;
         }
 
         internal bool IsModifiedFlags()
index ae87341..2097d22 100644 (file)
@@ -263,7 +263,7 @@ namespace System
                 if (_cachedInputRecord.eventType == Interop.KEY_EVENT)
                     return true;
 
-                Interop.InputRecord ir = new Interop.InputRecord();
+                Interop.InputRecord ir = default;
                 int numEventsRead = 0;
                 while (true)
                 {
@@ -706,8 +706,8 @@ namespace System
             Interop.Kernel32.CHAR_INFO[] data = new Interop.Kernel32.CHAR_INFO[sourceWidth * sourceHeight];
             bufferSize.X = (short)sourceWidth;
             bufferSize.Y = (short)sourceHeight;
-            Interop.Kernel32.COORD bufferCoord = new Interop.Kernel32.COORD();
-            Interop.Kernel32.SMALL_RECT readRegion = new Interop.Kernel32.SMALL_RECT();
+            Interop.Kernel32.COORD bufferCoord = default;
+            Interop.Kernel32.SMALL_RECT readRegion = default;
             readRegion.Left = (short)sourceLeft;
             readRegion.Right = (short)(sourceLeft + sourceWidth - 1);
             readRegion.Top = (short)sourceTop;
@@ -720,7 +720,7 @@ namespace System
                 throw Win32Marshal.GetExceptionForWin32Error(Marshal.GetLastWin32Error());
 
             // Overwrite old section
-            Interop.Kernel32.COORD writeCoord = new Interop.Kernel32.COORD();
+            Interop.Kernel32.COORD writeCoord = default;
             writeCoord.X = (short)sourceLeft;
             Interop.Kernel32.Color c = ConsoleColorToColorAttribute(sourceBackColor, true);
             c |= ConsoleColorToColorAttribute(sourceForeColor, false);
@@ -740,7 +740,7 @@ namespace System
             }
 
             // Write text to new location
-            Interop.Kernel32.SMALL_RECT writeRegion = new Interop.Kernel32.SMALL_RECT();
+            Interop.Kernel32.SMALL_RECT writeRegion = default;
             writeRegion.Left = (short)targetLeft;
             writeRegion.Right = (short)(targetLeft + sourceWidth);
             writeRegion.Top = (short)targetTop;
@@ -752,7 +752,7 @@ namespace System
 
         public static void Clear()
         {
-            Interop.Kernel32.COORD coordScreen = new Interop.Kernel32.COORD();
+            Interop.Kernel32.COORD coordScreen = default;
             Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO csbi;
             bool success;
             int conSize;
@@ -793,7 +793,7 @@ namespace System
         public static void SetCursorPosition(int left, int top)
         {
             IntPtr hConsole = OutputHandle;
-            Interop.Kernel32.COORD coords = new Interop.Kernel32.COORD();
+            Interop.Kernel32.COORD coords = default;
             coords.X = (short)left;
             coords.Y = (short)top;
             if (!Interop.Kernel32.SetConsoleCursorPosition(hConsole, coords))
@@ -846,7 +846,7 @@ namespace System
             if (height < srWindow.Bottom + 1 || height >= short.MaxValue)
                 throw new ArgumentOutOfRangeException(nameof(height), height, SR.ArgumentOutOfRange_ConsoleBufferLessThanWindowSize);
 
-            Interop.Kernel32.COORD size = new Interop.Kernel32.COORD();
+            Interop.Kernel32.COORD size = default;
             size.X = (short)width;
             size.Y = (short)height;
             if (!Interop.Kernel32.SetConsoleScreenBufferSize(OutputHandle, size))
@@ -969,7 +969,7 @@ namespace System
             // If the buffer is smaller than this new window size, resize the
             // buffer to be large enough.  Include window position.
             bool resizeBuffer = false;
-            Interop.Kernel32.COORD size = new Interop.Kernel32.COORD();
+            Interop.Kernel32.COORD size = default;
             size.X = csbi.dwSize.X;
             size.Y = csbi.dwSize.Y;
             if (csbi.dwSize.X < csbi.srWindow.Left + width)
@@ -1062,7 +1062,7 @@ namespace System
                 {
                     throw new IOException(SR.IO_NoConsole);
                 }
-                return new Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO();
+                return default;
             }
 
             // Note that if stdout is redirected to a file, the console handle may be a file.
@@ -1074,7 +1074,7 @@ namespace System
             {
                 int errorCode = Marshal.GetLastWin32Error();
                 if (errorCode == Interop.Errors.ERROR_INVALID_HANDLE && !throwOnNoConsole)
-                    return new Interop.Kernel32.CONSOLE_SCREEN_BUFFER_INFO();
+                    return default;
                 throw Win32Marshal.GetExceptionForWin32Error(errorCode);
             }
 
index 5dbaf7e..8aaf84a 100644 (file)
@@ -125,7 +125,7 @@ namespace System.Data.Common
             }
             else
             {
-                CancellationTokenRegistration registration = new CancellationTokenRegistration();
+                CancellationTokenRegistration registration = default;
                 if (cancellationToken.CanBeCanceled)
                 {
                     registration = cancellationToken.Register(s => ((DbCommand)s).CancelIgnoreFailure(), this);
@@ -166,7 +166,7 @@ namespace System.Data.Common
             }
             else
             {
-                CancellationTokenRegistration registration = new CancellationTokenRegistration();
+                CancellationTokenRegistration registration = default;
                 if (cancellationToken.CanBeCanceled)
                 {
                     registration = cancellationToken.Register(s => ((DbCommand)s).CancelIgnoreFailure(), this);
@@ -198,7 +198,7 @@ namespace System.Data.Common
             }
             else
             {
-                CancellationTokenRegistration registration = new CancellationTokenRegistration();
+                CancellationTokenRegistration registration = default;
                 if (cancellationToken.CanBeCanceled)
                 {
                     registration = cancellationToken.Register(s => ((DbCommand)s).CancelIgnoreFailure(), this);
index 0d449c1..4974b15 100644 (file)
@@ -95,7 +95,7 @@ namespace System.Data.Common
             PropertyDescriptor[] props = new PropertyDescriptor[_reader.FieldCount];
             for (int i = 0; i < si.Length; i++)
             {
-                SchemaInfo s = new SchemaInfo();
+                SchemaInfo s = default;
                 s.name = _reader.GetName(i);
                 s.type = _reader.GetFieldType(i);
                 s.typeName = _reader.GetDataTypeName(i);
index c893cfc..41b02ac 100644 (file)
@@ -100,7 +100,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlBinary newValue = new SqlBinary();
+            SqlBinary newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 17f7eea..7855a0c 100644 (file)
@@ -210,7 +210,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlByte newValue = new SqlByte();
+            SqlByte newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 8a64b95..44914df 100644 (file)
@@ -99,7 +99,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlBinary newValue = new SqlBinary();
+            SqlBinary newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 893c948..d318ab1 100644 (file)
@@ -101,7 +101,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlString newValue = new SqlString();
+            SqlString newValue = default;
 
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
index 692114a..857b416 100644 (file)
@@ -136,7 +136,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlDateTime newValue = new SqlDateTime();
+            SqlDateTime newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 3d624d9..c431374 100644 (file)
@@ -208,7 +208,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlDecimal newValue = new SqlDecimal();
+            SqlDecimal newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 36311be..bf3f6e0 100644 (file)
@@ -209,7 +209,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlDouble newValue = new SqlDouble();
+            SqlDouble newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index be24e79..782528f 100644 (file)
@@ -101,7 +101,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlGuid newValue = new SqlGuid();
+            SqlGuid newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 3d7cabb..788cb6b 100644 (file)
@@ -209,7 +209,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlInt16 newValue = new SqlInt16();
+            SqlInt16 newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 57660c3..ec30347 100644 (file)
@@ -209,7 +209,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlInt32 newValue = new SqlInt32();
+            SqlInt32 newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index d31a7ee..b1f25f0 100644 (file)
@@ -210,7 +210,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlInt64 newValue = new SqlInt64();
+            SqlInt64 newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 51fa06e..6572eed 100644 (file)
@@ -209,7 +209,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlMoney newValue = new SqlMoney();
+            SqlMoney newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 72e4fb0..b95c2ee 100644 (file)
@@ -207,7 +207,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlSingle newValue = new SqlSingle();
+            SqlSingle newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 8b7673f..985f825 100644 (file)
@@ -162,7 +162,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlString newValue = new SqlString();
+            SqlString newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index f3cd98a..d579310 100644 (file)
@@ -134,7 +134,7 @@ namespace System.Data.Common
 
         public override object ConvertXmlToObject(string s)
         {
-            SqlBoolean newValue = new SqlBoolean();
+            SqlBoolean newValue = default;
             string tempStr = string.Concat("<col>", s, "</col>"); // this is done since you can give fragmet to reader
             StringReader strReader = new StringReader(tempStr);
 
index 99f7c60..f4d6ad8 100644 (file)
@@ -1964,7 +1964,7 @@ namespace System.Data
             long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.ReadXml|INFO> {0}, denyResolving={1}", ObjectID, denyResolving);
             try
             {
-                DataTable.DSRowDiffIdUsageSection rowDiffIdUsage = new DataTable.DSRowDiffIdUsageSection();
+                DataTable.DSRowDiffIdUsageSection rowDiffIdUsage = default;
                 try
                 {
                     bool fDataFound = false;
@@ -2483,7 +2483,7 @@ namespace System.Data
                     return ReadXml(reader);
                 }
 
-                DataTable.DSRowDiffIdUsageSection rowDiffIdUsage = new DataTable.DSRowDiffIdUsageSection();
+                DataTable.DSRowDiffIdUsageSection rowDiffIdUsage = default;
                 try
                 {
                     bool fSchemaFound = false;
index 3bafed8..035169a 100644 (file)
@@ -5664,7 +5664,7 @@ namespace System.Data
             long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.ReadXml|INFO> {0}, denyResolving={1}", ObjectID, denyResolving);
             try
             {
-                RowDiffIdUsageSection rowDiffIdUsage = new RowDiffIdUsageSection();
+                RowDiffIdUsageSection rowDiffIdUsage = default;
                 try
                 {
                     bool fDataFound = false;
@@ -5904,7 +5904,7 @@ namespace System.Data
 
         internal XmlReadMode ReadXml(XmlReader reader, XmlReadMode mode, bool denyResolving)
         {
-            RowDiffIdUsageSection rowDiffIdUsage = new RowDiffIdUsageSection();
+            RowDiffIdUsageSection rowDiffIdUsage = default;
             try
             {
                 bool fSchemaFound = false;
index 5c273d1..0c90184 100644 (file)
@@ -773,7 +773,7 @@ namespace System.Data
             int lo = FindFirstMatchingRecord();
             if (lo == -1)
             {
-                return new Range();
+                return default;
             }
             int hi = FindLastMatchingRecord(lo);
             Debug.Assert(lo <= hi, "GetBinaryFilteredRecords : Invalid Search Results");
index 7158884..27f2168 100644 (file)
@@ -644,7 +644,7 @@ namespace System.Data
 
             if (IndexTree.NIL == nodeId)
             {
-                return new Range();
+                return default;
             }
             int recordIndex = _records.GetIndexByNode(nodeId);
 
index 1902b70..65fea05 100644 (file)
@@ -291,7 +291,7 @@ namespace System.Data.SqlClient
         internal static unsafe uint SNIOpenMarsSession(ConsumerInfo consumerInfo, SNIHandle parent, ref IntPtr pConn, bool fSync)
         {
             // initialize consumer info for MARS
-            Sni_Consumer_Info native_consumerInfo = new Sni_Consumer_Info();
+            Sni_Consumer_Info native_consumerInfo = default;
             MarshalConsumerInfo(consumerInfo, ref native_consumerInfo);
 
             return SNIOpenWrapper(ref native_consumerInfo, "session:", parent, out pConn, fSync);
@@ -301,7 +301,7 @@ namespace System.Data.SqlClient
         {
             fixed (byte* pin_instanceName = &instanceName[0])
             {
-                SNI_CLIENT_CONSUMER_INFO clientConsumerInfo = new SNI_CLIENT_CONSUMER_INFO();
+                SNI_CLIENT_CONSUMER_INFO clientConsumerInfo = default;
 
                 // initialize client ConsumerInfo part first
                 MarshalConsumerInfo(consumerInfo, ref clientConsumerInfo.ConsumerInfo);
index 01a519c..6c778ba 100644 (file)
@@ -163,7 +163,7 @@ namespace Microsoft.SqlServer.Server
             {
                 if (_columns.Count <= ordinal)
                 {
-                    SmiColumnOrder order = new SmiColumnOrder();
+                    SmiColumnOrder order = default;
                     order.Order = SortOrder.Unspecified;
                     order.SortOrdinal = -1;
                     return order;
index b317c66..2b2167f 100644 (file)
@@ -2773,7 +2773,7 @@ namespace System.Data.SqlClient
                 {
                     if (_isAsyncBulkCopy)
                     {
-                        CancellationTokenRegistration regReconnectCancel = new CancellationTokenRegistration();
+                        CancellationTokenRegistration regReconnectCancel = default;
                         TaskCompletionSource<object> cancellableReconnectTS = new TaskCompletionSource<object>();
                         if (cts.CanBeCanceled)
                         {
index 5ac2f13..cdbaaa2 100644 (file)
@@ -1644,7 +1644,7 @@ namespace System.Data.SqlClient
 
             TaskCompletionSource<int> source = new TaskCompletionSource<int>();
 
-            CancellationTokenRegistration registration = new CancellationTokenRegistration();
+            CancellationTokenRegistration registration = default;
             if (cancellationToken.CanBeCanceled)
             {
                 if (cancellationToken.IsCancellationRequested)
@@ -1727,7 +1727,7 @@ namespace System.Data.SqlClient
 
             TaskCompletionSource<SqlDataReader> source = new TaskCompletionSource<SqlDataReader>();
 
-            CancellationTokenRegistration registration = new CancellationTokenRegistration();
+            CancellationTokenRegistration registration = default;
             if (cancellationToken.CanBeCanceled)
             {
                 if (cancellationToken.IsCancellationRequested)
@@ -1872,7 +1872,7 @@ namespace System.Data.SqlClient
 
             TaskCompletionSource<XmlReader> source = new TaskCompletionSource<XmlReader>();
 
-            CancellationTokenRegistration registration = new CancellationTokenRegistration();
+            CancellationTokenRegistration registration = default;
             if (cancellationToken.CanBeCanceled)
             {
                 if (cancellationToken.IsCancellationRequested)
index 899ac79..7913850 100644 (file)
@@ -1043,7 +1043,7 @@ namespace System.Data.SqlClient
                 }
                 else
                 {
-                    CancellationTokenRegistration registration = new CancellationTokenRegistration();
+                    CancellationTokenRegistration registration = default;
                     if (cancellationToken.CanBeCanceled)
                     {
                         registration = cancellationToken.Register(s => ((TaskCompletionSource<DbConnectionInternal>)s).TrySetCanceled(), completion);
index 5b3aa72..d828468 100644 (file)
@@ -801,7 +801,7 @@ namespace System.Data.SqlClient
         public static TdsDateTime FromDateTime(DateTime dateTime, byte cb)
         {
             SqlDateTime sqlDateTime;
-            TdsDateTime tdsDateTime = new TdsDateTime();
+            TdsDateTime tdsDateTime = default;
 
             Debug.Assert(cb == 8 || cb == 4, "Invalid date time size!");
 
index c26a62c..cf28575 100644 (file)
@@ -93,7 +93,7 @@ namespace System.Data.SqlClient
 
         private SNIErrorDetails GetSniErrorDetails()
         {
-            SNIErrorDetails details = new SNIErrorDetails();
+            SNIErrorDetails details = default;
 
             if (TdsParserStateObjectFactory.UseManagedSNI)
             {
index ee154b3..892c7c0 100644 (file)
@@ -3914,7 +3914,7 @@ namespace System.Data.SqlClient
 
             multiPartTableName = default(MultiPartTableName);
 
-            mpt = new MultiPartTableName();
+            mpt = default;
             byte nParts;
 
             // Find out how many parts in the TDS stream
index 94b3fe5..284a404 100644 (file)
@@ -533,7 +533,7 @@ namespace System.Data.SqlClient
 
             internal NullBitmap Clone()
             {
-                NullBitmap newBitmap = new NullBitmap();
+                NullBitmap newBitmap = default;
                 newBitmap._nullBitmap = _nullBitmap == null ? null : (byte[])_nullBitmap.Clone();
                 newBitmap._columnsCount = _columnsCount;
                 return newBitmap;
index 898d531..a6c8688 100644 (file)
@@ -45,7 +45,7 @@ namespace System.Data.SqlClient
 
         private SNINativeMethodWrapper.ConsumerInfo CreateConsumerInfo(bool async)
         {
-            SNINativeMethodWrapper.ConsumerInfo myInfo = new SNINativeMethodWrapper.ConsumerInfo();
+            SNINativeMethodWrapper.ConsumerInfo myInfo = default;
 
             Debug.Assert(_outBuff.Length == _inBuff.Length, "Unexpected unequal buffers.");
 
index 77d1f6a..e413d90 100644 (file)
@@ -67,7 +67,7 @@ namespace System.Diagnostics
         private const int Flag_disposed = 0x100;
         private const int Flag_sourceVerified = 0x200;
 
-        private BitVector32 boolFlags = new BitVector32();
+        private BitVector32 boolFlags;
 
         private Hashtable messageLibraries;
         private static readonly Hashtable listenerInfos = new Hashtable(StringComparer.OrdinalIgnoreCase);
index f747c29..2c278b0 100644 (file)
@@ -105,7 +105,7 @@ namespace System.Diagnostics.Eventing.Reader
             _user = user;
             _logOnType = logOnType;
 
-            UnsafeNativeMethods.EvtRpcLogin erLogin = new UnsafeNativeMethods.EvtRpcLogin();
+            UnsafeNativeMethods.EvtRpcLogin erLogin = default;
             erLogin.Server = _server;
             erLogin.User = _user;
             erLogin.Domain = _domain;
index a7d1069..2761073 100644 (file)
@@ -591,7 +591,7 @@ namespace System.Diagnostics.Eventing.Reader
 
         public static void EvtSetChannelConfigProperty(EventLogHandle handle, UnsafeNativeMethods.EvtChannelConfigPropertyId enumType, object val)
         {
-            UnsafeNativeMethods.EvtVariant varVal = new UnsafeNativeMethods.EvtVariant();
+            UnsafeNativeMethods.EvtVariant varVal = default;
 
             CoTaskMemSafeHandle taskMem = new CoTaskMemSafeHandle();
 
index 8f89623..1b6cd03 100644 (file)
@@ -84,7 +84,7 @@ namespace System.Diagnostics
                 return (Interop.Version.VS_FIXEDFILEINFO)Marshal.PtrToStructure<Interop.Version.VS_FIXEDFILEINFO>(memRef);
             }
 
-            return new Interop.Version.VS_FIXEDFILEINFO();
+            return default;
         }
 
         private static unsafe string GetFileVersionLanguage(IntPtr memPtr)
index 8f33c8e..0798e63 100644 (file)
@@ -85,14 +85,14 @@ namespace System.Diagnostics
             if (newCounterType == Interop.Kernel32.PerformanceCounterOptions.PERF_ELAPSED_TIME)
                 return (float)GetElapsedTime(oldSample, newSample);
 
-            Interop.Kernel32.PerformanceCounterOptions.PDH_RAW_COUNTER newPdhValue = new Interop.Kernel32.PerformanceCounterOptions.PDH_RAW_COUNTER();
-            Interop.Kernel32.PerformanceCounterOptions.PDH_RAW_COUNTER oldPdhValue = new Interop.Kernel32.PerformanceCounterOptions.PDH_RAW_COUNTER();
+            Interop.Kernel32.PerformanceCounterOptions.PDH_RAW_COUNTER newPdhValue = default;
+            Interop.Kernel32.PerformanceCounterOptions.PDH_RAW_COUNTER oldPdhValue = default;
 
             FillInValues(oldSample, newSample, ref oldPdhValue, ref newPdhValue);
 
             LoadPerfCounterDll();
 
-            Interop.Kernel32.PerformanceCounterOptions.PDH_FMT_COUNTERVALUE pdhFormattedValue = new Interop.Kernel32.PerformanceCounterOptions.PDH_FMT_COUNTERVALUE();
+            Interop.Kernel32.PerformanceCounterOptions.PDH_FMT_COUNTERVALUE pdhFormattedValue = default;
             long timeBase = newSample.SystemFrequency;
             int result = Interop.PerfCounter.FormatFromRawValue((uint)newCounterType, Interop.Kernel32.PerformanceCounterOptions.PDH_FMT_DOUBLE | Interop.Kernel32.PerformanceCounterOptions.PDH_FMT_NOSCALE | Interop.Kernel32.PerformanceCounterOptions.PDH_FMT_NOCAP100,
                                                           ref timeBase, ref newPdhValue, ref oldPdhValue, ref pdhFormattedValue);
index 8d9e452..8345b9a 100644 (file)
@@ -1690,7 +1690,7 @@ namespace System.Diagnostics
                                                                                                     out securityDescriptorPointer, IntPtr.Zero))
                         throw new InvalidOperationException(SR.SetSecurityDescriptorFailed);
 
-                    Interop.Kernel32.SECURITY_ATTRIBUTES securityAttributes = new Interop.Kernel32.SECURITY_ATTRIBUTES();
+                    Interop.Kernel32.SECURITY_ATTRIBUTES securityAttributes = default;
                     securityAttributes.bInheritHandle = Interop.BOOL.FALSE;
 
                     //
@@ -1752,7 +1752,7 @@ namespace System.Diagnostics
                         throw new InvalidOperationException(SR.CantMapFileView);
 
                     // figure out what size the share memory really is.
-                    Interop.Kernel32.MEMORY_BASIC_INFORMATION meminfo = new Interop.Kernel32.MEMORY_BASIC_INFORMATION();
+                    Interop.Kernel32.MEMORY_BASIC_INFORMATION meminfo = default;
                     if (Interop.Kernel32.VirtualQuery(_fileViewAddress, ref meminfo, (UIntPtr)sizeof(Interop.Kernel32.MEMORY_BASIC_INFORMATION)) == UIntPtr.Zero)
                         throw new InvalidOperationException(SR.CantGetMappingSize);
 
index 7e511d2..6adee94 100644 (file)
@@ -462,9 +462,9 @@ namespace System.Diagnostics
             StringBuilder commandLine = BuildCommandLine(startInfo.FileName, StartInfo.Arguments);
             Process.AppendArguments(commandLine, StartInfo.ArgumentList);
 
-            Interop.Kernel32.STARTUPINFO startupInfo = new Interop.Kernel32.STARTUPINFO();
-            Interop.Kernel32.PROCESS_INFORMATION processInfo = new Interop.Kernel32.PROCESS_INFORMATION();
-            Interop.Kernel32.SECURITY_ATTRIBUTES unused_SecAttrs = new Interop.Kernel32.SECURITY_ATTRIBUTES();
+            Interop.Kernel32.STARTUPINFO startupInfo = default;
+            Interop.Kernel32.PROCESS_INFORMATION processInfo = default;
+            Interop.Kernel32.SECURITY_ATTRIBUTES unused_SecAttrs = default;
             SafeProcessHandle procSH = new SafeProcessHandle();
             SafeThreadHandle threadSH = new SafeThreadHandle();
 
@@ -836,7 +836,7 @@ namespace System.Diagnostics
         // for synchronous I/O and hence they can work fine with ReadFile/WriteFile synchronously!
         private void CreatePipe(out SafeFileHandle parentHandle, out SafeFileHandle childHandle, bool parentInputs)
         {
-            Interop.Kernel32.SECURITY_ATTRIBUTES securityAttributesParent = new Interop.Kernel32.SECURITY_ATTRIBUTES();
+            Interop.Kernel32.SECURITY_ATTRIBUTES securityAttributesParent = default;
             securityAttributesParent.bInheritHandle = Interop.BOOL.TRUE;
 
             SafeFileHandle hTmp = null;
index b2a1775..a3f3794 100644 (file)
@@ -80,7 +80,7 @@ namespace System.Diagnostics
                 processHandle = ProcessManager.OpenProcess(processId, Interop.Advapi32.ProcessOptions.PROCESS_QUERY_INFORMATION | Interop.Advapi32.ProcessOptions.PROCESS_VM_READ, true);
 
                 IntPtr[] moduleHandles = new IntPtr[64];
-                GCHandle moduleHandlesArrayHandle = new GCHandle();
+                GCHandle moduleHandlesArrayHandle = default;
                 int moduleCount = 0;
                 while (true)
                 {
index 34fb819..011776d 100644 (file)
@@ -144,7 +144,7 @@ namespace System.Diagnostics
             // So we will try to get the privilege here.
             // We could fail if the user account doesn't have right to do this, but that's fair.
 
-            Interop.Advapi32.LUID luid = new Interop.Advapi32.LUID();
+            Interop.Advapi32.LUID luid = default;
             if (!Interop.Advapi32.LookupPrivilegeValue(null, Interop.Advapi32.SeDebugPrivilege, out luid))
             {
                 return;
index 6eecd2a..6ec5eef 100644 (file)
@@ -56,7 +56,7 @@ namespace System.DirectoryServices.AccountManagement
 
             try
             {
-                UnsafeNativeMethods.LUID luid = new UnsafeNativeMethods.LUID();
+                UnsafeNativeMethods.LUID luid = default;
                 luid.low = 0;
                 luid.high = 0;
 
index b0eaebf..b009456 100644 (file)
@@ -682,7 +682,7 @@ namespace System.DirectoryServices.AccountManagement
 
         private void DoServerVerifyAndPropRetrieval()
         {
-            _serverProperties = new ServerProperties();
+            _serverProperties = default;
             if (_contextType == ContextType.ApplicationDirectory || _contextType == ContextType.Domain)
             {
                 ReadServerConfig(_name, ref _serverProperties);
index 0fc22dc..81c9ee4 100644 (file)
@@ -429,7 +429,7 @@ namespace System.DirectoryServices.AccountManagement
             public string DomainNameDns;
             [MarshalAs(UnmanagedType.LPWStr)]
             public string DomainForestName;
-            public Guid DomainGuid = new Guid();
+            public Guid DomainGuid;
         }
 
         /*
@@ -462,7 +462,7 @@ namespace System.DirectoryServices.AccountManagement
             public string DomainControllerName = null;
             public string DomainControllerAddress = null;
             public int DomainControllerAddressType = 0;
-            public Guid DomainGuid = new Guid();
+            public Guid DomainGuid;
             public string DomainName = null;
             public string DnsForestName = null;
             public int Flags = 0;
index fdf6529..614f5d0 100644 (file)
@@ -335,7 +335,7 @@ namespace System.DirectoryServices.Protocols
                     throw new ObjectDisposedException(GetType().Name);
                 }
 
-                var tempHandle = new SecurityHandle();
+                SecurityHandle tempHandle = default;
 
                 int error = Wldap32.ldap_get_option_sechandle(_connection._ldapHandle, LdapOption.LDAP_OPT_SECURITY_CONTEXT, ref tempHandle);
                 ErrorChecking.CheckAndSetLdapError(error);
index 7d9fd79..207d61f 100644 (file)
@@ -592,7 +592,7 @@ namespace System.DirectoryServices.ActiveDirectory
         public string DomainNameDns;
         [MarshalAs(UnmanagedType.LPWStr)]
         public string DomainForestName;
-        public Guid DomainGuid = new Guid();
+        public Guid DomainGuid = default;
     }
 
     [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
index 5878a7a..f1af856 100644 (file)
@@ -502,7 +502,7 @@ namespace System.DirectoryServices
                 }
 
                 // the new option is available, set it so we get the new PutEx behavior that will allow multiple changes
-                Variant value = new Variant();
+                Variant value = default;
                 value.varType = 11; //VT_BOOL
                 value.boolvalue = -1;
                 ((UnsafeNativeMethods.IAdsObjectOptions2)_adsObject).SetOption(8, value);
index 65dd718..117aab6 100644 (file)
@@ -675,7 +675,7 @@ namespace System.DirectoryServices
             AdsSearchPreferenceInfo info;
 
             // search scope
-            info = new AdsSearchPreferenceInfo();
+            info = default;
             info.dwSearchPref = (int)AdsSearchPreferences.SEARCH_SCOPE;
             info.vValue = new AdsValueHelper((int)SearchScope).GetStruct();
             prefList.Add(info);
@@ -683,7 +683,7 @@ namespace System.DirectoryServices
             // size limit
             if (_sizeLimit != 0 || !findMoreThanOne)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.SIZE_LIMIT;
                 info.vValue = new AdsValueHelper(findMoreThanOne ? SizeLimit : 1).GetStruct();
                 prefList.Add(info);
@@ -692,14 +692,14 @@ namespace System.DirectoryServices
             // time limit
             if (ServerTimeLimit >= new TimeSpan(0))
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.TIME_LIMIT;
                 info.vValue = new AdsValueHelper((int)ServerTimeLimit.TotalSeconds).GetStruct();
                 prefList.Add(info);
             }
 
             // propertyNamesOnly
-            info = new AdsSearchPreferenceInfo();
+            info = default;
             info.dwSearchPref = (int)AdsSearchPreferences.ATTRIBTYPES_ONLY;
             info.vValue = new AdsValueHelper(PropertyNamesOnly).GetStruct();
             prefList.Add(info);
@@ -707,7 +707,7 @@ namespace System.DirectoryServices
             // Timeout
             if (ClientTimeout >= new TimeSpan(0))
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.TIMEOUT;
                 info.vValue = new AdsValueHelper((int)ClientTimeout.TotalSeconds).GetStruct();
                 prefList.Add(info);
@@ -716,7 +716,7 @@ namespace System.DirectoryServices
             // page size
             if (PageSize != 0)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.PAGESIZE;
                 info.vValue = new AdsValueHelper(PageSize).GetStruct();
                 prefList.Add(info);
@@ -725,14 +725,14 @@ namespace System.DirectoryServices
             // page time limit
             if (ServerPageTimeLimit >= new TimeSpan(0))
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.PAGED_TIME_LIMIT;
                 info.vValue = new AdsValueHelper((int)ServerPageTimeLimit.TotalSeconds).GetStruct();
                 prefList.Add(info);
             }
 
             // chase referrals
-            info = new AdsSearchPreferenceInfo();
+            info = default;
             info.dwSearchPref = (int)AdsSearchPreferences.CHASE_REFERRALS;
             info.vValue = new AdsValueHelper((int)ReferralChasing).GetStruct();
             prefList.Add(info);
@@ -740,7 +740,7 @@ namespace System.DirectoryServices
             // asynchronous
             if (Asynchronous == true)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.ASYNCHRONOUS;
                 info.vValue = new AdsValueHelper(Asynchronous).GetStruct();
                 prefList.Add(info);
@@ -749,7 +749,7 @@ namespace System.DirectoryServices
             // tombstone
             if (Tombstone == true)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.TOMBSTONE;
                 info.vValue = new AdsValueHelper(Tombstone).GetStruct();
                 prefList.Add(info);
@@ -758,7 +758,7 @@ namespace System.DirectoryServices
             // attributescopequery
             if (_attributeScopeQuerySpecified)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.ATTRIBUTE_QUERY;
                 info.vValue = new AdsValueHelper(AttributeScopeQuery, AdsType.ADSTYPE_CASE_IGNORE_STRING).GetStruct();
                 prefList.Add(info);
@@ -767,7 +767,7 @@ namespace System.DirectoryServices
             // derefalias
             if (DerefAlias != DereferenceAlias.Never)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.DEREF_ALIASES;
                 info.vValue = new AdsValueHelper((int)DerefAlias).GetStruct();
                 prefList.Add(info);
@@ -776,7 +776,7 @@ namespace System.DirectoryServices
             // securitymask
             if (SecurityMasks != SecurityMasks.None)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.SECURITY_MASK;
                 info.vValue = new AdsValueHelper((int)SecurityMasks).GetStruct();
                 prefList.Add(info);
@@ -785,7 +785,7 @@ namespace System.DirectoryServices
             // extendeddn
             if (ExtendedDN != ExtendedDN.None)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.EXTENDED_DN;
                 info.vValue = new AdsValueHelper((int)ExtendedDN).GetStruct();
                 prefList.Add(info);
@@ -794,14 +794,14 @@ namespace System.DirectoryServices
             // dirsync
             if (directorySynchronizationSpecified)
             {
-                info = new AdsSearchPreferenceInfo();
+                info = default;
                 info.dwSearchPref = (int)AdsSearchPreferences.DIRSYNC;
                 info.vValue = new AdsValueHelper(DirectorySynchronization.GetDirectorySynchronizationCookie(), AdsType.ADSTYPE_PROV_SPECIFIC).GetStruct();
                 prefList.Add(info);
 
                 if (DirectorySynchronization.Option != DirectorySynchronizationOptions.None)
                 {
-                    info = new AdsSearchPreferenceInfo();
+                    info = default;
                     info.dwSearchPref = (int)AdsSearchPreferences.DIRSYNC_FLAG;
                     info.vValue = new AdsValueHelper((int)DirectorySynchronization.Option).GetStruct();
                     prefList.Add(info);
@@ -817,9 +817,9 @@ namespace System.DirectoryServices
                 // sort
                 if (Sort.PropertyName != null && Sort.PropertyName.Length > 0)
                 {
-                    info = new AdsSearchPreferenceInfo();
+                    info = default;
                     info.dwSearchPref = (int)AdsSearchPreferences.SORT_ON;
-                    AdsSortKey sortKey = new AdsSortKey();
+                    AdsSortKey sortKey = default;
                     sortKey.pszAttrType = Marshal.StringToCoTaskMemUni(Sort.PropertyName);
                     ptrToFree = sortKey.pszAttrType; // so we can free it later.
                     sortKey.pszReserved = (IntPtr)0;
@@ -833,7 +833,7 @@ namespace System.DirectoryServices
                 // vlv
                 if (directoryVirtualListViewSpecified)
                 {
-                    info = new AdsSearchPreferenceInfo();
+                    info = default;
                     info.dwSearchPref = (int)AdsSearchPreferences.VLV;
                     AdsVLV vlvValue = new AdsVLV();
                     vlvValue.beforeCount = _vlv.BeforeCount;
@@ -875,7 +875,7 @@ namespace System.DirectoryServices
                 // cacheResults
                 if (_cacheResultsSpecified)
                 {
-                    info = new AdsSearchPreferenceInfo();
+                    info = default;
                     info.dwSearchPref = (int)AdsSearchPreferences.CACHE_RESULTS;
                     info.vValue = new AdsValueHelper(CacheResults).GetStruct();
                     prefList.Add(info);
index 0c9e734..6a35ed1 100644 (file)
@@ -107,7 +107,7 @@ namespace System.DirectoryServices
                 throw new ObjectDisposedException(GetType().Name);
 
             // get the dirsync cookie back
-            AdsSearchColumn column = new AdsSearchColumn();
+            AdsSearchColumn column = default;
             AdsSearchColumn* pColumn = &column;
             SearchObject.GetColumn(Handle, _adsDirsynCookieName, (INTPTR_INTPTRCAST)pColumn);
             try
@@ -135,7 +135,7 @@ namespace System.DirectoryServices
                 throw new ObjectDisposedException(GetType().Name);
 
             // get the vlv response back
-            AdsSearchColumn column = new AdsSearchColumn();
+            AdsSearchColumn column = default;
             AdsSearchColumn* pColumn = &column;
             SearchObject.GetColumn(Handle, _adsVLVResponseName, (INTPTR_INTPTRCAST)pColumn);
             try
@@ -274,7 +274,7 @@ namespace System.DirectoryServices
                 {
                     try
                     {
-                        AdsSearchColumn column = new AdsSearchColumn();
+                        AdsSearchColumn column = default;
                         AdsSearchColumn* pColumn = &column;
                         _results.SearchObject.GetColumn(_results.Handle, pszColumnName, (INTPTR_INTPTRCAST)pColumn);
                         try
index 106865f..9177013 100644 (file)
@@ -259,7 +259,7 @@ namespace System.Drawing
             }
 
             IntPtr hbmRet = IntPtr.Zero;
-            var pbmi = new NativeMethods.BITMAPINFO_FLAT();
+            NativeMethods.BITMAPINFO_FLAT pbmi = default;
 
             // Validate hdc.
             Interop.Gdi32.ObjectType objType = Interop.Gdi32.GetObjectType(hdc);
index b7862e5..5413d28 100644 (file)
@@ -625,7 +625,7 @@ namespace System.Drawing.Drawing2D
 
         public void AddString(string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
         {
-            Rectangle layout = new Rectangle();
+            Rectangle layout = default;
             layout.X = origin.X;
             layout.Y = origin.Y;
             AddString(s, family, style, emSize, layout, format);
@@ -633,7 +633,7 @@ namespace System.Drawing.Drawing2D
 
         public void AddString(string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
         {
-            RectangleF layout = new RectangleF();
+            RectangleF layout = default;
             layout.X = origin.X;
             layout.Y = origin.Y;
             AddString(s, family, style, emSize, layout, format);
index 000c1bc..399733b 100644 (file)
@@ -162,7 +162,7 @@ namespace System.Drawing
             IntPtr newObject;
             FontStyle newStyle = FontStyle.Regular;
             float newSize;
-            Interop.User32.LOGFONT lf = new Interop.User32.LOGFONT();
+            Interop.User32.LOGFONT lf = default;
 
             // Sanity. Should we throw an exception?
             if (hfont == IntPtr.Zero)
index 1d25e3c..687676b 100644 (file)
@@ -226,7 +226,7 @@ namespace System.Drawing
         /// </summary>
         public static Font FromHfont(IntPtr hfont)
         {
-            var logFont = new Interop.User32.LOGFONT();
+            Interop.User32.LOGFONT logFont = default;
             SafeNativeMethods.GetObject(new HandleRef(null, hfont), ref logFont);
 
             using (ScreenDC dc = ScreenDC.Create())
@@ -309,7 +309,7 @@ namespace System.Drawing
             }
 
             // Now that we know the marshalled size is the same as LOGFONT, copy in the data
-            logFont = new Interop.User32.LOGFONT();
+            logFont = default;
 
             Marshal.StructureToPtr(lf, new IntPtr(&logFont), fDeleteOld: false);
 
index ccf9442..6231cfe 100644 (file)
@@ -310,7 +310,7 @@ namespace System.Drawing
                 throw new ArgumentNullException(nameof(graphics));
             }
 
-            Interop.User32.LOGFONT logFont = new Interop.User32.LOGFONT();
+            Interop.User32.LOGFONT logFont = default;
             Gdip.CheckStatus(Gdip.GdipGetLogFontW(
                 new HandleRef(this, NativeFont), new HandleRef(graphics, graphics.NativeGraphics), ref logFont));
 
index 1862a48..83d1534 100644 (file)
@@ -1374,7 +1374,7 @@ namespace System.Drawing
 
             public static StartupInput GetDefault()
             {
-                StartupInput result = new StartupInput();
+                StartupInput result = default;
                 result.GdiplusVersion = 1;
                 // result.DebugEventCallback = null;
                 result.SuppressBackgroundThread = false;
index 902f505..0fbaa90 100644 (file)
@@ -151,7 +151,7 @@ namespace System.Drawing
 
             window = LibX11Functions.XRootWindow(Gdip.Display, 0);
             defvisual = LibX11Functions.XDefaultVisual(Gdip.Display, 0);
-            XVisualInfo visual = new XVisualInfo();
+            XVisualInfo visual = default;
 
             /* Get XVisualInfo for this visual */
             visual.visualid = LibX11Functions.XVisualIDFromVisual(defvisual);
index 7d0871c..dbd458a 100644 (file)
@@ -1463,7 +1463,7 @@ namespace System.Drawing
                 throw new ArgumentNullException(nameof(font));
 
             RectangleF layout = new RectangleF(0, 0, layoutArea.Width, layoutArea.Height);
-            RectangleF boundingBox = new RectangleF();
+            RectangleF boundingBox = default;
 
             Gdip.CheckStatus(Gdip.GdipMeasureString(
                 new HandleRef(this, NativeGraphics),
@@ -1487,7 +1487,7 @@ namespace System.Drawing
                 throw new ArgumentNullException(nameof(font));
 
             RectangleF layout = new RectangleF(origin.X, origin.Y, 0, 0);
-            RectangleF boundingBox = new RectangleF();
+            RectangleF boundingBox = default;
 
             Gdip.CheckStatus(Gdip.GdipMeasureString(
                 new HandleRef(this, NativeGraphics),
@@ -1513,7 +1513,7 @@ namespace System.Drawing
                 throw new ArgumentNullException(nameof(font));
 
             RectangleF layout = new RectangleF(0, 0, layoutArea.Width, layoutArea.Height);
-            RectangleF boundingBox = new RectangleF();
+            RectangleF boundingBox = default;
 
             Gdip.CheckStatus(Gdip.GdipMeasureString(
                 new HandleRef(this, NativeGraphics),
index 74abe56..fee5856 100644 (file)
@@ -456,7 +456,7 @@ namespace System.Drawing
             writer.Write((ushort)1);    // only one icon
 
             // when transformed into a bitmap only a single image exists
-            IconDirEntry ide = new IconDirEntry();
+            IconDirEntry ide = default;
             ide.width = (byte)bitmap.Width;
             ide.height = (byte)bitmap.Height;
             ide.colorCount = 0; // 32 bbp == 0, for palette size
@@ -465,7 +465,7 @@ namespace System.Drawing
             ide.bitCount = 32;
             ide.imageOffset = 22;   // 22 is the first icon position (for single icon files)
 
-            BitmapInfoHeader bih = new BitmapInfoHeader();
+            BitmapInfoHeader bih = default;
             bih.biSize = (uint)Marshal.SizeOf(typeof(BitmapInfoHeader));
             bih.biWidth = bitmap.Width;
             bih.biHeight = 2 * bitmap.Height; // include both XOR and AND images
index 32c87d9..5d5c054 100644 (file)
@@ -217,9 +217,9 @@ namespace System.Drawing
             {
                 if (_iconSize.IsEmpty)
                 {
-                    var info = new SafeNativeMethods.ICONINFO();
+                    SafeNativeMethods.ICONINFO info = default;
                     SafeNativeMethods.GetIconInfo(new HandleRef(this, Handle), ref info);
-                    var bitmap = new SafeNativeMethods.BITMAP();
+                    SafeNativeMethods.BITMAP bitmap = default;
 
                     if (info.hbmColor != IntPtr.Zero)
                     {
@@ -760,9 +760,9 @@ namespace System.Drawing
             else if (_bestBitDepth == 0 || _bestBitDepth == 32)
             {
                 // This may be a 32bpp icon or an icon without any data.
-                var info = new SafeNativeMethods.ICONINFO();
+                SafeNativeMethods.ICONINFO info = default;
                 SafeNativeMethods.GetIconInfo(new HandleRef(this, _handle), ref info);
-                var bmp = new SafeNativeMethods.BITMAP();
+                SafeNativeMethods.BITMAP bmp = default;
                 try
                 {
                     if (info.hbmColor != IntPtr.Zero)
index f844c9a..2d0b83e 100644 (file)
@@ -102,7 +102,7 @@ namespace System.Drawing
             int propSize;
             IntPtr property;
             PropertyItem item = new PropertyItem();
-            GdipPropertyItem gdipProperty = new GdipPropertyItem();
+            GdipPropertyItem gdipProperty = default;
             int status;
 
             status = Gdip.GdipGetPropertyItemSize(nativeImage, propid,
@@ -289,7 +289,7 @@ namespace System.Drawing
             IntPtr dest = Marshal.AllocHGlobal(size);
             try
             {
-                GdipPropertyItem pi = new GdipPropertyItem();
+                GdipPropertyItem pi = default;
                 pi.id = propitem.Id;
                 pi.len = propitem.Len;
                 pi.type = propitem.Type;
@@ -397,7 +397,7 @@ namespace System.Drawing
                 int propNums, propsSize, propSize;
                 IntPtr properties, propPtr;
                 PropertyItem[] items;
-                GdipPropertyItem gdipProperty = new GdipPropertyItem();
+                GdipPropertyItem gdipProperty = default;
                 int status;
 
                 status = Gdip.GdipGetPropertySize(nativeImage, out propsSize, out propNums);
index 5490032..37765ce 100644 (file)
@@ -269,7 +269,7 @@ namespace System.Drawing
         {
             get
             {
-                Guid guid = new Guid();
+                Guid guid = default;
 
                 int status = Gdip.GdipGetImageRawFormat(new HandleRef(this, nativeImage), ref guid);
                 Gdip.CheckStatus(status);
index de1e516..eae3070 100644 (file)
@@ -221,7 +221,7 @@ namespace System.Drawing
             // writer queue.  See ReaderWriterLock.AcquireWriterLock method in the MSDN.
 
             bool readerLockHeld = s_rwImgListLock.IsReaderLockHeld;
-            LockCookie lockDowngradeCookie = new LockCookie();
+            LockCookie lockDowngradeCookie = default;
 
             t_threadWriterLockWaitCount++;
 
@@ -326,7 +326,7 @@ namespace System.Drawing
             // Acquire a writer lock to modify the image info list - See comments on Animate() about this locking.
 
             bool readerLockHeld = s_rwImgListLock.IsReaderLockHeld;
-            LockCookie lockDowngradeCookie = new LockCookie();
+            LockCookie lockDowngradeCookie = default;
 
             t_threadWriterLockWaitCount++;
 
index 654b920..cd470e3 100644 (file)
@@ -17,8 +17,6 @@ namespace System.Drawing.Imaging
         /// </summary>
         public ColorMap()
         {
-            _oldColor = new Color();
-            _newColor = new Color();
         }
 
         /// <summary>
index 969a139..da56dce 100644 (file)
@@ -497,7 +497,7 @@ namespace System.Drawing.Imaging
 
         public void SetWrapMode(WrapMode mode)
         {
-            SetWrapMode(mode, new Color(), false);
+            SetWrapMode(mode, default(Color), false);
         }
 
         public void SetWrapMode(WrapMode mode, Color color)
index 39f55ae..46d7e4c 100644 (file)
@@ -71,17 +71,17 @@ namespace System.Drawing.Imaging
         }
 
         public Metafile(IntPtr referenceHdc, EmfType emfType, string description) :
-            this(referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, emfType, description)
+            this(referenceHdc, default(RectangleF), MetafileFrameUnit.GdiCompatible, emfType, description)
         {
         }
 
         public Metafile(Stream stream, IntPtr referenceHdc, EmfType type, string description) :
-            this(stream, referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, type, description)
+            this(stream, referenceHdc, default(RectangleF), MetafileFrameUnit.GdiCompatible, type, description)
         {
         }
 
         public Metafile(string fileName, IntPtr referenceHdc, EmfType type, string description) :
-            this(fileName, referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, type, description)
+            this(fileName, referenceHdc, default(RectangleF), MetafileFrameUnit.GdiCompatible, type, description)
         {
         }
 
index 777779a..d524a44 100644 (file)
@@ -156,7 +156,7 @@ namespace System.Drawing.Imaging
                 if (this.MetafileSize == 0)
                 {
                     // GDI+ compatibility;
-                    return new Rectangle();
+                    return default;
                 }
 
                 return new Rectangle(header.x, header.y, header.width, header.height);
index e46f67a..4279a50 100644 (file)
@@ -186,7 +186,7 @@ namespace System.Drawing.Printing
         {
             get
             {
-                RectangleF printableArea = new RectangleF();
+                RectangleF printableArea = default;
                 DeviceContext dc = printerSettings.CreateInformationContext(this);
                 HandleRef hdc = new HandleRef(dc, dc.Hdc);
 
index 1ee2344..a769d3c 100644 (file)
@@ -902,7 +902,7 @@ namespace System.Drawing.Printing
                 default_page_settings.PrinterResolution.X,
                 default_page_settings.PrinterResolution.Y, ref graphics);
 
-            DOCINFO doc = new DOCINFO();
+            DOCINFO doc = default;
             doc.filename = name;
             doc.settings = settings;
             doc.default_page_settings = default_page_settings;
index 2c099e3..f8252f1 100644 (file)
@@ -117,7 +117,7 @@ namespace System.Drawing
             {
                 Font iconTitleFont = null;
 
-                var itfont = new Interop.User32.LOGFONT();
+                Interop.User32.LOGFONT itfont = default;
                 if (Interop.User32.SystemParametersInfoW(Interop.User32.SystemParametersAction.SPI_GETICONTITLELOGFONT, (uint)sizeof(Interop.User32.LOGFONT), &itfont, 0))
                 {
                     iconTitleFont = GetFontFromData(itfont);
index d8b20b3..7626221 100644 (file)
@@ -70,7 +70,7 @@ namespace System.Drawing
         {
             IntPtr graphicsContext = objc_msgSend(objc_getClass("NSGraphicsContext"), sel_registerName("currentContext"));
             IntPtr ctx = objc_msgSend(graphicsContext, sel_registerName("graphicsPort"));
-            Rect bounds = new Rect();
+            Rect bounds = default;
 
             CGContextSaveGState(ctx);
 
@@ -105,8 +105,8 @@ namespace System.Drawing
                 return new CarbonContext(port, context, (int)desktop_bounds.size.width, (int)desktop_bounds.size.height);
             }
 
-            QDRect window_bounds = new QDRect();
-            Rect view_bounds = new Rect();
+            QDRect window_bounds = default(QDRect);
+            Rect view_bounds = default(Rect);
 
             port = GetWindowPort(window);
 
index a15e1c2..48cbb93 100644 (file)
@@ -431,7 +431,7 @@ namespace System.Drawing.Internal
         /// </summary>
         public void TranslateTransform(int dx, int dy)
         {
-            var origin = new Point();
+            Point origin = default;
             Interop.Gdi32.OffsetViewportOrgEx(new HandleRef(this, _hDC), dx, dy, ref origin);
         }
 
index 7133753..08a8336 100644 (file)
@@ -143,7 +143,7 @@ namespace System.Drawing.Internal
                 return new Rectangle(-int.MaxValue, -int.MaxValue, int.MaxValue, int.MaxValue);
             }
 
-            var rect = new Interop.Gdi32.RECT();
+            Interop.Gdi32.RECT rect = default;
             Interop.Gdi32.GetRgnBox(new HandleRef(this, _nativeHandle), ref rect);
             return new Rectangle(new Point(rect.left, rect.top), rect.Size);
         }
index 37b4cba..e0c853b 100644 (file)
@@ -14,7 +14,7 @@ namespace System.Drawing
     [TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
     public readonly struct Color : IEquatable<Color>
     {
-        public static readonly Color Empty = new Color();
+        public static readonly Color Empty;
 
         // -------------------------------------------------------------------
         //  static list of "web" colors...
index 1ae45c8..c8fe4e8 100644 (file)
@@ -17,7 +17,7 @@ namespace System.Drawing
         /// <summary>
         /// Creates a new instance of the <see cref='System.Drawing.Point'/> class with member data left uninitialized.
         /// </summary>
-        public static readonly Point Empty = new Point();
+        public static readonly Point Empty;
 
         private int x; // Do not rename (binary serialization)
         private int y; // Do not rename (binary serialization)
index 4f3f0e4..0dfa991 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Drawing
         /// <summary>
         /// Creates a new instance of the <see cref='System.Drawing.PointF'/> class with member data left uninitialized.
         /// </summary>
-        public static readonly PointF Empty = new PointF();
+        public static readonly PointF Empty;
         private float x; // Do not rename (binary serialization)
         private float y; // Do not rename (binary serialization)
 
index c689428..2cfc93b 100644 (file)
@@ -14,7 +14,7 @@ namespace System.Drawing
     [TypeConverter("System.Drawing.RectangleConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
     public struct Rectangle : IEquatable<Rectangle>
     {
-        public static readonly Rectangle Empty = new Rectangle();
+        public static readonly Rectangle Empty;
 
         private int x; // Do not rename (binary serialization)
         private int y; // Do not rename (binary serialization)
index b611665..c5a7afb 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Drawing
         /// <summary>
         /// Initializes a new instance of the <see cref='System.Drawing.RectangleF'/> class.
         /// </summary>
-        public static readonly RectangleF Empty = new RectangleF();
+        public static readonly RectangleF Empty;
 
         private float x; // Do not rename (binary serialization)
         private float y; // Do not rename (binary serialization)
index f0c5b1e..e393551 100644 (file)
@@ -17,7 +17,7 @@ namespace System.Drawing
         /// <summary>
         /// Initializes a new instance of the <see cref='System.Drawing.Size'/> class.
         /// </summary>
-        public static readonly Size Empty = new Size();
+        public static readonly Size Empty;
 
         private int width; // Do not rename (binary serialization)
         private int height; // Do not rename (binary serialization)
index 9b0761c..c771a21 100644 (file)
@@ -17,7 +17,7 @@ namespace System.Drawing
         /// <summary>
         /// Initializes a new instance of the <see cref='System.Drawing.SizeF'/> class.
         /// </summary>
-        public static readonly SizeF Empty = new SizeF();
+        public static readonly SizeF Empty;
         private float width; // Do not rename (binary serialization)
         private float height; // Do not rename (binary serialization)
 
index 99e3ee7..b4e10f7 100644 (file)
@@ -182,7 +182,6 @@ namespace System.IO.Compression
             public ZLibStreamHandle()
                 : base(new IntPtr(-1), true)
             {
-                _zStream = new ZStream();
                 _zStream.Init();
 
                 _initializationState = State.NotInitialized;
index 95493e0..063fc39 100644 (file)
@@ -456,7 +456,7 @@ namespace System.IO.Compression
             Debug.Assert(_storedEntryNameBytes.Length <= ushort.MaxValue);
 
             // decide if we need the Zip64 extra field:
-            Zip64ExtraField zip64ExtraField = new Zip64ExtraField();
+            Zip64ExtraField zip64ExtraField = default;
             uint compressedSizeTruncated, uncompressedSizeTruncated, offsetOfLocalHeaderTruncated;
 
             bool zip64Needed = false;
@@ -804,7 +804,7 @@ namespace System.IO.Compression
             Debug.Assert(_storedEntryNameBytes.Length <= ushort.MaxValue);
 
             // decide if we need the Zip64 extra field:
-            Zip64ExtraField zip64ExtraField = new Zip64ExtraField();
+            Zip64ExtraField zip64ExtraField = default;
             bool zip64Used = false;
             uint compressedSizeTruncated, uncompressedSizeTruncated;
 
index 20fb1e7..f5028da 100644 (file)
@@ -35,7 +35,7 @@ namespace System.IO.Compression
         // assumes we are positioned at the beginning of an extra field subfield
         public static bool TryReadBlock(BinaryReader reader, long endExtraField, out ZipGenericExtraField field)
         {
-            field = new ZipGenericExtraField();
+            field = default;
 
             // not enough bytes to read tag + size
             if (endExtraField - reader.BaseStream.Position < 4)
@@ -159,7 +159,7 @@ namespace System.IO.Compression
                 }
             }
 
-            zip64Field = new Zip64ExtraField();
+            zip64Field = default;
 
             zip64Field._compressedSize = null;
             zip64Field._uncompressedSize = null;
@@ -174,7 +174,7 @@ namespace System.IO.Compression
             bool readLocalHeaderOffset, bool readStartDiskNumber,
             out Zip64ExtraField zip64Block)
         {
-            zip64Block = new Zip64ExtraField();
+            zip64Block = default;
 
             zip64Block._compressedSize = null;
             zip64Block._uncompressedSize = null;
@@ -231,7 +231,7 @@ namespace System.IO.Compression
             bool readUncompressedSize, bool readCompressedSize,
             bool readLocalHeaderOffset, bool readStartDiskNumber)
         {
-            Zip64ExtraField zip64Field = new Zip64ExtraField();
+            Zip64ExtraField zip64Field = default;
 
             zip64Field._compressedSize = null;
             zip64Field._uncompressedSize = null;
@@ -299,7 +299,7 @@ namespace System.IO.Compression
 
         public static bool TryReadBlock(BinaryReader reader, out Zip64EndOfCentralDirectoryLocator zip64EOCDLocator)
         {
-            zip64EOCDLocator = new Zip64EndOfCentralDirectoryLocator();
+            zip64EOCDLocator = default;
 
             if (reader.ReadUInt32() != SignatureConstant)
                 return false;
@@ -337,7 +337,7 @@ namespace System.IO.Compression
 
         public static bool TryReadBlock(BinaryReader reader, out Zip64EndOfCentralDirectoryRecord zip64EOCDRecord)
         {
-            zip64EOCDRecord = new Zip64EndOfCentralDirectoryRecord();
+            zip64EOCDRecord = default;
 
             if (reader.ReadUInt32() != SignatureConstant)
                 return false;
@@ -564,7 +564,7 @@ namespace System.IO.Compression
         // in either case, the zip64 extra field info will be incorporated into other fields
         public static bool TryReadBlock(BinaryReader reader, bool saveExtraFieldsAndComments, out ZipCentralDirectoryFileHeader header)
         {
-            header = new ZipCentralDirectoryFileHeader();
+            header = default;
 
             if (reader.ReadUInt32() != SignatureConstant)
                 return false;
@@ -693,7 +693,7 @@ namespace System.IO.Compression
 
         public static bool TryReadBlock(BinaryReader reader, out ZipEndOfCentralDirectoryBlock eocdBlock)
         {
-            eocdBlock = new ZipEndOfCentralDirectoryBlock();
+            eocdBlock = default;
             if (reader.ReadUInt32() != SignatureConstant)
                 return false;
 
index 4a6c3ac..c347e15 100644 (file)
@@ -46,7 +46,7 @@ namespace System.IO.Enumeration
             // We'll only suppress the media insertion prompt on the topmost directory as that is the
             // most likely scenario and we don't want to take the perf hit for large enumerations.
             // (We weren't consistent with how we handled this historically.)
-            using (new DisableMediaInsertionPrompt())
+            using (default(DisableMediaInsertionPrompt))
             {
                 // We need to initialize the directory handle up front to ensure
                 // we immediately throw IO exceptions for missing directory/etc.
index 69fa9d7..8c62969 100644 (file)
@@ -72,7 +72,7 @@ namespace System.IO
 
         public static FileAttributes GetAttributes(string fullPath)
         {
-            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = new Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA();
+            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = default;
             int errorCode = FillAttributeInfo(fullPath, ref data, returnErrorOnNotFound: true);
             if (errorCode != 0)
                 throw Win32Marshal.GetExceptionForWin32Error(errorCode, fullPath);
@@ -82,7 +82,7 @@ namespace System.IO
 
         public static DateTimeOffset GetCreationTime(string fullPath)
         {
-            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = new Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA();
+            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = default;
             int errorCode = FillAttributeInfo(fullPath, ref data, returnErrorOnNotFound: false);
             if (errorCode != 0)
                 throw Win32Marshal.GetExceptionForWin32Error(errorCode, fullPath);
@@ -99,7 +99,7 @@ namespace System.IO
 
         public static DateTimeOffset GetLastAccessTime(string fullPath)
         {
-            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = new Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA();
+            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = default;
             int errorCode = FillAttributeInfo(fullPath, ref data, returnErrorOnNotFound: false);
             if (errorCode != 0)
                 throw Win32Marshal.GetExceptionForWin32Error(errorCode, fullPath);
@@ -109,7 +109,7 @@ namespace System.IO
 
         public static DateTimeOffset GetLastWriteTime(string fullPath)
         {
-            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = new Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA();
+            Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data = default;
             int errorCode = FillAttributeInfo(fullPath, ref data, returnErrorOnNotFound: false);
             if (errorCode != 0)
                 throw Win32Marshal.GetExceptionForWin32Error(errorCode, fullPath);
@@ -185,7 +185,7 @@ namespace System.IO
                 return;
             }
 
-            Interop.Kernel32.WIN32_FIND_DATA findData = new Interop.Kernel32.WIN32_FIND_DATA();
+            Interop.Kernel32.WIN32_FIND_DATA findData = default;
             GetFindData(fullPath, ref findData);
             if (IsNameSurrogateReparsePoint(ref findData))
             {
index ca9d015..7f02a12 100644 (file)
@@ -145,7 +145,7 @@ namespace System.IO
         {
             if (_dataInitialized == -1)
             {
-                _data = new Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA();
+                _data = default;
                 Refresh();
             }
 
index 38de642..b60d81e 100644 (file)
@@ -245,7 +245,7 @@ namespace System.IO.MemoryMappedFiles
             Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default(Interop.Kernel32.SECURITY_ATTRIBUTES);
             if ((inheritability & HandleInheritability.Inheritable) != 0)
             {
-                secAttrs = new Interop.Kernel32.SECURITY_ATTRIBUTES();
+                secAttrs = default;
                 secAttrs.nLength = (uint)sizeof(Interop.Kernel32.SECURITY_ATTRIBUTES);
                 secAttrs.bInheritHandle = Interop.BOOL.TRUE;
             }
index 2648a39..46c0da4 100644 (file)
@@ -46,7 +46,7 @@ namespace System.IO.MemoryMappedFiles
             }
 
             // Query the view for its size and allocation type
-            Interop.Kernel32.MEMORY_BASIC_INFORMATION viewInfo = new Interop.Kernel32.MEMORY_BASIC_INFORMATION();
+            Interop.Kernel32.MEMORY_BASIC_INFORMATION viewInfo = default;
             Interop.Kernel32.VirtualQuery(viewHandle, ref viewInfo, (UIntPtr)Marshal.SizeOf(viewInfo));
             ulong viewSize = (ulong)viewInfo.RegionSize;
 
@@ -72,7 +72,7 @@ namespace System.IO.MemoryMappedFiles
                     throw Win32Marshal.GetExceptionForWin32Error(lastError);
                 }
                 // again query the view for its new size
-                viewInfo = new Interop.Kernel32.MEMORY_BASIC_INFORMATION();
+                viewInfo = default;
                 Interop.Kernel32.VirtualQuery(viewHandle, ref viewInfo, (UIntPtr)Marshal.SizeOf(viewInfo));
                 viewSize = (ulong)viewInfo.RegionSize;
             }
@@ -119,7 +119,7 @@ namespace System.IO.MemoryMappedFiles
                     if (error != Interop.Errors.ERROR_LOCK_VIOLATION)
                         throw Win32Marshal.GetExceptionForWin32Error(error);
 
-                    SpinWait spinWait = new SpinWait();
+                    SpinWait spinWait = default;
                     for (int w = 0; w < MaxFlushWaits; w++)
                     {
                         int pause = (1 << w);  // MaxFlushRetries should never be over 30
index 563dd97..d66d40d 100644 (file)
@@ -352,7 +352,7 @@ namespace System.IO.Pipelines
             // If the writer is completed (which it will be most of the time) then return a completed ValueTask
             if (_writerAwaitable.IsCompleted)
             {
-                var flushResult = new FlushResult();
+                FlushResult flushResult = default;
                 GetFlushResult(ref flushResult);
                 result = new ValueTask<FlushResult>(flushResult);
             }
index cf5cc25..4a4ff09 100644 (file)
@@ -205,7 +205,7 @@ namespace System.IO.Pipelines
                 return new ReadResult(buffer: default, isCanceled: false, isCompleted: true);
             }
 
-            var reg = new CancellationTokenRegistration();
+            CancellationTokenRegistration reg = default;
             if (cancellationToken.CanBeCanceled)
             {
                 reg = cancellationToken.UnsafeRegister(state => ((StreamPipeReader)state!).Cancel(), this);
@@ -291,7 +291,7 @@ namespace System.IO.Pipelines
                 return true;
             }
 
-            result = new ReadResult();
+            result = default;
             return false;
         }
 
index a5a7ec2..c87d6f3 100644 (file)
@@ -265,7 +265,7 @@ namespace System.IO.Pipelines
         {
             // Write all completed segments and whatever remains in the current segment
             // and flush the result.
-            var reg = new CancellationTokenRegistration();
+            CancellationTokenRegistration reg = default;
             if (cancellationToken.CanBeCanceled)
             {
                 reg = cancellationToken.UnsafeRegister(state => ((StreamPipeWriter)state!).Cancel(), this);
index aed3ec1..7c632ed 100644 (file)
@@ -32,7 +32,7 @@ namespace System.IO.Pipes
             SafePipeHandle newServerHandle;
 
             // Create the two pipe handles that make up the anonymous pipe.
-            var pinningHandle = new GCHandle();
+            GCHandle pinningHandle = default;
             try
             {
                 Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(inheritability, pipeSecurity, ref pinningHandle);
index f9c74cb..796c3f9 100644 (file)
@@ -144,7 +144,7 @@ namespace System.IO.Pipes
         {
             // This is the main connection loop. It will loop until the timeout expires.
             int elapsed = 0;
-            var sw = new SpinWait();
+            SpinWait sw = default;
             do
             {
                 cancellationToken.ThrowIfCancellationRequested();
index 99eeb0c..82f1eb3 100644 (file)
@@ -84,7 +84,7 @@ namespace System.IO.Pipes
                 maxNumberOfServerInstances = 255;
             }
 
-            var pinningHandle = new GCHandle();
+            GCHandle pinningHandle = default;
             try
             {
                 Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = PipeStream.GetSecAttrs(inheritability, pipeSecurity, ref pinningHandle);
index 04d966e..3973970 100644 (file)
@@ -402,7 +402,7 @@ namespace System.IO.Pipes
             Interop.Kernel32.SECURITY_ATTRIBUTES secAttrs = default(Interop.Kernel32.SECURITY_ATTRIBUTES);
             if ((inheritability & HandleInheritability.Inheritable) != 0)
             {
-                secAttrs = new Interop.Kernel32.SECURITY_ATTRIBUTES();
+                secAttrs = default;
                 secAttrs.nLength = (uint)sizeof(Interop.Kernel32.SECURITY_ATTRIBUTES);
                 secAttrs.bInheritHandle = Interop.BOOL.TRUE;
             }
index 785830d..4616384 100644 (file)
@@ -384,7 +384,7 @@ namespace System.IO.Ports
         {
             if (_handle == null) InternalResources.FileNotOpen();
 
-            SpinWait sw = new SpinWait();
+            SpinWait sw = default;
             while (!_writeQueue.IsEmpty)
             {
                 sw.SpinOnce();
index d634115..56cf3b7 100644 (file)
@@ -604,7 +604,7 @@ namespace System.IO.Ports
                 // fine for "LPT1" on Win9x, so that alone can't be relied here to
                 // detect non serial devices.
 
-                _commProp = new Interop.Kernel32.COMMPROP();
+                _commProp = default;
                 int pinStatus = 0;
 
                 if (!Interop.Kernel32.GetCommProperties(_handle, ref _commProp)
@@ -622,10 +622,10 @@ namespace System.IO.Ports
                 if (_commProp.dwMaxBaud != 0 && baudRate > _commProp.dwMaxBaud)
                     throw new ArgumentOutOfRangeException(nameof(baudRate), SR.Format(SR.Max_Baud, _commProp.dwMaxBaud));
 
-                _comStat = new Interop.Kernel32.COMSTAT();
+                _comStat = default;
                 // create internal DCB structure, initialize according to Platform SDK
                 // standard: ms-help://MS.MSNDNQTR.2002APR.1003/hardware/commun_965u.htm
-                _dcb = new Interop.Kernel32.DCB();
+                _dcb = default;
 
                 // set constant properties of the DCB
                 InitializeDCB(baudRate, parity, dataBits, stopBits, discardNull);
index 18e548d..41af1c7 100644 (file)
@@ -212,7 +212,7 @@ namespace System.Linq.Expressions.Interpreter
                 {
                     if (_keysAndValues[i].Key == key)
                     {
-                        _keysAndValues[i] = new KeyValuePair<TKey, TValue>();
+                        _keysAndValues[i] = default;
                         return;
                     }
                 }
index d9c63bd..930787d 100644 (file)
@@ -212,7 +212,7 @@ namespace System.Linq.Parallel
         // Returns the default settings
         internal static QuerySettings Empty
         {
-            get { return new QuerySettings(null, null, new CancellationToken(), null, null); }
+            get { return new QuerySettings(null, null, CancellationToken.None, null, null); }
         }
 
         // Cleanup internal state once the entire query is complete.
index 714e654..1e6c1a2 100644 (file)
@@ -82,7 +82,7 @@ namespace System.Linq.Parallel
             Debug.Assert(taskScheduler == TaskScheduler.Default, "PLINQ queries can currently execute only on the default scheduler.");
 
             TraceHelpers.TraceInfo("[timing]: {0}: Queue work {1} to occur asynchronously", DateTime.Now.Ticks, _taskIndex);
-            return Task.Factory.StartNew(s_baseWorkDelegate, this, new CancellationToken(), TaskCreationOptions.AttachedToParent | TaskCreationOptions.PreferFairness, taskScheduler);
+            return Task.Factory.StartNew(s_baseWorkDelegate, this, CancellationToken.None, TaskCreationOptions.AttachedToParent | TaskCreationOptions.PreferFairness, taskScheduler);
         }
 
         //-----------------------------------------------------------------------------------
index 6bbfc46..b803ea0 100644 (file)
@@ -104,7 +104,7 @@ namespace System.Linq
                 Debug.Assert(!_hasOnlyCollections);
 
                 var builder = new SparseArrayBuilder<TSource>(initialize: true);
-                var deferredCopies = new ArrayBuilder<int>();
+                ArrayBuilder<int> deferredCopies = default;
 
                 for (int i = 0; ; i++)
                 {
index 15ed767..62354cd 100644 (file)
@@ -33,7 +33,7 @@ namespace System.Linq
             public TResult[] ToArray()
             {
                 var builder = new SparseArrayBuilder<TResult>(initialize: true);
-                var deferredCopies = new ArrayBuilder<IEnumerable<TResult>>();
+                ArrayBuilder<IEnumerable<TResult>> deferredCopies = default;
 
                 foreach (TSource element in _source)
                 {
index a2417e8..2cb6775 100644 (file)
@@ -54,11 +54,11 @@ namespace System.Net.Http
             // Verify the hostName matches the certificate.
             unsafe
             {
-                var cppStruct = new Interop.Crypt32.CERT_CHAIN_POLICY_PARA();
+                Interop.Crypt32.CERT_CHAIN_POLICY_PARA cppStruct = default;
                 cppStruct.cbSize = (uint)sizeof(Interop.Crypt32.CERT_CHAIN_POLICY_PARA);
                 cppStruct.dwFlags = 0;
 
-                var eppStruct = new Interop.Crypt32.SSL_EXTRA_CERT_CHAIN_POLICY_PARA();
+                Interop.Crypt32.SSL_EXTRA_CERT_CHAIN_POLICY_PARA eppStruct = default;
                 eppStruct.cbSize = (uint)sizeof(Interop.Crypt32.SSL_EXTRA_CERT_CHAIN_POLICY_PARA);
                 eppStruct.dwAuthType = Interop.Crypt32.AuthType.AUTHTYPE_SERVER;
 
@@ -71,7 +71,7 @@ namespace System.Net.Http
                         Interop.Crypt32.CertChainPolicyIgnoreFlags.CERT_CHAIN_POLICY_IGNORE_ALL &
                         ~Interop.Crypt32.CertChainPolicyIgnoreFlags.CERT_CHAIN_POLICY_IGNORE_INVALID_NAME_FLAG;
 
-                    var status = new Interop.Crypt32.CERT_CHAIN_POLICY_STATUS();
+                    Interop.Crypt32.CERT_CHAIN_POLICY_STATUS status = default;
                     status.cbSize = (uint)sizeof(Interop.Crypt32.CERT_CHAIN_POLICY_STATUS);
                     if (Interop.Crypt32.CertVerifyCertificateChainPolicy(
                             (IntPtr)Interop.Crypt32.CertChainPolicy.CERT_CHAIN_POLICY_SSL,
index cea24d3..13034a2 100644 (file)
@@ -1027,7 +1027,7 @@ namespace System.Net.Http
             if (state.WindowsProxyUsePolicy == WindowsProxyUsePolicy.UseCustomProxy ||
                 state.WindowsProxyUsePolicy == WindowsProxyUsePolicy.UseWinInetProxy)
             {
-                var proxyInfo = new Interop.WinHttp.WINHTTP_PROXY_INFO();
+                Interop.WinHttp.WINHTTP_PROXY_INFO proxyInfo = default;
                 bool updateProxySettings = false;
                 Uri uri = state.RequestMessage.RequestUri;
 
index f677d10..ff1b71e 100644 (file)
@@ -22,7 +22,7 @@ namespace System.Net.Http
 
         public WinInetProxyHelper()
         {
-            var proxyConfig = new Interop.WinHttp.WINHTTP_CURRENT_USER_IE_PROXY_CONFIG();
+            Interop.WinHttp.WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig = default;
 
             try
             {
index 8b440de..9340e4a 100644 (file)
@@ -90,7 +90,7 @@ namespace System.Net.Http
             public void Initialize(CancellationToken cancellationToken)
             {
                 CancellationToken = cancellationToken;
-                var b = new AsyncTaskMethodBuilder();
+                AsyncTaskMethodBuilder b = default;
                 _ = b.Task; // force initialization
                 Builder = b;
             }
index 7d56346..43cc034 100644 (file)
@@ -36,7 +36,7 @@ namespace System.Net.Http
 
         // This lock can be folded into _nextFlushTicks for space optimization, but
         // this class should only have a single instance so would rather have clarity.
-        private SpinLock _flushLock = new SpinLock();
+        private SpinLock _flushLock = new SpinLock(enableThreadOwnerTracking: false); // mutable struct; do not make this readonly
 
         /// <summary>
         /// Checks when a proxy will become usable.
index a5158e3..3434641 100644 (file)
@@ -198,7 +198,7 @@ namespace System.Net.Http
             // won't actually discover a PAC file on the network since WPAD protocol isn't configured.
             if (_proxyHelper.AutoSettingsUsed && !_proxyHelper.RecentAutoDetectionFailure)
             {
-                var proxyInfo = new Interop.WinHttp.WINHTTP_PROXY_INFO();
+                Interop.WinHttp.WINHTTP_PROXY_INFO proxyInfo = default;
                 try
                 {
                     if (_proxyHelper.GetProxyForUrl(_sessionHandle, uri, out proxyInfo))
index 1e19e91..6c6243d 100644 (file)
@@ -62,7 +62,7 @@ namespace System.Net.Http
                 CFRunLoopStop(runLoop);
             };
 
-            var clientContext = new CFStreamClientContext();
+            CFStreamClientContext clientContext = default;
             CFRunLoopSourceRef loopSource =
                 proxy.ProxyType == CFProxy.kCFProxyTypeAutoConfigurationURL ?
                 CFNetworkExecuteProxyAutoConfigurationURL(proxy.AutoConfigurationURL, cfurl, cb, ref clientContext) :
index f091e8b..08fe539 100644 (file)
@@ -124,8 +124,7 @@ namespace System.Net
         {
             ValidateV2Property(); // CheckDispose and initilize HttpListener in the case of app.config timeouts
 
-            Interop.HttpApi.HTTP_TIMEOUT_LIMIT_INFO timeoutinfo =
-                new Interop.HttpApi.HTTP_TIMEOUT_LIMIT_INFO();
+            Interop.HttpApi.HTTP_TIMEOUT_LIMIT_INFO timeoutinfo = default;
 
             timeoutinfo.Flags = Interop.HttpApi.HTTP_FLAGS.HTTP_PROPERTY_FLAG_PRESENT;
             timeoutinfo.DrainEntityBody =
@@ -345,7 +344,7 @@ namespace System.Net
             // Set the association between request queue and url group. After this, requests for registered urls will
             // get delivered to this request queue.
             //
-            Interop.HttpApi.HTTP_BINDING_INFO info = new Interop.HttpApi.HTTP_BINDING_INFO();
+            Interop.HttpApi.HTTP_BINDING_INFO info = default;
             info.Flags = Interop.HttpApi.HTTP_FLAGS.HTTP_PROPERTY_FLAG_PRESENT;
             info.RequestQueueHandle = DangerousGetHandle();
 
@@ -366,7 +365,7 @@ namespace System.Net
             // is fine since http.sys allows to set HttpServerBindingProperty multiple times for valid
             // Url groups.
             //
-            Interop.HttpApi.HTTP_BINDING_INFO info = new Interop.HttpApi.HTTP_BINDING_INFO();
+            Interop.HttpApi.HTTP_BINDING_INFO info = default;
             info.Flags = Interop.HttpApi.HTTP_FLAGS.NONE;
             info.RequestQueueHandle = IntPtr.Zero;
 
@@ -1676,8 +1675,8 @@ namespace System.Net
         private void SendError(ulong requestId, HttpStatusCode httpStatusCode, ArrayList challenges)
         {
             if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"RequestId: {requestId}");
-            Interop.HttpApi.HTTP_RESPONSE httpResponse = new Interop.HttpApi.HTTP_RESPONSE();
-            httpResponse.Version = new Interop.HttpApi.HTTP_VERSION();
+            Interop.HttpApi.HTTP_RESPONSE httpResponse = default;
+            httpResponse.Version = default;
             httpResponse.Version.MajorVersion = (ushort)1;
             httpResponse.Version.MinorVersion = (ushort)1;
             httpResponse.StatusCode = (ushort)httpStatusCode;
@@ -1699,8 +1698,8 @@ namespace System.Net
                     httpResponse.Headers.UnknownHeaderCount = checked((ushort)(challenges == null ? 0 : challenges.Count));
                     GCHandle[] challengeHandles = null;
                     Interop.HttpApi.HTTP_UNKNOWN_HEADER[] headersArray = null;
-                    GCHandle headersArrayHandle = new GCHandle();
-                    GCHandle wwwAuthenticateHandle = new GCHandle();
+                    GCHandle headersArrayHandle = default;
+                    GCHandle wwwAuthenticateHandle = default;
                     if (httpResponse.Headers.UnknownHeaderCount > 0)
                     {
                         challengeHandles = new GCHandle[httpResponse.Headers.UnknownHeaderCount];
@@ -1924,7 +1923,7 @@ namespace System.Net
             {
                 int oldValue;
 
-                SpinWait spin = new SpinWait();
+                SpinWait spin = default;
                 while ((oldValue = Interlocked.CompareExchange(ref _ownershipState, 1, 0)) == 2)
                 {
                     // Must block until it equals 3 - we must be in the callback right now.
index 339db8a..19b8975 100644 (file)
@@ -148,7 +148,7 @@ namespace System.Net
         {
             get
             {
-                Guid guid = new Guid();
+                Guid guid = default;
                 *(1 + (ulong*)&guid) = RequestId;
                 return guid;
             }
index 4386639..5e75832 100644 (file)
@@ -32,7 +32,7 @@ namespace System.Net
         internal HttpListenerResponse()
         {
             if (NetEventSource.IsEnabled) NetEventSource.Info(this);
-            _nativeResponse = new Interop.HttpApi.HTTP_RESPONSE();
+            _nativeResponse = default;
             _nativeResponse.StatusCode = (ushort)HttpStatusCode.OK;
             _nativeResponse.Version.MajorVersion = 1;
             _nativeResponse.Version.MinorVersion = 1;
@@ -64,7 +64,7 @@ namespace System.Net
         public void CopyFrom(HttpListenerResponse templateResponse)
         {
             if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"templateResponse {templateResponse}");
-            _nativeResponse = new Interop.HttpApi.HTTP_RESPONSE();
+            _nativeResponse = default;
             _responseState = ResponseState.Created;
             _webHeaders = templateResponse._webHeaders;
             _boundaryType = templateResponse._boundaryType;
index 84e3408..db4575c 100644 (file)
@@ -93,7 +93,7 @@ namespace System.Net
                             pBuffer = (byte*)pBufferAsIntPtr;
                             offset = 0;
                         }
-                        Interop.HttpApi.HTTP_DATA_CHUNK dataChunk = new Interop.HttpApi.HTTP_DATA_CHUNK();
+                        Interop.HttpApi.HTTP_DATA_CHUNK dataChunk = default;
                         dataChunk.DataChunkType = Interop.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
                         dataChunk.pBuffer = (byte*)(pBuffer + offset);
                         dataChunk.BufferLength = dataToWrite;
@@ -316,7 +316,7 @@ namespace System.Net
                     Interop.HttpApi.HTTP_DATA_CHUNK* pDataChunk = null;
                     if (_httpContext.Response.BoundaryType == BoundaryType.Chunked)
                     {
-                        Interop.HttpApi.HTTP_DATA_CHUNK dataChunk = new Interop.HttpApi.HTTP_DATA_CHUNK();
+                        Interop.HttpApi.HTTP_DATA_CHUNK dataChunk = default;
                         dataChunk.DataChunkType = Interop.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
                         dataChunk.pBuffer = (byte*)pBuffer;
                         dataChunk.BufferLength = (uint)s_chunkTerminator.Length;
index 7d1c342..cb4069a 100644 (file)
@@ -139,19 +139,19 @@ namespace System.Net
                 {
                     chunkHeaderBuffer = GetChunkHeader(size, out chunkHeaderOffset);
 
-                    _dataChunks[0] = new Interop.HttpApi.HTTP_DATA_CHUNK();
+                    _dataChunks[0] = default;
                     _dataChunks[0].DataChunkType = Interop.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
                     _dataChunks[0].BufferLength = (uint)(chunkHeaderBuffer.Length - chunkHeaderOffset);
 
                     objectsToPin[0] = chunkHeaderBuffer;
 
-                    _dataChunks[1] = new Interop.HttpApi.HTTP_DATA_CHUNK();
+                    _dataChunks[1] = default;
                     _dataChunks[1].DataChunkType = Interop.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
                     _dataChunks[1].BufferLength = (uint)size;
 
                     objectsToPin[1] = buffer;
 
-                    _dataChunks[2] = new Interop.HttpApi.HTTP_DATA_CHUNK();
+                    _dataChunks[2] = default;
                     _dataChunks[2].DataChunkType = Interop.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
                     _dataChunks[2].BufferLength = (uint)s_CRLFArray.Length;
 
@@ -159,7 +159,7 @@ namespace System.Net
                 }
                 else
                 {
-                    _dataChunks[0] = new Interop.HttpApi.HTTP_DATA_CHUNK();
+                    _dataChunks[0] = default;
                     _dataChunks[0].DataChunkType = Interop.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
                     _dataChunks[0].BufferLength = (uint)size;
 
index 6e7a1ff..1fdd601 100644 (file)
@@ -1998,7 +1998,7 @@ namespace System.Net.WebSockets
                     }
 
                     Interop.WebSocket.Buffer payloadBuffer;
-                    payloadBuffer = new Interop.WebSocket.Buffer();
+                    payloadBuffer = default;
                     _webSocket._internalBuffer.PinSendBuffer(buffer.Value, out _BufferHasBeenPinned);
                     payloadBuffer.Data.BufferData = _webSocket._internalBuffer.ConvertPinnedSendPayloadToNative(buffer.Value);
                     payloadBuffer.Data.BufferLength = (uint)buffer.Value.Count;
@@ -2074,7 +2074,7 @@ namespace System.Net.WebSockets
                         return null;
                     }
 
-                    Interop.WebSocket.Buffer payloadBuffer = new Interop.WebSocket.Buffer();
+                    Interop.WebSocket.Buffer payloadBuffer = default;
                     if (CloseReason != null)
                     {
                         byte[] blob = Encoding.UTF8.GetBytes(CloseReason);
index 54c98bd..6ce5d7e 100644 (file)
@@ -133,7 +133,7 @@ namespace System.Net.WebSockets
                 NetEventSource.Enter(this, HttpWebSocket.GetTraceMsgForParameters(offset, count, cancellationToken));
             }
 
-            CancellationTokenRegistration cancellationTokenRegistration = new CancellationTokenRegistration();
+            CancellationTokenRegistration cancellationTokenRegistration = default;
 
             int bytesRead = 0;
             try
@@ -357,7 +357,7 @@ namespace System.Net.WebSockets
                 NetEventSource.Enter(this);
             }
 
-            CancellationTokenRegistration cancellationTokenRegistration = new CancellationTokenRegistration();
+            CancellationTokenRegistration cancellationTokenRegistration = default;
 
             try
             {
@@ -419,7 +419,7 @@ namespace System.Net.WebSockets
                 NetEventSource.Enter(this, HttpWebSocket.GetTraceMsgForParameters(offset, count, cancellationToken));
             }
 
-            CancellationTokenRegistration cancellationTokenRegistration = new CancellationTokenRegistration();
+            CancellationTokenRegistration cancellationTokenRegistration = default;
 
             try
             {
@@ -608,7 +608,7 @@ namespace System.Net.WebSockets
                 NetEventSource.Enter(this);
             }
 
-            CancellationTokenRegistration cancellationTokenRegistration = new CancellationTokenRegistration();
+            CancellationTokenRegistration cancellationTokenRegistration = default;
 
             try
             {
@@ -1097,9 +1097,9 @@ namespace System.Net.WebSockets
                 {
                     _dataChunks = new Interop.HttpApi.HTTP_DATA_CHUNK[2];
                     _dataChunksGCHandle = GCHandle.Alloc(_dataChunks, GCHandleType.Pinned);
-                    _dataChunks[0] = new Interop.HttpApi.HTTP_DATA_CHUNK();
+                    _dataChunks[0] = default;
                     _dataChunks[0].DataChunkType = Interop.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
-                    _dataChunks[1] = new Interop.HttpApi.HTTP_DATA_CHUNK();
+                    _dataChunks[1] = default;
                     _dataChunks[1].DataChunkType = Interop.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory;
                 }
 
index 9f899fe..833a5f8 100644 (file)
@@ -98,7 +98,7 @@ namespace System.Net.Mail
             {
                 return info[0];
             }
-            return new LineInfo();
+            return default;
         }
 
         internal SmtpReplyReader GetNextReplyReader()
@@ -296,7 +296,7 @@ namespace System.Net.Mail
             {
                 return info[0];
             }
-            return new LineInfo();
+            return default;
         }
 
         internal LineInfo[] ReadLines(SmtpReplyReader caller)
index b5187e1..cf0655c 100644 (file)
@@ -124,7 +124,7 @@ namespace System.Net.NetworkInformation
         {
             Debug.Assert(s_dynamicStoreRef == null);
 
-            var storeContext = new Interop.SystemConfiguration.SCDynamicStoreContext();
+            Interop.SystemConfiguration.SCDynamicStoreContext storeContext = default;
             using (SafeCreateHandle storeName = Interop.CoreFoundation.CFStringCreateWithCString("NetworkAddressChange.OSX"))
             {
                 s_dynamicStoreRef = Interop.SystemConfiguration.SCDynamicStoreCreate(
index 385ace9..3b4e464 100644 (file)
@@ -9,7 +9,7 @@ namespace System.Net.NetworkInformation
     /// IP statistics.
     internal class SystemIPGlobalStatistics : IPGlobalStatistics
     {
-        private readonly Interop.IpHlpApi.MibIpStats _stats = new Interop.IpHlpApi.MibIpStats();
+        private readonly Interop.IpHlpApi.MibIpStats _stats = default;
 
         private SystemIPGlobalStatistics() { }
 
index 4808c20..005971e 100644 (file)
@@ -39,7 +39,7 @@ namespace System.Net.NetworkInformation
 
         internal static Interop.IpHlpApi.MibIfRow2 GetIfEntry2(long index)
         {
-            Interop.IpHlpApi.MibIfRow2 ifRow = new Interop.IpHlpApi.MibIfRow2();
+            Interop.IpHlpApi.MibIfRow2 ifRow = default;
             if (index == 0)
             {
                 return ifRow;
index 5db20f6..7671efc 100644 (file)
@@ -200,7 +200,7 @@ namespace System.Net
         {
             if (NetEventSource.IsEnabled) NetEventSource.Enter(chainContext, cpp.dwFlags);
 
-            var status = new Interop.Crypt32.CERT_CHAIN_POLICY_STATUS();
+            Interop.Crypt32.CERT_CHAIN_POLICY_STATUS status = default;
             status.cbSize = (uint)sizeof(Interop.Crypt32.CERT_CHAIN_POLICY_STATUS);
 
             bool errorCode =
index 2c9f22c..003fb24 100644 (file)
@@ -104,7 +104,7 @@ namespace System.Net.Sockets
             else
             {
                 // Other
-                _ipPacketInformation = new IPPacketInformation();
+                _ipPacketInformation = default;
             }
         }
 
index d662eae..e39df10 100644 (file)
@@ -100,7 +100,7 @@ namespace System.Net.Sockets
                     bool canceledOperations = false;
 
                     // Wait until it's safe.
-                    SpinWait sw = new SpinWait();
+                    SpinWait sw = default;
                     while (!_released)
                     {
                         // The socket was not released due to the SafeHandle being used.
index 893a173..6901197 100644 (file)
@@ -202,7 +202,7 @@ namespace System.Net.Sockets
                 CancellationRegistration.Dispose();
 
                 // Try to transition from Waiting to Cancelled
-                var spinWait = new SpinWait();
+                SpinWait spinWait = default;
                 bool keepWaiting = true;
                 while (keepWaiting)
                 {
index c3233b5..29a0226 100644 (file)
@@ -1192,7 +1192,7 @@ namespace System.Net.Sockets
                 // The operation could complete so quickly that it races with the code
                 // initiating it.  Wait until that initiation code has completed before
                 // we try to undo the state it configures.
-                var sw = new SpinWait();
+                SpinWait sw = default;
                 while (_singleBufferHandleState == SingleBufferHandleState.InProcess)
                 {
                     sw.SpinOnce();
@@ -1233,7 +1233,7 @@ namespace System.Net.Sockets
             else
             {
                 // Other.
-                _receiveMessageFromPacketInfo = new IPPacketInformation();
+                _receiveMessageFromPacketInfo = default;
             }
         }
 
index a795b77..0946c9b 100644 (file)
@@ -1405,7 +1405,7 @@ namespace System.Net.Sockets
 
         public static unsafe SocketError GetLingerOption(SafeSocketHandle handle, out LingerOption optionValue)
         {
-            var opt = new Interop.Sys.LingerOption();
+            Interop.Sys.LingerOption opt = default;
             Interop.Error err = Interop.Sys.GetLingerOption(handle, &opt);
             if (err != Interop.Error.SUCCESS)
             {
index a66979b..dad69e9 100644 (file)
@@ -545,7 +545,7 @@ namespace System.Net.Sockets
 
         public static SocketError SetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, MulticastOption optionValue)
         {
-            Interop.Winsock.IPMulticastRequest ipmr = new Interop.Winsock.IPMulticastRequest();
+            Interop.Winsock.IPMulticastRequest ipmr = default;
 
 #pragma warning disable CS0618 // Address is marked obsolete
             ipmr.MulticastAddress = unchecked((int)optionValue.Group.Address);
@@ -590,7 +590,7 @@ namespace System.Net.Sockets
 
         public static SocketError SetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, IPv6MulticastOption optionValue)
         {
-            Interop.Winsock.IPv6MulticastRequest ipmr = new Interop.Winsock.IPv6MulticastRequest();
+            Interop.Winsock.IPv6MulticastRequest ipmr = default;
 
             ipmr.MulticastAddress = optionValue.Group.GetAddressBytes();
             ipmr.InterfaceIndex = unchecked((int)optionValue.InterfaceIndex);
@@ -607,7 +607,7 @@ namespace System.Net.Sockets
 
         public static SocketError SetLingerOption(SafeSocketHandle handle, LingerOption optionValue)
         {
-            Interop.Winsock.Linger lngopt = new Interop.Winsock.Linger();
+            Interop.Winsock.Linger lngopt = default;
             lngopt.OnOff = optionValue.Enabled ? (ushort)1 : (ushort)0;
             lngopt.Time = (ushort)optionValue.LingerTime;
 
@@ -666,7 +666,7 @@ namespace System.Net.Sockets
 
         public static SocketError GetMulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out MulticastOption optionValue)
         {
-            Interop.Winsock.IPMulticastRequest ipmr = new Interop.Winsock.IPMulticastRequest();
+            Interop.Winsock.IPMulticastRequest ipmr = default;
             int optlen = Interop.Winsock.IPMulticastRequest.Size;
 
             // This can throw ObjectDisposedException.
@@ -703,7 +703,7 @@ namespace System.Net.Sockets
 
         public static SocketError GetIPv6MulticastOption(SafeSocketHandle handle, SocketOptionName optionName, out IPv6MulticastOption optionValue)
         {
-            Interop.Winsock.IPv6MulticastRequest ipmr = new Interop.Winsock.IPv6MulticastRequest();
+            Interop.Winsock.IPv6MulticastRequest ipmr = default;
 
             int optlen = Interop.Winsock.IPv6MulticastRequest.Size;
 
@@ -727,7 +727,7 @@ namespace System.Net.Sockets
 
         public static SocketError GetLingerOption(SafeSocketHandle handle, out LingerOption optionValue)
         {
-            Interop.Winsock.Linger lngopt = new Interop.Winsock.Linger();
+            Interop.Winsock.Linger lngopt = default;
             int optlen = 4;
 
             // This can throw ObjectDisposedException.
@@ -757,7 +757,7 @@ namespace System.Net.Sockets
 
                 IntPtr rawHandle = handle.DangerousGetHandle();
                 IntPtr* fileDescriptorSet = stackalloc IntPtr[2] { (IntPtr)1, rawHandle };
-                Interop.Winsock.TimeValue IOwait = new Interop.Winsock.TimeValue();
+                Interop.Winsock.TimeValue IOwait = default;
 
                 // A negative timeout value implies an indefinite wait.
                 int socketCount;
@@ -853,7 +853,7 @@ namespace System.Net.Sockets
                 {
                     if (microseconds != -1)
                     {
-                        Interop.Winsock.TimeValue IOwait = new Interop.Winsock.TimeValue();
+                        Interop.Winsock.TimeValue IOwait = default;
                         MicrosecondsToTimeValue((long)(uint)microseconds, ref IOwait);
 
                         socketCount =
index 35d9015..1e91ad1 100644 (file)
@@ -22,7 +22,7 @@ namespace System.Runtime.Serialization.Json
         private readonly bool _useSimpleDictionaryFormat;
 
         public XmlObjectSerializerReadContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract)
-            : base(null, int.MaxValue, new StreamingContext(), true)
+            : base(null, int.MaxValue, default(StreamingContext), true)
         {
             this.rootTypeDataContract = rootTypeDataContract;
             this.serializerKnownTypeList = serializer.KnownTypes;
@@ -30,7 +30,7 @@ namespace System.Runtime.Serialization.Json
         }
 
         internal XmlObjectSerializerReadContextComplexJson(DataContractJsonSerializerImpl serializer, DataContract rootTypeDataContract)
-            : base(serializer, serializer.MaxItemsInObjectGraph, new StreamingContext(), false)
+            : base(serializer, serializer.MaxItemsInObjectGraph, default(StreamingContext), false)
         {
             this.rootTypeDataContract = rootTypeDataContract;
             this.serializerKnownTypeList = serializer.knownTypeList;
index ce19246..b116f64 100644 (file)
@@ -21,7 +21,7 @@ namespace System.Runtime.Serialization.Json
         private readonly bool _useSimpleDictionaryFormat;
 
         public XmlObjectSerializerWriteContextComplexJson(DataContractJsonSerializer serializer, DataContract rootTypeDataContract)
-            : base(null, int.MaxValue, new StreamingContext(), true)
+            : base(null, int.MaxValue, default(StreamingContext), true)
 
         {
             _jsonSerializer = serializer;
@@ -40,7 +40,7 @@ namespace System.Runtime.Serialization.Json
         }
 
         internal XmlObjectSerializerWriteContextComplexJson(DataContractJsonSerializerImpl serializer, DataContract rootTypeDataContract)
-            : base(serializer, serializer.MaxItemsInObjectGraph, new StreamingContext(), false)
+            : base(serializer, serializer.MaxItemsInObjectGraph, default(StreamingContext), false)
         {
             _emitXsiType = serializer.EmitTypeInformation;
             this.rootTypeDataContract = rootTypeDataContract;
index 9328579..5912642 100644 (file)
@@ -20,7 +20,7 @@ namespace System.Runtime.Serialization
     {
         protected XmlObjectSerializer serializer;
         protected DataContract rootTypeDataContract;
-        internal ScopedKnownTypes scopedKnownTypes = new ScopedKnownTypes();
+        internal ScopedKnownTypes scopedKnownTypes;
         protected DataContractDictionary serializerKnownDataContracts;
         private bool _isSerializerKnownDataContractsSetExplicit;
         protected IList<Type> serializerKnownTypeList;
@@ -50,7 +50,7 @@ namespace System.Runtime.Serialization
         internal XmlObjectSerializerContext(DataContractSerializer serializer, DataContract rootTypeDataContract, DataContractResolver dataContractResolver)
             : this(serializer,
             serializer.MaxItemsInObjectGraph,
-            new StreamingContext(),
+            default(StreamingContext),
             serializer.IgnoreExtensionDataObject,
             dataContractResolver
             )
index 7e6edc9..0993590 100644 (file)
@@ -24,7 +24,7 @@ namespace System.Runtime.Serialization
     internal class XmlObjectSerializerWriteContext : XmlObjectSerializerContext
 #endif
     {
-        private ObjectReferenceStack _byValObjectsInScope = new ObjectReferenceStack();
+        private ObjectReferenceStack _byValObjectsInScope;
         private XmlSerializableWriter _xmlSerializableWriter;
         private const int depthToCheckCyclicReference = 512;
         private ObjectToIdCache _serializedObjects;
index 39f42cd..2416926 100644 (file)
@@ -842,7 +842,7 @@ namespace System
                 }
                 else
                 {
-                    var pathSegments = new ArrayBuilder<string>();
+                    ArrayBuilder<string> pathSegments = default;
                     int current = 0;
                     while (current < path.Length)
                     {
index 31c5801..19e7202 100644 (file)
@@ -904,8 +904,8 @@ namespace System.Xml.Linq
 
         private sealed class ContentReader
         {
-            private readonly NamespaceCache _eCache = new NamespaceCache();
-            private readonly NamespaceCache _aCache = new NamespaceCache();
+            private readonly NamespaceCache _eCache;
+            private readonly NamespaceCache _aCache;
             private readonly IXmlLineInfo _lineInfo;
             private XContainer _currentContainer;
             private string _baseUri;
index 8c5102a..5ccbf7e 100644 (file)
@@ -844,7 +844,7 @@ namespace System.Xml.Linq
         {
             if (await reader.MoveToContentAsync().ConfigureAwait(false) != XmlNodeType.Element) throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ExpectedNodeType, XmlNodeType.Element, reader.NodeType));
 
-            XElement e = new XElement(new AsyncConstructionSentry());
+            XElement e = new XElement(default(AsyncConstructionSentry));
             await e.ReadElementFromAsync(reader, options, cancellationToken).ConfigureAwait(false);
 
             cancellationToken.ThrowIfCancellationRequested();
index 1f6fa3b..46f7068 100644 (file)
@@ -201,7 +201,7 @@ namespace System.Xml.Linq
         public ElementWriter(XmlWriter writer)
         {
             _writer = writer;
-            _resolver = new NamespaceResolver();
+            _resolver = default;
         }
 
         public void WriteElement(XElement e)
@@ -535,7 +535,7 @@ namespace System.Xml.Linq
             _writer = w;
             _element = null;
             _attributes = new List<XAttribute>();
-            _resolver = new NamespaceResolver();
+            _resolver = default;
         }
 
         private void FlushElement()
index 7b5a4eb..e45c917 100644 (file)
@@ -948,7 +948,7 @@ namespace System.Xml.XPath
         public static object XPathEvaluate(this XNode node, string expression, IXmlNamespaceResolver resolver)
         {
             if (node == null) throw new ArgumentNullException(nameof(node));
-            return new XPathEvaluator().Evaluate<object>(node, expression, resolver);
+            return default(XPathEvaluator).Evaluate<object>(node, expression, resolver);
         }
 
         /// <summary>
@@ -997,7 +997,7 @@ namespace System.Xml.XPath
         public static IEnumerable<XElement> XPathSelectElements(this XNode node, string expression, IXmlNamespaceResolver resolver)
         {
             if (node == null) throw new ArgumentNullException(nameof(node));
-            return (IEnumerable<XElement>)new XPathEvaluator().Evaluate<XElement>(node, expression, resolver);
+            return (IEnumerable<XElement>)default(XPathEvaluator).Evaluate<XElement>(node, expression, resolver);
         }
 
         private static XText CalibrateText(XText n)
index bd30e49..edfd33e 100644 (file)
@@ -1869,7 +1869,7 @@ namespace System.Xml.Schema
                 runningPositions = new List<RangePositionInfo>();
                 context.RunningPositions = runningPositions;
             }
-            RangePositionInfo rposInfo = new RangePositionInfo();
+            RangePositionInfo rposInfo = default;
             rposInfo.curpos = _firstpos.Clone();
 
             rposInfo.rangeCounters = new decimal[_minMaxNodesCount];
@@ -1987,8 +1987,8 @@ namespace System.Xml.Schema
                         rposInfo = runningPositions[j];
                         if (matchCount + 2 >= runningPositions.Count)
                         {
-                            runningPositions.Add(new RangePositionInfo());
-                            runningPositions.Add(new RangePositionInfo());
+                            runningPositions.Add(default(RangePositionInfo));
+                            runningPositions.Add(default(RangePositionInfo));
                         }
                         RangePositionInfo newRPosInfo = runningPositions[matchCount];
                         if (newRPosInfo.rangeCounters == null)
index 8949e58..c071cda 100644 (file)
@@ -368,7 +368,7 @@ namespace System.Xml.Schema
             bool schemasLockObtained = false;
             try
             {
-                SpinWait spinner = new SpinWait();
+                SpinWait spinner = default;
                 while (true)
                 {
                     Monitor.TryEnter(InternalSyncObject, ref thisLockObtained);
index 09456ad..2707825 100644 (file)
@@ -137,7 +137,7 @@ namespace System.Xml.Schema
         /// </summary>
         public XsdDateTime(string text, XsdDateTimeFlags kinds) : this()
         {
-            Parser parser = new Parser();
+            Parser parser = default;
             if (!parser.Parse(text, kinds))
             {
                 throw new FormatException(SR.Format(SR.XmlConvert_BadFormat, text, kinds));
@@ -162,10 +162,10 @@ namespace System.Xml.Schema
 
         internal static bool TryParse(string text, XsdDateTimeFlags kinds, out XsdDateTime result)
         {
-            Parser parser = new Parser();
+            Parser parser = default;
             if (!parser.Parse(text, kinds))
             {
-                result = new XsdDateTime();
+                result = default;
                 return false;
             }
             result = new XsdDateTime(parser);
index 8ab5bf6..9a73084 100644 (file)
@@ -438,7 +438,7 @@ namespace System.Xml.Schema
             int value, pos, numDigits;
             Parts parts = Parts.HasNone;
 
-            result = new XsdDuration();
+            result = default;
 
             s = s.Trim();
             length = s.Length;
index 0ef7265..b50d640 100644 (file)
@@ -968,7 +968,7 @@ namespace System.Xml.Serialization
             char[] chars = value.ToCharArray();
             int charsLength = chars.Length;
 
-            SoapArrayInfo soapArrayInfo = new SoapArrayInfo();
+            SoapArrayInfo soapArrayInfo = default;
 
             // Parse backwards to get length first, then optional dimensions, then qname.
             int pos = charsLength - 1;
@@ -1039,7 +1039,7 @@ namespace System.Xml.Serialization
 
         private SoapArrayInfo ParseSoap12ArrayType(string itemType, string arraySize)
         {
-            SoapArrayInfo soapArrayInfo = new SoapArrayInfo();
+            SoapArrayInfo soapArrayInfo = default;
 
             if (itemType != null && itemType.Length > 0)
                 soapArrayInfo.qname = itemType;
index dc2dffe..b68eaa4 100644 (file)
@@ -125,7 +125,7 @@ namespace System.Xml.Serialization
 #pragma warning restore 0414
         private readonly Type _primitiveType;
         private XmlMapping _mapping;
-        private XmlDeserializationEvents _events = new XmlDeserializationEvents();
+        private XmlDeserializationEvents _events;
         internal string DefaultNamespace = null;
         private Type _rootType;
         private bool _isReflectionBasedSerializer = false;
index 191ff57..9c8ae17 100644 (file)
@@ -58,7 +58,7 @@ namespace System.Xml.Xsl.IlGen
         /// </summary>
         public static StorageDescriptor None()
         {
-            return new StorageDescriptor();
+            return default;
         }
 
         /// <summary>
@@ -66,7 +66,7 @@ namespace System.Xml.Xsl.IlGen
         /// </summary>
         public static StorageDescriptor Stack(Type itemStorageType, bool isCached)
         {
-            StorageDescriptor storage = new StorageDescriptor();
+            StorageDescriptor storage = default;
             storage._location = ItemLocation.Stack;
             storage._itemStorageType = itemStorageType;
             storage._isCached = isCached;
@@ -78,7 +78,7 @@ namespace System.Xml.Xsl.IlGen
         /// </summary>
         public static StorageDescriptor Parameter(int paramIndex, Type itemStorageType, bool isCached)
         {
-            StorageDescriptor storage = new StorageDescriptor();
+            StorageDescriptor storage = default;
             storage._location = ItemLocation.Parameter;
             storage._locationObject = paramIndex;
             storage._itemStorageType = itemStorageType;
@@ -95,7 +95,7 @@ namespace System.Xml.Xsl.IlGen
                          typeof(IList<>).MakeGenericType(itemStorageType).IsAssignableFrom(loc.LocalType),
                          "Type " + itemStorageType + " does not match the local variable's type");
 
-            StorageDescriptor storage = new StorageDescriptor();
+            StorageDescriptor storage = default;
             storage._location = ItemLocation.Local;
             storage._locationObject = loc;
             storage._itemStorageType = itemStorageType;
@@ -111,7 +111,7 @@ namespace System.Xml.Xsl.IlGen
             Debug.Assert(locIter.LocalType.GetMethod("get_Current").ReturnType == itemStorageType,
                          "Type " + itemStorageType + " does not match type of Current property.");
 
-            StorageDescriptor storage = new StorageDescriptor();
+            StorageDescriptor storage = default;
             storage._location = ItemLocation.Current;
             storage._locationObject = locIter;
             storage._itemStorageType = itemStorageType;
@@ -127,7 +127,7 @@ namespace System.Xml.Xsl.IlGen
                          typeof(IList<>).MakeGenericType(itemStorageType).IsAssignableFrom(methGlobal.ReturnType),
                          "Type " + itemStorageType + " does not match the global method's return type");
 
-            StorageDescriptor storage = new StorageDescriptor();
+            StorageDescriptor storage = default;
             storage._location = ItemLocation.Global;
             storage._locationObject = methGlobal;
             storage._itemStorageType = itemStorageType;
index e16631c..9ad24cb 100644 (file)
@@ -1640,7 +1640,7 @@ namespace System.Xml.Xsl.IlGen
                             if (AllowReplace(XmlILOptimization.EliminateStrConcat, local0))
                             {
                                 // Concatenate all constant arguments
-                                StringConcat concat = new StringConcat();
+                                StringConcat concat = default;
                                 concat.Delimiter = local3;
 
                                 foreach (QilLiteral lit in local2)
index 3d66fae..7abb98e 100644 (file)
@@ -731,7 +731,7 @@ namespace System.Xml.Xsl.IlGen
         /// </remarks>
         protected override QilNode VisitOr(QilBinary ndOr)
         {
-            Label lblTemp = new Label();
+            Label lblTemp = default;
 
             // Visit left branch
             switch (_iterCurr.CurrentBranchingContext)
@@ -819,7 +819,7 @@ namespace System.Xml.Xsl.IlGen
         /// </remarks>
         protected override QilNode VisitNot(QilUnary ndNot)
         {
-            Label lblTemp = new Label();
+            Label lblTemp = default;
 
             // Visit operand
             // Reverse branch types
@@ -1153,7 +1153,7 @@ namespace System.Xml.Xsl.IlGen
         private void Sequence(QilList ndSeq)
         {
             LocalBuilder locIdx, locList;
-            Label lblStart, lblNext, lblOnEnd = new Label();
+            Label lblStart, lblNext, lblOnEnd = default;
             Label[] arrSwitchLabels;
             int i;
             Type itemStorageType = GetItemStorageType(ndSeq);
@@ -4413,7 +4413,7 @@ namespace System.Xml.Xsl.IlGen
 
             // By default, do not create a new iteration label
             hasOnEnd = false;
-            lblOnEnd = new Label();
+            lblOnEnd = default;
 
             // If loop is not involved in Xml construction, or if loop returns exactly one value, then do nothing
             if (!info.PushToWriterLast || nd.XmlType.IsSingleton)
index 2e68c6d..107e045 100644 (file)
@@ -262,7 +262,7 @@ namespace System.Xml.Xsl.Runtime
         /// </summary>
         public void Create(XPathNavigator context, XmlNavigatorFilter filter, bool orSelf)
         {
-            AncestorIterator wrapped = new AncestorIterator();
+            AncestorIterator wrapped = default;
             wrapped.Create(context, filter, orSelf);
             _stack.Reset();
 
@@ -602,7 +602,7 @@ namespace System.Xml.Xsl.Runtime
         /// </summary>
         public void Create(XPathNavigator context, XmlNavigatorFilter filter)
         {
-            XPathPrecedingDocOrderIterator wrapped = new XPathPrecedingDocOrderIterator();
+            XPathPrecedingDocOrderIterator wrapped = default;
             wrapped.Create(context, filter);
             _stack.Reset();
 
index e484841..06a768a 100644 (file)
@@ -161,7 +161,7 @@ namespace System.Xml.Xsl.Runtime
 
             Uri collationUri;
             CultureInfo cultInfo = null;
-            Options options = new Options();
+            Options options = default;
 
             if (throwOnError)
             {
index e67b087..9c237b7 100644 (file)
@@ -107,7 +107,7 @@ namespace System.Xml.Xsl.Xslt
             _invkGen = new InvokeGenerator(_f, debug);
             _matcherBuilder = new MatcherBuilder(_f, _refReplacer, _invkGen);
             _singlFocus = new SingletonFocus(_f);
-            _funcFocus = new FunctionFocus();
+            _funcFocus = default;
             _curLoop = new LoopFocus(_f);
             _strConcat = new QilStrConcatenator(_f);
             _varHelper = new VariableHelper(_f);
index 8074fb2..0739cef 100644 (file)
@@ -411,7 +411,7 @@ namespace System.Xml.Xsl.Xslt
             {
                 string keyName = (QilLiteral)name;
 
-                _compiler.ParseQName(keyName, out string prefix, out string local, new ThrowErrorHelper());
+                _compiler.ParseQName(keyName, out string prefix, out string local, default(ThrowErrorHelper));
                 string nsUri = ResolvePrefixThrow(/*ignoreDefaultNs:*/true, prefix);
                 QilName qname = _f.QName(local, nsUri, prefix);
 
@@ -643,7 +643,7 @@ namespace System.Xml.Xsl.Xslt
         private XmlQualifiedName ResolveQNameThrow(bool ignoreDefaultNs, QilNode qilName)
         {
             string name = (QilLiteral)qilName;
-            _compiler.ParseQName(name, out string prefix, out string local, new ThrowErrorHelper());
+            _compiler.ParseQName(name, out string prefix, out string local, default(ThrowErrorHelper));
             string nsUri = ResolvePrefixThrow(/*ignoreDefaultNs:*/ignoreDefaultNs, prefix);
 
             return new XmlQualifiedName(local, nsUri);
index 51dfd4f..29573ca 100644 (file)
@@ -1134,7 +1134,7 @@ namespace System.Xml.Xsl.Xslt
                         funcFlags = XslFlags.AnyType;
                         if (_compiler.Settings.EnableScript && ns != null)
                         {
-                            XmlExtensionFunction scrFunc = _compiler.Scripts.ResolveFunction(name, ns, args.Count, new NullErrorHelper());
+                            XmlExtensionFunction scrFunc = _compiler.Scripts.ResolveFunction(name, ns, args.Count, default(NullErrorHelper));
                             if (scrFunc != null)
                             {
                                 XmlQueryType xt = scrFunc.XmlReturnType;
index 1b248c3..182e7be 100644 (file)
@@ -266,7 +266,7 @@ namespace System.Xml.Xsl.Xslt
             }
         }
 
-        private StringConcat _strConcat = new StringConcat();
+        private StringConcat _strConcat;
 
         // returns false if attribute is actualy namespace
         private bool ReadAttribute(ref Record rec)
index 02dc1ba..1eeac8b 100644 (file)
@@ -60,7 +60,7 @@ namespace System.Reflection.Internal
             byte[] givenArray = array;
             array = null;
 
-            var union = new ByteArrayUnion();
+            ByteArrayUnion union = default;
             union.UnderlyingArray = givenArray;
             return union.ImmutableArray;
         }
@@ -82,7 +82,7 @@ namespace System.Reflection.Internal
         /// <returns>The underlying array, or null if <see cref="ImmutableArray{T}.IsDefault"/> is true.</returns>
         internal static byte[] DangerousGetUnderlyingArray(ImmutableArray<byte> array)
         {
-            var union = new ByteArrayUnion();
+            ByteArrayUnion union = default;
             union.ImmutableArray = array;
             return union.UnderlyingArray;
         }
index 50971d2..f12d586 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Reflection.TypeLoading.Ecma
         {
             MetadataReader reader = Reader;
 
-            InternalManifestResourceInfo result = new InternalManifestResourceInfo();
+            InternalManifestResourceInfo result = default;
             ManifestResourceHandleCollection manifestResources = reader.ManifestResources;
             foreach (ManifestResourceHandle resourceHandle in manifestResources)
             {
index 356acac..b5f4abf 100644 (file)
@@ -17,7 +17,7 @@ namespace System.Reflection.TypeLoading
             Debug.Assert(types != null);
 
             QueryResult<ConstructorInfo> queryResult = Query<ConstructorInfo>(bindingAttr);
-            ListBuilder<ConstructorInfo> candidates = new ListBuilder<ConstructorInfo>();
+            ListBuilder<ConstructorInfo> candidates = default;
             foreach (ConstructorInfo candidate in queryResult)
             {
                 if (candidate.QualifiesBasedOnParameterCount(bindingAttr, callConvention, types))
@@ -81,7 +81,7 @@ namespace System.Reflection.TypeLoading
             {
                 // Group #2: This group of api takes a set of parameter types and an optional binder.
                 QueryResult<MethodInfo> queryResult = Query<MethodInfo>(name, bindingAttr);
-                ListBuilder<MethodInfo> candidates = new ListBuilder<MethodInfo>();
+                ListBuilder<MethodInfo> candidates = default;
                 foreach (MethodInfo candidate in queryResult)
                 {
                     if (genericParameterCount != GenericParameterCountAny && genericParameterCount != candidate.GetGenericParameterCount())
@@ -124,7 +124,7 @@ namespace System.Reflection.TypeLoading
             {
                 // Group #2: This group of api takes a set of parameter types, a return type (both cannot be null) and an optional binder.
                 QueryResult<PropertyInfo> queryResult = Query<PropertyInfo>(name, bindingAttr);
-                ListBuilder<PropertyInfo> candidates = new ListBuilder<PropertyInfo>();
+                ListBuilder<PropertyInfo> candidates = default;
                 foreach (PropertyInfo candidate in queryResult)
                 {
                     if (types == null || (candidate.GetIndexParameters().Length == types.Length))
index 0bd585f..72df935 100644 (file)
@@ -15,7 +15,7 @@ namespace System.Globalization
             {
                 fixed (char* overrideDigits = digits)
                 {
-                    var numberBuffer = new Number.NumberBuffer();
+                    Number.NumberBuffer numberBuffer = default;
                     numberBuffer.overrideDigits = overrideDigits + startIndex;
                     numberBuffer.precision = precision;
                     numberBuffer.scale = scale;
@@ -44,7 +44,7 @@ namespace System.Globalization
             out bool sign
             )
         {
-            FormatProvider.Number.NumberBuffer numberBuffer = new FormatProvider.Number.NumberBuffer();
+            FormatProvider.Number.NumberBuffer numberBuffer = default;
 
             unsafe
             {
index 4bf034d..492a405 100644 (file)
@@ -296,7 +296,7 @@ namespace System.Numerics
 
             public static BigNumberBuffer Create()
             {
-                BigNumberBuffer number = new BigNumberBuffer();
+                BigNumberBuffer number = default;
                 number.digits = new StringBuilder();
                 return number;
             }
index c49d840..b80b134 100644 (file)
@@ -216,7 +216,7 @@ namespace Windows.UI.Xaml
         {
             get
             {
-                Duration duration = new Duration();
+                Duration duration = default;
                 duration._durationType = DurationType.Automatic;
 
                 return duration;
@@ -227,7 +227,7 @@ namespace Windows.UI.Xaml
         {
             get
             {
-                Duration duration = new Duration();
+                Duration duration = default;
                 duration._durationType = DurationType.Forever;
 
                 return duration;
index b2439d1..2942b2a 100644 (file)
@@ -33,7 +33,7 @@ namespace Windows.UI.Xaml.Media.Animation
                 throw new ArgumentOutOfRangeException(nameof(timeSpan));
             }
 
-            KeyTime keyTime = new KeyTime();
+            KeyTime keyTime = default;
 
             keyTime._timeSpan = timeSpan;
 
index 26af935..c297e68 100644 (file)
@@ -67,7 +67,7 @@ namespace Windows.UI.Xaml.Media.Animation
         {
             get
             {
-                RepeatBehavior forever = new RepeatBehavior();
+                RepeatBehavior forever = default;
                 forever.Type = RepeatBehaviorType.Forever;
 
                 return forever;
index cfbb12f..2460c84 100644 (file)
@@ -215,7 +215,7 @@ namespace Windows.UI.Xaml.Media
 
         private static Matrix CreateIdentity()
         {
-            Matrix matrix = new Matrix();
+            Matrix matrix = default;
             matrix.SetMatrix(1, 0,
                              0, 1,
                              0, 0);
index 9fee814..af001ab 100644 (file)
@@ -498,7 +498,7 @@ namespace Windows.UI.Xaml.Media.Media3D
 
         public static Matrix3D operator *(Matrix3D matrix1, Matrix3D matrix2)
         {
-            Matrix3D matrix3D = new Matrix3D();
+            Matrix3D matrix3D = default;
 
             matrix3D.M11 = matrix1.M11 * matrix2.M11 +
                            matrix1.M12 * matrix2.M21 +
@@ -588,7 +588,7 @@ namespace Windows.UI.Xaml.Media.Media3D
 
         private static Matrix3D CreateIdentity()
         {
-            Matrix3D matrix3D = new Matrix3D();
+            Matrix3D matrix3D = default;
             matrix3D.SetMatrix(1, 0, 0, 0,
                                0, 1, 0, 0,
                                0, 0, 1, 0,
index c133128..e4d6dbe 100644 (file)
@@ -260,7 +260,7 @@ namespace Windows.Foundation
 
         private static Rect CreateEmptyRect()
         {
-            Rect rect = new Rect();
+            Rect rect = default;
 
             // TODO: for consistency with width/height we should change these
             //       to assign directly to the backing fields.
index efb12f3..b0c6cde 100644 (file)
@@ -84,7 +84,7 @@ namespace Windows.Foundation
 
         private static Size CreateEmptySize()
         {
-            Size size = new Size();
+            Size size = default;
             // We can't set these via the property setters because negatives widths
             // are rejected in those APIs.
             size._width = float.NegativeInfinity;
index 0c4df0a..9866532 100644 (file)
@@ -41,7 +41,7 @@ namespace Windows.UI
 
         public static Color FromArgb(byte a, byte r, byte g, byte b)
         {
-            Color c1 = new Color();
+            Color c1 = default;
 
             c1.A = a;
             c1.R = r;
index 31a59fd..30925d5 100644 (file)
@@ -476,7 +476,7 @@ namespace System.Security.AccessControl
                     newState.Privileges.Luid = this.luid;
                     newState.Privileges.Attributes = enable ? Interop.Advapi32.SEPrivileges.SE_PRIVILEGE_ENABLED : Interop.Advapi32.SEPrivileges.SE_PRIVILEGE_DISABLED;
 
-                    Interop.Advapi32.TOKEN_PRIVILEGE previousState = new Interop.Advapi32.TOKEN_PRIVILEGE();
+                    Interop.Advapi32.TOKEN_PRIVILEGE previousState = default;
                     uint previousSize = 0;
 
                     //
index 90f1551..bec5385 100644 (file)
@@ -281,7 +281,7 @@ namespace System.Security.Cryptography
                 {
                     Interop.NCrypt.NCryptBuffer* buffers = stackalloc Interop.NCrypt.NCryptBuffer[3];
 
-                    Interop.NCrypt.PBE_PARAMS pbeParams = new Interop.NCrypt.PBE_PARAMS();
+                    Interop.NCrypt.PBE_PARAMS pbeParams = default;
                     Span<byte> salt = new Span<byte>(pbeParams.rgbSalt, Interop.NCrypt.PBE_PARAMS.RgbSaltSize);
                     RandomNumberGenerator.Fill(salt);
                     pbeParams.Params.cbSalt = salt.Length;
index d1e8960..40b7683 100644 (file)
@@ -95,7 +95,7 @@ namespace System.Security.Cryptography
         /// </summary>
         private static ECCurve Create(Oid oid)
         {
-            ECCurve curve = new ECCurve();
+            ECCurve curve = default;
             curve.CurveType = ECCurveType.Named;
             curve.Oid = oid;
             return curve;
index 725e807..e355c85 100644 (file)
@@ -54,7 +54,7 @@ namespace System.Security.Cryptography
                     throw new ObjectDisposedException(nameof(ECDiffieHellmanPublicKey));
                 }
 
-                ECParameters ecparams = new ECParameters();
+                ECParameters ecparams = default;
                 ECCng.ExportPrimeCurveParameters(ref ecparams, _keyBlob, includePrivateParameters: false);
                 return ecparams;
             }
@@ -81,7 +81,7 @@ namespace System.Security.Cryptography
                 }
                 else
                 {
-                    ECParameters ecparams = new ECParameters();
+                    ECParameters ecparams = default;
                     ECCng.ExportNamedCurveParameters(ref ecparams, _keyBlob, includePrivateParameters: false);
                     ecparams.Curve = ECCurve.CreateFromFriendlyName(_curveName);
                     return ecparams;
index c861f15..9006103 100644 (file)
@@ -138,7 +138,7 @@ namespace System.Security.Cryptography
                 {
                     Interop.NCrypt.NCryptBuffer* buffers = stackalloc Interop.NCrypt.NCryptBuffer[3];
 
-                    Interop.NCrypt.PBE_PARAMS pbeParams = new Interop.NCrypt.PBE_PARAMS();
+                    Interop.NCrypt.PBE_PARAMS pbeParams = default;
                     Span<byte> salt = new Span<byte>(pbeParams.rgbSalt, Interop.NCrypt.PBE_PARAMS.RgbSaltSize);
                     RandomNumberGenerator.Fill(salt);
                     pbeParams.Params.cbSalt = salt.Length;
index dd94672..36a01de 100644 (file)
@@ -112,7 +112,7 @@ namespace System.Security.Cryptography
         {
             using (CngKey key = Import())
             {
-                ECParameters ecparams = new ECParameters();
+                ECParameters ecparams = default;
                 byte[] blob = ECCng.ExportFullKeyBlob(key, includePrivateParameters: false);
                 ECCng.ExportPrimeCurveParameters(ref ecparams, blob, includePrivateParameters: false);
                 return ecparams;
@@ -132,7 +132,7 @@ namespace System.Security.Cryptography
         {
             using (CngKey key = Import())
             {
-                ECParameters ecparams = new ECParameters();
+                ECParameters ecparams = default;
                 string curveName = key.GetCurveName(out _);
 
                 if (string.IsNullOrEmpty(curveName))
index 381be95..2c5a781 100644 (file)
@@ -157,7 +157,7 @@ namespace Internal.NativeCrypto
                     byte bVersion;
                     ReadKeyBlobHeader(br, out bVersion);
 
-                    DSAParameters dsaParameters = new DSAParameters();
+                    DSAParameters dsaParameters = default;
 
                     if (bVersion > 2)
                     {
index 15f8ca7..8fb0ca3 100644 (file)
@@ -178,7 +178,7 @@ namespace Internal.NativeCrypto
 
                 uint expAsDword = br.ReadUInt32();
 
-                RSAParameters rsaParameters = new RSAParameters();
+                RSAParameters rsaParameters = default;
                 rsaParameters.Exponent = ExponentAsBytes(expAsDword);
                 rsaParameters.Modulus = br.ReadReversed(modulusLength);
                 if (includePrivateParameters)
index a9d15ea..b31bd55 100644 (file)
@@ -109,7 +109,7 @@ namespace Internal.Cryptography.Pal.AnyOS
             CmsRecipient recipient,
             out bool v0Recipient)
         {
-            KeyTransRecipientInfoAsn ktri = new KeyTransRecipientInfoAsn();
+            KeyTransRecipientInfoAsn ktri = default;
 
             if (recipient.RecipientIdentifierType == SubjectIdentifierType.SubjectKeyIdentifier)
             {
index 18f1ca9..6f35e2c 100644 (file)
@@ -127,7 +127,7 @@ namespace System.Security.Cryptography.Pkcs
             hasher.AppendData(data.Span);
             byte[] dataHash = hasher.GetHashAndReset();
 
-            SignerInfoAsn newSignerInfo = new SignerInfoAsn();
+            SignerInfoAsn newSignerInfo = default;
             newSignerInfo.DigestAlgorithm.Algorithm = DigestAlgorithm;
 
             // If the user specified attributes (not null, count > 0) we need attributes.
@@ -163,7 +163,7 @@ namespace System.Security.Cryptography.Pkcs
                 }
 
                 // Use the serializer/deserializer to DER-normalize the attribute order.
-                SignedAttributesSet signedAttrsSet = new SignedAttributesSet();
+                SignedAttributesSet signedAttrsSet = default;
                 signedAttrsSet.SignedAttributes = PkcsHelpers.NormalizeAttributeSet(
                     signedAttrs.ToArray(),
                     normalized => hasher.AppendData(normalized));
index 383bd37..e88618e 100644 (file)
@@ -69,7 +69,7 @@ namespace Internal.Cryptography.Pal
             bool hasPathLengthConstraint,
             int pathLengthConstraint)
         {
-            BasicConstraintsAsn constraints = new BasicConstraintsAsn();
+            BasicConstraintsAsn constraints = default;
 
             constraints.CA = certificateAuthority;
             if (hasPathLengthConstraint)
@@ -194,7 +194,7 @@ namespace Internal.Cryptography.Pal
             // The CapiSha1 value is the SHA-1 of the SubjectPublicKeyInfo field, inclusive
             // of the DER structural bytes.
 
-            SubjectPublicKeyInfoAsn spki = new SubjectPublicKeyInfoAsn();
+            SubjectPublicKeyInfoAsn spki = default;
             spki.Algorithm = new AlgorithmIdentifierAsn { Algorithm = key.Oid, Parameters = key.EncodedParameters.RawData };
             spki.SubjectPublicKey = key.EncodedKeyValue.RawData;
 
index f5a64f1..545d28d 100644 (file)
@@ -342,7 +342,7 @@ namespace Internal.Cryptography.Pal
             // check to see if we can figure out what key number it needs to re-open.
             int keySpec = GuessKeySpec(provider, keyName, machineKey, cngKey.AlgorithmGroup);
 
-            CRYPT_KEY_PROV_INFO keyProvInfo = new CRYPT_KEY_PROV_INFO();
+            CRYPT_KEY_PROV_INFO keyProvInfo = default;
 
             fixed (char* keyNamePtr = cngKey.KeyName)
             fixed (char* provNamePtr = cngKey.Provider.Provider)
@@ -529,7 +529,7 @@ namespace Internal.Cryptography.Pal
 
             // Make a new pal from bytes.
             CertificatePal pal = (CertificatePal)FromBlob(RawData, SafePasswordHandle.InvalidHandle, X509KeyStorageFlags.PersistKeySet);
-            CRYPT_KEY_PROV_INFO keyProvInfo = new CRYPT_KEY_PROV_INFO();
+            CRYPT_KEY_PROV_INFO keyProvInfo = default;
 
             fixed (char* keyName = keyContainerInfo.KeyContainerName)
             fixed (char* provName = keyContainerInfo.ProviderName)
index 87803da..dd8ff76 100644 (file)
@@ -148,7 +148,7 @@ namespace Internal.Cryptography.Pal
                     int cbData = 0;
                     if (!Interop.crypt32.CertGetCertificateContextProperty(_certContext, CertContextPropId.CERT_PUBKEY_ALG_PARA_PROP_ID, null, ref cbData))
                     {
-                        CERT_CHAIN_PARA chainPara = new CERT_CHAIN_PARA();
+                        CERT_CHAIN_PARA chainPara = default;
                         chainPara.cbSize = sizeof(CERT_CHAIN_PARA);
                         if (!Interop.crypt32.CertGetCertificateChain((IntPtr)ChainEngine.HCCE_CURRENT_USER, _certContext, (FILETIME*)null, SafeCertStoreHandle.InvalidHandle, ref chainPara, CertChainFlags.None, IntPtr.Zero, out certChainContext))
                             throw Marshal.GetHRForLastWin32Error().ToCryptographicException();
index 2136de8..6ccb01b 100644 (file)
@@ -45,7 +45,7 @@ namespace Internal.Cryptography.Pal
                 using (SafeChainEngineHandle storeHandle = GetChainEngine(trustMode, customTrustStore, useMachineContext))
                 using (SafeCertStoreHandle extraStoreHandle = ConvertStoreToSafeHandle(extraStore))
                 {
-                    CERT_CHAIN_PARA chainPara = new CERT_CHAIN_PARA();
+                    CERT_CHAIN_PARA chainPara = default;
                     chainPara.cbSize = Marshal.SizeOf<CERT_CHAIN_PARA>();
 
                     int applicationPolicyCount;
@@ -96,7 +96,7 @@ namespace Internal.Cryptography.Pal
                 // Need to get a valid SafeCertStoreHandle otherwise the default stores will be trusted
                 using (SafeCertStoreHandle customTrustStoreHandle = ConvertStoreToSafeHandle(customTrustStore, true))
                 {
-                    CERT_CHAIN_ENGINE_CONFIG customChainEngine = new CERT_CHAIN_ENGINE_CONFIG();
+                    CERT_CHAIN_ENGINE_CONFIG customChainEngine = default;
                     customChainEngine.cbSize = Marshal.SizeOf<CERT_CHAIN_ENGINE_CONFIG>();
                     customChainEngine.hExclusiveRoot = customTrustStoreHandle.DangerousGetHandle();
                     chainEngineHandle = Interop.crypt32.CertCreateCertificateChainEngine(ref customChainEngine);
index 1c1a3ba..24d535c 100644 (file)
@@ -37,11 +37,11 @@ namespace Internal.Cryptography.Pal
 
             unsafe
             {
-                CERT_CHAIN_POLICY_PARA para = new CERT_CHAIN_POLICY_PARA();
+                CERT_CHAIN_POLICY_PARA para = default;
                 para.cbSize = sizeof(CERT_CHAIN_POLICY_PARA);
                 para.dwFlags = (int)flags;
 
-                CERT_CHAIN_POLICY_STATUS status = new CERT_CHAIN_POLICY_STATUS();
+                CERT_CHAIN_POLICY_STATUS status = default;
                 status.cbSize = sizeof(CERT_CHAIN_POLICY_STATUS);
 
                 if (!Interop.crypt32.CertVerifyCertificateChainPolicy(ChainPolicy.CERT_CHAIN_POLICY_BASE, _chain, ref para, ref status))
index 081a66b..a68d931 100644 (file)
@@ -84,7 +84,7 @@ namespace Internal.Cryptography.Pal
                 {
                     blobFormat = CngKeyBlobFormat.EccPublicBlob;
                     keyBlob = ExportKeyBlob(bCryptKeyHandle, blobFormat);
-                    ECParameters ecparams = new ECParameters();
+                    ECParameters ecparams = default;
                     ExportNamedCurveParameters(ref ecparams, keyBlob, false);
                     ecparams.Curve = ECCurve.CreateFromFriendlyName(curveName);
                     ecdsa = new ECDsaCng();
index 522a1fa..9088a67 100644 (file)
@@ -53,7 +53,7 @@ namespace System.Security.Cryptography.X509Certificates
                 Helpers.ValidateDer(signatureAlgorithmAsn.Parameters.Value);
             }
 
-            SubjectPublicKeyInfoAsn spki = new SubjectPublicKeyInfoAsn();
+            SubjectPublicKeyInfoAsn spki = default;
             spki.Algorithm = new AlgorithmIdentifierAsn { Algorithm = PublicKey.Oid, Parameters = PublicKey.EncodedParameters.RawData };
             spki.SubjectPublicKey = PublicKey.EncodedKeyValue.RawData;
 
index 524a3e7..49154ee 100644 (file)
@@ -42,7 +42,7 @@ namespace System.Security.Principal
         {
             SafeLsaPolicyHandle policyHandle;
 
-            var attributes = new Interop.OBJECT_ATTRIBUTES();
+            Interop.OBJECT_ATTRIBUTES attributes = default;
             uint error = Interop.Advapi32.LsaOpenPolicy(systemName, ref attributes, (int)rights, out policyHandle);
             if (error == 0)
             {
index 3a28dfe..b45e196 100644 (file)
@@ -10,7 +10,7 @@ namespace System.ServiceModel.Syndication
 {
     public abstract class CategoriesDocument : IExtensibleSyndicationObject
     {
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
 
         internal CategoriesDocument()
         {
index 4028b02..df0b982 100644 (file)
@@ -13,7 +13,7 @@ namespace System.ServiceModel.Syndication
         private static IEnumerable<string> s_singleEmptyAccept;
         private Collection<string> _accepts;
         private Collection<CategoriesDocument> _categories;
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
 
         public ResourceCollectionInfo()
         {
index 689b6ab..98ea4d9 100644 (file)
@@ -10,7 +10,7 @@ namespace System.ServiceModel.Syndication
 {
     public class ServiceDocument : IExtensibleSyndicationObject
     {
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
         private Collection<Workspace> _workspaces;
 
         public ServiceDocument() : this(null)
index f64311e..8f5ae3d 100644 (file)
@@ -10,7 +10,7 @@ namespace System.ServiceModel.Syndication
     // NOTE: This class implements Clone so if you add any members, please update the copy ctor
     public class SyndicationCategory : IExtensibleSyndicationObject
     {
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
 
         public SyndicationCategory() : this((string)null)
         {
index f5eada8..112a487 100644 (file)
@@ -21,7 +21,7 @@ namespace System.ServiceModel.Syndication
         private Collection<SyndicationPerson> _authors;
         private Collection<SyndicationCategory> _categories;
         private Collection<SyndicationPerson> _contributors;
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
         private IEnumerable<SyndicationItem> _items;
         private DateTimeOffset _lastUpdatedTime;
         private Collection<SyndicationLink> _links;
index 3eded60..e860683 100644 (file)
@@ -15,7 +15,7 @@ namespace System.ServiceModel.Syndication
         private Collection<SyndicationPerson> _authors;
         private Collection<SyndicationCategory> _categories;
         private Collection<SyndicationPerson> _contributors;
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
         private DateTimeOffset _lastUpdatedTime;
         private Collection<SyndicationLink> _links;
         private DateTimeOffset _publishDate;
index 861aa6a..4a35271 100644 (file)
@@ -10,7 +10,7 @@ namespace System.ServiceModel.Syndication
     // NOTE: This class implements Clone so if you add any members, please update the copy ctor
     public class SyndicationLink : IExtensibleSyndicationObject
     {
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
         private long _length;
 
         public SyndicationLink(Uri uri) : this(uri, null, null, null, 0)
index 8845b27..53b37f1 100644 (file)
@@ -11,7 +11,7 @@ namespace System.ServiceModel.Syndication
     // NOTE: This class implements Clone so if you add any members, please update the copy ctor
     public class SyndicationPerson : IExtensibleSyndicationObject
     {
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
 
         public SyndicationPerson() : this((string)null)
         {
index 56a7e5c..0b42f19 100644 (file)
@@ -11,7 +11,7 @@ namespace System.ServiceModel.Syndication
     public class Workspace : IExtensibleSyndicationObject
     {
         private Collection<ResourceCollectionInfo> _collections;
-        private ExtensibleSyndicationObject _extensions = new ExtensibleSyndicationObject();
+        private ExtensibleSyndicationObject _extensions;
 
         public Workspace()
         {
index 4120427..72f07e9 100644 (file)
@@ -23,7 +23,7 @@ namespace System.ServiceProcess
     /// </devdoc>
     public class ServiceBase : Component
     {
-        private SERVICE_STATUS _status = new SERVICE_STATUS();
+        private SERVICE_STATUS _status;
         private IntPtr _statusHandle;
         private ServiceControlCallbackEx _commandCallbackEx;
         private ServiceMainCallback _mainCallback;
index d4a7acf..e635a9c 100644 (file)
@@ -464,7 +464,7 @@ namespace System.ServiceProcess
             {
                 using (var serviceHandle = GetServiceHandle(Interop.Advapi32.ServiceOptions.SERVICE_QUERY_STATUS))
                 {
-                    Interop.Advapi32.SERVICE_STATUS svcStatus = new Interop.Advapi32.SERVICE_STATUS();
+                    Interop.Advapi32.SERVICE_STATUS svcStatus = default;
                     bool success = Interop.Advapi32.QueryServiceStatus(serviceHandle, &svcStatus);
                     if (!success)
                         throw new Win32Exception(Marshal.GetLastWin32Error());
@@ -750,7 +750,7 @@ namespace System.ServiceProcess
         {
             using (var serviceHandle = GetServiceHandle(Interop.Advapi32.ServiceOptions.SERVICE_PAUSE_CONTINUE))
             {
-                Interop.Advapi32.SERVICE_STATUS status = new Interop.Advapi32.SERVICE_STATUS();
+                Interop.Advapi32.SERVICE_STATUS status = default;
                 bool result = Interop.Advapi32.ControlService(serviceHandle, Interop.Advapi32.ControlOptions.CONTROL_PAUSE, &status);
                 if (!result)
                 {
@@ -765,7 +765,7 @@ namespace System.ServiceProcess
         {
             using (var serviceHandle = GetServiceHandle(Interop.Advapi32.ServiceOptions.SERVICE_PAUSE_CONTINUE))
             {
-                Interop.Advapi32.SERVICE_STATUS status = new Interop.Advapi32.SERVICE_STATUS();
+                Interop.Advapi32.SERVICE_STATUS status = default;
                 bool result = Interop.Advapi32.ControlService(serviceHandle, Interop.Advapi32.ControlOptions.CONTROL_CONTINUE, &status);
                 if (!result)
                 {
@@ -779,7 +779,7 @@ namespace System.ServiceProcess
         {
             using (var serviceHandle = GetServiceHandle(Interop.Advapi32.ServiceOptions.SERVICE_USER_DEFINED_CONTROL))
             {
-                Interop.Advapi32.SERVICE_STATUS status = new Interop.Advapi32.SERVICE_STATUS();
+                Interop.Advapi32.SERVICE_STATUS status = default;
                 bool result = Interop.Advapi32.ControlService(serviceHandle, command, &status);
                 if (!result)
                 {
@@ -831,7 +831,7 @@ namespace System.ServiceProcess
                     throw;
                 }
 
-                GCHandle argPtrsHandle = new GCHandle();
+                GCHandle argPtrsHandle = default;
                 try
                 {
                     argPtrsHandle = GCHandle.Alloc(argPtrs, GCHandleType.Pinned);
@@ -872,7 +872,7 @@ namespace System.ServiceProcess
                     }
                 }
 
-                Interop.Advapi32.SERVICE_STATUS status = new Interop.Advapi32.SERVICE_STATUS();
+                Interop.Advapi32.SERVICE_STATUS status = default;
                 bool result = Interop.Advapi32.ControlService(serviceHandle, Interop.Advapi32.ControlOptions.CONTROL_STOP, &status);
                 if (!result)
                 {
index 7992063..71ec914 100644 (file)
@@ -178,10 +178,11 @@ namespace System.Text.Json
         /// <returns>"true" if successfully parsed.</returns>
         private static bool TryParseDateTimeOffset(ReadOnlySpan<byte> source, out DateTimeParseData parseData)
         {
+            parseData = default;
+
             // Source does not have enough characters for YYYY-MM-DD
             if (source.Length < 10)
             {
-                parseData = default;
                 return false;
             }
 
@@ -197,8 +198,6 @@ namespace System.Text.Json
             // just [year]["-"][month] (a) and just [year] (b), but we currently
             // don't permit it.
 
-            parseData = new DateTimeParseData();
-
             {
                 uint digit1 = source[0] - (uint)'0';
                 uint digit2 = source[1] - (uint)'0';
index 802fca0..b4058ec 100644 (file)
@@ -235,7 +235,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
                 //current head is empty and it is NOT the last segment,
                 //it means another thread is growing new segment
                 {
-                    SpinWait spin = new SpinWait();
+                    SpinWait spin = default;
                     while (head.IsEmpty)
                     {
                         if (head.Next == null)
@@ -319,7 +319,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
             tail = _tail;
             headLow = head.Low;
             tailHigh = tail.High;
-            SpinWait spin = new SpinWait();
+            SpinWait spin = default;
 
             //we loop until the observed values are stable and sensible.
             //This ensures that any update order by other methods can be tolerated.
@@ -456,7 +456,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
         {
             try
             {
-                SpinWait spin = new SpinWait();
+                SpinWait spin = default;
 
                 if (head == tail)
                 {
@@ -534,7 +534,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
         /// </param>
         public void Enqueue(T item)
         {
-            SpinWait spin = new SpinWait();
+            SpinWait spin = default;
             while (true)
             {
                 Segment tail = _tail;
@@ -779,7 +779,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
             /// <returns>return false only if the current segment is empty</returns>
             internal bool TryRemove(out T result)
             {
-                SpinWait spin = new SpinWait();
+                SpinWait spin = default;
                 int lowLocal = Low, highLocal = High;
                 while (lowLocal <= highLocal)
                 {
@@ -788,7 +788,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
                     {
                         //if the specified value is not available (this spot is taken by a push operation,
                         // but the value is not written into yet), then spin
-                        SpinWait spinLocal = new SpinWait();
+                        SpinWait spinLocal = default;
                         while (!_state[lowLocal]._value)
                         {
                             spinLocal.SpinOnce();
@@ -814,7 +814,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
                             //while the *current* thread is doing *this* Dequeue operation, and finds that it needs to
                             //dispose the current (and ONLY) segment. Then we need to wait till thread A finishes its
                             //Grow operation, this is the reason of having the following while loop
-                            spinLocal = new SpinWait();
+                            spinLocal = default;
                             while (_next == null)
                             {
                                 spinLocal.SpinOnce();
@@ -847,7 +847,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
                 int lowLocal = Low;
                 if (lowLocal > High)
                     return false;
-                SpinWait spin = new SpinWait();
+                SpinWait spin = default;
                 while (!_state[lowLocal]._value)
                 {
                     spin.SpinOnce();
@@ -866,7 +866,7 @@ namespace System.Threading.Tasks.Dataflow.Internal.Collections
             {
                 for (int i = start; i <= end; i++)
                 {
-                    SpinWait spin = new SpinWait();
+                    SpinWait spin = default;
                     while (!_state[i]._value)
                     {
                         spin.SpinOnce();
index dba1146..6f966cb 100644 (file)
@@ -1021,7 +1021,7 @@ namespace System.Threading.Tasks
                 "thread local functions should only be supplied for loops w/ thread local bodies");
 
             // Instantiate our result.  Specifics will be filled in later.
-            ParallelLoopResult result = new ParallelLoopResult();
+            ParallelLoopResult result = default;
 
             // We just return immediately if 'to' is smaller (or equal to) 'from'.
             if (toExclusive <= fromInclusive)
@@ -1282,7 +1282,7 @@ namespace System.Threading.Tasks
                 "thread local functions should only be supplied for loops w/ thread local bodies");
 
             // Instantiate our result.  Specifics will be filled in later.
-            ParallelLoopResult result = new ParallelLoopResult();
+            ParallelLoopResult result = default;
 
             // We just return immediately if 'to' is smaller (or equal to) 'from'.
             if (toExclusive <= fromInclusive)
@@ -3101,7 +3101,7 @@ namespace System.Threading.Tasks
             ParallelLoopStateFlags64 sharedPStateFlags = new ParallelLoopStateFlags64();
 
             // Instantiate our result.  Specifics will be filled in later.
-            ParallelLoopResult result = new ParallelLoopResult();
+            ParallelLoopResult result = default;
 
             // Keep track of any cancellations
             OperationCanceledException? oce = null;
index 50eb53e..44c3b1e 100644 (file)
@@ -208,7 +208,7 @@ namespace System.Threading.Tasks
             int oldLBI = pflags._lowestBreakIteration;
             if (iteration < oldLBI)
             {
-                SpinWait wait = new SpinWait();
+                SpinWait wait = default;
                 while (Interlocked.CompareExchange(
                     ref pflags._lowestBreakIteration,
                         iteration,
@@ -249,7 +249,7 @@ namespace System.Threading.Tasks
             long oldLBI = pflags.LowestBreakIteration;
             if (iteration < oldLBI)
             {
-                SpinWait wait = new SpinWait();
+                SpinWait wait = default;
                 while (Interlocked.CompareExchange(
                     ref pflags._lowestBreakIteration,
                         iteration,
@@ -419,7 +419,7 @@ namespace System.Threading.Tasks
 
         internal bool AtomicLoopStateUpdate(int newState, int illegalStates, ref int oldState)
         {
-            SpinWait sw = new SpinWait();
+            SpinWait sw = default;
 
             do
             {
index ddd16b5..82a2a15 100644 (file)
@@ -334,7 +334,7 @@ namespace System.Threading
                 throw new InvalidOperationException(SR.Barrier_InvalidOperation_CalledFromPHA);
             }
 
-            SpinWait spinner = new SpinWait();
+            SpinWait spinner = default;
             long newPhase = 0;
             while (true)
             {
@@ -435,7 +435,7 @@ namespace System.Threading
                 throw new InvalidOperationException(SR.Barrier_InvalidOperation_CalledFromPHA);
             }
 
-            SpinWait spinner = new SpinWait();
+            SpinWait spinner = default;
             while (true)
             {
                 int currentTotal = _currentTotalCount;
@@ -486,7 +486,7 @@ namespace System.Threading
         /// disposed.</exception>
         public void SignalAndWait()
         {
-            SignalAndWait(new CancellationToken());
+            SignalAndWait(CancellationToken.None);
         }
 
         /// <summary>
@@ -535,7 +535,7 @@ namespace System.Threading
         /// disposed.</exception>
         public bool SignalAndWait(TimeSpan timeout)
         {
-            return SignalAndWait(timeout, new CancellationToken());
+            return SignalAndWait(timeout, CancellationToken.None);
         }
 
         /// <summary>
@@ -589,7 +589,7 @@ namespace System.Threading
         /// disposed.</exception>
         public bool SignalAndWait(int millisecondsTimeout)
         {
-            return SignalAndWait(millisecondsTimeout, new CancellationToken());
+            return SignalAndWait(millisecondsTimeout, CancellationToken.None);
         }
 
         /// <summary>
@@ -637,7 +637,7 @@ namespace System.Threading
             int current;
             int currentTotal;
             long phase;
-            SpinWait spinner = new SpinWait();
+            SpinWait spinner = default;
             while (true)
             {
                 currentTotal = _currentTotalCount;
@@ -838,7 +838,7 @@ namespace System.Threading
             //1- The event is set
             //2- the phase count is incremented more than one time, this means the next phase is finished as well,
             //but the event will be reset again, so we check the phase count instead
-            SpinWait spinner = new SpinWait();
+            SpinWait spinner = default;
             while (!currentPhaseEvent.IsSet && CurrentPhaseNumber - observedPhase <= 1)
             {
                 spinner.SpinOnce();
index 03f5046..813306c 100644 (file)
@@ -225,7 +225,7 @@ namespace System.Threading
             Debug.Assert(_event != null);
 
             int observedCount;
-            SpinWait spin = new SpinWait();
+            SpinWait spin = default;
             while (true)
             {
                 observedCount = _currentCount;
@@ -332,7 +332,7 @@ namespace System.Threading
 
             // Loop around until we successfully increment the count.
             int observedCount;
-            SpinWait spin = new SpinWait();
+            SpinWait spin = default;
             while (true)
             {
                 observedCount = _currentCount;
@@ -417,7 +417,7 @@ namespace System.Threading
         /// disposed.</exception>
         public void Wait()
         {
-            Wait(Timeout.Infinite, new CancellationToken());
+            Wait(Timeout.Infinite, CancellationToken.None);
         }
 
 
@@ -465,7 +465,7 @@ namespace System.Threading
                 throw new ArgumentOutOfRangeException(nameof(timeout));
             }
 
-            return Wait((int)totalMilliseconds, new CancellationToken());
+            return Wait((int)totalMilliseconds, CancellationToken.None);
         }
 
         /// <summary>
@@ -512,7 +512,7 @@ namespace System.Threading
         /// disposed.</exception>
         public bool Wait(int millisecondsTimeout)
         {
-            return Wait(millisecondsTimeout, new CancellationToken());
+            return Wait(millisecondsTimeout, CancellationToken.None);
         }
 
         /// <summary>
index afd940a..57a1c63 100644 (file)
@@ -673,7 +673,7 @@ namespace System.Threading
                 throw GetInvalidTimeoutException(nameof(millisecondsTimeout));
             }
 
-            var lockCookie = new LockCookie();
+            LockCookie lockCookie = default;
             int threadID = GetCurrentThreadID();
             lockCookie._threadID = threadID;
 
@@ -876,7 +876,7 @@ namespace System.Threading
 
         public LockCookie ReleaseLock()
         {
-            var lockCookie = new LockCookie();
+            LockCookie lockCookie = default;
             int threadID = GetCurrentThreadID();
             lockCookie._threadID = threadID;
 
index ac07bcb..c5b6410 100644 (file)
@@ -11,7 +11,7 @@ namespace System.Transactions
     /// </summary>
     internal readonly struct EnlistmentTraceIdentifier : IEquatable<EnlistmentTraceIdentifier>
     {
-        public static readonly EnlistmentTraceIdentifier Empty = new EnlistmentTraceIdentifier();
+        public static readonly EnlistmentTraceIdentifier Empty = default;
 
         public EnlistmentTraceIdentifier(
             Guid resourceManagerIdentifier,
index 5ecf438..2d911c0 100644 (file)
@@ -2201,7 +2201,7 @@ namespace System.Transactions
                 }
 
                 // Just create a new transaction.
-                TransactionOptions options = new TransactionOptions();
+                TransactionOptions options = default;
 
                 options.IsolationLevel = tx._outcomeSource._isoLevel;
                 options.Timeout = newTimeout;
index 130e381..0dfd048 100644 (file)
@@ -11,7 +11,7 @@ namespace System.Transactions
     /// </summary>
     internal readonly struct TransactionTraceIdentifier : IEquatable<TransactionTraceIdentifier>
     {
-        public static readonly TransactionTraceIdentifier Empty = new TransactionTraceIdentifier();
+        public static readonly TransactionTraceIdentifier Empty = default;
 
         public TransactionTraceIdentifier(string transactionIdentifier, int cloneIdentifier)
         {
index 72ef934..aaea655 100644 (file)
@@ -37,7 +37,7 @@ namespace System.Drawing
                         culture = CultureInfo.CurrentCulture;
                     }
 
-                    ValueStringBuilder sb = new ValueStringBuilder();
+                    ValueStringBuilder sb = default;
                     sb.Append(font.Name);
                     sb.Append(culture.TextInfo.ListSeparator[0] + " ");
                     sb.Append(font.Size.ToString(culture.NumberFormat));