From ed78fadab63e6f8c4ee227521be93ec3aece1dc9 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 26 Jun 2020 07:52:35 -0400 Subject: [PATCH] Fix CA1805 for unnecessary initialization of fields (#38410) This has three primary benefits: 1. In some cases, in particular for static fields where other static fields have non-default initialization, the C# compiler can't elide the default initialization, resulting in more IL. 2. It highlights places where the field is otherwise unused and can be deleted, but where the presence of the initialization was silencing the C# compiler's warnings about the unused field. 3. It increases consistency and decreases maintenance / code size / etc. --- .../src/System/Diagnostics/Debugger.cs | 2 +- .../System/Diagnostics/StackFrameHelper.cs | 2 +- .../src/System/Reflection/Emit/ILGenerator.cs | 6 +- .../System/Reflection/Emit/MethodBuilder.cs | 4 +- .../System/Reflection/RuntimeParameterInfo.cs | 8 +-- .../src/System/Threading/Thread.CoreCLR.cs | 4 +- .../System/Threading/ThreadPool.CoreCLR.cs | 4 +- .../src/System/Variant.cs | 2 +- .../Common/src/Interop/Interop.Ldap.cs | 8 +-- .../Interop.Ssl.cs | 2 +- .../Advapi32/Interop.ENUM_SERVICE_STATUS.cs | 18 ++--- .../Interop.ENUM_SERVICE_STATUS_PROCESS.cs | 22 +++--- .../Common/src/Interop/Windows/BCrypt/Cng.cs | 2 +- .../SspiCli/SecurityPackageInfoClass.cs | 12 ++-- .../WinHttp/Interop.SafeWinHttpHandle.cs | 2 +- .../Common/src/System/CodeDom/CodeObject.cs | 2 +- .../src/System/CodeDom/CodeTypeReference.cs | 2 +- .../Data/ProviderBase/DbConnectionFactory.cs | 2 +- .../Common/src/System/Net/CookieParser.cs | 4 +- .../src/System/Net/Http/WinInetProxyHelper.cs | 2 +- .../Implementations/Mock/MockConnection.cs | 8 +-- .../Quic/Implementations/Mock/MockListener.cs | 2 +- .../Quic/Implementations/Mock/MockStream.cs | 4 +- .../MsQuic/Internal/MsQuicSession.cs | 2 +- .../Implementations/MsQuic/MsQuicStream.cs | 2 +- .../src/System/Net/NTAuthentication.Common.cs | 2 +- .../Security/Unix/SafeFreeSslCredentials.cs | 2 +- .../System/Net/WebSockets/ManagedWebSocket.cs | 12 ++-- .../InteropServices/ComEventsMethod.cs | 2 +- .../RuntimeBinder/Semantics/Conversion.cs | 2 +- .../src/CacheEntry.cs | 2 +- .../src/MemoryCache.cs | 2 +- .../src/TraceSourceLoggerProvider.cs | 2 +- .../src/Microsoft/Win32/SystemEvents.cs | 6 +- .../Microsoft/CSharp/CSharpCodeGenerator.cs | 4 +- .../Microsoft/VisualBasic/VBCodeGenerator.cs | 2 +- .../src/System/CodeDom/CodeCompileUnit.cs | 8 +-- .../src/System/CodeDom/CodeMemberEvent.cs | 2 +- .../src/System/CodeDom/CodeMemberMethod.cs | 6 +- .../src/System/CodeDom/CodeMemberProperty.cs | 2 +- .../src/System/CodeDom/CodeNamespace.cs | 2 +- .../src/System/CodeDom/CodeStatement.cs | 4 +- .../src/System/CodeDom/CodeTypeDeclaration.cs | 2 +- .../src/System/CodeDom/CodeTypeMember.cs | 6 +- .../System/CodeDom/Compiler/CodeGenerator.cs | 2 +- .../CaseInsensitiveHashCodeProvider.cs | 2 +- .../Specialized/NameObjectCollectionBase.cs | 2 +- .../Composition/Registration/ImportBuilder.cs | 2 +- .../Composition/Registration/PartBuilder.cs | 2 +- .../src/System/Threading/Lock.cs | 2 +- .../src/Microsoft/Internal/Lock.cs | 2 +- .../AttributedPartCreationInfo.cs | 4 +- .../Composition/Hosting/AggregateCatalog.cs | 2 +- .../Hosting/AggregateExportProvider.cs | 2 +- .../Composition/Hosting/ApplicationCatalog.cs | 8 +-- .../Composition/Hosting/AssemblyCatalog.cs | 6 +- .../Composition/Hosting/AtomicComposition.cs | 8 +-- .../Hosting/CatalogExportProvider.cs | 8 +-- .../ComposablePartCatalogCollection.cs | 6 +- .../Hosting/ComposablePartExportProvider.cs | 4 +- .../Hosting/CompositionContainer.cs | 2 +- .../Composition/Hosting/CompositionLock.cs | 6 +- .../Hosting/CompositionScopeDefinition.cs | 4 +- .../Composition/Hosting/CompositionService.cs | 4 +- .../Hosting/CompositionServices.cs | 4 +- .../Hosting/ExportsChangeEventArgs.cs | 2 +- .../Composition/Hosting/FilteredCatalog.cs | 2 +- .../Composition/Hosting/TypeCatalog.cs | 4 +- .../Primitives/ComposablePartCatalog.cs | 2 +- .../ContractBasedImportDefinition.cs | 4 +- .../DisposableReflectionComposablePart.cs | 2 +- .../ReflectionModel/ExportingMember.cs | 4 +- .../Composition/ReflectionModel/ImportType.cs | 2 +- .../ReflectionComposablePart.cs | 8 +-- .../Timers/TimersDescriptionAttribute.cs | 2 +- .../Convention/PartConventionBuilderOfT.cs | 4 +- .../Hosting/Util/SmallSparseInitonlyArray.cs | 2 +- .../Configuration/ApplicationSettingsBase.cs | 4 +- .../src/System/Configuration/Configuration.cs | 2 +- .../ConfigurationElementCollection.cs | 2 +- .../IntegerValidatorAttribute.cs | 2 +- .../LocalFileSettingsProvider.cs | 8 +-- .../Configuration/LongValidatorAttribute.cs | 2 +- .../Configuration/SettingValueElement.cs | 2 +- .../src/System/Configuration/SettingsBase.cs | 10 +-- .../SettingsPropertyCollection.cs | 4 +- .../Configuration/SettingsPropertyValue.cs | 6 +- .../SettingsPropertyValueCollection.cs | 6 +- .../TimeSpanValidatorAttribute.cs | 2 +- .../System/Data/Common/DBCommandBuilder.cs | 12 ++-- .../src/System/Data/Common/DataAdapter.cs | 30 ++------ .../Data/Common/DataCommonEventSource.cs | 2 +- .../src/System/Data/Common/ObjectStorage.cs | 4 +- .../src/System/Data/Common/SqlUDTStorage.cs | 4 +- .../src/System/Data/Constraint.cs | 6 +- .../src/System/Data/ConstraintCollection.cs | 2 +- .../src/System/Data/DataColumn.cs | 36 +++++----- .../src/System/Data/DataColumnCollection.cs | 4 +- .../src/System/Data/DataRelation.cs | 22 +++--- .../src/System/Data/DataRelationCollection.cs | 4 +- .../src/System/Data/DataRowCollection.cs | 2 +- .../src/System/Data/DataSet.cs | 14 ++-- .../src/System/Data/DataSysAttribute.cs | 2 +- .../src/System/Data/DataTable.cs | 45 ++++++------ .../src/System/Data/DataTableCollection.cs | 8 +-- .../src/System/Data/DataTableReader.cs | 22 +++--- .../System/Data/DataTableReaderListener.cs | 4 +- .../src/System/Data/DataView.cs | 20 +++--- .../src/System/Data/DataViewManager.cs | 2 +- .../src/System/Data/DataViewSetting.cs | 2 +- .../src/System/Data/Filter/BinaryNode.cs | 2 +- .../src/System/Data/Filter/DataExpression.cs | 10 +-- .../System/Data/Filter/ExpressionParser.cs | 16 ++--- .../src/System/Data/Filter/FunctionNode.cs | 2 +- .../src/System/Data/Filter/NameNode.cs | 3 - .../src/System/Data/ForeignKeyConstraint.cs | 10 +-- .../src/System/Data/Merger.cs | 8 +-- .../src/System/Data/RbTree.cs | 6 +- .../src/System/Data/RecordManager.cs | 2 +- .../src/System/Data/Select.cs | 6 +- .../src/System/Data/SimpleType.cs | 6 +- .../src/System/Data/SortExpressionBuilder.cs | 4 +- .../src/System/Data/UniqueConstraint.cs | 6 +- .../src/System/Data/XMLDiffLoader.cs | 4 +- .../src/System/Data/XMLSchema.cs | 10 +-- .../src/System/Data/XmlDataLoader.cs | 27 +++---- .../src/System/Data/XmlToDatasetMap.cs | 2 +- .../src/System/Data/xmlsaver.cs | 32 ++++----- .../src/System/Xml/DataPointer.cs | 2 +- .../src/System/Xml/XmlDataDocument.cs | 8 +-- .../System/Data/Common/NameValuePermission.cs | 4 +- .../Data/ProviderBase/DbConnectionPool.cs | 2 +- .../src/System/Data/Odbc/OdbcConnection.cs | 3 +- .../src/System/Data/Odbc/OdbcUtils.cs | 4 +- .../System.Data.OleDb/src/OleDbStruct.cs | 8 +-- .../Data/ProviderBase/DbConnectionFactory.cs | 2 +- .../Data/ProviderBase/DbConnectionPool.cs | 2 +- .../HttpHandlerDiagnosticListener.cs | 2 +- .../Diagnostics/EventLogEntryCollection.cs | 2 +- .../Reader/EventLogConfiguration.cs | 2 +- .../Diagnostics/Reader/EventLogQuery.cs | 4 +- .../Diagnostics/Reader/EventLogRecord.cs | 8 +-- .../Diagnostics/Reader/EventLogSession.cs | 2 +- .../Diagnostics/Reader/NativeWrapper.cs | 40 +++++------ .../Diagnostics/Reader/ProviderMetadata.cs | 20 +++--- .../Diagnostics/CounterSampleCalculator.cs | 2 +- .../System/Diagnostics/PerformanceCounter.cs | 4 +- .../Diagnostics/PerformanceCounterLib.cs | 2 +- .../Diagnostics/SharedPerformanceCounter.cs | 4 +- .../MonitoringDescriptionAttribute.cs | 2 +- .../src/System/Diagnostics/Process.Unix.cs | 2 +- .../src/System/Diagnostics/Process.cs | 2 +- .../src/System/Diagnostics/Switch.cs | 6 +- .../src/System/Diagnostics/Trace.cs | 2 +- .../src/System/Diagnostics/TraceEventCache.cs | 2 +- .../src/System/Diagnostics/TraceInternal.cs | 2 +- .../src/System/Diagnostics/TraceListener.cs | 2 +- .../src/System/Diagnostics/TraceSource.cs | 2 +- .../AccountManagement/AD/ADAMStoreCtx.cs | 4 +- .../AccountManagement/AD/ADDNLinkedAttrSet.cs | 28 ++++---- .../AccountManagement/AD/ADEntriesSet.cs | 8 +-- .../AccountManagement/AD/ADStoreCtx.cs | 22 +++--- .../AD/ADStoreCtx_LoadStore.cs | 10 +-- .../AccountManagement/AD/ADStoreCtx_Query.cs | 2 +- .../AccountManagement/AD/RangeRetriever.cs | 34 ++++----- .../AccountManagement/AD/TokenGroupsSet.cs | 4 +- .../AccountManagement/AccountInfo.cs | 22 +++--- .../AccountManagement/AdvancedFilters.cs | 24 +++---- .../AccountManagement/AuthZSet.cs | 10 +-- .../AuthenticablePrincipal.cs | 6 +- .../AccountManagement/ConfigurationHandler.cs | 2 +- .../AccountManagement/Context.cs | 14 ++-- .../AccountManagement/FindResult.cs | 2 +- .../AccountManagement/FindResultEnumerator.cs | 4 +- .../AccountManagement/Group.cs | 6 +- .../AccountManagement/NetCred.cs | 8 +-- .../AccountManagement/PasswordInfo.cs | 18 ++--- .../AccountManagement/Principal.cs | 20 +++--- .../AccountManagement/PrincipalCollection.cs | 6 +- .../PrincipalCollectionEnumerator.cs | 8 +-- .../AccountManagement/PrincipalSearcher.cs | 6 +- .../AccountManagement/QbeFilterDescription.cs | 2 +- .../AccountManagement/SAM/SAMGroupsSet.cs | 2 +- .../AccountManagement/SAM/SAMMembersSet.cs | 10 +-- .../AccountManagement/SAM/SAMQuerySet.cs | 8 +-- .../AccountManagement/SAM/SAMStoreCtx.cs | 10 +-- .../SAM/SAMStoreCtx_LoadStore.cs | 16 ++--- .../AccountManagement/StoreCtx.cs | 2 +- .../AccountManagement/TrackedCollection.cs | 2 +- .../TrackedCollectionEnumerator.cs | 10 +-- .../AccountManagement/User.cs | 12 ++-- .../AccountManagement/exceptions.cs | 6 +- .../AccountManagement/interopt.cs | 60 ++++++++-------- .../Protocols/Interop/SafeHandles.Linux.cs | 2 +- .../Protocols/Interop/SafeHandles.Windows.cs | 2 +- .../Protocols/common/DirectoryAttribute.cs | 2 +- .../Protocols/common/DirectoryControl.cs | 10 +-- .../Protocols/common/DirectoryRequest.cs | 6 +- .../Protocols/common/DirectoryResponse.cs | 2 +- .../Protocols/ldap/LdapAsyncResult.cs | 31 ++++---- .../Protocols/ldap/LdapConnection.Windows.cs | 2 +- .../Protocols/ldap/LdapDirectoryIdentifier.cs | 2 +- .../ldap/LdapPartialResultsProcessor.cs | 10 +-- .../Protocols/ldap/LdapSessionOptions.cs | 14 ++-- .../ActiveDirectory/ADAMInstance.cs | 20 +++--- .../ActiveDirectory/ADSearcher.cs | 2 +- .../ActiveDirectoryInterSiteTransport.cs | 10 +-- .../ActiveDirectoryPartition.cs | 8 +-- .../ActiveDirectoryReplicationMetaData.cs | 4 +- .../ActiveDirectorySchedule.cs | 2 +- .../ActiveDirectory/ActiveDirectorySchema.cs | 8 +-- .../ActiveDirectorySchemaClass.cs | 54 +++++++------- .../ActiveDirectorySchemaClassCollection.cs | 10 +-- .../ActiveDirectorySchemaProperty.cs | 64 ++++++++--------- ...ActiveDirectorySchemaPropertyCollection.cs | 10 +-- .../ActiveDirectory/ActiveDirectorySite.cs | 72 +++++++++---------- .../ActiveDirectorySiteCollection.cs | 6 +- .../ActiveDirectorySiteLink.cs | 12 ++-- .../ActiveDirectorySiteLinkBridge.cs | 12 ++-- .../ActiveDirectorySiteLinkCollection.cs | 6 +- .../ActiveDirectory/ActiveDirectorySubnet.cs | 12 ++-- .../ActiveDirectorySubnetCollection.cs | 8 +-- .../ActiveDirectory/ActiveDirectorySyntax.cs | 6 +- .../ActiveDirectory/ApplicationPartition.cs | 14 ++-- .../ActiveDirectory/AttributeMetaData.cs | 10 +-- .../ActiveDirectory/ConfigSet.cs | 20 +++--- .../ActiveDirectory/DirectoryContext.cs | 14 ++-- .../ActiveDirectory/DirectoryEntryManager.cs | 6 +- .../ActiveDirectory/DirectoryServer.cs | 28 ++++---- .../DirectoryServerCollection.cs | 16 ++--- .../ActiveDirectory/Domain.cs | 20 +++--- .../ActiveDirectory/DomainController.cs | 24 +++---- .../ActiveDirectory/Exception.cs | 2 +- .../ActiveDirectory/Forest.cs | 24 +++---- .../ForestTrustRelationshipInformation.cs | 2 +- .../ActiveDirectory/GlobalCatalog.cs | 4 +- .../ActiveDirectory/NativeMethods.cs | 20 +++--- .../ActiveDirectory/ReplicationConnection.cs | 46 ++++++------ .../ActiveDirectory/ReplicationCursor.cs | 8 +-- .../ReplicationCursorCollection.cs | 2 +- .../ActiveDirectory/ReplicationFailure.cs | 6 +- .../ReplicationFailureCollection.cs | 4 +- .../ActiveDirectory/ReplicationNeighbor.cs | 6 +- .../ReplicationNeighborCollection.cs | 4 +- .../ActiveDirectory/ReplicationOperation.cs | 6 +- .../ReplicationOperationCollection.cs | 4 +- .../ReplicationOperationInformation.cs | 4 +- .../TrustRelationshipInformation.cs | 6 +- .../ActiveDirectory/UnsafeNativeMethods.cs | 16 ++--- .../ActiveDirectory/Utils.cs | 2 +- .../DirectoryServices/DirectoryEntry.cs | 18 ++--- .../DirectoryServices/DirectorySearcher.cs | 26 +++---- .../DirectoryVirtualListView.cs | 10 +-- .../DirectoryServices/PropertyCollection.cs | 4 +- .../PropertyValueCollection.cs | 6 +- .../SearchResultCollection.cs | 17 ++--- .../System/Drawing/Drawing2D/CustomLineCap.cs | 2 +- .../src/System/Drawing/FontFamily.cs | 2 +- .../src/System/Drawing/Graphics.Unix.cs | 6 +- .../src/System/Drawing/Icon.Windows.cs | 2 +- .../Drawing/Imaging/MetafileHeaderEmf.cs | 2 +- .../Drawing/Imaging/MetafileHeaderWmf.cs | 2 +- .../Drawing/Internal/SystemColorTracker.cs | 2 +- .../Printing/PrintController.Windows.cs | 2 +- .../Drawing/Printing/PrintDocument.Unix.cs | 2 +- .../src/System/Drawing/SystemIcons.Windows.cs | 20 +++--- .../Drawing/ToolboxBitmapAttribute.Unix.cs | 4 +- .../src/misc/DpiHelper.cs | 6 +- .../Formats/Cbor/Reader/CborReader.String.cs | 2 +- .../System/Formats/Cbor/Reader/CborReader.cs | 12 ++-- .../Formats/Cbor/Writer/CborWriter.String.cs | 2 +- .../System/Formats/Cbor/Writer/CborWriter.cs | 20 +++--- .../Compression/DeflateManaged/InputBuffer.cs | 4 +- .../src/System/IO/FileSystemWatcher.OSX.cs | 2 +- .../src/System/IO/FileSystemWatcher.cs | 6 +- .../Win32/SafeMemoryMappedFileHandle.Unix.cs | 2 +- .../src/System/IO/Packaging/ContentType.cs | 2 +- .../Packaging/PartBasedPackageProperties.cs | 2 +- .../System/IO/Packaging/ZipStreamManager.cs | 2 +- .../src/System/IO/Ports/SerialPort.cs | 8 +-- .../src/System/IO/Ports/SerialStream.Unix.cs | 12 ++-- .../System/IO/Ports/SerialStream.Windows.cs | 12 ++-- .../src/System/IO/Ports/SerialStream.cs | 2 +- .../Interpreter/ControlFlowInstructions.cs | 2 +- .../Interpreter/InstructionList.cs | 19 +++-- .../OrderPreservingPipeliningMergeHelper.cs | 2 +- .../Binary/ConcatQueryOperator.cs | 4 +- .../QueryOperators/Binary/ZipQueryOperator.cs | 6 +- .../InlinedAggregationOperatorEnumerator.cs | 2 +- .../QueryOperators/PartitionedStreamMerger.cs | 4 +- .../QueryOperators/QueryOpeningEnumerator.cs | 2 +- .../Unary/ElementAtQueryOperator.cs | 4 +- .../Unary/IndexedSelectQueryOperator.cs | 4 +- .../Unary/IndexedWhereQueryOperator.cs | 4 +- .../Unary/SelectManyQueryOperator.cs | 4 +- .../Unary/TakeOrSkipQueryOperator.cs | 2 +- .../Unary/TakeOrSkipWhileQueryOperator.cs | 6 +- .../src/System/Linq/Parallel/Utils/Lookup.cs | 2 +- .../Linq/Parallel/Utils/PLINQETWProvider.cs | 2 +- .../Management/InteropClasses/WMIInterop.cs | 8 +-- .../System/Management/ManagementException.cs | 4 +- .../Management/ManagementObjectCollection.cs | 4 +- .../System/Management/ManagementOptions.cs | 2 +- .../src/System/Management/ManagementPath.cs | 2 +- .../src/System/Management/ManagementQuery.cs | 2 +- .../src/System/Management/ManagementScope.cs | 2 +- .../src/System/Management/Property.cs | 2 +- .../src/System/Management/WMIGenerator.cs | 10 +-- .../src/System/Management/WmiEventSink.cs | 2 +- .../System/Net/Http/WinHttpChannelBinding.cs | 4 +- .../src/System/Net/Http/WinHttpHandler.cs | 20 +++--- .../System/Net/Http/WinHttpRequestState.cs | 12 ++-- .../Net/Http/WinHttpTransportContext.cs | 2 +- .../src/System/Net/Http/DelegatingHandler.cs | 4 +- .../SocketsHttpHandler/Http2Connection.cs | 2 +- .../SocketsHttpHandler/Http3Connection.cs | 6 +- .../SocketsHttpHandler/Http3RequestStream.cs | 4 +- .../Http/SocketsHttpHandler/HttpConnection.cs | 2 +- .../HttpEnvironmentProxy.cs | 2 +- .../SocketsHttpHandler/HttpWindowsProxy.cs | 2 +- .../System/Net/Windows/AsyncRequestContext.cs | 4 +- .../Windows/HttpListenerRequest.Windows.cs | 2 +- .../Net/Windows/HttpRequestStream.Windows.cs | 2 +- .../System/Net/Windows/RequestContextBase.cs | 2 +- .../WebSocketHttpListenerDuplexStream.cs | 4 +- .../Net/Mail/AlternateViewCollection.cs | 2 +- .../src/System/Net/Mail/Attachment.cs | 2 +- .../System/Net/Mail/AttachmentCollection.cs | 2 +- .../Net/Mail/LinkedResourceCollection.cs | 2 +- .../src/System/Net/Mail/MailMessage.cs | 4 +- .../src/System/Net/Mail/SmtpConnection.cs | 1 - .../src/System/Net/Mail/SmtpTransport.cs | 2 +- .../src/System/Net/Mime/EightBitStream.cs | 2 +- .../src/System/Net/Mime/HeaderCollection.cs | 64 +---------------- .../src/System/Net/Mime/MimePart.cs | 4 +- .../src/System/Net/Mime/SmtpDateTime.cs | 2 +- .../Net/TrackingValidationObjectDictionary.cs | 2 +- .../NetworkAddressChange.Unix.cs | 2 +- .../NetworkAddressChange.Windows.cs | 14 ++-- .../Net/NetworkInformation/PhysicalAddress.cs | 2 +- .../SystemIPGlobalStatistics.cs | 2 +- .../SystemIPInterfaceProperties.cs | 4 +- .../SystemIPv4InterfaceProperties.cs | 8 +-- .../SystemNetworkInterface.cs | 4 +- .../UnixNetworkInterface.cs | 2 +- .../Net/NetworkInformation/Ping.Windows.cs | 4 +- .../src/System/Net/Cookie.cs | 10 +-- .../src/System/Net/CookieContainer.cs | 2 +- .../src/System/Net/CommandStream.cs | 2 +- .../src/System/Net/FtpControlStream.cs | 2 +- .../src/System/Net/FtpDataStream.cs | 4 +- .../src/System/Net/FtpWebRequest.cs | 4 +- .../src/System/Net/HttpWebRequest.cs | 12 ++-- .../System/Net/Security/NegotiateStream.cs | 2 +- .../src/System/Net/ServicePointManager.cs | 2 +- .../src/System/Net/Sockets/NetworkStream.cs | 2 +- .../Net/Sockets/SafeSocketHandle.Unix.cs | 2 +- .../src/System/Net/Sockets/Socket.Tasks.cs | 2 +- .../src/System/Net/Sockets/Socket.cs | 2 +- .../src/System/Net/Sockets/UDPClient.cs | 2 +- .../src/System/Net/WebClient.cs | 6 +- .../src/System/Diagnostics/DebugProvider.cs | 4 +- .../Diagnostics/Tracing/ActivityTracker.cs | 2 +- .../System/Diagnostics/Tracing/EventPipe.cs | 2 +- .../Tracing/EventPipeEventDispatcher.cs | 4 +- .../System/Diagnostics/Tracing/EventSource.cs | 6 +- .../RuntimeEventSourceHelper.Windows.cs | 8 +-- .../src/System/Globalization/Calendar.cs | 2 +- .../src/System/Globalization/CalendarData.cs | 2 +- .../Globalization/DateTimeFormatInfo.cs | 72 +++++++++---------- .../src/System/Globalization/DateTimeParse.cs | 2 +- .../Globalization/GregorianCalendarHelper.cs | 2 +- .../System/Globalization/NumberFormatInfo.cs | 10 +-- .../src/System/Globalization/TextInfo.cs | 2 +- .../System.Private.CoreLib/src/System/Guid.cs | 2 +- .../src/System/IO/FileStream.cs | 4 +- .../src/System/IO/StringWriter.cs | 2 +- .../src/System/Reflection/Assembly.cs | 2 +- .../src/System/Reflection/Emit/EventToken.cs | 2 +- .../src/System/Reflection/Emit/FieldToken.cs | 2 +- .../src/System/Reflection/Emit/MethodToken.cs | 2 +- .../System/Reflection/Emit/ParameterToken.cs | 2 +- .../System/Reflection/Emit/PropertyToken.cs | 2 +- .../System/Reflection/Emit/SignatureToken.cs | 2 +- .../src/System/Reflection/Emit/TypeToken.cs | 2 +- .../src/System/Runtime/MemoryFailPoint.cs | 4 +- .../src/System/Text/Decoder.cs | 4 +- .../System/Text/DecoderExceptionFallback.cs | 4 +- .../src/System/Text/Encoder.cs | 4 +- .../src/System/Text/EncoderFallback.cs | 4 +- .../Text/EncoderLatin1BestFitFallback.cs | 2 +- .../src/System/Text/Encoding.cs | 8 +-- .../src/System/Text/UTF32Encoding.cs | 10 +-- .../src/System/Text/UTF7Encoding.cs | 2 +- .../src/System/Text/UTF8Encoding.cs | 4 +- .../src/System/Text/UnicodeEncoding.cs | 8 +-- .../Threading/AbandonedMutexException.cs | 2 +- .../src/System/Threading/Tasks/Task.cs | 2 +- .../System/Threading/Tasks/TaskScheduler.cs | 2 +- .../src/System/Threading/ThreadLocal.cs | 2 +- .../src/System/Threading/ThreadPool.cs | 2 +- .../src/System/TimeZone.cs | 2 +- .../Serialization/CollectionDataContract.cs | 4 +- .../Runtime/Serialization/DataMember.cs | 2 +- .../Serialization/Json/JsonDataContract.cs | 2 +- .../Json/JsonFormatWriterGenerator.cs | 2 +- .../Serialization/Json/XmlJsonReader.cs | 4 +- .../Serialization/XmlFormatWriterGenerator.cs | 2 +- .../Serialization/XmlReaderDelegator.cs | 2 +- .../Serialization/XmlSerializableWriter.cs | 2 +- .../Xml/XmlDictionaryAsyncCheckWriter.cs | 2 +- .../System/Xml/XmlDictionaryReaderQuotas.cs | 2 +- .../System/Xml/Core/XmlAsyncCheckReader.cs | 2 +- .../System/Xml/Core/XmlAsyncCheckWriter.cs | 2 +- .../src/System/Xml/Core/XmlParserContext.cs | 6 +- .../src/System/Xml/Core/XmlReaderSettings.cs | 2 +- .../src/System/Xml/Core/XmlTextReaderImpl.cs | 6 +- .../System/Xml/Core/XsdValidatingReader.cs | 2 +- .../src/System/Xml/Dom/XmlElementList.cs | 2 +- .../System/Xml/Dom/XmlUnspecifiedAttribute.cs | 2 +- .../src/System/Xml/Schema/BaseProcessor.cs | 2 +- .../src/System/Xml/Schema/ConstraintStruct.cs | 8 +-- .../src/System/Xml/Schema/ContentValidator.cs | 8 +-- .../Xml/Schema/DataTypeImplementation.cs | 8 +-- .../src/System/Xml/Schema/DtdParser.cs | 20 +++--- .../src/System/Xml/Schema/Inference/Infer.cs | 2 +- .../src/System/Xml/Schema/NamespaceList.cs | 2 +- .../src/System/Xml/Schema/Parser.cs | 4 +- .../src/System/Xml/Schema/Preprocessor.cs | 4 +- .../Schema/SchemaCollectionpreProcessor.cs | 4 +- .../src/System/Xml/Schema/SchemaDeclBase.cs | 2 +- .../System/Xml/Schema/SchemaElementDecl.cs | 8 +-- .../src/System/Xml/Schema/SchemaInfo.cs | 4 +- .../src/System/Xml/Schema/XdrBuilder.cs | 2 +- .../src/System/Xml/Schema/XdrValidator.cs | 4 +- .../src/System/Xml/Schema/XmlSchema.cs | 10 +-- .../System/Xml/Schema/XmlSchemaCollection.cs | 4 +- .../src/System/Xml/Schema/XmlSchemaElement.cs | 2 +- .../Xml/Schema/XmlSchemaIdEntityConstraint.cs | 2 +- .../src/System/Xml/Schema/XmlSchemaObject.cs | 4 +- .../src/System/Xml/Schema/XmlSchemaSet.cs | 2 +- .../src/System/Xml/Schema/XsdValidator.cs | 4 +- .../System/Xml/Serialization/Compilation.cs | 4 +- .../src/System/Xml/Serialization/Mappings.cs | 12 ++-- .../src/System/Xml/Serialization/Models.cs | 4 +- .../ReflectionXmlSerializationReader.cs | 2 +- .../Xml/Serialization/SoapAttributes.cs | 2 +- .../Serialization/XmlAnyElementAttribute.cs | 2 +- .../Serialization/XmlArrayItemAttribute.cs | 2 +- .../System/Xml/Serialization/XmlAttributes.cs | 2 +- .../System/Xml/Serialization/XmlMapping.cs | 4 +- .../System/Xml/Serialization/XmlSchemas.cs | 2 +- .../XmlSerializationGeneratedCode.cs | 8 +-- .../Serialization/XmlSerializationILGen.cs | 8 +-- .../Serialization/XmlSerializationReader.cs | 4 +- .../XmlSerializationReaderILGen.cs | 2 +- .../Serialization/XmlSerializationWriter.cs | 4 +- .../System/Xml/Serialization/XmlSerializer.cs | 4 +- .../Serialization/XmlSerializerNamespaces.cs | 2 +- .../Xml/XPath/Internal/AttributeQuery.cs | 2 +- .../Xml/XPath/Internal/CacheChildrenQuery.cs | 4 +- .../Internal/DescendantoverDescendantQuery.cs | 2 +- .../src/System/Xml/XPath/Internal/Function.cs | 4 +- .../Xml/XPath/Internal/IteratorFilter.cs | 2 +- .../Xml/XPath/Internal/NodeFunctions.cs | 2 +- .../Xml/XPath/Internal/NumberFunctions.cs | 2 +- .../System/Xml/XPath/Internal/QueryBuilder.cs | 2 +- .../XPath/Internal/XPathDescendantIterator.cs | 2 +- .../System/Xml/XPath/Internal/XPathParser.cs | 2 +- .../src/System/Xml/XmlEncoding.cs | 2 +- .../src/System/Xml/XmlNamespacemanager.cs | 2 +- .../System/Xml/Xsl/IlGen/GenerateHelper.cs | 4 +- .../src/System/Xml/Xsl/IlGen/XmlILTrace.cs | 4 +- .../src/System/Xml/Xsl/XPath/XPathParser.cs | 4 +- .../src/System/Xml/Xsl/Xslt/Compiler.cs | 4 +- .../Xml/Xsl/Xslt/CompilerScopeManager.cs | 2 +- .../System/Xml/Xsl/Xslt/KeyMatchBuilder.cs | 2 +- .../System/Xml/Xsl/Xslt/OutputScopeManager.cs | 8 +-- .../System/Xml/Xsl/Xslt/QilStrConcatenator.cs | 2 +- .../src/System/Xml/Xsl/Xslt/Stylesheet.cs | 4 +- .../System/Xml/Xsl/Xslt/XPathPatternParser.cs | 2 +- .../src/System/Xml/Xsl/Xslt/XslAstAnalyzer.cs | 2 +- .../src/System/Xml/Xsl/Xslt/XsltInput.cs | 2 +- .../src/System/Xml/Xsl/Xslt/XsltLoader.cs | 2 +- .../src/System/Xml/Xsl/XsltOld/BuilderInfo.cs | 2 +- .../src/System/Xml/Xsl/XsltOld/Compiler.cs | 2 +- .../System/Xml/Xsl/XsltOld/ContainerAction.cs | 2 +- .../src/System/Xml/Xsl/XsltOld/Processor.cs | 2 +- .../System/Xml/Xsl/XsltOld/ReaderOutput.cs | 4 +- .../System/Xml/Xslt/XslCompiledTransform.cs | 10 +-- .../src/System/Xml/Xslt/XslTransform.cs | 4 +- .../src/System/Xml/Xslt/XsltArgumentList.cs | 2 +- .../Reflection/DispatchProxyGenerator.cs | 2 +- .../Utilities/FileStreamReadLightUp.cs | 2 +- .../MetadataLoadContext.CoreAssembly.cs | 2 +- .../Extensions/DeserializingResourceReader.cs | 4 +- .../Extensions/PreserializedResourceWriter.cs | 2 +- .../System/Runtime/Caching/MemoryMonitor.cs | 8 +-- .../Runtime/InteropServices/JavaScript/Map.cs | 4 +- .../RuntimeInformation.Windows.cs | 6 +- .../InteropServices/HandleCollector.cs | 2 +- .../src/System/Security/AccessControl/ACL.cs | 4 +- .../AccessControl/NativeObjectSecurity.cs | 4 +- .../Security/AccessControl/ObjectSecurity.cs | 8 +-- .../Security/AccessControl/Privilege.cs | 12 ++-- .../PrivilegeNotHeldException.cs | 2 +- .../DSACryptoServiceProvider.Windows.cs | 2 +- .../PasswordDeriveBytes.Windows.cs | 2 +- .../RC2CryptoServiceProvider.Windows.cs | 2 +- .../RSACryptoServiceProvider.Windows.cs | 2 +- .../Security/Cryptography/AsnEncodedData.cs | 2 +- .../src/System/Security/Cryptography/Oid.cs | 4 +- .../Pkcs/KeyAgreeRecipientInfo.cs | 12 ++-- .../Pkcs/KeyTransRecipientInfo.cs | 6 +- .../Cryptography/Pkcs/Pkcs9ContentType.cs | 2 +- .../Pkcs/Pkcs9DocumentDescription.cs | 2 +- .../Cryptography/Pkcs/Pkcs9DocumentName.cs | 2 +- .../Cryptography/Pkcs/Pkcs9MessageDigest.cs | 2 +- .../Cryptography/Pkcs/Pkcs9SigningTime.cs | 2 +- .../Security/Cryptography/HashAlgorithm.cs | 2 +- .../Pal.Unix/DirectoryBasedStoreProvider.cs | 2 +- .../X509Certificates/PublicKey.cs | 2 +- .../Security/Cryptography/Xml/CipherData.cs | 6 +- .../Cryptography/Xml/EncryptedReference.cs | 2 +- .../Cryptography/Xml/EncryptedType.cs | 2 +- .../Security/Cryptography/Xml/EncryptedXml.cs | 2 +- .../Cryptography/Xml/EncryptionMethod.cs | 4 +- .../Cryptography/Xml/EncryptionProperty.cs | 2 +- .../ExcAncestralNamespaceContextManager.cs | 2 +- .../Security/Cryptography/Xml/KeyInfo.cs | 2 +- .../Cryptography/Xml/KeyInfoX509Data.cs | 10 +-- .../Security/Cryptography/Xml/Reference.cs | 4 +- .../Security/Cryptography/Xml/Signature.cs | 2 +- .../Security/Cryptography/Xml/SignedInfo.cs | 6 +- .../Security/Cryptography/Xml/SignedXml.cs | 30 ++++---- .../Security/Cryptography/Xml/Transform.cs | 14 ++-- .../Xml/XmlDecryptionTransform.cs | 10 +-- .../Xml/XmlDsigBase64Transform.cs | 2 +- .../Cryptography/Xml/XmlDsigC14NTransform.cs | 2 +- .../Xml/XmlDsigEnvelopedSignatureTransform.cs | 8 +-- .../Xml/XmlDsigExcC14NTransform.cs | 2 +- .../Cryptography/Xml/XmlDsigXsltTransform.cs | 2 +- .../Cryptography/Xml/XmlLicenseTransform.cs | 6 +- .../Security/HostProtectionException.cs | 4 +- .../ServiceProcessDescriptionAttribute.cs | 2 +- .../src/System/Text/BaseCodePageEncoding.cs | 2 +- .../src/System/Text/DBCSCodePageEncoding.cs | 4 +- .../src/System/Text/DecoderBestFitFallback.cs | 4 +- .../src/System/Text/EncoderBestFitFallback.cs | 2 +- .../src/System/Text/EncodingByteBuffer.cs | 2 +- .../src/System/Text/EncodingCharBuffer.cs | 2 +- .../src/System/Text/ISCIIEncoding.cs | 18 ++--- .../Json/Serialization/JsonPropertyInfo.cs | 2 +- .../Serialization/JsonSerializerOptions.cs | 2 +- .../System/Text/RegularExpressions/Regex.cs | 2 +- .../RegexAssemblyCompiler.cs | 2 +- .../RegularExpressions/RegexLWCGCompiler.cs | 2 +- .../Threading/Channels/AsyncOperation.cs | 2 +- .../src/Base/DataflowBlockOptions.cs | 2 +- .../src/Base/DataflowLinkOptions.cs | 2 +- .../src/Internal/ReorderingBuffer.cs | 2 +- .../Threading/Tasks/ParallelLoopState.cs | 4 +- .../Transactions/CommittableTransaction.cs | 4 +- .../Transactions/Configuration/AppSettings.cs | 3 +- .../System/Transactions/EnterpriseServices.cs | 2 +- .../Transactions/InternalTransaction.cs | 8 +-- .../src/System/Transactions/Transaction.cs | 4 +- .../System/Transactions/TransactionManager.cs | 4 +- .../System/Transactions/TransactionScope.cs | 2 +- .../System/Globalization/GlobalizationMode.cs | 2 +- .../src/System/Media/SoundPlayer.cs | 22 +++--- 571 files changed, 1699 insertions(+), 1822 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs index d0b964778aaf6..8212454fa2cf6 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Debugger.cs @@ -73,7 +73,7 @@ public static extern bool IsAttached // desired events are actually reported to the debugger. // // Constant representing the default category - public static readonly string? DefaultCategory = null; + public static readonly string? DefaultCategory; // Posts a message for the attached debugger. If there is no // debugger attached, has no effect. The debugger may or may not diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs index be31abad855c3..45a6c709451de 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs @@ -43,7 +43,7 @@ private delegate void GetSourceLineInfoDelegate(Assembly? assembly, string assem int loadedPeSize, IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, out string? sourceFile, out int sourceLine, out int sourceColumn); - private static GetSourceLineInfoDelegate? s_getSourceLineInfo = null; + private static GetSourceLineInfoDelegate? s_getSourceLineInfo; [ThreadStatic] private static int t_reentrancy; diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs index 15ed61586508d..4bd2e56da2913 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs @@ -63,10 +63,10 @@ internal static T[] EnlargeArray(T[] incoming, int requiredSize) internal int m_localCount; internal SignatureHelper m_localSignature; - private int m_maxStackSize = 0; // Maximum stack size not counting the exceptions. + private int m_maxStackSize; // Maximum stack size not counting the exceptions. - private int m_maxMidStack = 0; // Maximum stack size for a given basic block. - private int m_maxMidStackCur = 0; // Running count of the maximum stack size for the current basic block. + private int m_maxMidStack; // Maximum stack size for a given basic block. + private int m_maxMidStackCur; // Running count of the maximum stack size for the current basic block. internal int CurrExcStackCount => m_currExcStackCount; diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs index 11b91310d2ef5..083df4d980f80 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs @@ -847,8 +847,8 @@ private void ParseCA(ConstructorInfo con) } } - internal bool m_canBeRuntimeImpl = false; - internal bool m_isDllImport = false; + internal bool m_canBeRuntimeImpl; + internal bool m_isDllImport; #endregion } diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs index f8a0ff0b329ce..f0e3fcef11a02 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs @@ -114,10 +114,10 @@ internal static ParameterInfo[] GetParameters( private int m_tkParamDef; private MetadataImport m_scope; private Signature? m_signature; - private volatile bool m_nameIsCached = false; - private readonly bool m_noMetadata = false; - private bool m_noDefaultValue = false; - private MethodBase? m_originalMember = null; + private volatile bool m_nameIsCached; + private readonly bool m_noMetadata; + private bool m_noDefaultValue; + private MethodBase? m_originalMember; #endregion #region Internal Properties diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs index f2d9fe66f9a53..f8e3712b5c3ae 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs @@ -15,8 +15,8 @@ internal sealed class ThreadHelper private Delegate _start; internal CultureInfo? _startCulture; internal CultureInfo? _startUICulture; - private object? _startArg = null; - private ExecutionContext? _executionContext = null; + private object? _startArg; + private ExecutionContext? _executionContext; internal ThreadHelper(Delegate start) { diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs index 8f8b1b7b7ac66..1fd02d120e1e6 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Threading/ThreadPool.CoreCLR.cs @@ -34,8 +34,8 @@ internal sealed class RegisteredWaitHandleSafe : CriticalFinalizerObject private static IntPtr InvalidHandle => new IntPtr(-1); private IntPtr registeredWaitHandle = InvalidHandle; private WaitHandle? m_internalWaitObject; - private bool bReleaseNeeded = false; - private volatile int m_lock = 0; + private bool bReleaseNeeded; + private volatile int m_lock; internal IntPtr GetHandle() => registeredWaitHandle; diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Variant.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Variant.cs index 402b993a01aac..93aa0efea64a4 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Variant.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Variant.cs @@ -104,7 +104,7 @@ internal struct Variant typeof(System.DBNull), }; - internal static readonly Variant Empty = default; + internal static readonly Variant Empty; internal static readonly Variant Missing = new Variant(Variant.CV_MISSING, Type.Missing, 0); internal static readonly Variant DBNull = new Variant(Variant.CV_NULL, System.DBNull.Value, 0); diff --git a/src/libraries/Common/src/Interop/Interop.Ldap.cs b/src/libraries/Common/src/Interop/Interop.Ldap.cs index 1c312dca820e0..94851e6bdecba 100644 --- a/src/libraries/Common/src/Interop/Interop.Ldap.cs +++ b/src/libraries/Common/src/Interop/Interop.Ldap.cs @@ -119,7 +119,7 @@ internal sealed class LDAP_TIMEVAL [StructLayout(LayoutKind.Sequential)] internal sealed class berval { - public int bv_len = 0; + public int bv_len; public IntPtr bv_val = IntPtr.Zero; public berval() { } @@ -129,8 +129,8 @@ public berval() { } internal sealed class LdapControl { public IntPtr ldctl_oid = IntPtr.Zero; - public berval ldctl_value = null; - public bool ldctl_iscritical = false; + public berval ldctl_value; + public bool ldctl_iscritical; public LdapControl() { } } @@ -161,7 +161,7 @@ internal struct SecPkgContext_IssuerListInfoEx [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal sealed class LdapMod { - public int type = 0; + public int type; public IntPtr attribute = IntPtr.Zero; public IntPtr values = IntPtr.Zero; diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs index b7edaf3919684..109bc06c5b4ec 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs @@ -223,7 +223,7 @@ internal sealed class SafeSslHandle : SafeHandle private SafeBioHandle? _readBio; private SafeBioHandle? _writeBio; private bool _isServer; - private bool _handshakeCompleted = false; + private bool _handshakeCompleted; public GCHandle AlpnHandle; diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ENUM_SERVICE_STATUS.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ENUM_SERVICE_STATUS.cs index 09f11603b6ed8..b8b78e037f518 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ENUM_SERVICE_STATUS.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ENUM_SERVICE_STATUS.cs @@ -11,15 +11,15 @@ internal partial class Advapi32 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal class ENUM_SERVICE_STATUS { - internal string? serviceName = null; - internal string? displayName = null; - internal int serviceType = 0; - internal int currentState = 0; - internal int controlsAccepted = 0; - internal int win32ExitCode = 0; - internal int serviceSpecificExitCode = 0; - internal int checkPoint = 0; - internal int waitHint = 0; + internal string? serviceName; + internal string? displayName; + internal int serviceType; + internal int currentState; + internal int controlsAccepted; + internal int win32ExitCode; + internal int serviceSpecificExitCode; + internal int checkPoint; + internal int waitHint; } } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ENUM_SERVICE_STATUS_PROCESS.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ENUM_SERVICE_STATUS_PROCESS.cs index 98b68242fc3e7..540ee83836679 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ENUM_SERVICE_STATUS_PROCESS.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ENUM_SERVICE_STATUS_PROCESS.cs @@ -11,17 +11,17 @@ internal partial class Advapi32 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal class ENUM_SERVICE_STATUS_PROCESS { - internal string? serviceName = null; - internal string? displayName = null; - internal int serviceType = 0; - internal int currentState = 0; - internal int controlsAccepted = 0; - internal int win32ExitCode = 0; - internal int serviceSpecificExitCode = 0; - internal int checkPoint = 0; - internal int waitHint = 0; - internal int processID = 0; - internal int serviceFlags = 0; + internal string? serviceName; + internal string? displayName; + internal int serviceType; + internal int currentState; + internal int controlsAccepted; + internal int win32ExitCode; + internal int serviceSpecificExitCode; + internal int checkPoint; + internal int waitHint; + internal int processID; + internal int serviceFlags; } } } diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs index bcb5bae2a13eb..18922d33de752 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs @@ -140,7 +140,7 @@ protected sealed override bool ReleaseHandle() internal sealed class SafeKeyHandle : SafeBCryptHandle { - private SafeAlgorithmHandle? _parentHandle = null; + private SafeAlgorithmHandle? _parentHandle; public void SetParentHandle(SafeAlgorithmHandle parentHandle) { diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/SecurityPackageInfoClass.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/SecurityPackageInfoClass.cs index e60c216b9b9f5..5f5ec91f61b62 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/SecurityPackageInfoClass.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/SecurityPackageInfoClass.cs @@ -11,12 +11,12 @@ namespace System.Net // _SecPkgInfoW in sspi.h. internal class SecurityPackageInfoClass { - internal int Capabilities = 0; - internal short Version = 0; - internal short RPCID = 0; - internal int MaxToken = 0; - internal string? Name = null; - internal string? Comment = null; + internal int Capabilities; + internal short Version; + internal short RPCID; + internal int MaxToken; + internal string? Name; + internal string? Comment; /* This is to support SSL with no client cert. diff --git a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.SafeWinHttpHandle.cs b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.SafeWinHttpHandle.cs index a2b2e720d3b26..00c51fba04ec5 100644 --- a/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.SafeWinHttpHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/WinHttp/Interop.SafeWinHttpHandle.cs @@ -15,7 +15,7 @@ internal partial class WinHttp { internal class SafeWinHttpHandle : SafeHandleZeroOrMinusOneIsInvalid { - private SafeWinHttpHandle? _parentHandle = null; + private SafeWinHttpHandle? _parentHandle; public SafeWinHttpHandle() : base(true) { diff --git a/src/libraries/Common/src/System/CodeDom/CodeObject.cs b/src/libraries/Common/src/System/CodeDom/CodeObject.cs index 841955ce9b36c..61b68e64092f1 100644 --- a/src/libraries/Common/src/System/CodeDom/CodeObject.cs +++ b/src/libraries/Common/src/System/CodeDom/CodeObject.cs @@ -17,7 +17,7 @@ public class CodeObject internal class CodeObject #endif { - private IDictionary _userData = null; + private IDictionary _userData; public CodeObject() { } diff --git a/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs b/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs index 2ff20b4033a99..566867fd9e5ec 100644 --- a/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs +++ b/src/libraries/Common/src/System/CodeDom/CodeTypeReference.cs @@ -32,7 +32,7 @@ internal class CodeTypeReference : CodeObject private string _baseType; private readonly bool _isInterface; private CodeTypeReferenceCollection _typeArguments; - private bool _needsFixup = false; + private bool _needsFixup; public CodeTypeReference() { diff --git a/src/libraries/Common/src/System/Data/ProviderBase/DbConnectionFactory.cs b/src/libraries/Common/src/System/Data/ProviderBase/DbConnectionFactory.cs index 197465b388e2a..af9baab64f708 100644 --- a/src/libraries/Common/src/System/Data/ProviderBase/DbConnectionFactory.cs +++ b/src/libraries/Common/src/System/Data/ProviderBase/DbConnectionFactory.cs @@ -22,7 +22,7 @@ internal abstract partial class DbConnectionFactory // s_pendingOpenNonPooled is an array of tasks used to throttle creation of non-pooled connections to // a maximum of Environment.ProcessorCount at a time. - private static uint s_pendingOpenNonPooledNext = 0; + private static uint s_pendingOpenNonPooledNext; private static readonly Task[] s_pendingOpenNonPooled = new Task[Environment.ProcessorCount]; private static Task s_completedTask; diff --git a/src/libraries/Common/src/System/Net/CookieParser.cs b/src/libraries/Common/src/System/Net/CookieParser.cs index c16c3fd39a518..359e111b76a9e 100644 --- a/src/libraries/Common/src/System/Net/CookieParser.cs +++ b/src/libraries/Common/src/System/Net/CookieParser.cs @@ -525,7 +525,7 @@ private static bool InternalSetNameMethod(Cookie cookie, string? value) return cookie.InternalSetName(value); } #else - private static Func? s_internalSetNameMethod = null; + private static Func? s_internalSetNameMethod; private static Func InternalSetNameMethod { get @@ -546,7 +546,7 @@ private static bool InternalSetNameMethod(Cookie cookie, string? value) } #endif - private static FieldInfo? s_isQuotedDomainField = null; + private static FieldInfo? s_isQuotedDomainField; private static FieldInfo IsQuotedDomainField { get diff --git a/src/libraries/Common/src/System/Net/Http/WinInetProxyHelper.cs b/src/libraries/Common/src/System/Net/Http/WinInetProxyHelper.cs index f597c7d30e083..9a3a48f01188c 100644 --- a/src/libraries/Common/src/System/Net/Http/WinInetProxyHelper.cs +++ b/src/libraries/Common/src/System/Net/Http/WinInetProxyHelper.cs @@ -17,7 +17,7 @@ internal class WinInetProxyHelper private const int RecentAutoDetectionInterval = 120_000; // 2 minutes in milliseconds. private readonly string? _autoConfigUrl, _proxy, _proxyBypass; private readonly bool _autoDetect; - private readonly bool _useProxy = false; + private readonly bool _useProxy; private bool _autoDetectionFailed; private int _lastTimeAutoDetectionFailed; // Environment.TickCount units (milliseconds). diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockConnection.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockConnection.cs index ae4040621033e..ce784c6efcaed 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockConnection.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockConnection.cs @@ -14,13 +14,13 @@ namespace System.Net.Quic.Implementations.Mock internal sealed class MockConnection : QuicConnectionProvider { private readonly bool _isClient; - private bool _disposed = false; + private bool _disposed; private IPEndPoint? _remoteEndPoint; private IPEndPoint? _localEndPoint; private object _syncObject = new object(); - private Socket? _socket = null; - private IPEndPoint? _peerListenEndPoint = null; - private TcpListener? _inboundListener = null; + private Socket? _socket; + private IPEndPoint? _peerListenEndPoint; + private TcpListener? _inboundListener; private long _nextOutboundBidirectionalStream; private long _nextOutboundUnidirectionalStream; diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockListener.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockListener.cs index 88297bdfdd517..1ac9d2a095815 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockListener.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockListener.cs @@ -13,7 +13,7 @@ namespace System.Net.Quic.Implementations.Mock { internal sealed class MockListener : QuicListenerProvider { - private bool _disposed = false; + private bool _disposed; private SslServerAuthenticationOptions? _sslOptions; private IPEndPoint _listenEndPoint; private TcpListener _tcpListener; diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockStream.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockStream.cs index f367d981bd101..6e27637e0dac5 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockStream.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/Mock/MockStream.cs @@ -13,14 +13,14 @@ namespace System.Net.Quic.Implementations.Mock { internal sealed class MockStream : QuicStreamProvider { - private bool _disposed = false; + private bool _disposed; private readonly long _streamId; private bool _canRead; private bool _canWrite; private MockConnection? _connection; - private Socket? _socket = null; + private Socket? _socket; // Constructor for outbound streams internal MockStream(MockConnection connection, long streamId, bool bidirectional) diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/MsQuic/Internal/MsQuicSession.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/MsQuic/Internal/MsQuicSession.cs index 0f19506b81a2d..6eeef6c486272 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/MsQuic/Internal/MsQuicSession.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/MsQuic/Internal/MsQuicSession.cs @@ -6,7 +6,7 @@ namespace System.Net.Quic.Implementations.MsQuic.Internal { internal sealed class MsQuicSession : IDisposable { - private bool _disposed = false; + private bool _disposed; private IntPtr _nativeObjPtr; private bool _opened; diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/MsQuic/MsQuicStream.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/MsQuic/MsQuicStream.cs index 6eed08f02de8e..6f3982491b4aa 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/MsQuic/MsQuicStream.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Quic/Implementations/MsQuic/MsQuicStream.cs @@ -61,7 +61,7 @@ internal sealed class MsQuicStream : QuicStreamProvider // Used by the class to indicate that the stream is writable. private readonly bool _canWrite; - private volatile bool _disposed = false; + private volatile bool _disposed; private List _receiveQuicBuffers = new List(); diff --git a/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs b/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs index 0149545a9ff22..290d529cef3a9 100644 --- a/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs +++ b/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs @@ -29,7 +29,7 @@ internal partial class NTAuthentication private string? _protocolName; private string? _clientSpecifiedSpn; - private ChannelBinding? _channelBinding = null; + private ChannelBinding? _channelBinding; // If set, no more calls should be made. internal bool IsCompleted => _isCompleted; diff --git a/src/libraries/Common/src/System/Net/Security/Unix/SafeFreeSslCredentials.cs b/src/libraries/Common/src/System/Net/Security/Unix/SafeFreeSslCredentials.cs index 90ee4654cebf0..26a056d189b6e 100644 --- a/src/libraries/Common/src/System/Net/Security/Unix/SafeFreeSslCredentials.cs +++ b/src/libraries/Common/src/System/Net/Security/Unix/SafeFreeSslCredentials.cs @@ -20,7 +20,7 @@ internal sealed class SafeFreeSslCredentials : SafeFreeCredentials private SafeEvpPKeyHandle? _certKeyHandle; private SslProtocols _protocols = SslProtocols.None; private EncryptionPolicy _policy; - private bool _isInvalid = false; + private bool _isInvalid; internal SafeX509Handle? CertHandle { diff --git a/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs index c5ecbe78b801d..095401251ef75 100644 --- a/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs +++ b/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -72,7 +72,7 @@ public static ManagedWebSocket CreateFromConnectedStream( /// expect to always receive unmasked payloads, whereas servers always send /// unmasked payloads and expect to always receive masked payloads. /// - private readonly bool _isServer = false; + private readonly bool _isServer; /// The agreed upon subprotocol with the server. private readonly string? _subprotocol; /// Timer used to send periodic pings to the server, at the interval specified @@ -104,9 +104,9 @@ public static ManagedWebSocket CreateFromConnectedStream( /// Whether we've ever received a close frame. private bool _receivedCloseFrame; /// The reason for the close, as sent by the server, or null if not yet closed. - private WebSocketCloseStatus? _closeStatus = null; + private WebSocketCloseStatus? _closeStatus; /// A description of the close reason as sent by the server, or null if not yet closed. - private string? _closeStatusDescription = null; + private string? _closeStatusDescription; /// /// The last header received in a ReceiveAsync. If ReceiveAsync got a header but then @@ -118,15 +118,15 @@ public static ManagedWebSocket CreateFromConnectedStream( /// private MessageHeader _lastReceiveHeader = new MessageHeader { Opcode = MessageOpcode.Text, Fin = true }; /// The offset of the next available byte in the _receiveBuffer. - private int _receiveBufferOffset = 0; + private int _receiveBufferOffset; /// The number of bytes available in the _receiveBuffer. - private int _receiveBufferCount = 0; + private int _receiveBufferCount; /// /// When dealing with partially read fragments of binary/text messages, a mask previously received may still /// apply, and the first new byte received may not correspond to the 0th position in the mask. This value is /// the next offset into the mask that should be applied. /// - private int _receivedMaskOffsetOffset = 0; + private int _receivedMaskOffsetOffset; /// /// Temporary send buffer. This should be released back to the ArrayPool once it's /// no longer needed for the current send operation. It is stored as an instance diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs b/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs index 30ad0d22d4183..54dbaf4ba3ead 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/ComEventsMethod.cs @@ -27,7 +27,7 @@ internal class ComEventsMethod /// public class DelegateWrapper { - private bool _once = false; + private bool _once; private int _expectedParamsCount; private Type?[]? _cachedTargetTypes; diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs index 3817e0bd226fb..7bfc530732cd9 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs @@ -208,7 +208,7 @@ private static bool isUserDefinedConversion(PredefinedType ptSrc, PredefinedType new byte[] /* OBJECT */ { right, right, right, right, right, right, right, right, right, right, right, right, right, right, right, same } }; #if DEBUG - private static volatile bool s_fCheckedBetter = false; + private static volatile bool s_fCheckedBetter; private void CheckBetterTable() { if (s_fCheckedBetter) diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/src/CacheEntry.cs b/src/libraries/Microsoft.Extensions.Caching.Memory/src/CacheEntry.cs index 9650030aaa7cb..2f5365ab43120 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/src/CacheEntry.cs +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/src/CacheEntry.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Caching.Memory { internal class CacheEntry : ICacheEntry { - private bool _added = false; + private bool _added; private static readonly Action ExpirationCallback = ExpirationTokensExpired; private readonly Action _notifyCacheOfExpiration; private readonly Action _notifyCacheEntryDisposed; diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs b/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs index d9eabc00dc10b..2d66e9b70d218 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs @@ -22,7 +22,7 @@ namespace Microsoft.Extensions.Caching.Memory public class MemoryCache : IMemoryCache { private readonly ConcurrentDictionary _entries; - private long _cacheSize = 0; + private long _cacheSize; private bool _disposed; private ILogger _logger; diff --git a/src/libraries/Microsoft.Extensions.Logging.TraceSource/src/TraceSourceLoggerProvider.cs b/src/libraries/Microsoft.Extensions.Logging.TraceSource/src/TraceSourceLoggerProvider.cs index 078765b7c48e6..d1a92936a80a8 100644 --- a/src/libraries/Microsoft.Extensions.Logging.TraceSource/src/TraceSourceLoggerProvider.cs +++ b/src/libraries/Microsoft.Extensions.Logging.TraceSource/src/TraceSourceLoggerProvider.cs @@ -20,7 +20,7 @@ public class TraceSourceLoggerProvider : ILoggerProvider private readonly ConcurrentDictionary _sources = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); - private bool _disposed = false; + private bool _disposed; /// /// Initializes a new instance of the class. diff --git a/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs b/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs index 06e9bff4dae87..2714b7df451f6 100644 --- a/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs +++ b/src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs @@ -28,14 +28,14 @@ public sealed class SystemEvents private static volatile Thread? s_windowThread; private static volatile ManualResetEvent? s_eventWindowReady; private static readonly Random s_randomTimerId = new Random(); - private static volatile bool s_registeredSessionNotification = false; + private static volatile bool s_registeredSessionNotification; private static volatile IntPtr s_defWindowProc; private static volatile string? s_className; // cross-thread marshaling private static volatile Queue? s_threadCallbackList; // list of Delegates - private static volatile int s_threadCallbackMessage = 0; + private static volatile int s_threadCallbackMessage; private static volatile ManualResetEvent? s_eventThreadTerminated; // Per-instance data that is isolated to the window thread. @@ -71,7 +71,7 @@ private SystemEvents() // stole from SystemInformation... if we get SystemInformation moved // to somewhere that we can use it... rip this! private static volatile IntPtr s_processWinStation = IntPtr.Zero; - private static volatile bool s_isUserInteractive = false; + private static volatile bool s_isUserInteractive; private static unsafe bool UserInteractive { get diff --git a/src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs b/src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs index 6369f87d6e104..7cc6655d042fc 100644 --- a/src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs +++ b/src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs @@ -22,7 +22,7 @@ internal sealed partial class CSharpCodeGenerator : ICodeCompiler, ICodeGenerato private CodeGeneratorOptions _options; private CodeTypeDeclaration _currentClass; private CodeTypeMember _currentMember; - private bool _inNestedBinary = false; + private bool _inNestedBinary; private readonly IDictionary _provOptions; private const int ParameterMultilineThreshold = 15; @@ -61,7 +61,7 @@ internal CSharpCodeGenerator(IDictionary providerOptions) _provOptions = providerOptions; } - private bool _generatingForLoop = false; + private bool _generatingForLoop; private string FileExtension => ".cs"; diff --git a/src/libraries/System.CodeDom/src/Microsoft/VisualBasic/VBCodeGenerator.cs b/src/libraries/System.CodeDom/src/Microsoft/VisualBasic/VBCodeGenerator.cs index 08880ebf037e0..aabef4e289ff4 100644 --- a/src/libraries/System.CodeDom/src/Microsoft/VisualBasic/VBCodeGenerator.cs +++ b/src/libraries/System.CodeDom/src/Microsoft/VisualBasic/VBCodeGenerator.cs @@ -46,7 +46,7 @@ internal sealed partial class VBCodeGenerator : CodeCompiler GeneratorSupport.GenericTypeDeclaration | GeneratorSupport.DeclareIndexerProperties; - private int _statementDepth = 0; + private int _statementDepth; private readonly IDictionary _provOptions; // This is the keyword list. To minimize search time and startup time, this is stored by length diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/CodeCompileUnit.cs b/src/libraries/System.CodeDom/src/System/CodeDom/CodeCompileUnit.cs index 71a42d8d1e111..a8382262d11ee 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/CodeCompileUnit.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/CodeCompileUnit.cs @@ -8,11 +8,11 @@ namespace System.CodeDom { public class CodeCompileUnit : CodeObject { - private StringCollection _assemblies = null; - private CodeAttributeDeclarationCollection _attributes = null; + private StringCollection _assemblies; + private CodeAttributeDeclarationCollection _attributes; - private CodeDirectiveCollection _startDirectives = null; - private CodeDirectiveCollection _endDirectives = null; + private CodeDirectiveCollection _startDirectives; + private CodeDirectiveCollection _endDirectives; public CodeCompileUnit() { } diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberEvent.cs b/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberEvent.cs index 66d1e2b298784..848ee1f5fa534 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberEvent.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberEvent.cs @@ -7,7 +7,7 @@ namespace System.CodeDom public class CodeMemberEvent : CodeTypeMember { private CodeTypeReference _type; - private CodeTypeReferenceCollection _implementationTypes = null; + private CodeTypeReferenceCollection _implementationTypes; public CodeMemberEvent() { } diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberMethod.cs b/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberMethod.cs index c35953bee713d..63b7884a7187c 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberMethod.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberMethod.cs @@ -9,11 +9,11 @@ public class CodeMemberMethod : CodeTypeMember private readonly CodeParameterDeclarationExpressionCollection _parameters = new CodeParameterDeclarationExpressionCollection(); private readonly CodeStatementCollection _statements = new CodeStatementCollection(); private CodeTypeReference _returnType; - private CodeTypeReferenceCollection _implementationTypes = null; - private CodeAttributeDeclarationCollection _returnAttributes = null; + private CodeTypeReferenceCollection _implementationTypes; + private CodeAttributeDeclarationCollection _returnAttributes; private CodeTypeParameterCollection _typeParameters; - private int _populated = 0x0; + private int _populated; private const int ParametersCollection = 0x1; private const int StatementsCollection = 0x2; private const int ImplTypesCollection = 0x4; diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberProperty.cs b/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberProperty.cs index 90f2731e14b82..2b8b9e3757b12 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberProperty.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/CodeMemberProperty.cs @@ -9,7 +9,7 @@ public class CodeMemberProperty : CodeTypeMember private CodeTypeReference _type; private bool _hasGet; private bool _hasSet; - private CodeTypeReferenceCollection _implementationTypes = null; + private CodeTypeReferenceCollection _implementationTypes; public CodeTypeReference PrivateImplementationType { get; set; } diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/CodeNamespace.cs b/src/libraries/System.CodeDom/src/System/CodeDom/CodeNamespace.cs index 54131ebbf4f07..cbc7999b8d96f 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/CodeNamespace.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/CodeNamespace.cs @@ -12,7 +12,7 @@ public class CodeNamespace : CodeObject private readonly CodeCommentStatementCollection _comments = new CodeCommentStatementCollection(); private readonly CodeTypeDeclarationCollection _classes = new CodeTypeDeclarationCollection(); - private int _populated = 0x0; + private int _populated; private const int ImportsCollection = 0x1; private const int CommentsCollection = 0x2; private const int TypesCollection = 0x4; diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/CodeStatement.cs b/src/libraries/System.CodeDom/src/System/CodeDom/CodeStatement.cs index 7d6d4cf2f9097..0f42c436d87fb 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/CodeStatement.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/CodeStatement.cs @@ -6,8 +6,8 @@ namespace System.CodeDom { public class CodeStatement : CodeObject { - private CodeDirectiveCollection _startDirectives = null; - private CodeDirectiveCollection _endDirectives = null; + private CodeDirectiveCollection _startDirectives; + private CodeDirectiveCollection _endDirectives; public CodeLinePragma LinePragma { get; set; } diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/CodeTypeDeclaration.cs b/src/libraries/System.CodeDom/src/System/CodeDom/CodeTypeDeclaration.cs index abc111464618d..319de1aea92a9 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/CodeTypeDeclaration.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/CodeTypeDeclaration.cs @@ -12,7 +12,7 @@ public class CodeTypeDeclaration : CodeTypeMember private readonly CodeTypeMemberCollection _members = new CodeTypeMemberCollection(); private bool _isEnum; private bool _isStruct; - private int _populated = 0x0; + private int _populated; private const int BaseTypesCollection = 0x1; private const int MembersCollection = 0x2; private CodeTypeParameterCollection _typeParameters; diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/CodeTypeMember.cs b/src/libraries/System.CodeDom/src/System/CodeDom/CodeTypeMember.cs index d2f062ccf7292..c2cd85d0adf2d 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/CodeTypeMember.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/CodeTypeMember.cs @@ -7,9 +7,9 @@ namespace System.CodeDom public class CodeTypeMember : CodeObject { private string _name; - private CodeAttributeDeclarationCollection _customAttributes = null; - private CodeDirectiveCollection _startDirectives = null; - private CodeDirectiveCollection _endDirectives = null; + private CodeAttributeDeclarationCollection _customAttributes; + private CodeDirectiveCollection _startDirectives; + private CodeDirectiveCollection _endDirectives; public string Name { diff --git a/src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeGenerator.cs b/src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeGenerator.cs index 04b9354d0e25d..af3965052cf3a 100644 --- a/src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeGenerator.cs +++ b/src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeGenerator.cs @@ -17,7 +17,7 @@ public abstract class CodeGenerator : ICodeGenerator private CodeTypeDeclaration _currentClass; private CodeTypeMember _currentMember; - private bool _inNestedBinary = false; + private bool _inNestedBinary; protected CodeTypeDeclaration CurrentClass => _currentClass; diff --git a/src/libraries/System.Collections.NonGeneric/src/System/Collections/CaseInsensitiveHashCodeProvider.cs b/src/libraries/System.Collections.NonGeneric/src/System/Collections/CaseInsensitiveHashCodeProvider.cs index 6470d80a1d37d..e964f66a2715e 100644 --- a/src/libraries/System.Collections.NonGeneric/src/System/Collections/CaseInsensitiveHashCodeProvider.cs +++ b/src/libraries/System.Collections.NonGeneric/src/System/Collections/CaseInsensitiveHashCodeProvider.cs @@ -13,7 +13,7 @@ namespace System.Collections [Obsolete("Please use StringComparer instead.")] public class CaseInsensitiveHashCodeProvider : IHashCodeProvider { - private static volatile CaseInsensitiveHashCodeProvider? s_invariantCaseInsensitiveHashCodeProvider = null; + private static volatile CaseInsensitiveHashCodeProvider? s_invariantCaseInsensitiveHashCodeProvider; private readonly CompareInfo _compareInfo; public CaseInsensitiveHashCodeProvider() diff --git a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs index 8d4b37f56ae9e..efd0c21a97452 100644 --- a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs +++ b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs @@ -24,7 +24,7 @@ namespace System.Collections.Specialized /// public abstract class NameObjectCollectionBase : ICollection, ISerializable, IDeserializationCallback { - private bool _readOnly = false; + private bool _readOnly; private ArrayList _entriesArray; private IEqualityComparer _keyComparer; private volatile Hashtable _entriesTable; diff --git a/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/ImportBuilder.cs b/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/ImportBuilder.cs index b9768585876ac..5728c2e6124da 100644 --- a/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/ImportBuilder.cs +++ b/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/ImportBuilder.cs @@ -13,7 +13,7 @@ public sealed class ImportBuilder private string _contractName; private Type _contractType; private bool _asMany; - private bool _asManySpecified = false; + private bool _asManySpecified; private bool _allowDefault; private bool _allowRecomposition; private CreationPolicy _requiredCreationPolicy; diff --git a/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/PartBuilder.cs b/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/PartBuilder.cs index f878f5f47a43c..f265f9404d3e4 100644 --- a/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/PartBuilder.cs +++ b/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/PartBuilder.cs @@ -15,7 +15,7 @@ public class PartBuilder private static readonly Type s_exportAttributeType = typeof(ExportAttribute); private readonly List _typeExportBuilders; private readonly List _constructorImportBuilders; - private bool _setCreationPolicy = false; + private bool _setCreationPolicy; private CreationPolicy _creationPolicy; // Metadata selection diff --git a/src/libraries/System.ComponentModel.Composition.Registration/src/System/Threading/Lock.cs b/src/libraries/System.ComponentModel.Composition.Registration/src/System/Threading/Lock.cs index a0de44438ab7f..f57acd49acc00 100644 --- a/src/libraries/System.ComponentModel.Composition.Registration/src/System/Threading/Lock.cs +++ b/src/libraries/System.ComponentModel.Composition.Registration/src/System/Threading/Lock.cs @@ -7,7 +7,7 @@ namespace System.Threading internal sealed class Lock : IDisposable { private readonly ReaderWriterLockSlim _thisLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); - private int _isDisposed = 0; + private int _isDisposed; public void EnterReadLock() { diff --git a/src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Lock.cs b/src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Lock.cs index 4589e3206ce76..131129187b387 100644 --- a/src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Lock.cs +++ b/src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Lock.cs @@ -10,7 +10,7 @@ namespace Microsoft.Internal internal sealed class Lock : IDisposable { private readonly ReaderWriterLockSlim _thisLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); - private int _isDisposed = 0; + private int _isDisposed; public void EnterReadLock() { _thisLock.EnterReadLock(); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs index 5ad1a4ec8c24f..dcaca4e402cdb 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModel/AttributedPartCreationInfo.cs @@ -17,9 +17,9 @@ namespace System.ComponentModel.Composition.AttributedModel internal class AttributedPartCreationInfo : IReflectionPartCreationInfo { private readonly Type _type; - private readonly bool _ignoreConstructorImports = false; + private readonly bool _ignoreConstructorImports; private readonly ICompositionElement? _origin; - private PartCreationPolicyAttribute? _partCreationPolicy = null; + private PartCreationPolicyAttribute? _partCreationPolicy; private ConstructorInfo? _constructor; private IEnumerable? _exports; private IEnumerable? _imports; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateCatalog.cs index 0fe41332e93f9..ab123f915caca 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateCatalog.cs @@ -20,7 +20,7 @@ namespace System.ComponentModel.Composition.Hosting public class AggregateCatalog : ComposablePartCatalog, INotifyComposablePartCatalogChanged { private readonly ComposablePartCatalogCollection _catalogs; - private volatile int _isDisposed = 0; + private volatile int _isDisposed; /// /// Initializes a new instance of the class. diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs index 2a7dd3e7d0cfd..6ddf2f3332b76 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs @@ -16,7 +16,7 @@ public class AggregateExportProvider : ExportProvider, IDisposable { private readonly ReadOnlyCollection _readOnlyProviders; private readonly ExportProvider[] _providers; - private volatile int _isDisposed = 0; + private volatile int _isDisposed; /// /// Initializes a new instance of the class. diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs index 3fc5ad7a00b29..d751fa5bdf675 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs @@ -15,11 +15,11 @@ namespace System.ComponentModel.Composition.Hosting { public partial class ApplicationCatalog : ComposablePartCatalog, ICompositionElement { - private bool _isDisposed = false; - private volatile AggregateCatalog? _innerCatalog = null; + private bool _isDisposed; + private volatile AggregateCatalog? _innerCatalog; private readonly object _thisLock = new object(); - private readonly ICompositionElement? _definitionOrigin = null; - private readonly ReflectionContext? _reflectionContext = null; + private readonly ICompositionElement? _definitionOrigin; + private readonly ReflectionContext? _reflectionContext; public ApplicationCatalog() { } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs index 563f2dcb5b68f..80215b7dae290 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs @@ -26,10 +26,10 @@ public class AssemblyCatalog : ComposablePartCatalog, ICompositionElement private readonly object _thisLock = new object(); private readonly ICompositionElement _definitionOrigin; private volatile Assembly _assembly; - private volatile ComposablePartCatalog? _innerCatalog = null; - private int _isDisposed = 0; + private volatile ComposablePartCatalog? _innerCatalog; + private int _isDisposed; - private readonly ReflectionContext? _reflectionContext = default(ReflectionContext); + private readonly ReflectionContext? _reflectionContext; /// /// Initializes a new instance of the class diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AtomicComposition.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AtomicComposition.cs index fedf72f5cb7e7..7a8742c71e8e4 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AtomicComposition.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AtomicComposition.cs @@ -37,12 +37,12 @@ public class AtomicComposition : IDisposable { private readonly AtomicComposition? _outerAtomicComposition; private KeyValuePair[]? _values; - private int _valueCount = 0; + private int _valueCount; private List? _completeActionList; private List? _revertActionList; - private bool _isDisposed = false; - private bool _isCompleted = false; - private bool _containsInnerAtomicComposition = false; + private bool _isDisposed; + private bool _isCompleted; + private bool _containsInnerAtomicComposition; public AtomicComposition() : this(null) diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CatalogExportProvider.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CatalogExportProvider.cs index c7693683c1091..599eab0f36aa4 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CatalogExportProvider.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CatalogExportProvider.cs @@ -44,9 +44,9 @@ protected override IEnumerable GetExportsCore(ImportDefinition definitio private ConditionalWeakTable>? _gcRoots; private readonly HashSet _partsToDispose = new HashSet(); private ComposablePartCatalog _catalog; - private volatile bool _isDisposed = false; - private volatile bool _isRunning = false; - private readonly bool _disableSilentRejection = false; + private volatile bool _isDisposed; + private volatile bool _isRunning; + private readonly bool _disableSilentRejection; private ExportProvider? _sourceProvider; private ImportEngine? _importEngine; private readonly CompositionOptions _compositionOptions; @@ -1051,7 +1051,7 @@ protected override bool IsMatchingDefinition(ComposablePartDefinition part, int private class CatalogPart { - private volatile bool _importsSatisfied = false; + private volatile bool _importsSatisfied; public CatalogPart(ComposablePart part) { Part = part; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartCatalogCollection.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartCatalogCollection.cs index ff38779414d2b..18f4634f5389a 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartCatalogCollection.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartCatalogCollection.cs @@ -24,9 +24,9 @@ internal class ComposablePartCatalogCollection : ICollection? _onChanged; private readonly Action? _onChanging; private List _catalogs = new List(); - private volatile bool _isCopyNeeded = false; - private volatile bool _isDisposed = false; - private bool _hasChanged = false; + private volatile bool _isCopyNeeded; + private volatile bool _isDisposed; + private bool _hasChanged; public ComposablePartCatalogCollection( IEnumerable? catalogs, diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs index 167d7cbd615f0..9ac101d182f08 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs @@ -16,8 +16,8 @@ namespace System.ComponentModel.Composition.Hosting public class ComposablePartExportProvider : ExportProvider, IDisposable { private List _parts = new List(); - private volatile bool _isDisposed = false; - private volatile bool _isRunning = false; + private volatile bool _isDisposed; + private volatile bool _isRunning; private readonly CompositionLock _lock; private ExportProvider? _sourceProvider; private ImportEngine? _importEngine; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs index b798781a98855..09e1d352d63e1 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs @@ -26,7 +26,7 @@ public partial class CompositionContainer : ExportProvider, ICompositionService, private IDisposable? _disposableAncestorExportProvider; private readonly ReadOnlyCollection _providers; - private volatile bool _isDisposed = false; + private volatile bool _isDisposed; private readonly object _lock = new object(); private static readonly ReadOnlyCollection EmptyProviders = new ReadOnlyCollection(Array.Empty()); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionLock.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionLock.cs index 0bf6c62d79b9d..24a7ca4a8b32f 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionLock.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionLock.cs @@ -23,12 +23,12 @@ namespace System.ComponentModel.Composition.Hosting internal sealed class CompositionLock : IDisposable { // narrow lock - private readonly Lock? _stateLock = null; + private readonly Lock? _stateLock; // wide lock private static readonly object _compositionLock = new object(); - private int _isDisposed = 0; - private readonly bool _isThreadSafe = false; + private int _isDisposed; + private readonly bool _isThreadSafe; private static readonly EmptyLockHolder _EmptyLockHolder = new EmptyLockHolder(); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs index b8d6b37b9f40a..594d263fbcccf 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs @@ -15,9 +15,9 @@ namespace System.ComponentModel.Composition.Hosting public class CompositionScopeDefinition : ComposablePartCatalog, INotifyComposablePartCatalogChanged { private ComposablePartCatalog? _catalog; - private IEnumerable? _publicSurface = null; + private IEnumerable? _publicSurface; private IEnumerable _children = Enumerable.Empty(); - private volatile int _isDisposed = 0; + private volatile int _isDisposed; /// /// Initializes a new instance of the class. diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionService.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionService.cs index 08b2a7bd0be6d..92ab9dd8a7050 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionService.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionService.cs @@ -15,8 +15,8 @@ namespace System.ComponentModel.Composition.Hosting /// public class CompositionService : ICompositionService, IDisposable { - private readonly CompositionContainer? _compositionContainer = null; - private readonly INotifyComposablePartCatalogChanged? _notifyCatalog = null; + private readonly CompositionContainer? _compositionContainer; + private readonly INotifyComposablePartCatalogChanged? _notifyCatalog; internal CompositionService(ComposablePartCatalog composablePartCatalog) { diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs index 8c3046711accc..688356f3d9341 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs @@ -370,8 +370,8 @@ private static bool TryContributeMetadataValue(this IDictionary private class MetadataList { - private Type? _arrayType = null; - private bool _containsNulls = false; + private Type? _arrayType; + private bool _containsNulls; private static readonly Type ObjectType = typeof(object); private static readonly Type TypeType = typeof(Type); private readonly Collection _innerList = new Collection(); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ExportsChangeEventArgs.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ExportsChangeEventArgs.cs index f57c618287a9b..171ae215c417d 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ExportsChangeEventArgs.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ExportsChangeEventArgs.cs @@ -19,7 +19,7 @@ public class ExportsChangeEventArgs : EventArgs { private readonly IEnumerable _addedExports; private readonly IEnumerable _removedExports; - private IEnumerable? _changedContractNames = null; + private IEnumerable? _changedContractNames; /// /// Initializes a new instance of the class with diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.cs index 2c7ba12c76f1d..f89d6c4b54ea8 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.cs @@ -18,7 +18,7 @@ public partial class FilteredCatalog : ComposablePartCatalog, INotifyComposableP private ComposablePartCatalog _innerCatalog; private FilteredCatalog? _complement; private readonly object _lock = new object(); - private volatile bool _isDisposed = false; + private volatile bool _isDisposed; /// /// Initializes a new instance of the class. diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/TypeCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/TypeCatalog.cs index 7e014e3a744b5..67e9b95eba7f1 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/TypeCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/TypeCatalog.cs @@ -26,9 +26,9 @@ namespace System.ComponentModel.Composition.Hosting public class TypeCatalog : ComposablePartCatalog, ICompositionElement { private readonly object _thisLock = new object(); - private Type[]? _types = null; + private Type[]? _types; private volatile List? _parts; - private volatile bool _isDisposed = false; + private volatile bool _isDisposed; private readonly ICompositionElement _definitionOrigin; private readonly Lazy>> _contractPartIndex; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartCatalog.cs index 7060c1b6e2ec0..ec08fe36dbebb 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartCatalog.cs @@ -23,7 +23,7 @@ namespace System.ComponentModel.Composition.Primitives public abstract class ComposablePartCatalog : IEnumerable, IDisposable { private bool _isDisposed; - private volatile IQueryable? _queryableParts = null; + private volatile IQueryable? _queryableParts; internal static readonly List> _EmptyExportsList = new List>(); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ContractBasedImportDefinition.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ContractBasedImportDefinition.cs index 0e2cea2a51391..7a641ef504f5c 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ContractBasedImportDefinition.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ContractBasedImportDefinition.cs @@ -25,8 +25,8 @@ public class ContractBasedImportDefinition : ImportDefinition private readonly IEnumerable> _requiredMetadata = Enumerable.Empty>(); private Expression>? _constraint; private readonly CreationPolicy _requiredCreationPolicy = CreationPolicy.Any; - private readonly string? _requiredTypeIdentity = null; - private bool _isRequiredMetadataValidated = false; + private readonly string? _requiredTypeIdentity; + private bool _isRequiredMetadataValidated; /// /// Initializes a new instance of the class. diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/DisposableReflectionComposablePart.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/DisposableReflectionComposablePart.cs index d3030dadaf10e..2e20ff41cd8ee 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/DisposableReflectionComposablePart.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/DisposableReflectionComposablePart.cs @@ -8,7 +8,7 @@ namespace System.ComponentModel.Composition.ReflectionModel { internal sealed class DisposableReflectionComposablePart : ReflectionComposablePart, IDisposable { - private volatile int _isDisposed = 0; + private volatile int _isDisposed; public DisposableReflectionComposablePart(ReflectionComposablePartDefinition definition) : base(definition) diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportingMember.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportingMember.cs index eaa450d2afdd6..4a49cb2ec0481 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportingMember.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportingMember.cs @@ -13,8 +13,8 @@ internal class ExportingMember { private readonly ExportDefinition _definition; private readonly ReflectionMember _member; - private object? _cachedValue = null; - private volatile bool _isValueCached = false; + private object? _cachedValue; + private volatile bool _isValueCached; public ExportingMember(ExportDefinition definition, ReflectionMember member) { diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs index 4c322cfcfae34..31a1779035b99 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportType.cs @@ -20,7 +20,7 @@ internal class ImportType private readonly bool _isAssignableCollectionType; private Type _contractType; private Func? _castSingleValue; - private readonly bool _isOpenGeneric = false; + private readonly bool _isOpenGeneric; [ThreadStatic] internal static Dictionary?>? _castSingleValueCache; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs index 3c227852ef3a3..7f1c0ee054831 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs @@ -17,11 +17,11 @@ namespace System.ComponentModel.Composition.ReflectionModel internal class ReflectionComposablePart : ComposablePart, ICompositionElement { private readonly ReflectionComposablePartDefinition _definition; - private volatile Dictionary? _importValues = null; - private volatile Dictionary? _importsCache = null; - private volatile Dictionary? _exportsCache = null; + private volatile Dictionary? _importValues; + private volatile Dictionary? _importsCache; + private volatile Dictionary? _exportsCache; private volatile bool _invokeImportsSatisfied = true; - private bool _initialCompositionComplete = false; + private bool _initialCompositionComplete; private volatile object? _cachedInstance; private readonly object _lock = new object(); diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/Timers/TimersDescriptionAttribute.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/Timers/TimersDescriptionAttribute.cs index c4520df8bfa98..45d3278e6f9d3 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/Timers/TimersDescriptionAttribute.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/Timers/TimersDescriptionAttribute.cs @@ -14,7 +14,7 @@ namespace System.Timers [AttributeUsage(AttributeTargets.All)] public class TimersDescriptionAttribute : DescriptionAttribute { - private bool _replaced = false; + private bool _replaced; /// /// Constructs a new sys description. diff --git a/src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilderOfT.cs b/src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilderOfT.cs index 6e4e06ac093bb..f20d512261a26 100644 --- a/src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilderOfT.cs +++ b/src/libraries/System.Composition.Convention/src/System/Composition/Convention/PartConventionBuilderOfT.cs @@ -132,8 +132,8 @@ protected static Expression> Reduce(Expression> private class ConstructorExpressionAdapter { - private ConstructorInfo _constructorInfo = null; - private Dictionary> _importBuilders = null; + private ConstructorInfo _constructorInfo; + private Dictionary> _importBuilders; public ConstructorExpressionAdapter(Expression> selectConstructor) { diff --git a/src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Util/SmallSparseInitonlyArray.cs b/src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Util/SmallSparseInitonlyArray.cs index 5fa8275b6d3d5..5ab42ee835775 100644 --- a/src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Util/SmallSparseInitonlyArray.cs +++ b/src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Util/SmallSparseInitonlyArray.cs @@ -15,7 +15,7 @@ private class Element { public int Index; public object Value; } private const int ElementIndexMask = 127; private const int LocalOffsetMax = 3; - private Element[] _elements = null; + private Element[] _elements; private SmallSparseInitonlyArray _overflow; public void Add(int index, object value) diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs index 64b519b7d5503..cc67297cab1f9 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs @@ -14,7 +14,7 @@ namespace System.Configuration /// public abstract class ApplicationSettingsBase : SettingsBase, INotifyPropertyChanged { - private bool _explicitSerializeOnClass = false; + private bool _explicitSerializeOnClass; private object[] _classAttributes; private readonly IComponent _owner; private PropertyChangedEventHandler _onPropertyChanged; @@ -27,7 +27,7 @@ public abstract class ApplicationSettingsBase : SettingsBase, INotifyPropertyCha private SettingsSavingEventHandler _onSettingsSaving; private string _settingsKey = string.Empty; private bool _firstLoad = true; - private bool _initialized = false; + private bool _initialized; /// /// Default constructor without a concept of "owner" component. diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs index 30ef519cd7457..929f5897bb74f 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs @@ -147,7 +147,7 @@ public Func AssemblyStringTransformer public FrameworkName TargetFramework { get; set; - } = null; + } internal bool TypeStringTransformerIsSet { get; private set; } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationElementCollection.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationElementCollection.cs index 64a77f00ed955..000d8cd434392 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationElementCollection.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationElementCollection.cs @@ -25,7 +25,7 @@ public abstract class ConfigurationElementCollection : ConfigurationElement, ICo private int _removedItemCount; // Number of items removed for this collection (not including parent) private string _removeElement = DefaultRemoveItemName; - internal bool InternalAddToEnd = false; + internal bool InternalAddToEnd; internal string InternalElementTagName = string.Empty; protected ConfigurationElementCollection() { } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/IntegerValidatorAttribute.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/IntegerValidatorAttribute.cs index 3c3069e47ba7d..1135e990d6602 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/IntegerValidatorAttribute.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/IntegerValidatorAttribute.cs @@ -36,6 +36,6 @@ public int MaxValue } } - public bool ExcludeRange { get; set; } = false; + public bool ExcludeRange { get; set; } } } \ No newline at end of file diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs index 8faf82e6b521a..9053a7be3a998 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs @@ -17,10 +17,10 @@ namespace System.Configuration public class LocalFileSettingsProvider : SettingsProvider, IApplicationSettingsProvider { private string _appName = string.Empty; - private ClientSettingsStore _store = null; - private string _prevLocalConfigFileName = null; - private string _prevRoamingConfigFileName = null; - private XmlEscaper _escaper = null; + private ClientSettingsStore _store; + private string _prevLocalConfigFileName; + private string _prevRoamingConfigFileName; + private XmlEscaper _escaper; /// /// Abstract SettingsProvider property. diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LongValidatorAttribute.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LongValidatorAttribute.cs index bee4661304ffd..1aca5815c53d6 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LongValidatorAttribute.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LongValidatorAttribute.cs @@ -34,6 +34,6 @@ public long MaxValue } } - public bool ExcludeRange { get; set; } = false; + public bool ExcludeRange { get; set; } } } \ No newline at end of file diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingValueElement.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingValueElement.cs index 672d6558f6036..e1571734f667c 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingValueElement.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingValueElement.cs @@ -12,7 +12,7 @@ public sealed class SettingValueElement : ConfigurationElement private static readonly XmlDocument _document = new XmlDocument(); private XmlNode _valueXml; - private bool _isModified = false; + private bool _isModified; protected internal override ConfigurationPropertyCollection Properties { diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs index b04afb370dae1..7c48b145c7f5d 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs @@ -8,11 +8,11 @@ namespace System.Configuration { public abstract class SettingsBase { - private SettingsPropertyCollection _properties = null; - private SettingsProviderCollection _providers = null; - private readonly SettingsPropertyValueCollection _propertyValues = null; - private SettingsContext _context = null; - private bool _isSynchronized = false; + private SettingsPropertyCollection _properties; + private SettingsProviderCollection _providers; + private readonly SettingsPropertyValueCollection _propertyValues; + private SettingsContext _context; + private bool _isSynchronized; protected SettingsBase() { diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyCollection.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyCollection.cs index ef473f4ea1f5c..2e478d01f3c6d 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyCollection.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyCollection.cs @@ -8,8 +8,8 @@ namespace System.Configuration { public class SettingsPropertyCollection : IEnumerable, ICloneable, ICollection { - private readonly Hashtable _hashtable = null; - private bool _readOnly = false; + private readonly Hashtable _hashtable; + private bool _readOnly; public SettingsPropertyCollection() { diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValue.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValue.cs index 8dee53d2ddd97..46118baf60d8d 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValue.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValue.cs @@ -14,9 +14,9 @@ namespace System.Configuration { public class SettingsPropertyValue { - private object _value = null; - private object _serializedValue = null; - private bool _changedSinceLastSerialized = false; + private object _value; + private object _serializedValue; + private bool _changedSinceLastSerialized; public string Name => Property.Name; public bool IsDirty { get; set; } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValueCollection.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValueCollection.cs index e0b8ead8a9ffd..ea850f0677edf 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValueCollection.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValueCollection.cs @@ -8,9 +8,9 @@ namespace System.Configuration { public class SettingsPropertyValueCollection : IEnumerable, ICloneable, ICollection { - private readonly Hashtable _indices = null; - private ArrayList _values = null; - private bool _readOnly = false; + private readonly Hashtable _indices; + private ArrayList _values; + private bool _readOnly; public SettingsPropertyValueCollection() { diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/TimeSpanValidatorAttribute.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/TimeSpanValidatorAttribute.cs index 48d6118643c81..cd67bc0da051d 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/TimeSpanValidatorAttribute.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/TimeSpanValidatorAttribute.cs @@ -47,6 +47,6 @@ public string MaxValueString } } - public bool ExcludeRange { get; set; } = false; + public bool ExcludeRange { get; set; } } } \ No newline at end of file diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs index 079451ed7a967..148ab3557e32d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs @@ -311,13 +311,13 @@ internal string GetNullParameterName(int index) private MissingMappingAction _missingMappingAction; private ConflictOption _conflictDetection = ConflictOption.CompareAllSearchableValues; - private bool _setAllValues = false; - private bool _hasPartialPrimaryKey = false; + private bool _setAllValues; + private bool _hasPartialPrimaryKey; private DataTable _dbSchemaTable; private DbSchemaRow[] _dbSchemaRows; private string[] _sourceColumnNames; - private ParameterNames _parameterNames = null; + private ParameterNames _parameterNames; private string _quotedBaseTableName; @@ -327,9 +327,9 @@ internal string GetNullParameterName(int index) private string _schemaSeparator = NameSeparator; private string _quotePrefix = string.Empty; private string _quoteSuffix = string.Empty; - private string _parameterNamePattern = null; - private string _parameterMarkerFormat = null; - private int _parameterNameMaxLength = 0; + private string _parameterNamePattern; + private string _parameterMarkerFormat; + private int _parameterNameMaxLength; protected DbCommandBuilder() : base() { diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataAdapter.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataAdapter.cs index 3a4238247559a..5dc2ed7da1bb1 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DataAdapter.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataAdapter.cs @@ -15,9 +15,9 @@ public class DataAdapter : Component, IDataAdapter private bool _acceptChangesDuringUpdate = true; private bool _acceptChangesDuringUpdateAfterInsert = true; - private bool _continueUpdateOnError = false; - private bool _hasFillErrorHandler = false; - private bool _returnProviderSpecificTypes = false; + private bool _continueUpdateOnError; + private bool _hasFillErrorHandler; + private bool _returnProviderSpecificTypes; private bool _acceptChangesDuringFill = true; private LoadOption _fillLoadOption; @@ -29,28 +29,11 @@ public class DataAdapter : Component, IDataAdapter private static int s_objectTypeCount; // Bid counter internal readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount); -#if DEBUG - // if true, we are asserting that the caller has provided a select command - // which should not return an empty result set - private readonly bool _debugHookNonEmptySelectCommand = false; -#endif - [Conditional("DEBUG")] private void AssertReaderHandleFieldCount(DataReaderContainer readerHandler) { #if DEBUG - Debug.Assert(!_debugHookNonEmptySelectCommand || readerHandler.FieldCount > 0, "Scenario expects non-empty results but no fields reported by reader"); -#endif - } - - [Conditional("DEBUG")] - private void AssertSchemaMapping(SchemaMapping mapping) - { -#if DEBUG - if (_debugHookNonEmptySelectCommand) - { - Debug.Assert(mapping != null && mapping.DataValues != null && mapping.DataTable != null, "Debug hook specifies that non-empty results are not expected"); - } + Debug.Assert(readerHandler.FieldCount > 0, "Scenario expects non-empty results but no fields reported by reader"); #endif } @@ -460,9 +443,6 @@ protected virtual int Fill(DataTable[] dataTables, IDataReader dataReader, int s if (dataReader.IsClosed) { -#if DEBUG - Debug.Assert(!_debugHookNonEmptySelectCommand, "Debug hook asserts data reader should be open"); -#endif break; } DataReaderContainer readerHandler = DataReaderContainer.Create(dataReader, ReturnProviderSpecificTypes); @@ -535,8 +515,6 @@ internal int FillFromReader(DataSet dataset, DataTable datatable, string srcTabl SchemaMapping mapping = FillMapping(dataset, datatable, srcTable, dataReader, schemaCount, parentChapterColumn, parentChapterValue); schemaCount++; // don't increment if no SchemaTable ( a non-row returning result ) - AssertSchemaMapping(mapping); - if (null == mapping) { continue; // loop to next result diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DataCommonEventSource.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DataCommonEventSource.cs index 5e81755634011..6aa603d2c08c7 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DataCommonEventSource.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DataCommonEventSource.cs @@ -11,7 +11,7 @@ namespace System.Data internal class DataCommonEventSource : EventSource { internal static readonly DataCommonEventSource Log = new DataCommonEventSource(); - private static long s_nextScopeId = 0; + private static long s_nextScopeId; private const int TraceEventId = 1; diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs index ffe4960cce7b8..106857c7dfe9d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs @@ -15,15 +15,13 @@ namespace System.Data.Common { internal sealed class ObjectStorage : DataStorage { - private static readonly object s_defaultValue = null; - private enum Families { DATETIME, NUMBER, STRING, BOOLEAN, ARRAY }; private object[] _values; private readonly bool _implementsIXmlSerializable; internal ObjectStorage(DataColumn column, Type type) - : base(column, type, s_defaultValue, DBNull.Value, typeof(ICloneable).IsAssignableFrom(type), GetStorageType(type)) + : base(column, type, null, DBNull.Value, typeof(ICloneable).IsAssignableFrom(type), GetStorageType(type)) { _implementsIXmlSerializable = typeof(IXmlSerializable).IsAssignableFrom(type); } diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs index 8d0306d266dc7..a56b4717ba28f 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs @@ -17,8 +17,8 @@ namespace System.Data.Common internal sealed class SqlUdtStorage : DataStorage { private object[] _values; - private readonly bool _implementsIXmlSerializable = false; - private readonly bool _implementsIComparable = false; + private readonly bool _implementsIXmlSerializable; + private readonly bool _implementsIComparable; private static readonly ConcurrentDictionary s_typeToNull = new ConcurrentDictionary(); diff --git a/src/libraries/System.Data.Common/src/System/Data/Constraint.cs b/src/libraries/System.Data.Common/src/System/Data/Constraint.cs index 01a30b75b282d..f3b404442f637 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Constraint.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Constraint.cs @@ -15,10 +15,10 @@ namespace System.Data public abstract class Constraint { private string _schemaName = string.Empty; - private bool _inCollection = false; - private DataSet _dataSet = null; + private bool _inCollection; + private DataSet _dataSet; internal string _name = string.Empty; - internal PropertyCollection _extendedProperties = null; + internal PropertyCollection _extendedProperties; internal Constraint() { } diff --git a/src/libraries/System.Data.Common/src/System/Data/ConstraintCollection.cs b/src/libraries/System.Data.Common/src/System/Data/ConstraintCollection.cs index c94653512d3c8..0bfa003e447a6 100644 --- a/src/libraries/System.Data.Common/src/System/Data/ConstraintCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/ConstraintCollection.cs @@ -20,7 +20,7 @@ public sealed class ConstraintCollection : InternalDataCollectionBase private CollectionChangeEventHandler _onCollectionChanged; private Constraint[] _delayLoadingConstraints; - private bool _fLoadForeignKeyConstraintsOnly = false; + private bool _fLoadForeignKeyConstraintsOnly; /// /// ConstraintCollection constructor. Used only by DataTable. diff --git a/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs b/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs index d44ec1e0b8875..be75588010f32 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataColumn.cs @@ -27,33 +27,33 @@ namespace System.Data public class DataColumn : MarshalByValueComponent { private bool _allowNull = true; - private string _caption = null; - private string _columnName = null; - private Type _dataType = null; + private string _caption; + private string _columnName; + private Type _dataType; private StorageType _storageType; internal object _defaultValue = DBNull.Value; // DefaultValue Converter private DataSetDateTime _dateTimeMode = DataSetDateTime.UnspecifiedLocal; - private DataExpression _expression = null; + private DataExpression _expression; private int _maxLength = -1; private int _ordinal = -1; - private bool _readOnly = false; - internal Index _sortIndex = null; - internal DataTable _table = null; - private bool _unique = false; + private bool _readOnly; + internal Index _sortIndex; + internal DataTable _table; + private bool _unique; internal MappingType _columnMapping = MappingType.Element; internal int _hashCode; internal int _errors; - private bool _isSqlType = false; - private bool _implementsINullable = false; - private bool _implementsIChangeTracking = false; - private bool _implementsIRevertibleChangeTracking = false; - private bool _implementsIXMLSerializable = false; + private bool _isSqlType; + private bool _implementsINullable; + private bool _implementsIChangeTracking; + private bool _implementsIRevertibleChangeTracking; + private bool _implementsIXMLSerializable; private bool _defaultValueIsNull = true; - internal List _dependentColumns = null; // list of columns whose expression consume values from this column - internal PropertyCollection _extendedProperties = null; + internal List _dependentColumns; // list of columns whose expression consume values from this column + internal PropertyCollection _extendedProperties; private DataStorage _storage; @@ -61,11 +61,11 @@ public class DataColumn : MarshalByValueComponent private AutoIncrementValue _autoInc; // The _columnClass member is the class for the unfoliated virtual nodes in the XML. - internal string _columnUri = null; + internal string _columnUri; private string _columnPrefix = string.Empty; - internal string _encodedColumnName = null; + internal string _encodedColumnName; - internal SimpleType _simpleType = null; + internal SimpleType _simpleType; private static int s_objectTypeCount; private readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs b/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs index 014ad8b400b0a..d549720ec3d19 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs @@ -27,8 +27,8 @@ public sealed class DataColumnCollection : InternalDataCollectionBase private bool _fInClear; private DataColumn[] _columnsImplementingIChangeTracking = Array.Empty(); - private int _nColumnsImplementingIChangeTracking = 0; - private int _nColumnsImplementingIRevertibleChangeTracking = 0; + private int _nColumnsImplementingIChangeTracking; + private int _nColumnsImplementingIRevertibleChangeTracking; /// /// DataColumnCollection constructor. Used only by DataTable. diff --git a/src/libraries/System.Data.Common/src/System/Data/DataRelation.cs b/src/libraries/System.Data.Common/src/System/Data/DataRelation.cs index edd7854206c88..2df029b4db65d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataRelation.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataRelation.cs @@ -34,28 +34,28 @@ namespace System.Data public class DataRelation { // properties - private DataSet _dataSet = null; - internal PropertyCollection _extendedProperties = null; + private DataSet _dataSet; + internal PropertyCollection _extendedProperties; internal string _relationName = string.Empty; // state private DataKey _childKey; private DataKey _parentKey; - private UniqueConstraint _parentKeyConstraint = null; - private ForeignKeyConstraint _childKeyConstraint = null; + private UniqueConstraint _parentKeyConstraint; + private ForeignKeyConstraint _childKeyConstraint; // Design time serialization - internal string[] _parentColumnNames = null; - internal string[] _childColumnNames = null; - internal string _parentTableName = null; - internal string _childTableName = null; - internal string _parentTableNamespace = null; - internal string _childTableNamespace = null; + internal string[] _parentColumnNames; + internal string[] _childColumnNames; + internal string _parentTableName; + internal string _childTableName; + internal string _parentTableNamespace; + internal string _childTableNamespace; /// /// This stores whether the child element appears beneath the parent in the XML persisted files. /// - internal bool _nested = false; + internal bool _nested; /// /// This stores whether the relationship should make sure that KeyConstraints and ForeignKeyConstraints diff --git a/src/libraries/System.Data.Common/src/System/Data/DataRelationCollection.cs b/src/libraries/System.Data.Common/src/System/Data/DataRelationCollection.cs index 6d06f03941362..64a08498758be 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataRelationCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataRelationCollection.cs @@ -17,7 +17,7 @@ namespace System.Data [DefaultProperty("Table")] public abstract class DataRelationCollection : InternalDataCollectionBase { - private DataRelation _inTransition = null; + private DataRelation _inTransition; private int _defaultNameIndex = 1; @@ -684,7 +684,7 @@ internal sealed class DataSetRelationCollection : DataRelationCollection { private readonly DataSet _dataSet; private readonly ArrayList _relations; - private DataRelation[] _delayLoadingRelations = null; + private DataRelation[] _delayLoadingRelations; internal DataSetRelationCollection(DataSet dataSet) { diff --git a/src/libraries/System.Data.Common/src/System/Data/DataRowCollection.cs b/src/libraries/System.Data.Common/src/System/Data/DataRowCollection.cs index 4e877e6a0d4d0..297458257965e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataRowCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataRowCollection.cs @@ -24,7 +24,7 @@ protected override int CompareSateliteTreeNode(DataRow record1, DataRow record2) private readonly DataTable _table; private readonly DataRowTree _list = new DataRowTree(); - internal int _nullInList = 0; + internal int _nullInList; /// /// Creates the DataRowCollection for the given table. diff --git a/src/libraries/System.Data.Common/src/System/Data/DataSet.cs b/src/libraries/System.Data.Common/src/System/Data/DataSet.cs index f4d6ad887d5ce..da9e198485f0a 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataSet.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataSet.cs @@ -38,7 +38,7 @@ public class DataSet : MarshalByValueComponent, IListSource, IXmlSerializable, I // Public Collections private readonly DataTableCollection _tableCollection; private readonly DataRelationCollection _relationCollection; - internal PropertyCollection _extendedProperties = null; + internal PropertyCollection _extendedProperties; private string _dataSetName = "NewDataSet"; private string _datasetPrefix = string.Empty; internal string _namespaceURI = string.Empty; @@ -50,12 +50,12 @@ public class DataSet : MarshalByValueComponent, IListSource, IXmlSerializable, I private bool _cultureUserSet; // Internal definitions - internal bool _fInReadXml = false; - internal bool _fInLoadDiffgram = false; - internal bool _fTopLevelTable = false; - internal bool _fInitInProgress = false; + internal bool _fInReadXml; + internal bool _fInLoadDiffgram; + internal bool _fTopLevelTable; + internal bool _fInitInProgress; internal bool _fEnableCascading = true; - internal bool _fIsSchemaLoading = false; + internal bool _fIsSchemaLoading; private bool _fBoundToDocument; // for XmlDataDocument internal string _mainTableName = string.Empty; @@ -67,7 +67,7 @@ public class DataSet : MarshalByValueComponent, IListSource, IXmlSerializable, I private static int s_objectTypeCount; // Bid counter private readonly int _objectID = Interlocked.Increment(ref s_objectTypeCount); - private static XmlSchemaComplexType s_schemaTypeForWSDL = null; + private static XmlSchemaComplexType s_schemaTypeForWSDL; internal bool _useDataSetSchemaOnly; // UseDataSetSchemaOnly , for YUKON internal bool _udtIsWrapped; // if UDT is wrapped , for YUKON diff --git a/src/libraries/System.Data.Common/src/System/Data/DataSysAttribute.cs b/src/libraries/System.Data.Common/src/System/Data/DataSysAttribute.cs index 67fb98e2d88d7..9e490eeecff0e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataSysAttribute.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataSysAttribute.cs @@ -15,7 +15,7 @@ namespace System.Data [Obsolete("DataSysDescriptionAttribute has been deprecated. https://go.microsoft.com/fwlink/?linkid=14202", false)] public class DataSysDescriptionAttribute : DescriptionAttribute { - private bool _replaced = false; + private bool _replaced; /// /// Constructs a new sys description. diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index 917908ec2a451..cea19a281a658 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -32,7 +32,7 @@ namespace System.Data public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializeNotification, ISerializable, IXmlSerializable { private DataSet _dataSet; - private DataView _defaultView = null; + private DataView _defaultView; /// /// Monotonically increasing number representing the order have been added to . @@ -48,7 +48,7 @@ public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializ private readonly ConstraintCollection _constraintCollection; //SimpleContent implementation - private int _elementColumnCount = 0; + private int _elementColumnCount; // relations internal DataRelationCollection _parentRelationsCollection; @@ -64,9 +64,9 @@ public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializ private int _shadowCount; // props - internal PropertyCollection _extendedProperties = null; + internal PropertyCollection _extendedProperties; private string _tableName = string.Empty; - internal string _tableNamespace = null; + internal string _tableNamespace; private string _tablePrefix = string.Empty; internal DataExpression _displayExpression; internal bool _fNestedInDataset = true; @@ -85,48 +85,45 @@ public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializ internal string _encodedTableName; // For XmlDataDocument only internal DataColumn _xmlText; // text values of a complex xml element internal DataColumn _colUnique; - internal bool _textOnly = false; // the table has only text value with possible attributes internal decimal _minOccurs = 1; // default = 1 internal decimal _maxOccurs = 1; // default = 1 - internal bool _repeatableElement = false; - private object _typeName = null; + internal bool _repeatableElement; + private object _typeName; // primary key info internal UniqueConstraint _primaryKey; internal IndexField[] _primaryIndex = Array.Empty(); - private DataColumn[] _delayedSetPrimaryKey = null; + private DataColumn[] _delayedSetPrimaryKey; // Loading Schema and/or Data related optimization private Index _loadIndex; - private Index _loadIndexwithOriginalAdded = null; - private Index _loadIndexwithCurrentDeleted = null; + private Index _loadIndexwithOriginalAdded; + private Index _loadIndexwithCurrentDeleted; private int _suspendIndexEvents; - private bool _savedEnforceConstraints = false; - private bool _inDataLoad = false; + private bool _savedEnforceConstraints; + private bool _inDataLoad; private bool _initialLoad; - private readonly bool _schemaLoading = false; private bool _enforceConstraints = true; - internal bool _suspendEnforceConstraints = false; + internal bool _suspendEnforceConstraints; - protected internal bool fInitInProgress = false; - private readonly bool _inLoad = false; - internal bool _fInLoadDiffgram = false; + protected internal bool fInitInProgress; + internal bool _fInLoadDiffgram; private byte _isTypedDataTable; // 0 == unknown, 1 = yes, 2 = No private DataRow[] _emptyDataRowArray; // Property Descriptor Cache for DataBinding - private PropertyDescriptorCollection _propertyDescriptorCollectionCache = null; + private PropertyDescriptorCollection _propertyDescriptorCollectionCache; // Cache for relation that has this table as nested child table. private DataRelation[] _nestedParentRelations = Array.Empty(); // Dependent column list for expression evaluation - internal List _dependentColumns = null; + internal List _dependentColumns; // events - private bool _mergingData = false; + private bool _mergingData; private DataRowChangeEventHandler _onRowChangedDelegate; private DataRowChangeEventHandler _onRowChangingDelegate; private DataRowChangeEventHandler _onRowDeletingDelegate; @@ -148,7 +145,7 @@ public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializ internal readonly List _delayedViews = new List(); private readonly List _dataViewListeners = new List(); - internal Hashtable _rowDiffId = null; + internal Hashtable _rowDiffId; internal readonly ReaderWriterLockSlim _indexesLock = new ReaderWriterLockSlim(); internal int _ukColumnPositionForInference = -1; @@ -1544,8 +1541,6 @@ internal DataRelation[] NestedParentRelations } } - internal bool SchemaLoading => _schemaLoading; - internal void CacheNestedParent() { _nestedParentRelations = FindNestedParentRelations(); @@ -2777,7 +2772,7 @@ internal void InsertRow(DataRow row, long proposedID, int pos, bool fireEvent) if (deferredException != null) throw deferredException; - if (EnforceConstraints && !_inLoad) + if (EnforceConstraints) { // if we are evaluating expression, we need to validate constraints int columnCount = _columnCollection.Count; @@ -4156,7 +4151,7 @@ private DataRowChangeEventArgs RaiseRowChanging(DataRowChangeEventArgs args, Dat private DataRowChangeEventArgs RaiseRowChanging(DataRowChangeEventArgs args, DataRow eRow, DataRowAction eAction, bool fireEvent) { // check all constraints - if (EnforceConstraints && !_inLoad) + if (EnforceConstraints) { int columnCount = _columnCollection.Count; for (int i = 0; i < columnCount; ++i) diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableCollection.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableCollection.cs index f4b033a2f9c5f..32a6cef7c4f09 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTableCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTableCollection.cs @@ -17,13 +17,13 @@ namespace System.Data [ListBindable(false)] public sealed class DataTableCollection : InternalDataCollectionBase { - private readonly DataSet _dataSet = null; + private readonly DataSet _dataSet; private readonly ArrayList _list = new ArrayList(); private int _defaultNameIndex = 1; - private DataTable[] _delayedAddRangeTables = null; + private DataTable[] _delayedAddRangeTables; - private CollectionChangeEventHandler _onCollectionChangedDelegate = null; - private CollectionChangeEventHandler _onCollectionChangingDelegate = null; + private CollectionChangeEventHandler _onCollectionChangedDelegate; + private CollectionChangeEventHandler _onCollectionChangingDelegate; private static int s_objectTypeCount; // Bid counter private readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableReader.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableReader.cs index 005563950549e..3afb5adc94fc9 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTableReader.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTableReader.cs @@ -9,23 +9,23 @@ namespace System.Data { public sealed class DataTableReader : DbDataReader { - private readonly DataTable[] _tables = null; + private readonly DataTable[] _tables; private bool _isOpen = true; - private DataTable _schemaTable = null; + private DataTable _schemaTable; private int _tableCounter = -1; private int _rowCounter = -1; - private DataTable _currentDataTable = null; - private DataRow _currentDataRow = null; + private DataTable _currentDataTable; + private DataRow _currentDataRow; private bool _hasRows = true; - private bool _reachEORows = false; - private bool _currentRowRemoved = false; - private bool _schemaIsChanged = false; - private bool _started = false; - private bool _readerIsInvalid = false; - private DataTableReaderListener _listener = null; - private bool _tableCleared = false; + private bool _reachEORows; + private bool _currentRowRemoved; + private bool _schemaIsChanged; + private bool _started; + private bool _readerIsInvalid; + private DataTableReaderListener _listener; + private bool _tableCleared; public DataTableReader(DataTable dataTable) { diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableReaderListener.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableReaderListener.cs index 186b19928f2ca..a6a65cb3706df 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTableReaderListener.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTableReaderListener.cs @@ -8,8 +8,8 @@ namespace System.Data { internal sealed class DataTableReaderListener { - private DataTable _currentDataTable = null; - private bool _isSubscribed = false; + private DataTable _currentDataTable; + private bool _isSubscribed; private readonly WeakReference _readerWeak; internal DataTableReaderListener(DataTableReader reader) diff --git a/src/libraries/System.Data.Common/src/System/Data/DataView.cs b/src/libraries/System.Data.Common/src/System/Data/DataView.cs index 350e5cf961385..26119100b9ddf 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataView.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataView.cs @@ -22,7 +22,7 @@ public class DataView : MarshalByValueComponent, IBindingListView, System.Compon { private DataViewManager _dataViewManager; private DataTable _table; - private bool _locked = false; + private bool _locked; private Index _index; private Dictionary _findIndexes; @@ -35,16 +35,16 @@ public class DataView : MarshalByValueComponent, IBindingListView, System.Compon /// /// IFilter will allow LinqDataView to wrap instead of using a DataExpression /// - private IFilter _rowFilter = null; + private IFilter _rowFilter; private DataViewRowState _recordStates = DataViewRowState.CurrentRows; private bool _shouldOpen = true; - private bool _open = false; + private bool _open; private bool _allowNew = true; private bool _allowEdit = true; private bool _allowDelete = true; - private bool _applyDefaultSort = false; + private bool _applyDefaultSort; internal DataRow _addNewRow; private ListChangedEventArgs _addNewMoved; @@ -52,12 +52,12 @@ public class DataView : MarshalByValueComponent, IBindingListView, System.Compon private System.ComponentModel.ListChangedEventHandler _onListChanged; internal static ListChangedEventArgs s_resetEventArgs = new ListChangedEventArgs(ListChangedType.Reset, -1); - private DataTable _delayedTable = null; - private string _delayedRowFilter = null; - private string _delayedSort = null; + private DataTable _delayedTable; + private string _delayedRowFilter; + private string _delayedSort; private DataViewRowState _delayedRecordStates = (DataViewRowState)(-1); - private bool _fInitInProgress = false; - private bool _fEndInitInProgress = false; + private bool _fInitInProgress; + private bool _fEndInitInProgress; /// /// You can't delay create the DataRowView instances since multiple thread read access is valid @@ -86,7 +86,7 @@ private DataRowReferenceComparer() { } public int GetHashCode(DataRow obj) => obj._objectID; } - private readonly DataViewListener _dvListener = null; + private readonly DataViewListener _dvListener; private static int s_objectTypeCount; // Bid counter private readonly int _objectID = System.Threading.Interlocked.Increment(ref s_objectTypeCount); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataViewManager.cs b/src/libraries/System.Data.Common/src/System/Data/DataViewManager.cs index 250f723e7a160..c8a02f660dac6 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataViewManager.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataViewManager.cs @@ -16,7 +16,7 @@ public class DataViewManager : MarshalByValueComponent, IBindingList, System.Com private DataSet _dataSet; private readonly DataViewManagerListItemTypeDescriptor _item; private readonly bool _locked; - internal int _nViews = 0; + internal int _nViews; private static readonly NotSupportedException s_notSupported = new NotSupportedException(); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataViewSetting.cs b/src/libraries/System.Data.Common/src/System/Data/DataViewSetting.cs index 6b180e7015ae1..94d6500a2d7e6 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataViewSetting.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataViewSetting.cs @@ -14,7 +14,7 @@ public class DataViewSetting private string _sort = string.Empty; private string _rowFilter = string.Empty; private DataViewRowState _rowStateFilter = DataViewRowState.CurrentRows; - private bool _applyDefaultSort = false; + private bool _applyDefaultSort; internal DataViewSetting() { } diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs index da1d3f4ffc9a0..224bc5e4c0570 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs @@ -1509,7 +1509,7 @@ internal sealed class LikeNode : BinaryNode private static readonly char[] s_trimChars = new char[] { (char)0x20, (char)0x3000 }; private int _kind; - private string _pattern = null; + private string _pattern; internal LikeNode(DataTable table, int op, ExpressionNode left, ExpressionNode right) : base(table, op, left, right) diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/DataExpression.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/DataExpression.cs index 05fc0ec87e3be..6574581ab3f11 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/DataExpression.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/DataExpression.cs @@ -11,12 +11,12 @@ namespace System.Data { internal sealed class DataExpression : IFilter { - internal string _originalExpression = null; // original, unoptimized string + internal string _originalExpression; // original, unoptimized string - private readonly bool _parsed = false; - private bool _bound = false; - private ExpressionNode _expr = null; - private DataTable _table = null; + private readonly bool _parsed; + private bool _bound; + private ExpressionNode _expr; + private DataTable _table; private readonly StorageType _storageType; private readonly Type _dataType; // This set if the expression is part of ExpressionCoulmn private DataColumn[] _dependency = Array.Empty(); diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs index 85b49ee262deb..cfaf53769bc55 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs @@ -97,14 +97,14 @@ to prevent future compatibility problems. private readonly char _exponentU = 'E'; internal char[] _text; - internal int _pos = 0; - internal int _start = 0; + internal int _pos; + internal int _start; internal Tokens _token; internal int _op = Operators.Noop; internal OperatorInfo[] _ops = new OperatorInfo[MaxPredicates]; - internal int _topOperator = 0; - internal int _topNode = 0; + internal int _topOperator; + internal int _topNode; private readonly DataTable _table; @@ -113,7 +113,7 @@ to prevent future compatibility problems. internal int _prevOperand; - internal ExpressionNode _expression = null; + internal ExpressionNode _expression; internal ExpressionParser(DataTable table) { @@ -1396,9 +1396,9 @@ internal enum Tokens /// internal sealed class OperatorInfo { - internal Nodes _type = 0; - internal int _op = 0; - internal int _priority = 0; + internal Nodes _type; + internal int _op; + internal int _priority; internal OperatorInfo(Nodes type, int op, int pri) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs index 33aa941e3034c..50ed891f04201 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs @@ -13,7 +13,7 @@ internal sealed class FunctionNode : ExpressionNode { internal readonly string _name; internal readonly int _info = -1; - internal int _argumentCount = 0; + internal int _argumentCount; internal const int initialCapacity = 1; internal ExpressionNode[] _arguments; diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/NameNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/NameNode.cs index 0c641428f8436..045b66c9fbb84 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/NameNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/NameNode.cs @@ -9,11 +9,8 @@ namespace System.Data { internal sealed class NameNode : ExpressionNode { - internal char _open = '\0'; - internal char _close = '\0'; internal string _name; internal bool _found; - internal bool _type = false; internal DataColumn _column; internal NameNode(DataTable table, char[] text, int start, int pos) : base(table) diff --git a/src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs b/src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs index 650cac5d52f22..dda3eefb3340c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs +++ b/src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs @@ -27,11 +27,11 @@ public class ForeignKeyConstraint : Constraint private DataKey _parentKey; // Design time serialization - internal string _constraintName = null; - internal string[] _parentColumnNames = null; - internal string[] _childColumnNames = null; - internal string _parentTableName = null; - internal string _parentTableNamespace = null; + internal string _constraintName; + internal string[] _parentColumnNames; + internal string[] _childColumnNames; + internal string _parentTableName; + internal string _parentTableNamespace; /// /// Initializes a new instance of the class with the specified parent and diff --git a/src/libraries/System.Data.Common/src/System/Data/Merger.cs b/src/libraries/System.Data.Common/src/System/Data/Merger.cs index 702a0e159c635..5fc4dc08f1001 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Merger.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Merger.cs @@ -10,12 +10,12 @@ namespace System.Data { internal sealed class Merger { - private readonly DataSet _dataSet = null; - private readonly DataTable _dataTable = null; + private readonly DataSet _dataSet; + private readonly DataTable _dataTable; private readonly bool _preserveChanges; private readonly MissingSchemaAction _missingSchemaAction; - private readonly bool _isStandAlonetable = false; - private bool _IgnoreNSforTableLookup = false; // Everett Behavior : SQL BU DT 370850 + private readonly bool _isStandAlonetable; + private bool _IgnoreNSforTableLookup; // Everett Behavior : SQL BU DT 370850 internal Merger(DataSet dataSet, bool preserveChanges, MissingSchemaAction missingSchemaAction) { diff --git a/src/libraries/System.Data.Common/src/System/Data/RbTree.cs b/src/libraries/System.Data.Common/src/System/Data/RbTree.cs index 6c02513d2db49..385506678b5e4 100644 --- a/src/libraries/System.Data.Common/src/System/Data/RbTree.cs +++ b/src/libraries/System.Data.Common/src/System/Data/RbTree.cs @@ -98,13 +98,13 @@ internal abstract class RBTree : IEnumerable private TreePage[] _pageTable; // initial size 4, then doubles (grows) - it never shrinks private int[] _pageTableMap; - private int _inUsePageCount = 0; // contains count of allocated pages per tree, its <= the capacity of pageTable + private int _inUsePageCount; // contains count of allocated pages per tree, its <= the capacity of pageTable private int _nextFreePageLine; // used for keeping track of position of last used free page in pageTable public int root; private int _version; - private int _inUseNodeCount = 0; // total number of nodes currently in use by this tree. - private int _inUseSatelliteTreeCount = 0; // total number of satellite associated with this tree. + private int _inUseNodeCount; // total number of nodes currently in use by this tree. + private int _inUseSatelliteTreeCount; // total number of satellite associated with this tree. private readonly TreeAccessMethod _accessMethod; protected abstract int CompareNode(K record1, K record2); diff --git a/src/libraries/System.Data.Common/src/System/Data/RecordManager.cs b/src/libraries/System.Data.Common/src/System/Data/RecordManager.cs index 7bf4394bd14b1..72b59261d28a5 100644 --- a/src/libraries/System.Data.Common/src/System/Data/RecordManager.cs +++ b/src/libraries/System.Data.Common/src/System/Data/RecordManager.cs @@ -13,7 +13,7 @@ internal sealed class RecordManager private int _lastFreeRecord; private int _minimumCapacity = 50; - private int _recordCapacity = 0; + private int _recordCapacity; private readonly List _freeRecordList = new List(); private DataRow[] _rows; diff --git a/src/libraries/System.Data.Common/src/System/Data/Select.cs b/src/libraries/System.Data.Common/src/System/Data/Select.cs index 972ff0b74af3e..406e42c5a6d9f 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Select.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Select.cs @@ -26,9 +26,9 @@ internal sealed class Select private sealed class ColumnInfo { - public bool flag = false; // Misc. Use - public bool equalsOperator = false; // True when the associated expr has = Operator defined - public BinaryNode expr = null; // Binary Search capable expression associated + public bool flag; // Misc. Use + public bool equalsOperator; // True when the associated expr has = Operator defined + public BinaryNode expr; // Binary Search capable expression associated } private ColumnInfo[] _candidateColumns; diff --git a/src/libraries/System.Data.Common/src/System/Data/SimpleType.cs b/src/libraries/System.Data.Common/src/System/Data/SimpleType.cs index 07973d61669b1..1a842838955ea 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SimpleType.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SimpleType.cs @@ -13,9 +13,9 @@ namespace System.Data { internal sealed class SimpleType : ISerializable { - private string _baseType = null; // base type name - private SimpleType _baseSimpleType = null; - private XmlQualifiedName _xmlBaseType = null; // Qualified name of Basetype + private string _baseType; // base type name + private SimpleType _baseSimpleType; + private XmlQualifiedName _xmlBaseType; // Qualified name of Basetype private string _name = string.Empty; private int _length = -1; private int _minLength = -1; diff --git a/src/libraries/System.Data.Common/src/System/Data/SortExpressionBuilder.cs b/src/libraries/System.Data.Common/src/System/Data/SortExpressionBuilder.cs index e0545390bb6bc..3a1836d228ca8 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SortExpressionBuilder.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SortExpressionBuilder.cs @@ -41,8 +41,8 @@ internal class SortExpressionBuilder : IComparer> private readonly LinkedList> _selectors = new LinkedList>(); private readonly LinkedList> _comparers = new LinkedList>(); - private LinkedListNode> _currentSelector = null; - private LinkedListNode> _currentComparer = null; + private LinkedListNode> _currentSelector; + private LinkedListNode> _currentComparer; /// /// Adds a sorting selector/comparer in the correct order diff --git a/src/libraries/System.Data.Common/src/System/Data/UniqueConstraint.cs b/src/libraries/System.Data.Common/src/System/Data/UniqueConstraint.cs index 38b84a22efe53..d82a10b6a6310 100644 --- a/src/libraries/System.Data.Common/src/System/Data/UniqueConstraint.cs +++ b/src/libraries/System.Data.Common/src/System/Data/UniqueConstraint.cs @@ -15,11 +15,11 @@ public class UniqueConstraint : Constraint { private DataKey _key; private Index _constraintIndex; - internal bool _bPrimaryKey = false; + internal bool _bPrimaryKey; // Design time serialization - internal string _constraintName = null; - internal string[] _columnNames = null; + internal string _constraintName; + internal string[] _columnNames; /// /// Initializes a new instance of the with the specified name and diff --git a/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs b/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs index d45e90a14532e..ae1dade93c206 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs @@ -12,8 +12,8 @@ namespace System.Data internal sealed class XMLDiffLoader { private ArrayList _tables; - private DataSet _dataSet = null; - private DataTable _dataTable = null; + private DataSet _dataSet; + private DataTable _dataTable; internal void LoadDiffGram(DataSet ds, XmlReader dataTextReader) { diff --git a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs index a5aa2f48d6486..83b4328891480 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs @@ -128,10 +128,10 @@ public ConstraintTable(DataTable t, XmlSchemaIdentityConstraint c) internal sealed class XSDSchema : XMLSchema { - private XmlSchemaSet _schemaSet = null; - private XmlSchemaElement _dsElement = null; - private DataSet _ds = null; - private string _schemaName = null; + private XmlSchemaSet _schemaSet; + private XmlSchemaElement _dsElement; + private DataSet _ds; + private string _schemaName; private ArrayList _columnExpressions; private Hashtable _constraintNodes; private ArrayList _refTables; @@ -149,7 +149,7 @@ internal sealed class XSDSchema : XMLSchema private Hashtable _existingSimpleTypeMap; - private bool _fromInference = false; + private bool _fromInference; internal bool FromInference { diff --git a/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs b/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs index fa1a9e4bcb63e..499f34dec7a46 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs @@ -16,19 +16,18 @@ namespace System.Data internal sealed class XmlDataLoader { private readonly DataSet _dataSet; - private XmlToDatasetMap _nodeToSchemaMap = null; + private XmlToDatasetMap _nodeToSchemaMap; private readonly Hashtable _nodeToRowMap; - private readonly Stack _childRowsStack = null; - private readonly Hashtable _htableExcludedNS = null; - private readonly bool _fIsXdr = false; - internal bool _isDiffgram = false; + private readonly Stack _childRowsStack; + private readonly bool _fIsXdr; + internal bool _isDiffgram; - private XmlElement _topMostNode = null; - private readonly bool _ignoreSchema = false; + private XmlElement _topMostNode; + private readonly bool _ignoreSchema; private readonly DataTable _dataTable; - private readonly bool _isTableLevel = false; - private bool _fromInference = false; + private readonly bool _isTableLevel; + private bool _fromInference; internal XmlDataLoader(DataSet dataset, bool IsXdr, bool ignoreSchema) { @@ -239,13 +238,7 @@ internal bool FColumnElement(XmlElement e) private bool FExcludedNamespace(string ns) { - if (ns.Equals(Keywords.XSD_XMLNS_NS)) - return true; - - if (_htableExcludedNS == null) - return false; - - return _htableExcludedNS.Contains(ns); + return ns.Equals(Keywords.XSD_XMLNS_NS); } private bool FIgnoreNamespace(XmlNode node) @@ -555,7 +548,7 @@ private void SetRowValueFromXmlText(DataRow row, DataColumn col, string xmlText) row[col] = col.ConvertXmlToObject(xmlText); } - private XmlReader _dataReader = null; + private XmlReader _dataReader; private object _XSD_XMLNS_NS; private object _XDR_SCHEMA; private object _XDRNS; diff --git a/src/libraries/System.Data.Common/src/System/Data/XmlToDatasetMap.cs b/src/libraries/System.Data.Common/src/System/Data/XmlToDatasetMap.cs index 1e959a88ea2d6..5065485fe4f96 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XmlToDatasetMap.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XmlToDatasetMap.cs @@ -98,7 +98,7 @@ public TableSchemaInfo(DataTable tableSchema) private XmlNodeIdHashtable _tableSchemaMap; // Holds all the tables information - private TableSchemaInfo _lastTableSchemaInfo = null; + private TableSchemaInfo _lastTableSchemaInfo; // Used to infer schema diff --git a/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs b/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs index e3b842fd40d5d..8d81bf8a51031 100644 --- a/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs +++ b/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs @@ -39,13 +39,13 @@ internal sealed class XmlTreeGen private XmlDocument _dc; private XmlElement _sRoot; - private int _prefixCount = 0; + private int _prefixCount; private readonly SchemaFormat _schFormat = SchemaFormat.Public; - private string _filePath = null; - private string _fileName = null; - private string _fileExt = null; - private XmlElement _dsElement = null; - private XmlElement _constraintSeparator = null; + private string _filePath; + private string _fileName; + private string _fileExt; + private XmlElement _dsElement; + private XmlElement _constraintSeparator; /// /// This converter allows new versions of the framework to write @@ -2239,11 +2239,11 @@ internal sealed class NewDiffgramGen internal DataSet _ds; internal DataTable _dt; internal XmlWriter _xmlw; - private bool _fBefore = false; - private bool _fErrors = false; - internal Hashtable _rowsOrder = null; + private bool _fBefore; + private bool _fErrors; + internal Hashtable _rowsOrder; private readonly ArrayList _tables = new ArrayList(); - private readonly bool _writeHierarchy = false; + private readonly bool _writeHierarchy; internal NewDiffgramGen(DataSet ds) @@ -2642,16 +2642,16 @@ internal sealed class XmlDataTreeWriter { private XmlWriter _xmlw; - private readonly DataSet _ds = null; - private readonly DataTable _dt = null; + private readonly DataSet _ds; + private readonly DataTable _dt; private readonly ArrayList _dTables = new ArrayList(); private readonly DataTable[] _topLevelTables; - private readonly bool _fFromTable = false; // also means no hierarchy - private bool _isDiffgram = false; - private Hashtable _rowsOrder = null; - private readonly bool _writeHierarchy = false; + private readonly bool _fFromTable; // also means no hierarchy + private bool _isDiffgram; + private Hashtable _rowsOrder; + private readonly bool _writeHierarchy; diff --git a/src/libraries/System.Data.Common/src/System/Xml/DataPointer.cs b/src/libraries/System.Data.Common/src/System/Xml/DataPointer.cs index a93e956fdd804..9fb28c3fa64cd 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/DataPointer.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/DataPointer.cs @@ -15,7 +15,7 @@ internal sealed class DataPointer : IXmlDataVirtualNode private XmlNode _node; private DataColumn _column; private bool _fOnValue; - private bool _bNeedFoliate = false; + private bool _bNeedFoliate; private bool _isInUse; internal DataPointer(XmlDataDocument doc, XmlNode node) diff --git a/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs b/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs index 2a092f953a0ae..26a72c6480a21 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs @@ -44,10 +44,10 @@ public class XmlDataDocument : XmlDocument private object _foliationLock; internal const string XSI_NIL = "xsi:nil"; internal const string XSI = "xsi"; - private bool _bForceExpandEntity = false; - internal XmlAttribute _attrXml = null; - internal bool _bLoadFromDataSet = false; - internal bool _bHasXSINIL = false; + private bool _bForceExpandEntity; + internal XmlAttribute _attrXml; + internal bool _bLoadFromDataSet; + internal bool _bHasXSINIL; internal void AddPointer(IXmlDataVirtualNode pointer) { diff --git a/src/libraries/System.Data.Odbc/src/Common/System/Data/Common/NameValuePermission.cs b/src/libraries/System.Data.Odbc/src/Common/System/Data/Common/NameValuePermission.cs index 2a3da7ad33695..e3598d3b7e42d 100644 --- a/src/libraries/System.Data.Odbc/src/Common/System/Data/Common/NameValuePermission.cs +++ b/src/libraries/System.Data.Odbc/src/Common/System/Data/Common/NameValuePermission.cs @@ -19,8 +19,6 @@ internal sealed class NameValuePermission : IComparable private NameValuePermission[] _tree; // with branches - internal static readonly NameValuePermission Default = null; // = new NameValuePermission(String.Empty, new string[] { "File Name" }, KeyRestrictionBehavior.AllowOnly); - internal NameValuePermission() { // root node } @@ -286,4 +284,4 @@ internal NameValuePermission CopyNameValue() return new NameValuePermission(this); } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Data.Odbc/src/Common/System/Data/ProviderBase/DbConnectionPool.cs b/src/libraries/System.Data.Odbc/src/Common/System/Data/ProviderBase/DbConnectionPool.cs index 4ecf414a136fd..9893abb946b38 100644 --- a/src/libraries/System.Data.Odbc/src/Common/System/Data/ProviderBase/DbConnectionPool.cs +++ b/src/libraries/System.Data.Odbc/src/Common/System/Data/ProviderBase/DbConnectionPool.cs @@ -111,7 +111,7 @@ internal WaitHandle[] GetHandles(bool withCreate) private readonly ConcurrentStack _stackNew = new ConcurrentStack(); private readonly ConcurrentQueue _pendingOpens = new ConcurrentQueue(); - private int _pendingOpensWaiting = 0; + private int _pendingOpensWaiting; private readonly WaitCallback _poolCreateRequest; diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs index 99c23d527a32d..a3cc66caf0078 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs @@ -21,7 +21,6 @@ public sealed partial class OdbcConnection : DbConnection, ICloneable private WeakReference _weakTransaction; private OdbcConnectionHandle _connectionHandle; - private readonly ConnectionState _extraState = default(ConnectionState); // extras, like Executing and Fetching, that we add to the State. public OdbcConnection(string connectionString) : this() { @@ -155,7 +154,7 @@ internal ConnectionState InternalState { get { - return (this.State | _extraState); + return this.State; } } diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcUtils.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcUtils.cs index 0699b5d408f19..d121bf180d915 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcUtils.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcUtils.cs @@ -353,8 +353,8 @@ internal sealed class CStringTokenizer private readonly string _sqlstatement; private readonly char _quote; // typically the semicolon '"' private readonly char _escape; // typically the same char as the quote - private readonly int _len = 0; - private int _idx = 0; + private readonly int _len; + private int _idx; internal CStringTokenizer(string text, char quote, char escape) { diff --git a/src/libraries/System.Data.OleDb/src/OleDbStruct.cs b/src/libraries/System.Data.OleDb/src/OleDbStruct.cs index 4e81c374034ee..1495574a320b6 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbStruct.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbStruct.cs @@ -424,15 +424,15 @@ internal sealed class tagDBCOLUMNINFO internal IntPtr iOrdinal = (IntPtr)0; - internal int dwFlags = 0; + internal int dwFlags; internal IntPtr ulColumnSize = (IntPtr)0; - internal short wType = 0; + internal short wType; - internal byte bPrecision = 0; + internal byte bPrecision; - internal byte bScale = 0; + internal byte bScale; internal tagDBIDX columnid; diff --git a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionFactory.cs b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionFactory.cs index ff92071a9c778..771b8c17f8518 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionFactory.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionFactory.cs @@ -23,7 +23,7 @@ internal abstract class DbConnectionFactory // s_pendingOpenNonPooled is an array of tasks used to throttle creation of non-pooled connections to // a maximum of Environment.ProcessorCount at a time. - private static int s_pendingOpenNonPooledNext = 0; + private static int s_pendingOpenNonPooledNext; private static readonly Task[] s_pendingOpenNonPooled = new Task[Environment.ProcessorCount]; private static Task s_completedTask; diff --git a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionPool.cs b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionPool.cs index aaba1bededf59..d0f671a8fa993 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionPool.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionPool.cs @@ -351,7 +351,7 @@ protected override bool ReleaseHandle() private readonly ConcurrentStack _stackNew = new ConcurrentStack(); private readonly ConcurrentQueue _pendingOpens = new ConcurrentQueue(); - private int _pendingOpensWaiting = 0; + private int _pendingOpensWaiting; private readonly WaitCallback _poolCreateRequest; diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/HttpHandlerDiagnosticListener.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/HttpHandlerDiagnosticListener.cs index 16023f62623c5..b9903767e8f13 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/HttpHandlerDiagnosticListener.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/HttpHandlerDiagnosticListener.cs @@ -807,7 +807,7 @@ private static Func CreateFieldGetter(Type classType, st private const string TraceStateHeaderName = "tracestate"; // Fields for controlling initialization of the HttpHandlerDiagnosticListener singleton - private bool initialized = false; + private bool initialized; // Fields for reflection private static FieldInfo s_connectionGroupListField; diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntryCollection.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntryCollection.cs index d831492d06a81..73f140c39fb65 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntryCollection.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogEntryCollection.cs @@ -72,7 +72,7 @@ private class EntriesEnumerator : IEnumerator { private readonly EventLogEntryCollection entries; private int num = -1; - private EventLogEntry cachedEntry = null; + private EventLogEntry cachedEntry; internal EntriesEnumerator(EventLogEntryCollection entries) { diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogConfiguration.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogConfiguration.cs index 3e56d51399284..d24e982e4e337 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogConfiguration.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogConfiguration.cs @@ -46,7 +46,7 @@ public class EventLogConfiguration : IDisposable { private readonly EventLogHandle _handle = EventLogHandle.Zero; - private readonly EventLogSession _session = null; + private readonly EventLogSession _session; public EventLogConfiguration(string logName) : this(logName, null) { } diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogQuery.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogQuery.cs index 995b37e847711..4186aeecb3229 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogQuery.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogQuery.cs @@ -37,9 +37,9 @@ public EventLogQuery(string path, PathType pathType, string query) public EventLogSession Session { get; set; } - public bool TolerateQueryErrors { get; set; } = false; + public bool TolerateQueryErrors { get; set; } - public bool ReverseDirection { get; set; } = false; + public bool ReverseDirection { get; set; } internal string Path { get; } diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogRecord.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogRecord.cs index 07c6ef9b3a6ea..95da0ef5dbe74 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogRecord.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogRecord.cs @@ -21,10 +21,10 @@ public class EventLogRecord : EventRecord private readonly object _syncObject; // Cached DisplayNames for each instance - private string _levelName = null; - private string _taskName = null; - private string _opcodeName = null; - private IEnumerable _keywordsNames = null; + private string _levelName; + private string _taskName; + private string _opcodeName; + private IEnumerable _keywordsNames; // Cached DisplayNames for each instance private bool _levelNameReady; diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogSession.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogSession.cs index 2c278b01dc859..850269ee4c089 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogSession.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/EventLogSession.cs @@ -46,7 +46,7 @@ public class EventLogSession : IDisposable internal EventLogHandle renderContextHandleUser = EventLogHandle.Zero; // The dummy sync object for the two contexts. - private readonly object _syncObject = null; + private readonly object _syncObject; private readonly string _server; private readonly string _user; diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs index 2761073de750c..189511c784c84 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs @@ -23,26 +23,26 @@ internal class NativeWrapper public class SystemProperties { // Indicates if the SystemProperties values were already computed (for this event Instance, surely). - public bool filled = false; - - public ushort? Id = null; - public byte? Version = null; - public ushort? Qualifiers = null; - public byte? Level = null; - public ushort? Task = null; - public byte? Opcode = null; - public ulong? Keywords = null; - public ulong? RecordId = null; - public string ProviderName = null; - public Guid? ProviderId = null; - public string ChannelName = null; - public uint? ProcessId = null; - public uint? ThreadId = null; - public string ComputerName = null; - public System.Security.Principal.SecurityIdentifier UserId = null; - public DateTime? TimeCreated = null; - public Guid? ActivityId = null; - public Guid? RelatedActivityId = null; + public bool filled; + + public ushort? Id; + public byte? Version; + public ushort? Qualifiers; + public byte? Level; + public ushort? Task; + public byte? Opcode; + public ulong? Keywords; + public ulong? RecordId; + public string ProviderName; + public Guid? ProviderId; + public string ChannelName; + public uint? ProcessId; + public uint? ThreadId; + public string ComputerName; + public System.Security.Principal.SecurityIdentifier UserId; + public DateTime? TimeCreated; + public Guid? ActivityId; + public Guid? RelatedActivityId; public SystemProperties() { diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/ProviderMetadata.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/ProviderMetadata.cs index 0464e2f60a382..47cf2e79b4472 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/ProviderMetadata.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/ProviderMetadata.cs @@ -24,7 +24,7 @@ public class ProviderMetadata : IDisposable private EventLogHandle _defaultProviderHandle = EventLogHandle.Zero; - private readonly EventLogSession _session = null; + private readonly EventLogSession _session; private readonly string _providerName; private readonly CultureInfo _cultureInfo; @@ -32,15 +32,15 @@ public class ProviderMetadata : IDisposable // caching of the IEnumerable, , , on the ProviderMetadata // they do not change with every call. - private IList _levels = null; - private IList _opcodes = null; - private IList _tasks = null; - private IList _keywords = null; - private IList _standardLevels = null; - private IList _standardOpcodes = null; - private IList _standardTasks = null; - private IList _standardKeywords = null; - private IList _channelReferences = null; + private IList _levels; + private IList _opcodes; + private IList _tasks; + private IList _keywords; + private IList _standardLevels; + private IList _standardOpcodes; + private IList _standardTasks; + private IList _standardKeywords; + private IList _channelReferences; private readonly object _syncObject; diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/CounterSampleCalculator.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/CounterSampleCalculator.cs index 0798e63dc3d8a..2cad00d315f74 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/CounterSampleCalculator.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/CounterSampleCalculator.cs @@ -14,7 +14,7 @@ namespace System.Diagnostics /// public static class CounterSampleCalculator { - private static volatile bool s_perfCounterDllLoaded = false; + private static volatile bool s_perfCounterDllLoaded; /// /// Converts 100NS elapsed time to fractional seconds diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounter.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounter.cs index 37e4b41d98a4f..739cc72542535 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounter.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounter.cs @@ -26,8 +26,8 @@ public sealed class PerformanceCounter : Component, ISupportInitialize private PerformanceCounterInstanceLifetime _instanceLifetime = PerformanceCounterInstanceLifetime.Global; private bool _isReadOnly; - private bool _initialized = false; - private string _helpMsg = null; + private bool _initialized; + private string _helpMsg; private int _counterType = -1; // Cached old sample diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs index 7facea0fcdd6c..4584a835ebaef 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs @@ -1268,7 +1268,7 @@ internal static void UnregisterCategory(string categoryName) internal class PerformanceMonitor { - private PerformanceDataRegistryKey perfDataKey = null; + private PerformanceDataRegistryKey perfDataKey; private readonly string machineName; internal PerformanceMonitor(string machineName) diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs index 22e268f5db584..49c46b87f6bd3 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs @@ -1649,8 +1649,8 @@ private int ResolveAddress(long address, int sizeToRead) private class FileMapping { internal int _fileMappingSize; - private SafeMemoryMappedViewHandle _fileViewAddress = null; - private SafeMemoryMappedFileHandle _fileMappingHandle = null; + private SafeMemoryMappedViewHandle _fileViewAddress; + private SafeMemoryMappedFileHandle _fileMappingHandle; //The version of the file mapping name is independent from the //assembly version. diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/MonitoringDescriptionAttribute.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/MonitoringDescriptionAttribute.cs index 8288802a68053..80b24869bf362 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/MonitoringDescriptionAttribute.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/MonitoringDescriptionAttribute.cs @@ -15,7 +15,7 @@ namespace System.Diagnostics [AttributeUsage(AttributeTargets.All)] public class MonitoringDescriptionAttribute : DescriptionAttribute { - private bool _replaced = false; + private bool _replaced; /// /// Constructs a new sys description. diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs index 29ec30ccdd885..f617898171c53 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs @@ -17,7 +17,7 @@ public partial class Process : IDisposable { private static readonly UTF8Encoding s_utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false); - private static volatile bool s_initialized = false; + private static volatile bool s_initialized; private static readonly object s_initializedGate = new object(); private static readonly Interop.Sys.SigChldCallback s_sigChildHandler = OnSigChild; private static readonly ReaderWriterLockSlim s_processStartLock = new ReaderWriterLockSlim(); diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs index 1dfd571aafce0..f0cf12cb539c6 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs @@ -81,7 +81,7 @@ public partial class Process : Component internal bool _pendingOutputRead; internal bool _pendingErrorRead; - private static int s_cachedSerializationSwitch = 0; + private static int s_cachedSerializationSwitch; /// /// diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/Switch.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/Switch.cs index 666f7bcc9ed45..484c84ffc8fb3 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/Switch.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/Switch.cs @@ -21,9 +21,9 @@ public abstract class Switch { private readonly string? _description; private readonly string _displayName; - private int _switchSetting = 0; - private volatile bool _initialized = false; - private bool _initializing = false; + private int _switchSetting; + private volatile bool _initialized; + private bool _initializing; private volatile string _switchValueString = string.Empty; private readonly string? _defaultValue; private object? _initializedLock; diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/Trace.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/Trace.cs index c745bb2391f7c..aca0bf00e7b41 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/Trace.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/Trace.cs @@ -19,7 +19,7 @@ private Trace() { } - private static CorrelationManager? s_correlationManager = null; + private static CorrelationManager? s_correlationManager; public static CorrelationManager CorrelationManager { get diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs index ba84e57898e50..2e49228adbfb5 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceEventCache.cs @@ -14,7 +14,7 @@ public partial class TraceEventCache { private long _timeStamp = -1; private DateTime _dateTime = DateTime.MinValue; - private string? _stackTrace = null; + private string? _stackTrace; public DateTime DateTime { diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs index 3983502000d97..75c1dfbd201ba 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs @@ -42,7 +42,7 @@ public override void OnIndentSizeChanged(int indentSize) public override void WriteLine(string? message) { TraceInternal.WriteLine(message); } } - private static volatile string? s_appName = null; + private static volatile string? s_appName; private static volatile TraceListenerCollection? s_listeners; private static volatile bool s_autoFlush; private static volatile bool s_useGlobalLock; diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs index 1fdbe85b91293..ced582a3eb0cd 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs @@ -25,7 +25,7 @@ public abstract class TraceListener : MarshalByRefObject, IDisposable private StringDictionary? _attributes; private string? _listenerName; - private TraceFilter? _filter = null; + private TraceFilter? _filter; /// /// Initializes a new instance of the class. diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceSource.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceSource.cs index 57e2ad33244ca..58b7e073d62ae 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceSource.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceSource.cs @@ -19,7 +19,7 @@ public class TraceSource private volatile TraceListenerCollection? _listeners; private readonly SourceLevels _switchLevel; private readonly string _sourceName; - internal volatile bool _initCalled = false; // Whether we've called Initialize already. + internal volatile bool _initCalled; // Whether we've called Initialize already. private StringDictionary? _attributes; public TraceSource(string name) diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADAMStoreCtx.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADAMStoreCtx.cs index d98151ba3fd4c..2fc0727b88f7e 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADAMStoreCtx.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADAMStoreCtx.cs @@ -19,8 +19,8 @@ namespace System.DirectoryServices.AccountManagement internal partial class ADAMStoreCtx : ADStoreCtx { private const int mappingIndex = 1; - private List _cachedBindableObjectList = null; - private string _cachedBindableObjectFilter = null; + private List _cachedBindableObjectList; + private string _cachedBindableObjectFilter; private readonly object _objectListLock = new object(); public ADAMStoreCtx(DirectoryEntry ctxBase, bool ownCtxBase, string username, string password, string serverName, ContextOptions options) : base(ctxBase, ownCtxBase, username, password, options) diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADDNLinkedAttrSet.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADDNLinkedAttrSet.cs index b3bf9f3d2d958..b27b136a9cfe5 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADDNLinkedAttrSet.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADDNLinkedAttrSet.cs @@ -1295,7 +1295,7 @@ public override void Dispose() // // - private UnsafeNativeMethods.IADsPathname _pathCracker = null; + private UnsafeNativeMethods.IADsPathname _pathCracker; private readonly object _pathLock = new object(); private Dictionary _usersVisited = new Dictionary(); @@ -1304,9 +1304,9 @@ public override void Dispose() private List _groupsToVisit = new List(); - protected object current = null; // current member of the group (or current group of the user) + protected object current; // current member of the group (or current group of the user) - private bool _returnedPrimaryGroup = false; + private bool _returnedPrimaryGroup; private readonly string _primaryGroupDN; // the DN of the user's PrimaryGroup (not included in this.members/originalMembers) private readonly bool _recursive; @@ -1315,14 +1315,14 @@ public override void Dispose() private IEnumerable _members; // the membership we're currently enumerating over private readonly Queue _originalMembers = new Queue(); // the membership we started off with (before recursing) - private IEnumerator _membersEnum = null; + private IEnumerator _membersEnum; private ADStoreCtx _storeCtx; private readonly ADStoreCtx _originalStoreCtx; private bool _atBeginning = true; - private bool _disposed = false; + private bool _disposed; // foreign // This contains a list of employees built while enumerating the current group. These are FSP objects in the current domain and need to @@ -1331,25 +1331,25 @@ public override void Dispose() // List of objects from the group tha are actual fake group objects. private List _fakePrincipalMembers = new List(); // list of SIDs + store that have been translated. These could be any principal object - private SidList _foreignMembersToReturn = null; + private SidList _foreignMembersToReturn; - private Principal _currentForeignPrincipal = null; - private DirectoryEntry _currentForeignDE = null; + private Principal _currentForeignPrincipal; + private DirectoryEntry _currentForeignDE; private List _foreignGroups = new List(); // members based on a query (used for users who are group members by virtue of their primaryGroupId pointing to the group) private readonly DirectorySearcher _primaryGroupMembersSearcher; - private SearchResultCollection _queryMembersResults = null; - private IEnumerator _queryMembersResultEnumerator = null; + private SearchResultCollection _queryMembersResults; + private IEnumerator _queryMembersResultEnumerator; - private DirectorySearcher _currentMembersSearcher = null; + private DirectorySearcher _currentMembersSearcher; private readonly Queue _memberSearchersQueue = new Queue(); private readonly Queue _memberSearchersQueueOriginal = new Queue(); - private SearchResultCollection _memberSearchResults = null; - private IEnumerator _memberSearchResultsEnumerator = null; + private SearchResultCollection _memberSearchResults; + private IEnumerator _memberSearchResultsEnumerator; private ExpansionMode _expansionMode; private readonly ExpansionMode _originalExpansionMode; @@ -1394,7 +1394,7 @@ internal class ADDNLinkedAttrSetBookmark : ResultSetBookmark public List groupsToVisit; public List groupsVisited; public IEnumerable members; - public IEnumerator membersEnum = null; + public IEnumerator membersEnum; public Queue membersQueue; public ADStoreCtx storeCtx; public object current; diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADEntriesSet.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADEntriesSet.cs index 95bb3e8921214..484f10c4cfd81 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADEntriesSet.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADEntriesSet.cs @@ -16,12 +16,12 @@ internal class ADEntriesSet : ResultSet private readonly ADStoreCtx _storeCtx; private readonly IEnumerator _enumerator; - private SearchResult _current = null; - private bool _endReached = false; + private SearchResult _current; + private bool _endReached; - private bool _disposed = false; + private bool _disposed; - private readonly object _discriminant = null; + private readonly object _discriminant; internal ADEntriesSet(SearchResultCollection src, ADStoreCtx storeCtx) { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs index ea8490e6e2d63..a5bd2239d247d 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs @@ -28,10 +28,10 @@ internal partial class ADStoreCtx : StoreCtx private readonly bool _ownCtxBase; // if true, we "own" ctxBase and must Dispose of it when we're done - private bool _disposed = false; + private bool _disposed; protected internal NetCred Credentials { get { return this.credentials; } } - protected NetCred credentials = null; + protected NetCred credentials; protected internal AuthenticationTypes AuthTypes { get { return this.authTypes; } } protected AuthenticationTypes authTypes; @@ -2421,22 +2421,20 @@ private ulong LockoutDuration } protected object domainInfoLock = new object(); - protected string domainFlatName = null; - protected string domainDnsName = null; - protected string forestDnsName = null; - protected string userSuppliedServerName = null; - protected string defaultNamingContext = null; - protected string contextBasePartitionDN = null; //contains the DN of the Partition to which the user supplied context base (this.ctxBase) belongs. - protected string dnsHostName = null; - protected ulong lockoutDuration = 0; + protected string domainFlatName; + protected string domainDnsName; + protected string forestDnsName; + protected string userSuppliedServerName; + protected string defaultNamingContext; + protected string contextBasePartitionDN; //contains the DN of the Partition to which the user supplied context base (this.ctxBase) belongs. + protected string dnsHostName; + protected ulong lockoutDuration; protected enum StoreCapabilityMap { ASQSearch = 1, } - protected StoreCapabilityMap storeCapability = 0; - // Must be called inside of lock(domainInfoLock) protected virtual void LoadDomainInfo() { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs index f27aad7412f00..7059a8c17a296 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs @@ -799,12 +799,12 @@ internal override Type NativeType(Principal p) /************************/ // This table only includes properties that are writeable. - private static Hashtable s_propertyMappingTableByProperty = null; - private static Hashtable s_propertyMappingTableByLDAP = null; - protected static Dictionary NonPresentAttrDefaultStateMapping = null; - private static Hashtable s_propertyMappingTableByPropertyFull = null; + private static Hashtable s_propertyMappingTableByProperty; + private static Hashtable s_propertyMappingTableByLDAP; + protected static Dictionary NonPresentAttrDefaultStateMapping; + private static Hashtable s_propertyMappingTableByPropertyFull; - protected static Dictionary> TypeToLdapPropListMap = null; + protected static Dictionary> TypeToLdapPropListMap; private class PropertyMappingTableEntry { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_Query.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_Query.cs index 624691f2ecab5..ff9f0d8ffbb3b 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_Query.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_Query.cs @@ -309,7 +309,7 @@ internal override ResultSet Query(PrincipalSearcher ps, int sizeLimit) {typeof(BadLogonCountFilter), "badPwdCount", new FilterConverterDelegate(MatchingIntConverter)} }; - private static Hashtable s_filterPropertiesTable = null; + private static Hashtable s_filterPropertiesTable; private class FilterPropertyTableEntry { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs index 5e43e105cf897..8a57531b5eb19 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs @@ -228,22 +228,22 @@ public object Current } } - private bool _disposed = false; // keeps track of whether this object was disposed or not. - private readonly bool _disposeDirEntry = false; // If set to true then the RangeRetriever object will own the directory entry - // supplied to it in the constructor and will be responsible for disposing this entry - // when Dispose() is called on this object. - private bool _cacheValues = false; // If set to true then the attribute values will be cached in the InnerList - // By default caching is turned off. - private readonly DirectoryEntry _de; // the DirectoryEntry whose property we're retrieving the values of - private readonly string _propertyName; // the property we're retrieving the values of - - private bool _endReached = false; // if true, all property values (from all chunks) have been retrieved - - private int _lowRange = 0; // the lower-bound of the current chunk - private int _currentIndex = 0; // Index of the next object we will return. - private bool _cacheFilled = false; // Set to true after we have visited all attributes in the directory - - private object _currentResult = null; // the property value the enumerator is positioned at - private IEnumerator _currentEnumerator = null; // the PropertyValueCollection enumerator for the current chunk + private bool _disposed; // keeps track of whether this object was disposed or not. + private readonly bool _disposeDirEntry; // If set to true then the RangeRetriever object will own the directory entry + // supplied to it in the constructor and will be responsible for disposing this entry + // when Dispose() is called on this object. + private bool _cacheValues; // If set to true then the attribute values will be cached in the InnerList + // By default caching is turned off. + private readonly DirectoryEntry _de; // the DirectoryEntry whose property we're retrieving the values of + private readonly string _propertyName; // the property we're retrieving the values of + + private bool _endReached; // if true, all property values (from all chunks) have been retrieved + + private int _lowRange; // the lower-bound of the current chunk + private int _currentIndex; // Index of the next object we will return. + private bool _cacheFilled; // Set to true after we have visited all attributes in the directory + + private object _currentResult; // the property value the enumerator is positioned at + private IEnumerator _currentEnumerator; // the PropertyValueCollection enumerator for the current chunk } } diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/TokenGroupsSet.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/TokenGroupsSet.cs index 6a2c73515ceee..77d2b4357006b 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/TokenGroupsSet.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/TokenGroupsSet.cs @@ -33,12 +33,12 @@ internal TokenGroupSet( private readonly ADStoreCtx _storeCtx; private bool _atBeginning = true; - private DirectoryEntry _current = null; // current member of the group (or current group of the user) + private DirectoryEntry _current; // current member of the group (or current group of the user) private IEnumerator _tokenGroupsEnum; private SecurityIdentifier _currentSID; - private bool _disposed = false; + private bool _disposed; private readonly string _attributeToQuery; diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AccountInfo.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AccountInfo.cs index d430a43c84997..108c22fb00c54 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AccountInfo.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AccountInfo.cs @@ -20,7 +20,7 @@ internal class AccountInfo // // AccountLockoutTime - private Nullable _accountLockoutTime = null; + private Nullable _accountLockoutTime; private LoadState _accountLockoutTimeLoaded = LoadState.NotSet; public Nullable AccountLockoutTime @@ -32,7 +32,7 @@ public Nullable AccountLockoutTime } // LastLogon - private Nullable _lastLogon = null; + private Nullable _lastLogon; private LoadState _lastLogonLoaded = LoadState.NotSet; public Nullable LastLogon @@ -64,8 +64,8 @@ public PrincipalValueCollection PermittedWorkstations // without needing to ever call the set accessor. Therefore, rather than a simple "changed" flag set // by the set accessor, we need to track the original value of the property, and flag it as changed // if current value != original value. - private byte[] _permittedLogonTimes = null; - private byte[] _permittedLogonTimesOriginal = null; + private byte[] _permittedLogonTimes; + private byte[] _permittedLogonTimesOriginal; private LoadState _permittedLogonTimesLoaded = LoadState.NotSet; public byte[] PermittedLogonTimes @@ -99,7 +99,7 @@ public byte[] PermittedLogonTimes } // AccountExpirationDate - private Nullable _expirationDate = null; + private Nullable _expirationDate; private LoadState _expirationDateChanged = LoadState.NotSet; public Nullable AccountExpirationDate @@ -120,7 +120,7 @@ public Nullable AccountExpirationDate } // SmartcardLogonRequired - private bool _smartcardLogonRequired = false; + private bool _smartcardLogonRequired; private LoadState _smartcardLogonRequiredChanged = LoadState.NotSet; public bool SmartcardLogonRequired @@ -141,7 +141,7 @@ public bool SmartcardLogonRequired } // DelegationPermitted - private bool _delegationPermitted = false; + private bool _delegationPermitted; private LoadState _delegationPermittedChanged = LoadState.NotSet; public bool DelegationPermitted @@ -162,7 +162,7 @@ public bool DelegationPermitted } // BadLogonCount - private int _badLogonCount = 0; + private int _badLogonCount; private LoadState _badLogonCountChanged = LoadState.NotSet; public int BadLogonCount @@ -174,7 +174,7 @@ public int BadLogonCount } // HomeDirectory - private string _homeDirectory = null; + private string _homeDirectory; private LoadState _homeDirectoryChanged = LoadState.NotSet; public string HomeDirectory @@ -195,7 +195,7 @@ public string HomeDirectory } // HomeDrive - private string _homeDrive = null; + private string _homeDrive; private LoadState _homeDriveChanged = LoadState.NotSet; public string HomeDrive @@ -216,7 +216,7 @@ public string HomeDrive } // ScriptPath - private string _scriptPath = null; + private string _scriptPath; private LoadState _scriptPathChanged = LoadState.NotSet; public string ScriptPath diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AdvancedFilters.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AdvancedFilters.cs index 28beafe72f953..3765569bba983 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AdvancedFilters.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AdvancedFilters.cs @@ -19,8 +19,8 @@ protected internal AdvancedFilters(Principal p) _p = p; } - private bool _badPasswordAttemptChanged = false; - private QbeMatchType _badPasswordAttemptVal = null; + private bool _badPasswordAttemptChanged; + private QbeMatchType _badPasswordAttemptVal; private readonly Principal _p; public void LastBadPasswordAttempt(DateTime lastAttempt, MatchType match) @@ -37,8 +37,8 @@ public void LastBadPasswordAttempt(DateTime lastAttempt, MatchType match) _badPasswordAttemptChanged = true; } - private bool _expirationTimeChanged = false; - private QbeMatchType _expirationTimeVal = null; + private bool _expirationTimeChanged; + private QbeMatchType _expirationTimeVal; public void AccountExpirationDate(DateTime expirationTime, MatchType match) { @@ -54,8 +54,8 @@ public void AccountExpirationDate(DateTime expirationTime, MatchType match) _expirationTimeChanged = true; } - private bool _lockoutTimeChanged = false; - private QbeMatchType _lockoutTimeVal = null; + private bool _lockoutTimeChanged; + private QbeMatchType _lockoutTimeVal; public void AccountLockoutTime(DateTime lockoutTime, MatchType match) { @@ -71,8 +71,8 @@ public void AccountLockoutTime(DateTime lockoutTime, MatchType match) _lockoutTimeChanged = true; } - private bool _badLogonCountChanged = false; - private QbeMatchType _badLogonCountVal = null; + private bool _badLogonCountChanged; + private QbeMatchType _badLogonCountVal; public void BadLogonCount(int badLogonCount, MatchType match) { @@ -88,8 +88,8 @@ public void BadLogonCount(int badLogonCount, MatchType match) _badLogonCountChanged = true; } - private bool _logonTimeChanged = false; - private QbeMatchType _logonTimeVal = null; + private bool _logonTimeChanged; + private QbeMatchType _logonTimeVal; public void LastLogonTime(DateTime logonTime, MatchType match) { @@ -105,8 +105,8 @@ public void LastLogonTime(DateTime logonTime, MatchType match) _logonTimeChanged = true; } - private bool _passwordSetTimeChanged = false; - private QbeMatchType _passwordSetTimeVal = null; + private bool _passwordSetTimeChanged; + private QbeMatchType _passwordSetTimeVal; public void LastPasswordSetTime(DateTime passwordSetTime, MatchType match) { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthZSet.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthZSet.cs index 0f9a955e329ec..e8c063d9a967f 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthZSet.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthZSet.cs @@ -524,10 +524,10 @@ public override void Dispose() // // The user whose groups we're retrieving - private readonly SafeMemoryPtr _psUserSid = null; + private readonly SafeMemoryPtr _psUserSid; // The SID of the machine domain of the machine we're running on - private readonly SafeMemoryPtr _psMachineSid = null; + private readonly SafeMemoryPtr _psMachineSid; // The user's StoreCtx private readonly StoreCtx _userStoreCtx; @@ -551,16 +551,16 @@ public override void Dispose() private readonly SidList _groupSidList; // The native TOKEN_GROUPS returned by AuthzGetInformationFromContext - private readonly SafeMemoryPtr _psBuffer = null; + private readonly SafeMemoryPtr _psBuffer; // Have we been disposed? - private bool _disposed = false; + private bool _disposed; // Maps sidIssuerName --> PrincipalContext private readonly Hashtable _contexts = new Hashtable(); // Contains cached results if the local machine is a DC. - private bool? _localMachineIsDC = null; + private bool? _localMachineIsDC; // // Guarantees finalization of the native resources diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthenticablePrincipal.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthenticablePrincipal.cs index e8cfb35a8be81..8d043926cb62e 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthenticablePrincipal.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthenticablePrincipal.cs @@ -17,7 +17,7 @@ public class AuthenticablePrincipal : Principal // // Enabled property - private bool _enabled = false; // the actual property value + private bool _enabled; // the actual property value private LoadState _enabledChanged = LoadState.NotSet; // change-tracking public Nullable Enabled @@ -67,7 +67,7 @@ public Nullable Enabled // AccountInfo-related properties/methods // - private AccountInfo _accountInfo = null; + private AccountInfo _accountInfo; private AccountInfo AccountInfo { @@ -162,7 +162,7 @@ public void UnlockAccount() // PasswordInfo-related properties/methods // - private PasswordInfo _passwordInfo = null; + private PasswordInfo _passwordInfo; private PasswordInfo PasswordInfo { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/ConfigurationHandler.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/ConfigurationHandler.cs index ea57e455a6190..59a2a45c96a53 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/ConfigurationHandler.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/ConfigurationHandler.cs @@ -34,6 +34,6 @@ public string DebugLogFile } private readonly DebugLevel _debugLevel = GlobalConfig.DefaultDebugLevel; - private readonly string _debugLogFile = null; + private readonly string _debugLogFile; } } diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Context.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Context.cs index 0a63cb11da418..cc4dff7271788 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Context.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Context.cs @@ -1021,11 +1021,11 @@ public void Dispose() // // Are we initialized? - private bool _initialized = false; + private bool _initialized; private readonly object _initializationLock = new object(); // Have we been disposed? - private bool _disposed = false; + private bool _disposed; internal bool Disposed { get { return _disposed; } } // Our constructor parameters @@ -1052,7 +1052,7 @@ internal ServerProperties ServerInformation private readonly ContextType _contextType; // The server we're connected to - private string _connectedServer = null; + private string _connectedServer; // The reason there are different contexts for groups, users and computers is so that // when a principal is created it will go into the appropriate default container. This is so users don't @@ -1062,12 +1062,12 @@ internal ServerProperties ServerInformation // The StoreCtx to be used when inserting a new User/Computer/Group Principal into this // PrincipalContext. - private StoreCtx _userCtx = null; - private StoreCtx _computerCtx = null; - private StoreCtx _groupCtx = null; + private StoreCtx _userCtx; + private StoreCtx _computerCtx; + private StoreCtx _groupCtx; // The StoreCtx to be used when querying against this PrincipalContext for Principals - private StoreCtx _queryCtx = null; + private StoreCtx _queryCtx; internal StoreCtx QueryCtx { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/FindResult.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/FindResult.cs index 957bba5561a86..e9a0763de8a0c 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/FindResult.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/FindResult.cs @@ -76,7 +76,7 @@ internal PrincipalSearchResult(ResultSet resultSet) // The ResultSet returned by the query. private readonly ResultSet _resultSet; - private bool _disposed = false; + private bool _disposed; private void CheckDisposed() { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/FindResultEnumerator.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/FindResultEnumerator.cs index c10a8a6b686ff..6fc67d01ea7fa 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/FindResultEnumerator.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/FindResultEnumerator.cs @@ -182,10 +182,10 @@ internal FindResultEnumerator(ResultSet resultSet) private bool _beforeStart = true; // if true, we've reached the end of the ResultSet - private bool _endReached = false; + private bool _endReached; // true if Dispose() has been called - private bool _disposed = false; + private bool _disposed; // private void CheckDisposed() diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Group.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Group.cs index 6eceace86068c..8bccbb7a785c6 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Group.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Group.cs @@ -39,7 +39,7 @@ public GroupPrincipal(PrincipalContext context, string samAccountName) : this(co // // IsSecurityGroup property - private bool _isSecurityGroup = false; // the actual property value + private bool _isSecurityGroup; // the actual property value private LoadState _isSecurityGroupChanged = LoadState.NotSet; // change-tracking public Nullable IsSecurityGroup @@ -130,7 +130,7 @@ public Nullable GroupScope } // Members property - private PrincipalCollection _members = null; + private PrincipalCollection _members; public PrincipalCollection Members { @@ -212,7 +212,7 @@ public PrincipalSearchResult GetMembers(bool recursive) } } - private bool _disposed = false; + private bool _disposed; public override void Dispose() { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/NetCred.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/NetCred.cs index 9547b14071e9c..864eb5427cc38 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/NetCred.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/NetCred.cs @@ -93,9 +93,9 @@ private unsafe void SplitUsername(string username, ref string parsedUserName, re } // - private readonly string _username = null; - private readonly string _password = null; - private string _domainname = null; - private string _parsedUserName = null; + private readonly string _username; + private readonly string _password; + private string _domainname; + private string _parsedUserName; } } diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PasswordInfo.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PasswordInfo.cs index b1f116e07efd6..01d66fee8167c 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PasswordInfo.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PasswordInfo.cs @@ -19,7 +19,7 @@ internal class PasswordInfo // // LastPasswordSet - private Nullable _lastPasswordSet = null; + private Nullable _lastPasswordSet; private LoadState _lastPasswordSetLoaded = LoadState.NotSet; public Nullable LastPasswordSet @@ -31,7 +31,7 @@ public Nullable LastPasswordSet } // LastBadPasswordAttempt - private Nullable _lastBadPasswordAttempt = null; + private Nullable _lastBadPasswordAttempt; private LoadState _lastBadPasswordAttemptLoaded = LoadState.NotSet; public Nullable LastBadPasswordAttempt @@ -43,7 +43,7 @@ public Nullable LastBadPasswordAttempt } // PasswordNotRequired - private bool _passwordNotRequired = false; + private bool _passwordNotRequired; private LoadState _passwordNotRequiredChanged = LoadState.NotSet; public bool PasswordNotRequired @@ -61,7 +61,7 @@ public bool PasswordNotRequired } // PasswordNeverExpires - private bool _passwordNeverExpires = false; + private bool _passwordNeverExpires; private LoadState _passwordNeverExpiresChanged = LoadState.NotSet; public bool PasswordNeverExpires @@ -79,9 +79,9 @@ public bool PasswordNeverExpires } // UserCannotChangePassword - private bool _cannotChangePassword = false; + private bool _cannotChangePassword; private LoadState _cannotChangePasswordChanged = LoadState.NotSet; - private bool _cannotChangePasswordRead = false; + private bool _cannotChangePasswordRead; // For this property we are doing an on demand load. The store will not load this property when load is called beacuse // the loading of this property is perf intensive. HandleGet still needs to be called to load the other object properties if @@ -109,7 +109,7 @@ public bool UserCannotChangePassword } // AllowReversiblePasswordEncryption - private bool _allowReversiblePasswordEncryption = false; + private bool _allowReversiblePasswordEncryption; private LoadState _allowReversiblePasswordEncryptionChanged = LoadState.NotSet; public bool AllowReversiblePasswordEncryption @@ -130,7 +130,7 @@ public bool AllowReversiblePasswordEncryption // Methods exposed to the public through AuthenticablePrincipal // - private string _storedNewPassword = null; + private string _storedNewPassword; public void SetPassword(string newPassword) { @@ -167,7 +167,7 @@ public void ChangePassword(string oldPassword, string newPassword) _owningPrincipal.GetStoreCtxToUse().ChangePassword(_owningPrincipal, oldPassword, newPassword); } - private bool _expirePasswordImmediately = false; + private bool _expirePasswordImmediately; public void ExpirePasswordNow() { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs index 8c2bcb0871291..879e32831fccc 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs @@ -726,22 +726,22 @@ internal void AdvancedFilterSet(string attribute, object value, Type objectType, // // True indicates this is a new Principal object that has not yet been persisted to the store - internal bool unpersisted = false; + internal bool unpersisted; // True means our store object has been deleted - private bool _isDeleted = false; + private bool _isDeleted; // True means that StoreCtx.Load() has been called on this Principal to load in the values // of all the delay-loaded properties. - private bool _loaded = false; + private bool _loaded; // True means this principal corresponds to one of the well-known SIDs that do not have a // corresponding store object (e.g., NT AUTHORITY\NETWORK SERVICE). Such principals // should be treated as read-only. - internal bool fakePrincipal = false; + internal bool fakePrincipal; // Directly corresponds to the Principal.PrincipalContext public property - private PrincipalContext _ctx = null; + private PrincipalContext _ctx; internal bool Loaded { @@ -821,7 +821,7 @@ internal StoreCtx GetStoreCtxToUse() // Set by StoreCtx.GetAsPrincipal when this Principal was instantiated by it. // If not set, this is a unpersisted principal and StoreCtx.PushChangesToNative() // has not yet been called on it - private object _underlyingObject = null; + private object _underlyingObject; internal object UnderlyingObject { get @@ -842,7 +842,7 @@ internal object UnderlyingObject // Set by StoreCtx.GetAsPrincipal when this Principal was instantiated by it. // If not set, this object was not created from a search. We need to store the searchresult until the object is persisted because // we may need to load properties from it. - private object _underlyingSearchObject = null; + private object _underlyingSearchObject; internal object UnderlyingSearchObject { get @@ -863,7 +863,7 @@ internal object UnderlyingSearchObject // can correspond to more than one possible principal in the store (e.g., WinFS's "multiple principals // per contact" model), the StoreCtx can use this to track and discern which principal in the // UnderlyingObject this Principal object corresponds to. Set by GetAsPrincipal(), if set at all. - private object _discriminant = null; + private object _discriminant; internal object Discriminant { get { return _discriminant; } @@ -872,14 +872,14 @@ internal object Discriminant // A store-specific key, used to determine if two CLR Principal objects represent the same store principal. // Set by GetAsPrincipal when Principal is created from a query, or when a unpersisted Principal is persisted. - private StoreKey _key = null; + private StoreKey _key; internal StoreKey Key { get { return _key; } set { _key = value; } } - private bool _disposed = false; + private bool _disposed; // Checks if the principal has been disposed or deleted, and throws an appropriate exception if it has. [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)] diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollection.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollection.cs index 67ec5e8dbbc8c..943e660a217ae 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollection.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollection.cs @@ -671,8 +671,8 @@ internal void Dispose() private readonly List _removedValuesPending = new List(); // Has this collection been cleared? - private bool _clearPending = false; - private bool _clearCompleted = false; + private bool _clearPending; + private bool _clearCompleted; internal bool ClearCompleted { @@ -693,7 +693,7 @@ internal void MarkChange() } // To support disposal - private bool _disposed = false; + private bool _disposed; private void CheckDisposed() { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollectionEnumerator.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollectionEnumerator.cs index 437c7fce7aadd..3434105b0cb9d 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollectionEnumerator.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollectionEnumerator.cs @@ -277,9 +277,9 @@ List insertedValuesPending private readonly List _removedValuesPending; private readonly List _removedValuesCompleted; - private bool _endReached = false; // true if there are no results left to iterate over + private bool _endReached; // true if there are no results left to iterate over - private IEnumerator _enumerator = null; // The insertedValues{Completed,Pending} enumerator, used by MoveNext + private IEnumerator _enumerator; // The insertedValues{Completed,Pending} enumerator, used by MoveNext private enum CurrentEnumeratorMode // The set of values that MoveNext is currently iterating over { @@ -292,7 +292,7 @@ private enum CurrentEnumeratorMode // The set of values that MoveNext i private CurrentEnumeratorMode _currentMode = CurrentEnumeratorMode.None; // To support IDisposable - private bool _disposed = false; + private bool _disposed; private void CheckDisposed() { @@ -306,7 +306,7 @@ private void CheckDisposed() // When this enumerator was constructed, to detect changes made to the PrincipalCollection after it was constructed private readonly DateTime _creationTime = DateTime.UtcNow; - private readonly PrincipalCollection _memberCollection = null; + private readonly PrincipalCollection _memberCollection; private void CheckChanged() { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalSearcher.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalSearcher.cs index 68d1811c0a0eb..ec7fc43ff105b 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalSearcher.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalSearcher.cs @@ -201,7 +201,7 @@ public virtual void Dispose() private PrincipalContext _ctx; // Are we disposed? - private bool _disposed = false; + private bool _disposed; // Directly corresponds to the PrincipalSearcher.QueryFilter property. // Null means "return all principals". @@ -209,7 +209,7 @@ public virtual void Dispose() // The default page size to use. This value is automatically set // whenever a PrincipalContext is assigned to this object. - private int _pageSize = 0; + private int _pageSize; internal int PageSize { @@ -220,7 +220,7 @@ internal int PageSize // Set by StoreCtx. PushFilterToNativeSearcher(), based on the qbeFilter. // If not set, either there is no underlying searcher (SAM), or PushFilterToNativeSearcher has not // yet been called. - private object _underlyingSearcher = null; + private object _underlyingSearcher; internal object UnderlyingSearcher { get diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/QbeFilterDescription.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/QbeFilterDescription.cs index 35188ebc0ed5d..657c454ca630f 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/QbeFilterDescription.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/QbeFilterDescription.cs @@ -117,7 +117,7 @@ public object Extra set { _extra = value; } } - private object _extra = null; + private object _extra; public abstract string PropertyName { get; } } diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMGroupsSet.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMGroupsSet.cs index 34a361d93474b..76a26e7a1933c 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMGroupsSet.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMGroupsSet.cs @@ -98,7 +98,7 @@ internal override void Reset() private bool _atBeginning = true; - private DirectoryEntry _current = null; + private DirectoryEntry _current; } } diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMMembersSet.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMMembersSet.cs index 008b11467c1a1..11f7b3affffc8 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMMembersSet.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMMembersSet.cs @@ -569,7 +569,7 @@ public override void Dispose() private readonly bool _recursive; - private bool _disposed = false; + private bool _disposed; private readonly SAMStoreCtx _storeCtx; @@ -582,8 +582,8 @@ public override void Dispose() private List _groupsToVisit = new List(); - private DirectoryEntry _current = null; // current member of the group (if enumerating local group and found a real principal) - private Principal _currentFakePrincipal = null; // current member of the group (if enumerating local group and found a fake pricipal) + private DirectoryEntry _current; // current member of the group (if enumerating local group and found a real principal) + private Principal _currentFakePrincipal; // current member of the group (if enumerating local group and found a fake pricipal) private UnsafeNativeMethods.IADsGroup _group; // the group whose membership we're currently enumerating over private readonly UnsafeNativeMethods.IADsGroup _originalGroup; // the group whose membership we started off with (before recursing) @@ -592,10 +592,10 @@ public override void Dispose() // foreign private List _foreignMembers = new List(); - private Principal _currentForeign = null; // current member of the group (if enumerating foreign principal) + private Principal _currentForeign; // current member of the group (if enumerating foreign principal) private List _foreignGroups = new List(); - private ResultSet _foreignResultSet = null; // current foreign group's ResultSet (if enumerating via proxy to foreign group) + private ResultSet _foreignResultSet; // current foreign group's ResultSet (if enumerating via proxy to foreign group) } internal class SAMMembersSetBookmark : ResultSetBookmark diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMQuerySet.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMQuerySet.cs index b3e5762a1e760..4b88b5b5d8844 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMQuerySet.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMQuerySet.cs @@ -179,8 +179,8 @@ internal override void Reset() private readonly SAMStoreCtx _storeCtx; private readonly DirectoryEntry _ctxBase; private readonly DirectoryEntries _entries; - private readonly IEnumerator _enumerator = null; // the enumerator for "entries" - private DirectoryEntry _current = null; // the DirectoryEntry that we're currently positioned at + private readonly IEnumerator _enumerator; // the enumerator for "entries" + private DirectoryEntry _current; // the DirectoryEntry that we're currently positioned at // Filter parameters private readonly int _sizeLimit; // -1 == no limit @@ -188,10 +188,10 @@ internal override void Reset() private readonly SAMMatcher _matcher; // Count of number of results returned so far - private int _resultsReturned = 0; + private int _resultsReturned; // Have we run out of entries? - private bool _endReached = false; + private bool _endReached; } internal abstract class SAMMatcher diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx.cs index a95059eaa00af..ee1fdf0352e8b 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx.cs @@ -17,10 +17,10 @@ internal partial class SAMStoreCtx : StoreCtx private readonly bool _ownCtxBase; // if true, we "own" ctxBase and must Dispose of it when we're done - private bool _disposed = false; + private bool _disposed; internal NetCred Credentials { get { return _credentials; } } - private readonly NetCred _credentials = null; + private readonly NetCred _credentials; internal AuthenticationTypes AuthTypes { get { return _authTypes; } } private readonly AuthenticationTypes _authTypes; @@ -1005,9 +1005,9 @@ internal string MachineFlatName } private readonly object _computerInfoLock = new object(); - private Nullable _isLSAM = null; - private string _machineUserSuppliedName = null; - private string _machineFlatName = null; + private Nullable _isLSAM; + private string _machineUserSuppliedName; + private string _machineFlatName; // computerInfoLock must be held coming in here private void LoadComputerInfo() diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx_LoadStore.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx_LoadStore.cs index de42ccee60160..ca759a8597c2b 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx_LoadStore.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx_LoadStore.cs @@ -722,17 +722,17 @@ internal override Type NativeType(Principal p) {PropertyNames.PwdInfoAllowReversiblePasswordEncryption, typeof(ComputerPrincipal), null, null, new ToWinNTConverterDelegate(ExceptionToWinNTConverter)} }; - private static readonly Hashtable s_userPropertyMappingTableByProperty = null; - private static readonly Hashtable s_userPropertyMappingTableByWinNT = null; + private static readonly Hashtable s_userPropertyMappingTableByProperty; + private static readonly Hashtable s_userPropertyMappingTableByWinNT; - private static readonly Hashtable s_groupPropertyMappingTableByProperty = null; - private static readonly Hashtable s_groupPropertyMappingTableByWinNT = null; + private static readonly Hashtable s_groupPropertyMappingTableByProperty; + private static readonly Hashtable s_groupPropertyMappingTableByWinNT; - private static readonly Hashtable s_computerPropertyMappingTableByProperty = null; - private static readonly Hashtable s_computerPropertyMappingTableByWinNT = null; + private static readonly Hashtable s_computerPropertyMappingTableByProperty; + private static readonly Hashtable s_computerPropertyMappingTableByWinNT; - private static readonly Dictionary s_validPropertyMap = null; - private static readonly Dictionary s_maskMap = null; + private static readonly Dictionary s_validPropertyMap; + private static readonly Dictionary s_maskMap; [Flags] private enum ObjectMask diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/StoreCtx.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/StoreCtx.cs index 74c1ad891a1b9..3d1122a9437f9 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/StoreCtx.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/StoreCtx.cs @@ -25,7 +25,7 @@ internal abstract class StoreCtx : IDisposable // The PrincipalContext object to which this StoreCtx belongs. Initialized by PrincipalContext after it creates // this StoreCtx instance. - private PrincipalContext _owningContext = null; + private PrincipalContext _owningContext; internal PrincipalContext OwningContext { get diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/TrackedCollection.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/TrackedCollection.cs index 0e7dcc5d6657e..d57c76b043f45 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/TrackedCollection.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/TrackedCollection.cs @@ -205,7 +205,7 @@ internal class ValueEl //public T insertedValue = T.default; public T insertedValue; - public Pair originalValue = null; + public Pair originalValue; public T GetCurrentValue() { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/TrackedCollectionEnumerator.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/TrackedCollectionEnumerator.cs index 0d9f91ecd9e40..66e1ccc207f34 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/TrackedCollectionEnumerator.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/TrackedCollectionEnumerator.cs @@ -143,25 +143,25 @@ internal TrackedCollectionEnumerator(string outerClassName, TrackedCollection // // Have we been disposed? - private bool _disposed = false; + private bool _disposed; // The name of our outer class. Used when throwing an ObjectDisposedException. private readonly string _outerClassName; - private readonly List.ValueEl> _combinedValues = null; + private readonly List.ValueEl> _combinedValues; // The value we're currently positioned at private T _current; // The enumerator for our inner list, combinedValues. - private IEnumerator _enumerator = null; + private IEnumerator _enumerator; // True when we reach the end of combinedValues (no more values to enumerate in the TrackedCollection) - private bool _endReached = false; + private bool _endReached; // When this enumerator was constructed, to detect changes made to the TrackedCollection after it was constructed private readonly DateTime _creationTime = DateTime.UtcNow; - private readonly TrackedCollection _trackedCollection = null; + private readonly TrackedCollection _trackedCollection; private void CheckDisposed() { diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/User.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/User.cs index 702ba2162f54a..a6026966b243a 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/User.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/User.cs @@ -42,7 +42,7 @@ public UserPrincipal(PrincipalContext context, string samAccountName, string pas // // GivenName - private string _givenName = null; // the actual property value + private string _givenName; // the actual property value private LoadState _givenNameChanged = LoadState.NotSet; // change-tracking public string GivenName @@ -63,7 +63,7 @@ public string GivenName } // MiddleName - private string _middleName = null; // the actual property value + private string _middleName; // the actual property value private LoadState _middleNameChanged = LoadState.NotSet; // change-tracking public string MiddleName @@ -84,7 +84,7 @@ public string MiddleName } // Surname - private string _surname = null; // the actual property value + private string _surname; // the actual property value private LoadState _surnameChanged = LoadState.NotSet; // change-tracking public string Surname @@ -105,7 +105,7 @@ public string Surname } // EmailAddress - private string _emailAddress = null; // the actual property value + private string _emailAddress; // the actual property value private LoadState _emailAddressChanged = LoadState.NotSet; // change-tracking public string EmailAddress @@ -126,7 +126,7 @@ public string EmailAddress } // VoiceTelephoneNumber - private string _voiceTelephoneNumber = null; // the actual property value + private string _voiceTelephoneNumber; // the actual property value private LoadState _voiceTelephoneNumberChanged = LoadState.NotSet; // change-tracking public string VoiceTelephoneNumber @@ -147,7 +147,7 @@ public string VoiceTelephoneNumber } // EmployeeId - private string _employeeID = null; // the actual property value + private string _employeeID; // the actual property value private LoadState _employeeIDChanged = LoadState.NotSet; // change-tracking public string EmployeeId diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs index 882e3133493d4..8006ecc6cf89c 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/exceptions.cs @@ -107,8 +107,8 @@ protected PrincipalExistsException(SerializationInfo info, StreamingContext cont [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class PrincipalServerDownException : PrincipalException { - private readonly int _errorCode = 0; - private readonly string _serverName = null; + private readonly int _errorCode; + private readonly string _serverName; public PrincipalServerDownException() : base() { } @@ -151,7 +151,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class PrincipalOperationException : PrincipalException { - private readonly int _errorCode = 0; + private readonly int _errorCode; public PrincipalOperationException() : base() { } diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/interopt.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/interopt.cs index 81c9ee444fe07..a510ae7d51da5 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/interopt.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/interopt.cs @@ -459,15 +459,15 @@ public static extern int DsRoleGetPrimaryDomainInformation( [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class DomainControllerInfo { - public string DomainControllerName = null; - public string DomainControllerAddress = null; - public int DomainControllerAddressType = 0; + public string DomainControllerName; + public string DomainControllerAddress; + public int DomainControllerAddressType; public Guid DomainGuid; - public string DomainName = null; - public string DnsForestName = null; - public int Flags = 0; - public string DcSiteName = null; - public string ClientSiteName = null; + public string DomainName; + public string DnsForestName; + public int Flags; + public string DcSiteName; + public string ClientSiteName; } /* @@ -506,11 +506,11 @@ public static extern int DsGetDcName( [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class WKSTA_INFO_100 { - public int wki100_platform_id = 0; - public string wki100_computername = null; - public string wki100_langroup = null; - public int wki100_ver_major = 0; - public int wki100_ver_minor = 0; + public int wki100_platform_id; + public string wki100_computername; + public string wki100_langroup; + public int wki100_ver_major; + public int wki100_ver_minor; }; [DllImport("wkscli.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "NetWkstaGetInfo", CharSet = CharSet.Unicode)] @@ -651,7 +651,7 @@ public struct LUID [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class TOKEN_GROUPS { - public int groupCount = 0; + public int groupCount; public IntPtr groups = IntPtr.Zero; } @@ -659,7 +659,7 @@ public sealed class TOKEN_GROUPS public sealed class SID_AND_ATTR { public IntPtr pSid = IntPtr.Zero; - public int attrs = 0; + public int attrs; } // @@ -675,21 +675,21 @@ public sealed class TOKEN_USER [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class SID_IDENTIFIER_AUTHORITY { - public byte b1 = 0; - public byte b2 = 0; - public byte b3 = 0; - public byte b4 = 0; - public byte b5 = 0; - public byte b6 = 0; + public byte b1; + public byte b2; + public byte b3; + public byte b4; + public byte b5; + public byte b6; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class LSA_OBJECT_ATTRIBUTES { - public int length = 0; + public int length; public IntPtr rootDirectory = IntPtr.Zero; public IntPtr objectName = IntPtr.Zero; - public int attributes = 0; + public int attributes; public IntPtr securityDescriptor = IntPtr.Zero; public IntPtr securityQualityOfService = IntPtr.Zero; } @@ -704,25 +704,25 @@ public sealed class POLICY_ACCOUNT_DOMAIN_INFO [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class LSA_UNICODE_STRING { - public ushort length = 0; - public ushort maximumLength = 0; + public ushort length; + public ushort maximumLength; public IntPtr buffer = IntPtr.Zero; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class LSA_UNICODE_STRING_Managed { - public ushort length = 0; - public ushort maximumLength = 0; + public ushort length; + public ushort maximumLength; public string buffer; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public sealed class LSA_TRANSLATED_NAME { - public int use = 0; + public int use; public LSA_UNICODE_STRING name = new LSA_UNICODE_STRING(); - public int domainIndex = 0; + public int domainIndex; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] @@ -731,7 +731,7 @@ public sealed class LSA_REFERENCED_DOMAIN_LIST // To stop the compiler from autogenerating a constructor for this class private LSA_REFERENCED_DOMAIN_LIST() { } - public int entries = 0; + public int entries; public IntPtr domains = IntPtr.Zero; } diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Linux.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Linux.cs index 8478b4b150430..fa75fdc3e0386 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Linux.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Linux.cs @@ -8,7 +8,7 @@ namespace System.DirectoryServices.Protocols { internal sealed class ConnectionHandle : SafeHandleZeroOrMinusOneIsInvalid { - internal bool _needDispose = false; + internal bool _needDispose; internal ConnectionHandle() :base(true) diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Windows.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Windows.cs index 26d3b4992b1bb..d11d19f5b3d94 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Windows.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/Interop/SafeHandles.Windows.cs @@ -35,7 +35,7 @@ protected override bool ReleaseHandle() internal sealed class ConnectionHandle : SafeHandleZeroOrMinusOneIsInvalid { - internal bool _needDispose = false; + internal bool _needDispose; internal ConnectionHandle() : base(true) { diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryAttribute.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryAttribute.cs index 5a9d65408f14c..97c9a78e17d39 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryAttribute.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryAttribute.cs @@ -12,7 +12,7 @@ namespace System.DirectoryServices.Protocols public class DirectoryAttribute : CollectionBase { private string _attributeName = ""; - internal bool _isSearchResult = false; + internal bool _isSearchResult; // Does not request Unicode byte order mark prefix be emitted, but turn on error detection. private static readonly UTF8Encoding s_utf8EncoderWithErrorDetection = new UTF8Encoding(false, true); // No Error detection. diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryControl.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryControl.cs index ca22f76d9d0be..40e6725a84b24 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryControl.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryControl.cs @@ -55,7 +55,7 @@ public class SortKey { private string _name; private string _rule; - private bool _order = false; + private bool _order; public SortKey() { @@ -809,10 +809,10 @@ internal SortResponseControl(ResultCode result, string attributeName, bool criti public class VlvRequestControl : DirectoryControl { - private int _before = 0; - private int _after = 0; - private int _offset = 0; - private int _estimateCount = 0; + private int _before; + private int _after; + private int _offset; + private int _estimateCount; private byte[] _target; private byte[] _context; diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryRequest.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryRequest.cs index 15772fdb66d19..fe263511e438c 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryRequest.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryRequest.cs @@ -188,7 +188,7 @@ public ModifyDNRequest(string distinguishedName, string newParentDistinguishedNa public class ExtendedRequest : DirectoryRequest { - private byte[] _requestValue = null; + private byte[] _requestValue; public ExtendedRequest() { } @@ -326,10 +326,10 @@ public TimeSpan TimeLimit public bool TypesOnly { get; set; } - private object _directoryFilter = null; + private object _directoryFilter; private SearchScope _directoryScope = SearchScope.Subtree; private DereferenceAlias _directoryRefAlias = DereferenceAlias.Never; - private int _directorySizeLimit = 0; + private int _directorySizeLimit; private TimeSpan _directoryTimeLimit = new TimeSpan(0); } } diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryResponse.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryResponse.cs index 414ee99e6dc58..f0b4b42caa3e1 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryResponse.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryResponse.cs @@ -121,7 +121,7 @@ public class SearchResponse : DirectoryResponse { private SearchResultReferenceCollection _referenceCollection = new SearchResultReferenceCollection(); private SearchResultEntryCollection _entryCollection = new SearchResultEntryCollection(); - internal bool searchDone = false; + internal bool searchDone; internal SearchResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral) { } public SearchResultReferenceCollection References diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapAsyncResult.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapAsyncResult.cs index 6b2421c5c4648..864a3a32d081a 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapAsyncResult.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapAsyncResult.cs @@ -9,14 +9,13 @@ namespace System.DirectoryServices.Protocols { internal class LdapAsyncResult : IAsyncResult { - private LdapAsyncWaitHandle _asyncWaitHandle = null; - internal AsyncCallback _callback = null; - internal bool _completed = false; - private readonly bool _completedSynchronously = false; - internal ManualResetEvent _manualResetEvent = null; - private readonly object _stateObject = null; - internal LdapRequestState _resultObject = null; - internal bool _partialResults = false; + private LdapAsyncWaitHandle _asyncWaitHandle; + internal AsyncCallback _callback; + internal bool _completed; + internal ManualResetEvent _manualResetEvent; + private readonly object _stateObject; + internal LdapRequestState _resultObject; + internal bool _partialResults; public LdapAsyncResult(AsyncCallback callbackRoutine, object state, bool partialResults) { @@ -30,10 +29,10 @@ public LdapAsyncResult(AsyncCallback callbackRoutine, object state, bool partial WaitHandle IAsyncResult.AsyncWaitHandle { - get => _asyncWaitHandle ?? (_asyncWaitHandle = new LdapAsyncWaitHandle(_manualResetEvent.SafeWaitHandle)); + get => _asyncWaitHandle ??= new LdapAsyncWaitHandle(_manualResetEvent.SafeWaitHandle); } - bool IAsyncResult.CompletedSynchronously => _completedSynchronously; + bool IAsyncResult.CompletedSynchronously => false; bool IAsyncResult.IsCompleted => _completed; @@ -62,10 +61,10 @@ public LdapAsyncWaitHandle(SafeWaitHandle handle) : base() internal class LdapRequestState { - internal DirectoryResponse _response = null; - internal LdapAsyncResult _ldapAsync = null; - internal Exception _exception = null; - internal bool _abortCalled = false; + internal DirectoryResponse _response; + internal LdapAsyncResult _ldapAsync; + internal Exception _exception; + internal bool _abortCalled; public LdapRequestState() { } } @@ -85,8 +84,8 @@ internal class LdapPartialAsyncResult : LdapAsyncResult internal ResultsStatus _resultStatus = ResultsStatus.PartialResult; internal TimeSpan _requestTimeout; - internal SearchResponse _response = null; - internal Exception _exception = null; + internal SearchResponse _response; + internal Exception _exception; internal DateTime _startTime; public LdapPartialAsyncResult(int messageID, AsyncCallback callbackRoutine, object state, bool partialResults, LdapConnection con, bool partialCallback, TimeSpan requestTimeout) : base(callbackRoutine, state, partialResults) diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.Windows.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.Windows.cs index 6ae5eb96143f6..9be6e1284f301 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.Windows.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapConnection.Windows.cs @@ -9,7 +9,7 @@ namespace System.DirectoryServices.Protocols { public partial class LdapConnection { - private bool _setFQDNDone = false; + private bool _setFQDNDone; private void InternalInitConnectionHandle(string hostname) { diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapDirectoryIdentifier.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapDirectoryIdentifier.cs index 2d512ca790455..3c8bcfeb7a0b5 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapDirectoryIdentifier.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapDirectoryIdentifier.cs @@ -6,7 +6,7 @@ namespace System.DirectoryServices.Protocols { public class LdapDirectoryIdentifier : DirectoryIdentifier { - private readonly string[] _servers = null; + private readonly string[] _servers; public LdapDirectoryIdentifier(string server) : this(server != null ? new string[] { server } : null, false, false) { diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs index b80b5995c38c5..b7f695de8a4b9 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs @@ -13,9 +13,9 @@ namespace System.DirectoryServices.Protocols internal class LdapPartialResultsProcessor { private readonly ArrayList _resultList = new ArrayList(); - private readonly ManualResetEvent _workThreadWaitHandle = null; - private bool _workToDo = false; - private int _currentIndex = 0; + private readonly ManualResetEvent _workThreadWaitHandle; + private bool _workToDo; + private int _currentIndex; internal LdapPartialResultsProcessor(ManualResetEvent eventHandle) { @@ -335,8 +335,8 @@ private void AddResult(SearchResponse partialResults, SearchResponse newResult) internal class PartialResultsRetriever { - private readonly ManualResetEvent _workThreadWaitHandle = null; - private readonly LdapPartialResultsProcessor _processor = null; + private readonly ManualResetEvent _workThreadWaitHandle; + private readonly LdapPartialResultsProcessor _processor; internal PartialResultsRetriever(ManualResetEvent eventHandle, LdapPartialResultsProcessor processor) { diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.cs index e59d8352ab68e..4a71f4675662f 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapSessionOptions.cs @@ -118,15 +118,15 @@ internal struct SecurityHandle public partial class LdapSessionOptions { - private readonly LdapConnection _connection = null; + private readonly LdapConnection _connection; private ReferralCallback _callbackRoutine = new ReferralCallback(); - internal QueryClientCertificateCallback _clientCertificateDelegate = null; - private VerifyServerCertificateCallback _serverCertificateDelegate = null; + internal QueryClientCertificateCallback _clientCertificateDelegate; + private VerifyServerCertificateCallback _serverCertificateDelegate; - private readonly QUERYFORCONNECTIONInternal _queryDelegate = null; - private readonly NOTIFYOFNEWCONNECTIONInternal _notifiyDelegate = null; - private readonly DEREFERENCECONNECTIONInternal _dereferenceDelegate = null; - private readonly VERIFYSERVERCERT _serverCertificateRoutine = null; + private readonly QUERYFORCONNECTIONInternal _queryDelegate; + private readonly NOTIFYOFNEWCONNECTIONInternal _notifiyDelegate; + private readonly DEREFERENCECONNECTIONInternal _dereferenceDelegate; + private readonly VERIFYSERVERCERT _serverCertificateRoutine; internal LdapSessionOptions(LdapConnection connection) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADAMInstance.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADAMInstance.cs index bb0c83e28b0ee..61cba81445158 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADAMInstance.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADAMInstance.cs @@ -11,23 +11,23 @@ namespace System.DirectoryServices.ActiveDirectory { public class AdamInstance : DirectoryServer { - private readonly string[] _becomeRoleOwnerAttrs = null; - private bool _disposed = false; + private readonly string[] _becomeRoleOwnerAttrs; + private bool _disposed; // for public properties - private string _cachedHostName = null; + private string _cachedHostName; private int _cachedLdapPort = -1; private int _cachedSslPort = -1; - private bool _defaultPartitionInitialized = false; - private bool _defaultPartitionModified = false; - private ConfigurationSet _currentConfigSet = null; - private string _cachedDefaultPartition = null; - private AdamRoleCollection _cachedRoles = null; + private bool _defaultPartitionInitialized; + private bool _defaultPartitionModified; + private ConfigurationSet _currentConfigSet; + private string _cachedDefaultPartition; + private AdamRoleCollection _cachedRoles; private IntPtr _ADAMHandle = (IntPtr)0; private IntPtr _authIdentity = IntPtr.Zero; - private SyncUpdateCallback _userDelegate = null; - private readonly SyncReplicaFromAllServersCallback _syncAllFunctionPointer = null; + private SyncUpdateCallback _userDelegate; + private readonly SyncReplicaFromAllServersCallback _syncAllFunctionPointer; #region constructors internal AdamInstance(DirectoryContext context, string adamInstanceName) diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADSearcher.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADSearcher.cs index f61535cfbff82..33f3f3d0cd085 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADSearcher.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADSearcher.cs @@ -8,7 +8,7 @@ namespace System.DirectoryServices.ActiveDirectory { internal class ADSearcher { - private readonly DirectorySearcher _searcher = null; + private readonly DirectorySearcher _searcher; private static readonly TimeSpan s_defaultTimeSpan = new TimeSpan(0, 120, 0); public ADSearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, SearchScope scope) diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryInterSiteTransport.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryInterSiteTransport.cs index 8991c709a1b7c..26f5df13d3f70 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryInterSiteTransport.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryInterSiteTransport.cs @@ -9,12 +9,12 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectoryInterSiteTransport : IDisposable { - private readonly DirectoryContext _context = null; - private readonly DirectoryEntry _cachedEntry = null; + private readonly DirectoryContext _context; + private readonly DirectoryEntry _cachedEntry; private readonly ActiveDirectoryTransportType _transport; - private bool _disposed = false; - private bool _linkRetrieved = false; - private bool _bridgeRetrieved = false; + private bool _disposed; + private bool _linkRetrieved; + private bool _bridgeRetrieved; private readonly ReadOnlySiteLinkCollection _siteLinkCollection = new ReadOnlySiteLinkCollection(); private readonly ReadOnlySiteLinkBridgeCollection _bridgeCollection = new ReadOnlySiteLinkBridgeCollection(); diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryPartition.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryPartition.cs index dbc799e02f59e..73328956dc895 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryPartition.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryPartition.cs @@ -6,10 +6,10 @@ namespace System.DirectoryServices.ActiveDirectory { public abstract class ActiveDirectoryPartition : IDisposable { - private bool _disposed = false; - internal string partitionName = null; - internal DirectoryContext context = null; - internal DirectoryEntryManager directoryEntryMgr = null; + private bool _disposed; + internal string partitionName; + internal DirectoryContext context; + internal DirectoryEntryManager directoryEntryMgr; #region constructors protected ActiveDirectoryPartition() diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryReplicationMetaData.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryReplicationMetaData.cs index 7ad1d0285de73..66c855cdb6041 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryReplicationMetaData.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryReplicationMetaData.cs @@ -10,8 +10,8 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectoryReplicationMetadata : DictionaryBase { - private readonly DirectoryServer _server = null; - private readonly Hashtable _nameTable = null; + private readonly DirectoryServer _server; + private readonly Hashtable _nameTable; internal ActiveDirectoryReplicationMetadata(DirectoryServer server) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchedule.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchedule.cs index 2ae4757c6f3b9..d1093767065b3 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchedule.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchedule.cs @@ -46,7 +46,7 @@ public class ActiveDirectorySchedule { // 24*7*4 = 672 private readonly bool[] _scheduleArray = new bool[672]; - private readonly long _utcOffSet = 0; + private readonly long _utcOffSet; public ActiveDirectorySchedule() { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchema.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchema.cs index ea10e68612d13..95703049eea07 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchema.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchema.cs @@ -26,10 +26,10 @@ public enum PropertyTypes : int public class ActiveDirectorySchema : ActiveDirectoryPartition { - private bool _disposed = false; - private DirectoryEntry _schemaEntry = null; - private DirectoryEntry _abstractSchemaEntry = null; - private DirectoryServer _cachedSchemaRoleOwner = null; + private bool _disposed; + private DirectoryEntry _schemaEntry; + private DirectoryEntry _abstractSchemaEntry; + private DirectoryServer _cachedSchemaRoleOwner; #region constructors internal ActiveDirectorySchema(DirectoryContext context, string distinguishedName) diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs index 8b4b2d41af9af..71c04852557cc 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs @@ -15,36 +15,36 @@ namespace System.DirectoryServices.ActiveDirectory public class ActiveDirectorySchemaClass : IDisposable { // private variables - private DirectoryEntry _classEntry = null; - private DirectoryEntry _schemaEntry = null; - private DirectoryEntry _abstractClassEntry = null; - private readonly NativeComInterfaces.IAdsClass _iadsClass = null; - private readonly DirectoryContext _context = null; - internal bool isBound = false; - private bool _disposed = false; - private ActiveDirectorySchema _schema = null; - private bool _propertiesFromSchemaContainerInitialized = false; - private bool _isDefunctOnServer = false; - private Hashtable _propertyValuesFromServer = null; + private DirectoryEntry _classEntry; + private DirectoryEntry _schemaEntry; + private DirectoryEntry _abstractClassEntry; + private readonly NativeComInterfaces.IAdsClass _iadsClass; + private readonly DirectoryContext _context; + internal bool isBound; + private bool _disposed; + private ActiveDirectorySchema _schema; + private bool _propertiesFromSchemaContainerInitialized; + private bool _isDefunctOnServer; + private Hashtable _propertyValuesFromServer; // private variables for all the properties of this class - private readonly string _ldapDisplayName = null; - private string _commonName = null; - private string _oid = null; - private string _description = null; - private bool _descriptionInitialized = false; - private bool _isDefunct = false; - private ActiveDirectorySchemaClassCollection _possibleSuperiors = null; - private ActiveDirectorySchemaClassCollection _auxiliaryClasses = null; - private ReadOnlyActiveDirectorySchemaClassCollection _possibleInferiors = null; - private ActiveDirectorySchemaPropertyCollection _mandatoryProperties = null; - private ActiveDirectorySchemaPropertyCollection _optionalProperties = null; - private ActiveDirectorySchemaClass _subClassOf = null; + private readonly string _ldapDisplayName; + private string _commonName; + private string _oid; + private string _description; + private bool _descriptionInitialized; + private bool _isDefunct; + private ActiveDirectorySchemaClassCollection _possibleSuperiors; + private ActiveDirectorySchemaClassCollection _auxiliaryClasses; + private ReadOnlyActiveDirectorySchemaClassCollection _possibleInferiors; + private ActiveDirectorySchemaPropertyCollection _mandatoryProperties; + private ActiveDirectorySchemaPropertyCollection _optionalProperties; + private ActiveDirectorySchemaClass _subClassOf; private SchemaClassType _type = SchemaClassType.Structural; - private bool _typeInitialized = false; - private byte[] _schemaGuidBinaryForm = null; - private string _defaultSDSddlForm = null; - private bool _defaultSDSddlFormInitialized = false; + private bool _typeInitialized; + private byte[] _schemaGuidBinaryForm; + private string _defaultSDSddlForm; + private bool _defaultSDSddlFormInitialized; #region constructors public ActiveDirectorySchemaClass(DirectoryContext context, string ldapDisplayName) diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClassCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClassCollection.cs index c506669acc835..67c1261c5e01a 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClassCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClassCollection.cs @@ -9,11 +9,11 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectorySchemaClassCollection : CollectionBase { - private DirectoryEntry _classEntry = null; - private readonly string _propertyName = null; - private readonly ActiveDirectorySchemaClass _schemaClass = null; - private readonly bool _isBound = false; - private readonly DirectoryContext _context = null; + private DirectoryEntry _classEntry; + private readonly string _propertyName; + private readonly ActiveDirectorySchemaClass _schemaClass; + private readonly bool _isBound; + private readonly DirectoryContext _context; internal ActiveDirectorySchemaClassCollection(DirectoryContext context, ActiveDirectorySchemaClass schemaClass, diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaProperty.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaProperty.cs index f13544ef2b14a..d2a38f6c61ac7 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaProperty.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaProperty.cs @@ -22,42 +22,42 @@ internal enum SearchFlags : int public class ActiveDirectorySchemaProperty : IDisposable { // private variables - private DirectoryEntry _schemaEntry = null; - private DirectoryEntry _propertyEntry = null; - private DirectoryEntry _abstractPropertyEntry = null; - private readonly NativeComInterfaces.IAdsProperty _iadsProperty = null; - private readonly DirectoryContext _context = null; - internal bool isBound = false; - private bool _disposed = false; - private ActiveDirectorySchema _schema = null; - private bool _propertiesFromSchemaContainerInitialized = false; - private bool _isDefunctOnServer = false; - private SearchResult _propertyValuesFromServer = null; + private DirectoryEntry _schemaEntry; + private DirectoryEntry _propertyEntry; + private DirectoryEntry _abstractPropertyEntry; + private readonly NativeComInterfaces.IAdsProperty _iadsProperty; + private readonly DirectoryContext _context; + internal bool isBound; + private bool _disposed; + private ActiveDirectorySchema _schema; + private bool _propertiesFromSchemaContainerInitialized; + private bool _isDefunctOnServer; + private SearchResult _propertyValuesFromServer; // private variables for caching properties - private readonly string _ldapDisplayName = null; - private string _commonName = null; - private string _oid = null; + private readonly string _ldapDisplayName; + private string _commonName; + private string _oid; private ActiveDirectorySyntax _syntax = (ActiveDirectorySyntax)(-1); - private bool _syntaxInitialized = false; - private string _description = null; - private bool _descriptionInitialized = false; - private bool _isSingleValued = false; - private bool _isSingleValuedInitialized = false; - private bool _isInGlobalCatalog = false; - private bool _isInGlobalCatalogInitialized = false; - private Nullable _rangeLower = null; - private bool _rangeLowerInitialized = false; - private Nullable _rangeUpper = null; - private bool _rangeUpperInitialized = false; - private bool _isDefunct = false; + private bool _syntaxInitialized; + private string _description; + private bool _descriptionInitialized; + private bool _isSingleValued; + private bool _isSingleValuedInitialized; + private bool _isInGlobalCatalog; + private bool _isInGlobalCatalogInitialized; + private Nullable _rangeLower; + private bool _rangeLowerInitialized; + private Nullable _rangeUpper; + private bool _rangeUpperInitialized; + private bool _isDefunct; private SearchFlags _searchFlags = SearchFlags.None; - private bool _searchFlagsInitialized = false; - private ActiveDirectorySchemaProperty _linkedProperty = null; - private bool _linkedPropertyInitialized = false; - private Nullable _linkId = null; - private bool _linkIdInitialized = false; - private byte[] _schemaGuidBinaryForm = null; + private bool _searchFlagsInitialized; + private ActiveDirectorySchemaProperty _linkedProperty; + private bool _linkedPropertyInitialized; + private Nullable _linkId; + private bool _linkIdInitialized; + private byte[] _schemaGuidBinaryForm; // OMObjectClass values for the syntax //0x2B0C0287731C00854A diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaPropertyCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaPropertyCollection.cs index 5bea1fa12e76e..756dff0abb277 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaPropertyCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaPropertyCollection.cs @@ -9,11 +9,11 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectorySchemaPropertyCollection : CollectionBase { - private DirectoryEntry _classEntry = null; - private readonly string _propertyName = null; - private readonly ActiveDirectorySchemaClass _schemaClass = null; - private readonly bool _isBound = false; - private readonly DirectoryContext _context = null; + private DirectoryEntry _classEntry; + private readonly string _propertyName; + private readonly ActiveDirectorySchemaClass _schemaClass; + private readonly bool _isBound; + private readonly DirectoryContext _context; internal ActiveDirectorySchemaPropertyCollection(DirectoryContext context, ActiveDirectorySchemaClass schemaClass, diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySite.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySite.cs index a5290e58c7c68..0a6bda09473a9 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySite.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySite.cs @@ -28,36 +28,35 @@ public enum ActiveDirectorySiteOptions public class ActiveDirectorySite : IDisposable { - internal readonly DirectoryContext context = null; - private readonly string _name = null; - internal readonly DirectoryEntry cachedEntry = null; - private DirectoryEntry _ntdsEntry = null; - private readonly ActiveDirectorySubnetCollection _subnets = null; - private DirectoryServer _topologyGenerator = null; + internal readonly DirectoryContext context; + private readonly string _name; + internal readonly DirectoryEntry cachedEntry; + private DirectoryEntry _ntdsEntry; + private readonly ActiveDirectorySubnetCollection _subnets; + private DirectoryServer _topologyGenerator; private readonly ReadOnlySiteCollection _adjacentSites = new ReadOnlySiteCollection(); - private bool _disposed = false; + private bool _disposed; private readonly DomainCollection _domains = new DomainCollection(null); private readonly ReadOnlyDirectoryServerCollection _servers = new ReadOnlyDirectoryServerCollection(); private readonly ReadOnlySiteLinkCollection _links = new ReadOnlySiteLinkCollection(); private ActiveDirectorySiteOptions _siteOptions = ActiveDirectorySiteOptions.None; private ReadOnlyDirectoryServerCollection _bridgeheadServers = new ReadOnlyDirectoryServerCollection(); - private readonly DirectoryServerCollection _SMTPBridgeheadServers = null; - private readonly DirectoryServerCollection _RPCBridgeheadServers = null; - private byte[] _replicationSchedule = null; - - internal bool existing = false; - private bool _subnetRetrieved = false; - private bool _isADAMServer = false; - private readonly bool _checkADAM = false; - private bool _topologyTouched = false; - private bool _adjacentSitesRetrieved = false; - private readonly string _siteDN = null; - private bool _domainsRetrieved = false; - private bool _serversRetrieved = false; - private bool _belongLinksRetrieved = false; - private bool _bridgeheadServerRetrieved = false; - private bool _SMTPBridgeRetrieved = false; - private bool _RPCBridgeRetrieved = false; + private readonly DirectoryServerCollection _SMTPBridgeheadServers; + private readonly DirectoryServerCollection _RPCBridgeheadServers; + private byte[] _replicationSchedule; + + internal bool existing; + private bool _subnetRetrieved; + private bool _isADAMServer; + private bool _topologyTouched; + private bool _adjacentSitesRetrieved; + private readonly string _siteDN; + private bool _domainsRetrieved; + private bool _serversRetrieved; + private bool _belongLinksRetrieved; + private bool _bridgeheadServerRetrieved; + private bool _SMTPBridgeRetrieved; + private bool _RPCBridgeRetrieved; private const int ERROR_NO_SITENAME = 1919; @@ -664,22 +663,19 @@ private bool IsADAM { get { - if (!_checkADAM) + DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); + PropertyValueCollection values; + try { - DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); - PropertyValueCollection values = null; - try - { - values = de.Properties["supportedCapabilities"]; - } - catch (COMException e) - { - throw ExceptionHelper.GetExceptionFromCOMException(context, e); - } - - if (values.Contains(SupportedCapability.ADAMOid)) - _isADAMServer = true; + values = de.Properties["supportedCapabilities"]; } + catch (COMException e) + { + throw ExceptionHelper.GetExceptionFromCOMException(context, e); + } + + if (values.Contains(SupportedCapability.ADAMOid)) + _isADAMServer = true; return _isADAMServer; } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteCollection.cs index 5e85364b26da9..bedaf86c6dc17 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteCollection.cs @@ -9,9 +9,9 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectorySiteCollection : CollectionBase { - internal DirectoryEntry de = null; - internal bool initialized = false; - internal DirectoryContext context = null; + internal DirectoryEntry de; + internal bool initialized; + internal DirectoryContext context; internal ActiveDirectorySiteCollection() { } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLink.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLink.cs index 244b020f7b3f3..d922ba9f372d7 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLink.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLink.cs @@ -12,19 +12,19 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectorySiteLink : IDisposable { - internal readonly DirectoryContext context = null; - private readonly string _name = null; + internal readonly DirectoryContext context; + private readonly string _name; private readonly ActiveDirectoryTransportType _transport = ActiveDirectoryTransportType.Rpc; - private bool _disposed = false; + private bool _disposed; - internal bool existing = false; - internal readonly DirectoryEntry cachedEntry = null; + internal bool existing; + internal readonly DirectoryEntry cachedEntry; private const int systemDefaultCost = 0; private readonly TimeSpan _systemDefaultInterval = new TimeSpan(0, 15, 0); private const int appDefaultCost = 100; private const int appDefaultInterval = 180; private readonly ActiveDirectorySiteCollection _sites = new ActiveDirectorySiteCollection(); - private bool _siteRetrieved = false; + private bool _siteRetrieved; public ActiveDirectorySiteLink(DirectoryContext context, string siteLinkName) : this(context, siteLinkName, ActiveDirectoryTransportType.Rpc, null) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkBridge.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkBridge.cs index 286cd8489d017..b2a9043171f49 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkBridge.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkBridge.cs @@ -12,15 +12,15 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectorySiteLinkBridge : IDisposable { - internal readonly DirectoryContext context = null; - private readonly string _name = null; + internal readonly DirectoryContext context; + private readonly string _name; private readonly ActiveDirectoryTransportType _transport = ActiveDirectoryTransportType.Rpc; - private bool _disposed = false; + private bool _disposed; - private bool _existing = false; - internal DirectoryEntry cachedEntry = null; + private bool _existing; + internal DirectoryEntry cachedEntry; private readonly ActiveDirectorySiteLinkCollection _links = new ActiveDirectorySiteLinkCollection(); - private bool _linksRetrieved = false; + private bool _linksRetrieved; public ActiveDirectorySiteLinkBridge(DirectoryContext context, string bridgeName) : this(context, bridgeName, ActiveDirectoryTransportType.Rpc) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs index 3f6afc747b36a..008c1f2dc0d29 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySiteLinkCollection.cs @@ -9,9 +9,9 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectorySiteLinkCollection : CollectionBase { - internal DirectoryEntry de = null; - internal bool initialized = false; - internal DirectoryContext context = null; + internal DirectoryEntry de; + internal bool initialized; + internal DirectoryContext context; internal ActiveDirectorySiteLinkCollection() { } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySubnet.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySubnet.cs index 111d06edb7016..c487bea29c012 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySubnet.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySubnet.cs @@ -9,13 +9,13 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectorySubnet : IDisposable { - private ActiveDirectorySite _site = null; - private readonly string _name = null; - internal readonly DirectoryContext context = null; - private bool _disposed = false; + private ActiveDirectorySite _site; + private readonly string _name; + internal readonly DirectoryContext context; + private bool _disposed; - internal bool existing = false; - internal DirectoryEntry cachedEntry = null; + internal bool existing; + internal DirectoryEntry cachedEntry; public static ActiveDirectorySubnet FindByName(DirectoryContext context, string subnetName) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySubnetCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySubnetCollection.cs index 540be8cbfc5c0..c8fe681c27227 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySubnetCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySubnetCollection.cs @@ -10,10 +10,10 @@ namespace System.DirectoryServices.ActiveDirectory { public class ActiveDirectorySubnetCollection : CollectionBase { - internal readonly Hashtable changeList = null; - internal bool initialized = false; - private readonly string _siteDN = null; - private readonly DirectoryContext _context = null; + internal readonly Hashtable changeList; + internal bool initialized; + private readonly string _siteDN; + private readonly DirectoryContext _context; private readonly ArrayList _copyList = new ArrayList(); internal ActiveDirectorySubnetCollection(DirectoryContext context, string siteDN) diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySyntax.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySyntax.cs index 8ecf3e03efcba..0490c437ea271 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySyntax.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySyntax.cs @@ -61,9 +61,9 @@ public bool Equals(OMObjectClass OMObjectClass) internal class Syntax { - public readonly string attributeSyntax = null; - public readonly int oMSyntax = 0; - public readonly OMObjectClass oMObjectClass = null; + public readonly string attributeSyntax; + public readonly int oMSyntax; + public readonly OMObjectClass oMObjectClass; public Syntax(string attributeSyntax, int oMSyntax, OMObjectClass oMObjectClass) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ApplicationPartition.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ApplicationPartition.cs index 970561cb0f95f..21bf1253671b1 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ApplicationPartition.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ApplicationPartition.cs @@ -24,15 +24,15 @@ internal enum ApplicationPartitionType : int public class ApplicationPartition : ActiveDirectoryPartition { - private bool _disposed = false; + private bool _disposed; private ApplicationPartitionType _appType = (ApplicationPartitionType)(-1); private bool _committed = true; - private DirectoryEntry _domainDNSEntry = null; - private DirectoryEntry _crossRefEntry = null; - private string _dnsName = null; - private DirectoryServerCollection _cachedDirectoryServers = null; - private bool _securityRefDomainModified = false; - private string _securityRefDomain = null; + private DirectoryEntry _domainDNSEntry; + private DirectoryEntry _crossRefEntry; + private string _dnsName; + private DirectoryServerCollection _cachedDirectoryServers; + private bool _securityRefDomainModified; + private string _securityRefDomain; #region constructors // Public Constructors diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/AttributeMetaData.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/AttributeMetaData.cs index 1d55b97d84a58..ade21a876922b 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/AttributeMetaData.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/AttributeMetaData.cs @@ -10,12 +10,12 @@ namespace System.DirectoryServices.ActiveDirectory { public class AttributeMetadata { - private readonly string _pszLastOriginatingDsaDN = null; + private readonly string _pszLastOriginatingDsaDN; - private string _originatingServerName = null; - private readonly DirectoryServer _server = null; - private readonly Hashtable _nameTable = null; - private readonly bool _advanced = false; + private string _originatingServerName; + private readonly DirectoryServer _server; + private readonly Hashtable _nameTable; + private readonly bool _advanced; internal AttributeMetadata(IntPtr info, bool advanced, DirectoryServer server, Hashtable table) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ConfigSet.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ConfigSet.cs index 6fc86392dfc2c..a951f09cb986b 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ConfigSet.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ConfigSet.cs @@ -13,18 +13,18 @@ namespace System.DirectoryServices.ActiveDirectory public class ConfigurationSet { // Private Variables - private readonly DirectoryContext _context = null; - private readonly DirectoryEntryManager _directoryEntryMgr = null; - private bool _disposed = false; + private readonly DirectoryContext _context; + private readonly DirectoryEntryManager _directoryEntryMgr; + private bool _disposed; // variables corresponding to public properties - private readonly string _configSetName = null; - private ReadOnlySiteCollection _cachedSites = null; - private AdamInstanceCollection _cachedADAMInstances = null; - private ApplicationPartitionCollection _cachedApplicationPartitions = null; - private ActiveDirectorySchema _cachedSchema = null; - private AdamInstance _cachedSchemaRoleOwner = null; - private AdamInstance _cachedNamingRoleOwner = null; + private readonly string _configSetName; + private ReadOnlySiteCollection _cachedSites; + private AdamInstanceCollection _cachedADAMInstances; + private ApplicationPartitionCollection _cachedApplicationPartitions; + private ActiveDirectorySchema _cachedSchema; + private AdamInstance _cachedSchemaRoleOwner; + private AdamInstance _cachedNamingRoleOwner; private ReplicationSecurityLevel _cachedSecurityLevel = (ReplicationSecurityLevel)(-1); // 4 minutes timeout for locating an ADAM instance in the configset diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryContext.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryContext.cs index 2c3573e8b7ff5..77a2f8845cbbb 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryContext.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryContext.cs @@ -22,14 +22,14 @@ public enum DirectoryContextType public class DirectoryContext { - private string _name = null; + private string _name; private DirectoryContextType _contextType; - private NetworkCredential _credential = null; - internal string serverName = null; - internal bool usernameIsNull = false; - internal bool passwordIsNull = false; - private bool _validated = false; - private bool _contextIsValid = false; + private NetworkCredential _credential; + internal string serverName; + internal bool usernameIsNull; + internal bool passwordIsNull; + private bool _validated; + private bool _contextIsValid; internal static LoadLibrarySafeHandle ADHandle; internal static LoadLibrarySafeHandle ADAMHandle; diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryEntryManager.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryEntryManager.cs index 60af77fcbb591..c64a763e6800f 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryEntryManager.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryEntryManager.cs @@ -85,9 +85,9 @@ public override string ToString() internal class DirectoryEntryManager { private readonly Hashtable _directoryEntries = new Hashtable(); - private string _bindingPrefix = null; - private readonly DirectoryContext _context = null; - private readonly NativeComInterfaces.IAdsPathname _pathCracker = null; + private string _bindingPrefix; + private readonly DirectoryContext _context; + private readonly NativeComInterfaces.IAdsPathname _pathCracker; internal DirectoryEntryManager(DirectoryContext context) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs index 5f191c7770e03..0a9b280ce63d1 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs @@ -11,30 +11,26 @@ namespace System.DirectoryServices.ActiveDirectory { public abstract class DirectoryServer : IDisposable { - private bool _disposed = false; - internal DirectoryContext context = null; - internal string replicaName = null; - internal DirectoryEntryManager directoryEntryMgr = null; + private bool _disposed; + internal DirectoryContext context; + internal string replicaName; + internal DirectoryEntryManager directoryEntryMgr; // internal variables for the public properties - internal bool siteInfoModified = false; - internal string cachedSiteName = null; - internal string cachedSiteObjectName = null; - internal string cachedServerObjectName = null; - internal string cachedNtdsaObjectName = null; + internal bool siteInfoModified; + internal string cachedSiteName; + internal string cachedSiteObjectName; + internal string cachedServerObjectName; + internal string cachedNtdsaObjectName; internal Guid cachedNtdsaObjectGuid = Guid.Empty; - // disable csharp compiler warning #0414: field assigned unused value -#pragma warning disable 0414 - internal string cachedIPAddress = null; -#pragma warning restore 0414 - internal ReadOnlyStringCollection cachedPartitions = null; + internal ReadOnlyStringCollection cachedPartitions; internal const int DS_REPSYNC_ASYNCHRONOUS_OPERATION = 0x00000001; internal const int DS_REPSYNC_ALL_SOURCES = 0x00000010; internal const int DS_REPSYNCALL_ID_SERVERS_BY_DN = 0x00000004; internal const int DS_REPL_NOTSUPPORTED = 50; - private ReplicationConnectionCollection _inbound = null; - private ReplicationConnectionCollection _outbound = null; + private ReplicationConnectionCollection _inbound; + private ReplicationConnectionCollection _outbound; #region constructors protected DirectoryServer() diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServerCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServerCollection.cs index 64de6d61b67e8..b8ec8ed266445 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServerCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServerCollection.cs @@ -10,15 +10,15 @@ namespace System.DirectoryServices.ActiveDirectory { public class DirectoryServerCollection : CollectionBase { - internal readonly string siteDN = null; - internal readonly string transportDN = null; - internal readonly DirectoryContext context = null; - internal bool initialized = false; - internal readonly Hashtable changeList = null; + internal readonly string siteDN; + internal readonly string transportDN; + internal readonly DirectoryContext context; + internal bool initialized; + internal readonly Hashtable changeList; private readonly ArrayList _copyList = new ArrayList(); - private readonly DirectoryEntry _crossRefEntry = null; - private readonly bool _isADAM = false; - private readonly bool _isForNC = false; + private readonly DirectoryEntry _crossRefEntry; + private readonly bool _isADAM; + private readonly bool _isForNC; internal DirectoryServerCollection(DirectoryContext context, string siteDN, string transportName) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs index 102c829d539cc..0c5b12bc81f18 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs @@ -27,21 +27,21 @@ public enum DomainMode : int public class Domain : ActiveDirectoryPartition { /// Private Variables - private string _crossRefDN = null; - private string _trustParent = null; + private string _crossRefDN; + private string _trustParent; // internal variables corresponding to public properties - private DomainControllerCollection _cachedDomainControllers = null; - private DomainCollection _cachedChildren = null; + private DomainControllerCollection _cachedDomainControllers; + private DomainCollection _cachedChildren; private DomainMode _currentDomainMode = (DomainMode)(-1); private int _domainModeLevel = -1; - private DomainController _cachedPdcRoleOwner = null; - private DomainController _cachedRidRoleOwner = null; - private DomainController _cachedInfrastructureRoleOwner = null; - private Domain _cachedParent = null; - private Forest _cachedForest = null; + private DomainController _cachedPdcRoleOwner; + private DomainController _cachedRidRoleOwner; + private DomainController _cachedInfrastructureRoleOwner; + private Domain _cachedParent; + private Forest _cachedForest; // this is needed because null value for parent is valid - private bool _isParentInitialized = false; + private bool _isParentInitialized; #region constructors // internal constructors diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DomainController.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DomainController.cs index f3d2241353012..5a04887a80162 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DomainController.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DomainController.cs @@ -42,20 +42,20 @@ public class DomainController : DirectoryServer { private IntPtr _dsHandle = IntPtr.Zero; private IntPtr _authIdentity = IntPtr.Zero; - private readonly string[] _becomeRoleOwnerAttrs = null; - private bool _disposed = false; + private readonly string[] _becomeRoleOwnerAttrs; + private bool _disposed; // internal variables for the public properties - private string _cachedComputerObjectName = null; - private string _cachedOSVersion = null; - private double _cachedNumericOSVersion = 0; - private Forest _currentForest = null; - private Domain _cachedDomain = null; - private ActiveDirectoryRoleCollection _cachedRoles = null; - private bool _dcInfoInitialized = false; - - internal SyncUpdateCallback userDelegate = null; - internal readonly SyncReplicaFromAllServersCallback syncAllFunctionPointer = null; + private string _cachedComputerObjectName; + private string _cachedOSVersion; + private double _cachedNumericOSVersion; + private Forest _currentForest; + private Domain _cachedDomain; + private ActiveDirectoryRoleCollection _cachedRoles; + private bool _dcInfoInitialized; + + internal SyncUpdateCallback userDelegate; + internal readonly SyncReplicaFromAllServersCallback syncAllFunctionPointer; // this is twice the maximum allowed RIDPool size which is 15k internal const int UpdateRidPoolSeizureValue = 30000; diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs index cfcab7902c771..7ba082add6dda 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Exception.cs @@ -162,7 +162,7 @@ protected ActiveDirectoryObjectExistsException(SerializationInfo info, Streaming [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public class SyncFromAllServersOperationException : ActiveDirectoryOperationException, ISerializable { - private readonly SyncFromAllServersErrorInformation[] _errors = null; + private readonly SyncFromAllServersErrorInformation[] _errors; public SyncFromAllServersOperationException(string message, Exception inner, SyncFromAllServersErrorInformation[] errors) : base(message, inner) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Forest.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Forest.cs index 2ddf82ad5c2ee..eafdd89b3f70c 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Forest.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Forest.cs @@ -26,21 +26,21 @@ public enum ForestMode : int public class Forest : IDisposable { // Private Variables - private readonly DirectoryContext _context = null; - private readonly DirectoryEntryManager _directoryEntryMgr = null; - private bool _disposed = false; + private readonly DirectoryContext _context; + private readonly DirectoryEntryManager _directoryEntryMgr; + private bool _disposed; // Internal variables corresponding to public properties - private readonly string _forestDnsName = null; - private ReadOnlySiteCollection _cachedSites = null; - private DomainCollection _cachedDomains = null; - private GlobalCatalogCollection _cachedGlobalCatalogs = null; - private ApplicationPartitionCollection _cachedApplicationPartitions = null; + private readonly string _forestDnsName; + private ReadOnlySiteCollection _cachedSites; + private DomainCollection _cachedDomains; + private GlobalCatalogCollection _cachedGlobalCatalogs; + private ApplicationPartitionCollection _cachedApplicationPartitions; private int _forestModeLevel = -1; - private Domain _cachedRootDomain = null; - private ActiveDirectorySchema _cachedSchema = null; - private DomainController _cachedSchemaRoleOwner = null; - private DomainController _cachedNamingRoleOwner = null; + private Domain _cachedRootDomain; + private ActiveDirectorySchema _cachedSchema; + private DomainController _cachedSchemaRoleOwner; + private DomainController _cachedNamingRoleOwner; #region constructors internal Forest(DirectoryContext context, string forestDnsName, DirectoryEntryManager directoryEntryMgr) diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ForestTrustRelationshipInformation.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ForestTrustRelationshipInformation.cs index aaa1b7693f026..4fab6241b11d2 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ForestTrustRelationshipInformation.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ForestTrustRelationshipInformation.cs @@ -16,7 +16,7 @@ public class ForestTrustRelationshipInformation : TrustRelationshipInformation private ArrayList _binaryData = new ArrayList(); private Hashtable _excludedNameTime = new Hashtable(); private ArrayList _binaryDataTime = new ArrayList(); - internal bool retrieved = false; + internal bool retrieved; internal ForestTrustRelationshipInformation(DirectoryContext context, string source, DS_DOMAIN_TRUSTS unmanagedTrust, TrustType type) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/GlobalCatalog.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/GlobalCatalog.cs index cab5dfbab8ef2..77cda29394b22 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/GlobalCatalog.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/GlobalCatalog.cs @@ -11,8 +11,8 @@ namespace System.DirectoryServices.ActiveDirectory public class GlobalCatalog : DomainController { // private variables - private ActiveDirectorySchema _schema = null; - private bool _disabled = false; + private ActiveDirectorySchema _schema; + private bool _disabled; #region constructors internal GlobalCatalog(DirectoryContext context, string globalCatalogName) diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs index a9be42ce01519..e9d51c50a34d5 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/NativeMethods.cs @@ -243,18 +243,18 @@ public OSVersionInfoEx() } // The OSVersionInfoSize field must be set to Marshal.SizeOf(this) - public int osVersionInfoSize = 0; - public int majorVersion = 0; - public int minorVersion = 0; - public int buildNumber = 0; - public int platformId = 0; + public int osVersionInfoSize; + public int majorVersion; + public int minorVersion; + public int buildNumber; + public int platformId; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string csdVersion = null; - public short servicePackMajor = 0; - public short servicePackMinor = 0; - public short suiteMask = 0; - public byte productType = 0; - public byte reserved = 0; + public short servicePackMajor; + public short servicePackMinor; + public short suiteMask; + public byte productType; + public byte reserved; } /*typedef struct _LUID { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationConnection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationConnection.cs index 28cf5a6bd1fa8..3b131736accd9 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationConnection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationConnection.cs @@ -23,17 +23,16 @@ public enum ReplicationSpan public class ReplicationConnection : IDisposable { - internal readonly DirectoryContext context = null; - internal readonly DirectoryEntry cachedDirectoryEntry = null; - internal bool existingConnection = false; - private bool _disposed = false; - private readonly bool _checkADAM = false; - private bool _isADAMServer = false; - private int _options = 0; - - private readonly string _connectionName = null; - private string _sourceServerName = null; - private string _destinationServerName = null; + internal readonly DirectoryContext context; + internal readonly DirectoryEntry cachedDirectoryEntry; + internal bool existingConnection; + private bool _disposed; + private bool _isADAMServer; + private int _options; + + private readonly string _connectionName; + private string _sourceServerName; + private string _destinationServerName; private readonly ActiveDirectoryTransportType _transport = ActiveDirectoryTransportType.Rpc; private const string ADAMGuid = "1.2.840.113556.1.4.1851"; @@ -824,22 +823,19 @@ private bool IsADAM { get { - if (!_checkADAM) + DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); + PropertyValueCollection values; + try { - DirectoryEntry de = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE); - PropertyValueCollection values = null; - try - { - values = de.Properties["supportedCapabilities"]; - } - catch (COMException e) - { - throw ExceptionHelper.GetExceptionFromCOMException(context, e); - } - - if (values.Contains(ADAMGuid)) - _isADAMServer = true; + values = de.Properties["supportedCapabilities"]; } + catch (COMException e) + { + throw ExceptionHelper.GetExceptionFromCOMException(context, e); + } + + if (values.Contains(ADAMGuid)) + _isADAMServer = true; return _isADAMServer; } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursor.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursor.cs index 913c6ee3a8213..98608023d4aaf 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursor.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursor.cs @@ -8,12 +8,12 @@ namespace System.DirectoryServices.ActiveDirectory { public class ReplicationCursor { - private readonly string _serverDN = null; + private readonly string _serverDN; private readonly DateTime _syncTime; - private readonly bool _advanced = false; - private string _sourceServer = null; + private readonly bool _advanced; + private string _sourceServer; - private readonly DirectoryServer _server = null; + private readonly DirectoryServer _server; private ReplicationCursor() { } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursorCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursorCollection.cs index 10487511cbb4b..00d74c81032a5 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursorCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationCursorCollection.cs @@ -9,7 +9,7 @@ namespace System.DirectoryServices.ActiveDirectory { public class ReplicationCursorCollection : ReadOnlyCollectionBase { - private readonly DirectoryServer _server = null; + private readonly DirectoryServer _server; internal ReplicationCursorCollection(DirectoryServer server) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailure.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailure.cs index 9acc0c21af50f..f7486e9e88560 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailure.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailure.cs @@ -12,9 +12,9 @@ public class ReplicationFailure private readonly string _sourceDsaDN; internal int lastResult; - private readonly DirectoryServer _server = null; - private string _sourceServer = null; - private readonly Hashtable _nameTable = null; + private readonly DirectoryServer _server; + private string _sourceServer; + private readonly Hashtable _nameTable; internal ReplicationFailure(IntPtr addr, DirectoryServer server, Hashtable table) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailureCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailureCollection.cs index 0bc4a28ac57ec..a88fa061f06f6 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailureCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationFailureCollection.cs @@ -9,8 +9,8 @@ namespace System.DirectoryServices.ActiveDirectory { public class ReplicationFailureCollection : ReadOnlyCollectionBase { - private readonly DirectoryServer _server = null; - private readonly Hashtable _nameTable = null; + private readonly DirectoryServer _server; + private readonly Hashtable _nameTable; internal ReplicationFailureCollection(DirectoryServer server) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighbor.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighbor.cs index 2c0e42701b783..08f8d297d3780 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighbor.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighbor.cs @@ -37,9 +37,9 @@ public enum ReplicationNeighborOptions : long private readonly string _sourceServerDN; - private readonly DirectoryServer _server = null; - private string _sourceServer = null; - private readonly Hashtable _nameTable = null; + private readonly DirectoryServer _server; + private string _sourceServer; + private readonly Hashtable _nameTable; internal ReplicationNeighbor(IntPtr addr, DirectoryServer server, Hashtable table) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighborCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighborCollection.cs index 1b4f715490ff7..46bf5fcd26a49 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighborCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationNeighborCollection.cs @@ -9,8 +9,8 @@ namespace System.DirectoryServices.ActiveDirectory { public class ReplicationNeighborCollection : ReadOnlyCollectionBase { - private readonly DirectoryServer _server = null; - private readonly Hashtable _nameTable = null; + private readonly DirectoryServer _server; + private readonly Hashtable _nameTable; internal ReplicationNeighborCollection(DirectoryServer server) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperation.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperation.cs index 305ca147aec87..3ec53ed97e252 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperation.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperation.cs @@ -11,9 +11,9 @@ public class ReplicationOperation { private readonly string _dsaDN; - private readonly DirectoryServer _server = null; - private string _sourceServer = null; - private readonly Hashtable _nameTable = null; + private readonly DirectoryServer _server; + private string _sourceServer; + private readonly Hashtable _nameTable; internal ReplicationOperation(IntPtr addr, DirectoryServer server, Hashtable table) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperationCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperationCollection.cs index 3e5e79a47dd13..e674106a4f7c9 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperationCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperationCollection.cs @@ -9,8 +9,8 @@ namespace System.DirectoryServices.ActiveDirectory { public class ReplicationOperationCollection : ReadOnlyCollectionBase { - private readonly DirectoryServer _server = null; - private readonly Hashtable _nameTable = null; + private readonly DirectoryServer _server; + private readonly Hashtable _nameTable; internal ReplicationOperationCollection(DirectoryServer server) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperationInformation.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperationInformation.cs index 579af1108f74e..bd4583eeca88f 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperationInformation.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ReplicationOperationInformation.cs @@ -7,8 +7,8 @@ namespace System.DirectoryServices.ActiveDirectory public class ReplicationOperationInformation { internal DateTime startTime; - internal ReplicationOperation currentOp = null; - internal ReplicationOperationCollection collection = null; + internal ReplicationOperation currentOp; + internal ReplicationOperationCollection collection; public ReplicationOperationInformation() { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustRelationshipInformation.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustRelationshipInformation.cs index 0b8201a7b1bba..e48e1ed084a09 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustRelationshipInformation.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/TrustRelationshipInformation.cs @@ -24,11 +24,11 @@ public enum TrustDirection public class TrustRelationshipInformation { - internal string source = null; - internal string target = null; + internal string source; + internal string target; internal TrustType type; internal TrustDirection direction; - internal DirectoryContext context = null; + internal DirectoryContext context; internal TrustRelationshipInformation() { } diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs index 207d61f04cd02..802f35fcf6e5c 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/UnsafeNativeMethods.cs @@ -592,14 +592,14 @@ internal sealed class DSROLE_PRIMARY_DOMAIN_INFO_BASIC public string DomainNameDns; [MarshalAs(UnmanagedType.LPWStr)] public string DomainForestName; - public Guid DomainGuid = default; + public Guid DomainGuid; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal sealed class SID_AND_ATTR { public IntPtr pSid = IntPtr.Zero; - public int attrs = 0; + public int attrs; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] @@ -611,12 +611,12 @@ internal sealed class TOKEN_USER [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal sealed class SID_IDENTIFIER_AUTHORITY { - public byte b1 = 0; - public byte b2 = 0; - public byte b3 = 0; - public byte b4 = 0; - public byte b5 = 0; - public byte b6 = 0; + public byte b1; + public byte b2; + public byte b3; + public byte b4; + public byte b5; + public byte b6; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Utils.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Utils.cs index 805418b55354d..71304df5cdfab 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Utils.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Utils.cs @@ -1976,7 +1976,7 @@ internal static string SplitServerNameAndPortNumber(string serverName, out strin return serverName; } - private static string s_NTAuthorityString = null; + private static string s_NTAuthorityString; internal static string GetNtAuthorityString() { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs index 78573e9b92a0e..4fcb48c6f1cbd 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs @@ -28,20 +28,20 @@ public class DirectoryEntry : Component private bool _cacheFilled; // disable csharp compiler warning #0414: field assigned unused value #pragma warning disable 0414 - internal bool propertiesAlreadyEnumerated = false; + internal bool propertiesAlreadyEnumerated; #pragma warning restore 0414 - private bool _disposed = false; + private bool _disposed; private AuthenticationTypes _authenticationType = AuthenticationTypes.Secure; private NetworkCredential _credentials; private readonly DirectoryEntryConfiguration _options; - private PropertyCollection _propertyCollection = null; - internal bool allowMultipleChange = false; - private bool _userNameIsNull = false; - private bool _passwordIsNull = false; - private bool _objectSecurityInitialized = false; - private bool _objectSecurityModified = false; - private ActiveDirectorySecurity _objectSecurity = null; + private PropertyCollection _propertyCollection; + internal bool allowMultipleChange; + private bool _userNameIsNull; + private bool _passwordIsNull; + private bool _objectSecurityInitialized; + private bool _objectSecurityModified; + private ActiveDirectorySecurity _objectSecurity; private const string SecurityDescriptorProperty = "ntSecurityDescriptor"; /// diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs index e8cb80aae5989..53948d84254e9 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs @@ -20,34 +20,34 @@ public class DirectorySearcher : Component private DirectoryEntry _searchRoot; private string _filter = defaultFilter; private StringCollection _propertiesToLoad; - private bool _disposed = false; + private bool _disposed; private static readonly TimeSpan s_minusOneSecond = new TimeSpan(0, 0, -1); // search preference variables private SearchScope _scope = System.DirectoryServices.SearchScope.Subtree; - private bool _scopeSpecified = false; - private int _sizeLimit = 0; + private bool _scopeSpecified; + private int _sizeLimit; private TimeSpan _serverTimeLimit = s_minusOneSecond; private TimeSpan _clientTimeout = s_minusOneSecond; - private int _pageSize = 0; + private int _pageSize; private TimeSpan _serverPageTimeLimit = s_minusOneSecond; private ReferralChasingOption _referralChasing = ReferralChasingOption.External; private SortOption _sort = new SortOption(); private bool _cacheResults = true; - private bool _cacheResultsSpecified = false; - private bool _rootEntryAllocated = false; // true: if a temporary entry inside Searcher has been created - private string _assertDefaultNamingContext = null; + private bool _cacheResultsSpecified; + private bool _rootEntryAllocated; // true: if a temporary entry inside Searcher has been created + private string _assertDefaultNamingContext; private string _attributeScopeQuery = ""; - private bool _attributeScopeQuerySpecified = false; + private bool _attributeScopeQuerySpecified; private DereferenceAlias _derefAlias = DereferenceAlias.Never; private SecurityMasks _securityMask = SecurityMasks.None; private ExtendedDN _extendedDN = ExtendedDN.None; - private DirectorySynchronization _sync = null; - internal bool directorySynchronizationSpecified = false; - private DirectoryVirtualListView _vlv = null; - internal bool directoryVirtualListViewSpecified = false; - internal SearchResultCollection searchResult = null; + private DirectorySynchronization _sync; + internal bool directorySynchronizationSpecified; + private DirectoryVirtualListView _vlv; + internal bool directoryVirtualListViewSpecified; + internal SearchResultCollection searchResult; private const string defaultFilter = "(objectClass=*)"; diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryVirtualListView.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryVirtualListView.cs index 52e7f39b9efcd..283fd3a800bb9 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryVirtualListView.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryVirtualListView.cs @@ -8,12 +8,12 @@ namespace System.DirectoryServices { public class DirectoryVirtualListView { - private int _beforeCount = 0; - private int _afterCount = 0; - private int _offset = 0; + private int _beforeCount; + private int _afterCount; + private int _offset; private string _target = ""; - private int _approximateTotal = 0; - private int _targetPercentage = 0; + private int _approximateTotal; + private int _targetPercentage; public DirectoryVirtualListView() { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyCollection.cs index c9f9e28873134..f4b04a880f78d 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyCollection.cs @@ -15,7 +15,7 @@ namespace System.DirectoryServices public class PropertyCollection : IDictionary { private readonly DirectoryEntry _entry; - internal readonly Hashtable valueTable = null; + internal readonly Hashtable valueTable; internal PropertyCollection(DirectoryEntry entry) { @@ -176,7 +176,7 @@ private class PropertyEnumerator : IDictionaryEnumerator, IDisposable { private readonly DirectoryEntry _entry; // clone (to be disposed) private readonly DirectoryEntry _parentEntry; // original entry to pass to PropertyValueCollection - private string _currentPropName = null; + private string _currentPropName; public PropertyEnumerator(DirectoryEntry parent, DirectoryEntry clone) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyValueCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyValueCollection.cs index b6d92b7368c78..283faf931e37d 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyValueCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyValueCollection.cs @@ -22,9 +22,9 @@ internal enum UpdateType private readonly DirectoryEntry _entry; private UpdateType _updateType = UpdateType.None; - private readonly ArrayList _changeList = null; - private readonly bool _allowMultipleChange = false; - private readonly bool _needNewBehavior = false; + private readonly ArrayList _changeList; + private readonly bool _allowMultipleChange; + private readonly bool _needNewBehavior; internal PropertyValueCollection(DirectoryEntry entry, string propertyName) { diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/SearchResultCollection.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/SearchResultCollection.cs index 6a35ed156f4f5..28b5067293a1d 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/SearchResultCollection.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/SearchResultCollection.cs @@ -27,7 +27,7 @@ public class SearchResultCollection : MarshalByRefObject, ICollection, IEnumerab private readonly IntPtr _adsDirsynCookieName = Marshal.StringToCoTaskMemUni(ADS_DIRSYNC_COOKIE); private const string ADS_VLV_RESPONSE = "fc8cb04d-311d-406c-8cb9-1ae8b843b419"; private readonly IntPtr _adsVLVResponseName = Marshal.StringToCoTaskMemUni(ADS_VLV_RESPONSE); - internal DirectorySearcher srch = null; + internal DirectorySearcher srch; internal SearchResultCollection(DirectoryEntry root, IntPtr searchHandle, string[] propertiesLoaded, DirectorySearcher srch) { @@ -235,7 +235,6 @@ private class ResultsEnumerator : IEnumerator private bool _initialized; private SearchResult _currentResult; private bool _eof; - private readonly bool _waitForResult = false; internal ResultsEnumerator(SearchResultCollection results, string parentUserName, string parentPassword, AuthenticationTypes parentAuthenticationType) { @@ -382,17 +381,9 @@ public bool MoveNext() } else { - // if user chooses to wait to continue the search - if (_waitForResult) - { - continue; - } - else - { - uint temp = (uint)errorCode; - temp = ((((temp) & 0x0000FFFF) | (7 << 16) | 0x80000000)); - throw COMExceptionHelper.CreateFormattedComException((int)temp); - } + uint temp = (uint)errorCode; + temp = (temp & 0x0000FFFF) | (7 << 16) | 0x80000000; + throw COMExceptionHelper.CreateFormattedComException((int)temp); } } //throw a clearer exception if the filter was invalid diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCap.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCap.cs index 1eff8d09fad03..4632e109549ef 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCap.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCap.cs @@ -16,7 +16,7 @@ public partial class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable // Handle to native line cap object internal SafeCustomLineCapHandle nativeCap = null!; - private bool _disposed = false; + private bool _disposed; // For subclass creation internal CustomLineCap() { } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/FontFamily.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/FontFamily.cs index b77f22611a694..ec4eefbe8419c 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/FontFamily.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/FontFamily.cs @@ -22,7 +22,7 @@ public sealed partial class FontFamily : MarshalByRefObject, IDisposable #if DEBUG private static readonly object s_lockObj = new object(); - private static int s_idCount = 0; + private static int s_idCount; private int _id; #endif diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs index 4ac48539db114..6d278f420eb66 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs @@ -46,9 +46,9 @@ namespace System.Drawing public sealed partial class Graphics : MarshalByRefObject, IDisposable, IDeviceContext { internal IMacContext? maccontext; - private bool disposed = false; - private static float defDpiX = 0; - private static float defDpiY = 0; + private bool disposed; + private static float defDpiX; + private static float defDpiY; internal Graphics(IntPtr nativeGraphics) => NativeGraphics = nativeGraphics; diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.cs index a71a09d6e793e..4b983764be28a 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.cs @@ -36,7 +36,7 @@ public sealed partial class Icon : MarshalByRefObject, ICloneable, IDisposable, private uint _bestImageOffset; private uint _bestBitDepth; private uint _bestBytesInRes; - private bool? _isBestImagePng = null; + private bool? _isBestImagePng; private Size _iconSize = Size.Empty; private IntPtr _handle = IntPtr.Zero; private readonly bool _ownHandle = true; diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs index 8053f55a2a614..9e1c36c907a99 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs @@ -16,7 +16,7 @@ internal class MetafileHeaderEmf public MetafileType type = MetafileType.Invalid; public int size; public int version; - public EmfPlusFlags emfPlusFlags = 0; + public EmfPlusFlags emfPlusFlags; public float dpiX; public float dpiY; public int X; diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs index e0f8413fe01e2..0da2f04e6bf27 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs @@ -16,7 +16,7 @@ internal class MetafileHeaderWmf public MetafileType type = MetafileType.Invalid; public int size = Marshal.SizeOf(typeof(MetafileHeaderWmf)); public int version; - public EmfPlusFlags emfPlusFlags = 0; + public EmfPlusFlags emfPlusFlags; public float dpiX; public float dpiY; public int X; diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs index 5c339e7109557..b8f575f0fa979 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs @@ -22,7 +22,7 @@ internal static class SystemColorTracker private const int EXPAND_FACTOR = 2; private static WeakReference[] list = new WeakReference[INITIAL_SIZE]; - private static int count = 0; + private static int count; private static bool addedTracker; private static readonly object lockObject = new object(); diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintController.Windows.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintController.Windows.cs index e47770e4683a4..8a85de7db7a38 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintController.Windows.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintController.Windows.cs @@ -65,7 +65,7 @@ public static explicit operator SafeDeviceModeHandle(IntPtr handle) } } - private protected SafeDeviceModeHandle? _modeHandle = null; + private protected SafeDeviceModeHandle? _modeHandle; /// /// If you have nested PrintControllers, this method won't get called on the inner one. diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.Unix.cs index e26c79ce36344..40d21b5e21882 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.Unix.cs @@ -47,7 +47,7 @@ public class PrintDocument : System.ComponentModel.Component private PrinterSettings printersettings; private PrintController printcontroller; private string documentname; - private bool originAtMargins = false; // .NET V1.1 Beta + private bool originAtMargins; // .NET V1.1 Beta public PrintDocument() { diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemIcons.Windows.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/SystemIcons.Windows.cs index 287279c6d75a3..d69d84d2d4f0d 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemIcons.Windows.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/SystemIcons.Windows.cs @@ -8,16 +8,16 @@ namespace System.Drawing { public static class SystemIcons { - private static Icon? s_application = null; - private static Icon? s_asterisk = null; - private static Icon? s_error = null; - private static Icon? s_exclamation = null; - private static Icon? s_hand = null; - private static Icon? s_information = null; - private static Icon? s_question = null; - private static Icon? s_warning = null; - private static Icon? s_winlogo = null; - private static Icon? s_shield = null; + private static Icon? s_application; + private static Icon? s_asterisk; + private static Icon? s_error; + private static Icon? s_exclamation; + private static Icon? s_hand; + private static Icon? s_information; + private static Icon? s_question; + private static Icon? s_warning; + private static Icon? s_winlogo; + private static Icon? s_shield; public static Icon Application => GetIcon(ref s_application, SafeNativeMethods.IDI_APPLICATION); diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.Unix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.Unix.cs index 8269301c5ce79..115dea41ba541 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.Unix.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.Unix.cs @@ -42,8 +42,8 @@ namespace System.Drawing [AttributeUsage(AttributeTargets.Class)] public class ToolboxBitmapAttribute : Attribute { - private Image? smallImage = null; - private Image? bigImage = null; + private Image? smallImage; + private Image? bigImage; public static readonly ToolboxBitmapAttribute Default = new ToolboxBitmapAttribute(); private ToolboxBitmapAttribute() diff --git a/src/libraries/System.Drawing.Common/src/misc/DpiHelper.cs b/src/libraries/System.Drawing.Common/src/misc/DpiHelper.cs index a45b7886b9d27..d24c8c2a70b4a 100644 --- a/src/libraries/System.Drawing.Common/src/misc/DpiHelper.cs +++ b/src/libraries/System.Drawing.Common/src/misc/DpiHelper.cs @@ -16,7 +16,7 @@ namespace System.Windows.Forms internal static class DpiHelper { private const double LogicalDpi = 96.0; - private static bool s_isInitialized = false; + private static bool s_isInitialized; /// /// The primary screen's (device) current horizontal DPI /// @@ -27,8 +27,8 @@ internal static class DpiHelper /// private static double s_deviceDpiY = LogicalDpi; - private static double s_logicalToDeviceUnitsScalingFactorX = 0.0; - private static double s_logicalToDeviceUnitsScalingFactorY = 0.0; + private static double s_logicalToDeviceUnitsScalingFactorX; + private static double s_logicalToDeviceUnitsScalingFactorY; private static InterpolationMode s_interpolationMode = InterpolationMode.Invalid; private static void Initialize() diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.String.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.String.cs index 568f1c0c0055d..f2c58151aeb47 100644 --- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.String.cs +++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.String.cs @@ -14,7 +14,7 @@ public partial class CborReader // Implements major type 2,3 decoding per https://tools.ietf.org/html/rfc7049#section-2.1 // stores a reusable List allocation for storing indefinite length string chunk offsets - private List<(int Offset, int Length)>? _indefiniteLengthStringRangeAllocation = null; + private List<(int Offset, int Length)>? _indefiniteLengthStringRangeAllocation; /// /// Reads the next data item as a byte string (major type 2). diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.cs index a4f08cebb5220..def363d7e2104 100644 --- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.cs +++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Reader/CborReader.cs @@ -13,17 +13,17 @@ namespace System.Formats.Cbor public partial class CborReader { private readonly ReadOnlyMemory _data; - private int _offset = 0; + private int _offset; private Stack? _nestedDataItems; - private CborMajorType? _currentMajorType = null; // major type of the currently written data item. Null iff at the root context + private CborMajorType? _currentMajorType; // major type of the currently written data item. Null iff at the root context private int? _definiteLength; // predetermined definite-length of current data item context - private int _itemsRead = 0; // number of items read in the current context - private int _frameOffset = 0; // buffer offset particular to the current data item context - private bool _isTagContext = false; // true if reader is expecting a tagged value + private int _itemsRead; // number of items read in the current context + private int _frameOffset; // buffer offset particular to the current data item context + private bool _isTagContext; // true if reader is expecting a tagged value // Map-specific book-keeping - private int? _currentKeyOffset = null; // offset for the current key encoding + private int? _currentKeyOffset; // offset for the current key encoding private (int Offset, int Length)? _previousKeyEncodingRange; // previous key encoding range private HashSet<(int Offset, int Length)>? _keyEncodingRanges; // all key encoding ranges up to encoding equality diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.String.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.String.cs index 4c604e76a6cde..0d46a66e46b99 100644 --- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.String.cs +++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.String.cs @@ -13,7 +13,7 @@ public partial class CborWriter // Implements major type 2,3 encoding per https://tools.ietf.org/html/rfc7049#section-2.1 // keeps track of chunk offsets for written indefinite-length string ranges - private List<(int Offset, int Length)>? _currentIndefiniteLengthStringRanges = null; + private List<(int Offset, int Length)>? _currentIndefiniteLengthStringRanges; /// /// Writes a buffer as a byte string encoding (major type 2). diff --git a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs index ae2479f81f886..01cd4a2edf831 100644 --- a/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs +++ b/src/libraries/System.Formats.Cbor/src/System/Formats/Cbor/Writer/CborWriter.cs @@ -17,21 +17,21 @@ public partial class CborWriter private static readonly ArrayPool s_bufferPool = ArrayPool.Create(); private byte[] _buffer = null!; - private int _offset = 0; + private int _offset; private Stack? _nestedDataItems; - private CborMajorType? _currentMajorType = null; // major type of the current data item context + private CborMajorType? _currentMajorType; // major type of the current data item context private int? _definiteLength; // predetermined definite-length of current data item context - private int _itemsWritten = 0; // number of items written in the current context - private int _frameOffset = 0; // buffer offset particular to the current data item context - private bool _isTagContext = false; // true if writer is expecting a tagged value + private int _itemsWritten; // number of items written in the current context + private int _frameOffset; // buffer offset particular to the current data item context + private bool _isTagContext; // true if writer is expecting a tagged value // Map-specific book-keeping - private int? _currentKeyOffset = null; // offset for the current key encoding - private int? _currentValueOffset = null; // offset for the current value encoding - private bool _keysRequireSorting = false; // tracks whether key/value pair encodings need to be sorted - private List? _keyValuePairEncodingRanges = null; // all key/value pair encoding ranges - private HashSet<(int Offset, int Length)>? _keyEncodingRanges = null; // all key encoding ranges up to encoding equality + private int? _currentKeyOffset; // offset for the current key encoding + private int? _currentValueOffset; // offset for the current value encoding + private bool _keysRequireSorting; // tracks whether key/value pair encodings need to be sorted + private List? _keyValuePairEncodingRanges; // all key/value pair encoding ranges + private HashSet<(int Offset, int Length)>? _keyEncodingRanges; // all key encoding ranges up to encoding equality /// /// The conformance mode used by this writer. diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InputBuffer.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InputBuffer.cs index 13efb3eaf96c0..422d18d5ab0d4 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InputBuffer.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateManaged/InputBuffer.cs @@ -21,8 +21,8 @@ internal sealed class InputBuffer private byte[]? _buffer; // byte array to store input private int _start; // start poisition of the buffer private int _end; // end position of the buffer - private uint _bitBuffer = 0; // store the bits here, we can quickly shift in this buffer - private int _bitsInBuffer = 0; // number of bits available in bitBuffer + private uint _bitBuffer; // store the bits here, we can quickly shift in this buffer + private int _bitsInBuffer; // number of bits available in bitBuffer /// Total bits available in the input buffer. public int AvailableBits => _bitsInBuffer; diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.OSX.cs b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.OSX.cs index e1ed5359794a8..746649663575d 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.OSX.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.OSX.cs @@ -185,7 +185,7 @@ private static class StaticWatcherRunLoopManager // A reference to the RunLoop that we can use to start or stop a Watcher private static CFRunLoopRef s_watcherRunLoop = IntPtr.Zero; - private static int s_scheduledStreamsCount = 0; + private static int s_scheduledStreamsCount; private static readonly object s_lockObject = new object(); diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs index 9a69d22219df0..b3f2ed317d30f 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs @@ -31,13 +31,13 @@ public partial class FileSystemWatcher : Component, ISupportInitialize private NotifyFilters _notifyFilters = c_defaultNotifyFilters; // Flag to watch subtree of this directory - private bool _includeSubdirectories = false; + private bool _includeSubdirectories; // Flag to note whether we are attached to the thread pool and responding to changes - private bool _enabled = false; + private bool _enabled; // Are we in init? - private bool _initializing = false; + private bool _initializing; // Buffer size private uint _internalBufferSize = 8192; diff --git a/src/libraries/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedFileHandle.Unix.cs b/src/libraries/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedFileHandle.Unix.cs index c206df9fc5a38..ea91737589edd 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedFileHandle.Unix.cs +++ b/src/libraries/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedFileHandle.Unix.cs @@ -13,7 +13,7 @@ namespace Microsoft.Win32.SafeHandles public sealed partial class SafeMemoryMappedFileHandle : SafeHandleZeroOrMinusOneIsInvalid { /// Counter used to produce a unique handle value. - private static long s_counter = 0; + private static long s_counter; /// /// The underlying FileStream. May be null. We hold onto the stream rather than just diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ContentType.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ContentType.cs index e00099376f85a..f8c93ba826c22 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ContentType.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ContentType.cs @@ -562,7 +562,7 @@ private void EnsureParameterDictionary() private string _subType = string.Empty; private readonly string _originalString; private Dictionary? _parameterDictionary; - private readonly bool _isInitialized = false; + private readonly bool _isInitialized; private const string Quote = "\""; private const char SemicolonSeparator = ';'; diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs index 7de12f3a250b0..39a31b8c5f5d9 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs @@ -835,7 +835,7 @@ private void CloseXmlWriter() // (Uses object comparison rather than string comparison.) private const int NumCoreProperties = 16; private readonly Dictionary _propertyDictionary = new Dictionary(NumCoreProperties); - private bool _dirty = false; + private bool _dirty; // This System.Xml.NameTable makes sure that we use the same references to strings // throughout (including when parsing Xml) and so can perform reference comparisons diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipStreamManager.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipStreamManager.cs index e7d70c2ecbd14..91aea214b8f07 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipStreamManager.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipStreamManager.cs @@ -15,7 +15,7 @@ internal class ZipStreamManager : IDisposable private readonly ZipArchive _zipArchive; private readonly FileAccess _packageFileAccess; private readonly FileMode _packageFileMode; - private bool _disposed = false; + private bool _disposed; public ZipStreamManager(ZipArchive zipArchive, FileMode packageFileMode, FileAccess packageFileAccess) { diff --git a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs index f1417a0da9a02..2ee6f070f6db4 100644 --- a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs +++ b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs @@ -57,12 +57,12 @@ public partial class SerialPort : Component private int _writeBufferSize = DefaultWriteBufferSize; // ---------- members for internal support ---------* - private SerialStream _internalSerialStream = null; + private SerialStream _internalSerialStream; private byte[] _inBuffer = new byte[DefaultBufferSize]; - private int _readPos = 0; // position of next byte to read in the read buffer. readPos <= readLen - private int _readLen = 0; // position of first unreadable byte => CachedBytesToRead is the number of readable bytes left. + private int _readPos; // position of next byte to read in the read buffer. readPos <= readLen + private int _readLen; // position of first unreadable byte => CachedBytesToRead is the number of readable bytes left. private readonly char[] _oneChar = new char[1]; - private char[] _singleCharBuffer = null; + private char[] _singleCharBuffer; public event SerialErrorReceivedEventHandler ErrorReceived; public event SerialPinChangedEventHandler PinChanged; diff --git a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Unix.cs b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Unix.cs index dd8ea97d7b96c..12fe45fa1397a 100644 --- a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Unix.cs +++ b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Unix.cs @@ -19,23 +19,23 @@ internal sealed partial class SerialStream : Stream private const int TimeoutResolution = 30; // time [ms] loop has to be idle before it stops private const int IOLoopIdleTimeout = 2000; - private bool _ioLoopFinished = false; + private bool _ioLoopFinished; - private SafeSerialDeviceHandle _handle = null; + private SafeSerialDeviceHandle _handle; private int _baudRate; private StopBits _stopBits; private Parity _parity; private int _dataBits = 8; - private bool _rtsEnable = false; - private int _readTimeout = 0; - private int _writeTimeout = 0; + private bool _rtsEnable; + private int _readTimeout; + private int _writeTimeout; private byte[] _tempBuf = new byte[1]; private Task _ioLoop; private object _ioLoopLock = new object(); private ConcurrentQueue _readQueue = new ConcurrentQueue(); private ConcurrentQueue _writeQueue = new ConcurrentQueue(); - private long _totalBytesRead = 0; + private long _totalBytesRead; private long TotalBytesAvailable => _totalBytesRead + BytesToRead; private long _lastTotalBytesAvailable; diff --git a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs index 487b8b5d08a96..99ecbf4f8599a 100644 --- a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs +++ b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs @@ -39,12 +39,12 @@ internal sealed partial class SerialStream : Stream // called when any of the pin/ring-related triggers occurs internal event SerialPinChangedEventHandler PinChanged; - private SafeFileHandle _handle = null; + private SafeFileHandle _handle; // members supporting properties exposed to SerialPort private byte _parityReplace = (byte)'?'; private readonly bool _isAsync = true; - private bool _rtsEnable = false; + private bool _rtsEnable; // The internal C# representations of Win32 structures necessary for communication // hold most of the internal "fields" maintaining information about the port. @@ -53,9 +53,9 @@ internal sealed partial class SerialStream : Stream private Interop.Kernel32.COMSTAT _comStat; private Interop.Kernel32.COMMPROP _commProp; - private readonly ThreadPoolBoundHandle _threadPoolBinding = null; + private readonly ThreadPoolBoundHandle _threadPoolBinding; private readonly EventLoopRunner _eventRunner; - private readonly Task _waitForComEventTask = null; + private readonly Task _waitForComEventTask; private readonly byte[] _tempBuf; // used to avoid multiple array allocations in ReadByte() @@ -1541,8 +1541,8 @@ internal sealed class EventLoopRunner { private readonly WeakReference streamWeakReference; internal ManualResetEvent waitCommEventWaitHandle = new ManualResetEvent(false); - private readonly SafeFileHandle handle = null; - private readonly ThreadPoolBoundHandle threadPoolBinding = null; + private readonly SafeFileHandle handle; + private readonly ThreadPoolBoundHandle threadPoolBinding; private readonly bool isAsync; internal bool endEventLoop; private readonly int eventsOccurred; diff --git a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.cs b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.cs index e0a2cd8bd42c2..35d76203f36ef 100644 --- a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.cs +++ b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.cs @@ -18,7 +18,7 @@ internal sealed partial class SerialStream : Stream // members supporting properties exposed to SerialPort private readonly string _portName; - private bool _inBreak = false; + private bool _inBreak; private Handshake _handshake; #pragma warning disable CS0067 // Events shared by Windows and Linux, on Linux we currently never call them diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/ControlFlowInstructions.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/ControlFlowInstructions.cs index f72dde86e8c36..3d71f508dc412 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/ControlFlowInstructions.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/ControlFlowInstructions.cs @@ -293,7 +293,7 @@ public override int Run(InterpretedFrame frame) internal sealed class EnterTryCatchFinallyInstruction : IndexedBranchInstruction { - private readonly bool _hasFinally = false; + private readonly bool _hasFinally; private TryCatchFinallyHandler? _tryHandler; internal void SetTryHandler(TryCatchFinallyHandler tryHandler) diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/InstructionList.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/InstructionList.cs index 5c1fa2ca2a633..34116fb84ffef 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/InstructionList.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/InstructionList.cs @@ -77,9 +77,10 @@ internal sealed class InstructionList private int _runtimeLabelCount; private List? _labels; +#if DEBUG // list of (instruction index, cookie) sorted by instruction index: - private List>? _debugCookies = null; - + private List>? _debugCookies; +#endif #region Debug View internal sealed class DebugView @@ -101,7 +102,10 @@ public InstructionView[] GetInstructionViews(bool includeDebugCookies = false) _list._instructions, _list._objects, (index) => _list._labels![index].TargetIndex, - includeDebugCookies ? _list._debugCookies : null +#if DEBUG + includeDebugCookies ? _list._debugCookies : +#endif + null ); } @@ -230,10 +234,7 @@ public void UnEmit() public void SetDebugCookie(object? cookie) { #if DEBUG - if (_debugCookies == null) - { - _debugCookies = new List>(); - } + _debugCookies ??= new List>(); Debug.Assert(Count > 0); _debugCookies.Add(new KeyValuePair(Count - 1, cookie)); @@ -300,7 +301,11 @@ public InstructionArray ToArray() _instructions.ToArray(), _objects?.ToArray(), BuildRuntimeLabels(), +#if DEBUG _debugCookies +#else + null +#endif ); } diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs index 2587ed422588e..9e709e25c837f 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Merging/OrderPreservingPipeliningMergeHelper.cs @@ -239,7 +239,7 @@ private class OrderedPipeliningMergeEnumerator : MergeEnumerator /// /// Tracks whether MoveNext() has already been called previously. /// - private bool _initialized = false; + private bool _initialized; /// /// Constructor diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/ConcatQueryOperator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/ConcatQueryOperator.cs index ec1d6fe8b11ce..032275c614265 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/ConcatQueryOperator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/ConcatQueryOperator.cs @@ -27,8 +27,8 @@ namespace System.Linq.Parallel /// internal sealed class ConcatQueryOperator : BinaryQueryOperator { - private readonly bool _prematureMergeLeft = false; // Whether to prematurely merge the left data source - private readonly bool _prematureMergeRight = false; // Whether to prematurely merge the right data source + private readonly bool _prematureMergeLeft; // Whether to prematurely merge the left data source + private readonly bool _prematureMergeRight; // Whether to prematurely merge the right data source //--------------------------------------------------------------------------------------- // Initializes a new concatenation operator. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/ZipQueryOperator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/ZipQueryOperator.cs index d88505490f495..bbeea16ab1d6d 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/ZipQueryOperator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Binary/ZipQueryOperator.cs @@ -31,9 +31,9 @@ internal sealed class ZipQueryOperator private readonly Func _resultSelector; // To select result elements. private readonly QueryOperator _leftChild; private readonly QueryOperator _rightChild; - private readonly bool _prematureMergeLeft = false; // Whether to prematurely merge the left data source - private readonly bool _prematureMergeRight = false; // Whether to prematurely merge the right data source - private readonly bool _limitsParallelism = false; // Whether this operator limits parallelism + private readonly bool _prematureMergeLeft; // Whether to prematurely merge the left data source + private readonly bool _prematureMergeRight; // Whether to prematurely merge the right data source + private readonly bool _limitsParallelism; // Whether this operator limits parallelism //--------------------------------------------------------------------------------------- // Initializes a new zip operator. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Inlined/InlinedAggregationOperatorEnumerator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Inlined/InlinedAggregationOperatorEnumerator.cs index d73ff9b0ae8ba..fd6521a35985d 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Inlined/InlinedAggregationOperatorEnumerator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Inlined/InlinedAggregationOperatorEnumerator.cs @@ -33,7 +33,7 @@ namespace System.Linq.Parallel internal abstract class InlinedAggregationOperatorEnumerator : QueryOperatorEnumerator { private readonly int _partitionIndex; // This partition's unique index. - private bool _done = false; + private bool _done; protected CancellationToken _cancellationToken; //--------------------------------------------------------------------------------------- diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/PartitionedStreamMerger.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/PartitionedStreamMerger.cs index 6062fd3012f75..7707eb74eb11c 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/PartitionedStreamMerger.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/PartitionedStreamMerger.cs @@ -21,14 +21,14 @@ internal class PartitionedStreamMerger : IPartitionedStreamRecipient? _mergeExecutor = null; + private MergeExecutor? _mergeExecutor; private readonly TaskScheduler _taskScheduler; private readonly int _queryId; // ID of the current query execution private readonly CancellationState _cancellationState; #if DEBUG - private bool _received = false; + private bool _received; #endif // Returns the merge executor which merges the received partitioned stream. internal MergeExecutor? MergeExecutor diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/QueryOpeningEnumerator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/QueryOpeningEnumerator.cs index d7725daf97514..e38463ca78385 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/QueryOpeningEnumerator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/QueryOpeningEnumerator.cs @@ -28,7 +28,7 @@ internal class QueryOpeningEnumerator : IEnumerator private QuerySettings _querySettings; private readonly ParallelMergeOptions? _mergeOptions; private readonly bool _suppressOrderPreservation; - private int _moveNextIteration = 0; + private int _moveNextIteration; private bool _hasQueryOpeningFailed; // -- Cancellation and Dispose fields-- diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/ElementAtQueryOperator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/ElementAtQueryOperator.cs index 21f1642465b5a..ddbc1a96865da 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/ElementAtQueryOperator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/ElementAtQueryOperator.cs @@ -24,8 +24,8 @@ namespace System.Linq.Parallel internal sealed class ElementAtQueryOperator : UnaryQueryOperator { private readonly int _index; // The index that we're looking for. - private readonly bool _prematureMerge = false; // Whether to prematurely merge the input of this operator. - private readonly bool _limitsParallelism = false; // Whether this operator limits parallelism + private readonly bool _prematureMerge; // Whether to prematurely merge the input of this operator. + private readonly bool _limitsParallelism; // Whether this operator limits parallelism //--------------------------------------------------------------------------------------- // Constructs a new instance of the contains search operator. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/IndexedSelectQueryOperator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/IndexedSelectQueryOperator.cs index d6b65908cfdbf..af962a0f142b4 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/IndexedSelectQueryOperator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/IndexedSelectQueryOperator.cs @@ -27,8 +27,8 @@ internal sealed class IndexedSelectQueryOperator : UnaryQueryOp { // Selector function. Used to project elements to a transformed view during execution. private readonly Func _selector; - private bool _prematureMerge = false; // Whether to prematurely merge the input of this operator. - private bool _limitsParallelism = false; // Whether this operator limits parallelism + private bool _prematureMerge; // Whether to prematurely merge the input of this operator. + private bool _limitsParallelism; // Whether this operator limits parallelism //--------------------------------------------------------------------------------------- // Initializes a new select operator. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/IndexedWhereQueryOperator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/IndexedWhereQueryOperator.cs index a569ce404ed35..403c022c534ef 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/IndexedWhereQueryOperator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/IndexedWhereQueryOperator.cs @@ -26,8 +26,8 @@ internal sealed class IndexedWhereQueryOperator : UnaryQueryOperat { // Predicate function. Used to filter out non-matching elements during execution. private readonly Func _predicate; - private bool _prematureMerge = false; // Whether to prematurely merge the input of this operator. - private bool _limitsParallelism = false; // Whether this operator limits parallelism + private bool _prematureMerge; // Whether to prematurely merge the input of this operator. + private bool _limitsParallelism; // Whether this operator limits parallelism //--------------------------------------------------------------------------------------- // Initializes a new where operator. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/SelectManyQueryOperator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/SelectManyQueryOperator.cs index 55d08d45e86dc..248527f0c7dfd 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/SelectManyQueryOperator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/SelectManyQueryOperator.cs @@ -36,8 +36,8 @@ internal sealed class SelectManyQueryOperator private readonly Func>? _rightChildSelector; // To select a new child each iteration. private readonly Func>? _indexedRightChildSelector; // To select a new child each iteration. private readonly Func? _resultSelector; // An optional result selection function. - private bool _prematureMerge = false; // Whether to prematurely merge the input of this operator. - private bool _limitsParallelism = false; // Whether to prematurely merge the input of this operator. + private bool _prematureMerge; // Whether to prematurely merge the input of this operator. + private bool _limitsParallelism; // Whether to prematurely merge the input of this operator. //--------------------------------------------------------------------------------------- // Initializes a new select-many operator. diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/TakeOrSkipQueryOperator.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/TakeOrSkipQueryOperator.cs index 39e0c284d8e65..4eecf61101d71 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/TakeOrSkipQueryOperator.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/QueryOperators/Unary/TakeOrSkipQueryOperator.cs @@ -35,7 +35,7 @@ internal sealed class TakeOrSkipQueryOperator : UnaryQueryOperator : UnaryQueryOperator private readonly Func? _indexedPredicate; private readonly bool _take; // Whether to take (true) or skip (false). - private bool _prematureMerge = false; // Whether to prematurely merge the input of this operator. - private bool _limitsParallelism = false; // The precomputed value of LimitsParallelism + private bool _prematureMerge; // Whether to prematurely merge the input of this operator. + private bool _limitsParallelism; // The precomputed value of LimitsParallelism //--------------------------------------------------------------------------------------- // Initializes a new take-while operator. @@ -400,7 +400,7 @@ protected override void Dispose(bool disposing) private class OperatorState { - internal volatile int _updatesDone = 0; + internal volatile int _updatesDone; internal TKey _currentLowKey = default!; } } diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Lookup.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Lookup.cs index a871131348730..0ae20ac2de1a6 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Lookup.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/Lookup.cs @@ -39,7 +39,7 @@ internal class Lookup : ILookup where TKey: notn { private readonly IDictionary> _dict; private readonly IEqualityComparer _comparer; - private IGrouping? _defaultKeyGrouping = null; + private IGrouping? _defaultKeyGrouping; internal Lookup(IEqualityComparer comparer) { diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/PLINQETWProvider.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/PLINQETWProvider.cs index 9a61f040ded2c..442733b206293 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/PLINQETWProvider.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/PLINQETWProvider.cs @@ -38,7 +38,7 @@ private PlinqEtwProvider() { } /// If PLINQ ever supports other schedulers, that information will need to be passed into the query events. private static readonly int s_defaultSchedulerId = TaskScheduler.Default.Id; /// Static counter used to generate unique IDs - private static int s_queryId = 0; + private static int s_queryId; /// Generates the next consecutive query ID. [NonEvent] diff --git a/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs b/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs index 21b647a28c26e..04e751475e306 100644 --- a/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs +++ b/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs @@ -1436,9 +1436,9 @@ internal class MTAHelper private class MTARequest { public AutoResetEvent evtDone = new AutoResetEvent(false); - public Type typeToCreate = null; - public object createdObject = null; - public Exception exception = null; + public Type typeToCreate; + public object createdObject; + public Exception exception; public MTARequest(Type typeToCreate) { @@ -1451,7 +1451,7 @@ public MTARequest(Type typeToCreate) private static readonly AutoResetEvent evtGo = new AutoResetEvent(false); // tells the worker to create an object on our behalf - private static bool workerThreadInitialized = false; + private static bool workerThreadInitialized; // Initialize worker thread // This is not done in a static constructor so that we don't do this in an MTA only application private static void InitWorkerThread() diff --git a/src/libraries/System.Management/src/System/Management/ManagementException.cs b/src/libraries/System.Management/src/System/Management/ManagementException.cs index 19a58f44f06fb..b57104af14aa4 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementException.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementException.cs @@ -589,8 +589,8 @@ public enum ManagementStatus [Serializable] public class ManagementException : SystemException { - private readonly ManagementBaseObject errorObject = null; - private readonly ManagementStatus errorCode = 0; + private readonly ManagementBaseObject errorObject; + private readonly ManagementStatus errorCode; internal static void ThrowWithExtendedInfo(ManagementStatus errorCode) { diff --git a/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs b/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs index 047f728467546..03e3f768394e7 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs @@ -64,7 +64,7 @@ public class ManagementObjectCollection : ICollection, IEnumerable, IDisposable internal ManagementScope scope; internal EnumerationOptions options; private readonly IEnumWbemClassObject enumWbem; //holds WMI enumerator for this collection - private bool isDisposed = false; + private bool isDisposed; //Constructor internal ManagementObjectCollection( @@ -407,7 +407,7 @@ public class ManagementObjectEnumerator : IEnumerator, IDisposable private int cacheIndex; //used to walk the enumeration cache private IWbemClassObjectFreeThreaded[] cachedObjects; //points to objects currently available in enumeration cache private bool atEndOfCollection; - private bool isDisposed = false; + private bool isDisposed; //constructor internal ManagementObjectEnumerator( diff --git a/src/libraries/System.Management/src/System/Management/ManagementOptions.cs b/src/libraries/System.Management/src/System/Management/ManagementOptions.cs index 16012dee59487..b66177ff6a260 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementOptions.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementOptions.cs @@ -1278,7 +1278,7 @@ public class ConnectionOptions : ManagementOptions //Fields private string locale; private string username; - private SecureString securePassword = null; + private SecureString securePassword; private string authority; private ImpersonationLevel impersonation; private AuthenticationLevel authentication; diff --git a/src/libraries/System.Management/src/System/Management/ManagementPath.cs b/src/libraries/System.Management/src/System/Management/ManagementPath.cs index 1f385e2c5d18b..7b210fe33767b 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementPath.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementPath.cs @@ -77,7 +77,7 @@ public class ManagementPath : ICloneable //Used to minimize the cases in which new wbemPath (WMI object path parser) objects need to be constructed //This is done for performance reasons. - private bool isWbemPathShared = false; + private bool isWbemPathShared; internal event IdentifierChangedEventHandler IdentifierChanged; diff --git a/src/libraries/System.Management/src/System/Management/ManagementQuery.cs b/src/libraries/System.Management/src/System/Management/ManagementQuery.cs index 1c49c3019e4de..90563b7514c1a 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementQuery.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementQuery.cs @@ -610,7 +610,7 @@ public override object Clone() //CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC// public class SelectQuery : WqlObjectQuery { - private bool isSchemaQuery = false; + private bool isSchemaQuery; private string className; private string condition; private StringCollection selectedProperties; diff --git a/src/libraries/System.Management/src/System/Management/ManagementScope.cs b/src/libraries/System.Management/src/System/Management/ManagementScope.cs index 54abbc5b3b2fb..6fc957b580577 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementScope.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementScope.cs @@ -1389,7 +1389,7 @@ internal int ExecMethodAsync_(string strObjectPath, string strMethodName, int lF internal class SecurityHandler { - private bool needToReset = false; + private bool needToReset; private readonly IntPtr handle; private readonly ManagementScope scope; diff --git a/src/libraries/System.Management/src/System/Management/Property.cs b/src/libraries/System.Management/src/System/Management/Property.cs index eb8a14ae562e2..b802086f32f7a 100644 --- a/src/libraries/System.Management/src/System/Management/Property.cs +++ b/src/libraries/System.Management/src/System/Management/Property.cs @@ -84,7 +84,7 @@ public class PropertyData private readonly string propertyName; private object propertyValue; - private long propertyNullEnumValue = 0; + private long propertyNullEnumValue; private int propertyType; private int propertyFlavor; private QualifierDataCollection qualifiers; diff --git a/src/libraries/System.Management/src/System/Management/WMIGenerator.cs b/src/libraries/System.Management/src/System/Management/WMIGenerator.cs index 927a35474b61f..e3fdb8d27e983 100644 --- a/src/libraries/System.Management/src/System/Management/WMIGenerator.cs +++ b/src/libraries/System.Management/src/System/Management/WMIGenerator.cs @@ -51,21 +51,21 @@ internal class ManagementClassGenerator private string OriginalNamespace = string.Empty; private string OriginalClassName = string.Empty; private readonly string OriginalPath = string.Empty; - private bool bSingletonClass = false; + private bool bSingletonClass; private bool bUnsignedSupported = true; private string NETNamespace = string.Empty; private string arrConvFuncName = string.Empty; private string enumType = string.Empty; private const int DMTF_DATETIME_STR_LENGTH = 25; - private bool bDateConversionFunctionsAdded = false; - private bool bTimeSpanConversionFunctionsAdded = false; + private bool bDateConversionFunctionsAdded; + private bool bTimeSpanConversionFunctionsAdded; private ManagementClass classobj; private CodeDomProvider cp; - private TextWriter tw = null; + private TextWriter tw; private readonly string genFileName = string.Empty; private CodeTypeDeclaration cc; private CodeTypeDeclaration ccc; @@ -102,7 +102,7 @@ internal class ManagementClassGenerator private SortedList PublicNamesUsed = new SortedList(StringComparer.OrdinalIgnoreCase); private SortedList PrivateNamesUsed = new SortedList(StringComparer.OrdinalIgnoreCase); - private bool bHasEmbeddedProperties = false; + private bool bHasEmbeddedProperties; /// diff --git a/src/libraries/System.Management/src/System/Management/WmiEventSink.cs b/src/libraries/System.Management/src/System/Management/WmiEventSink.cs index 962017aafb97a..ea68dd9360ce1 100644 --- a/src/libraries/System.Management/src/System/Management/WmiEventSink.cs +++ b/src/libraries/System.Management/src/System/Management/WmiEventSink.cs @@ -9,7 +9,7 @@ namespace System.Management internal class WmiEventSink : IWmiEventSource { - private static int s_hash = 0; + private static int s_hash; private readonly int hash; private readonly ManagementOperationObserver watcher; private readonly object context; diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpChannelBinding.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpChannelBinding.cs index 6ca49c250fb28..41ce8e455a696 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpChannelBinding.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpChannelBinding.cs @@ -13,8 +13,8 @@ namespace System.Net.Http { internal class WinHttpChannelBinding : ChannelBinding { - private int _size = 0; - private string _cachedToString = null; + private int _size; + private string _cachedToString; internal WinHttpChannelBinding(SafeWinHttpHandle requestHandle) { diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs index 8e77c98ed62f1..2fd07d840cb67 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs @@ -49,13 +49,13 @@ public class WinHttpHandler : HttpMessageHandler private static StringBuilder t_requestHeadersBuilder; private readonly object _lockObject = new object(); - private bool _doManualDecompressionCheck = false; - private WinInetProxyHelper _proxyHelper = null; + private bool _doManualDecompressionCheck; + private WinInetProxyHelper _proxyHelper; private bool _automaticRedirection = HttpHandlerDefaults.DefaultAutomaticRedirection; private int _maxAutomaticRedirections = HttpHandlerDefaults.DefaultMaxAutomaticRedirections; private DecompressionMethods _automaticDecompression = HttpHandlerDefaults.DefaultAutomaticDecompression; private CookieUsePolicy _cookieUsePolicy = CookieUsePolicy.UseInternalCookieStoreOnly; - private CookieContainer _cookieContainer = null; + private CookieContainer _cookieContainer; private SslProtocols _sslProtocols = SslProtocols.None; // Use most secure protocols available. private Func< @@ -63,15 +63,15 @@ private Func< X509Certificate2, X509Chain, SslPolicyErrors, - bool> _serverCertificateValidationCallback = null; - private bool _checkCertificateRevocationList = false; + bool> _serverCertificateValidationCallback; + private bool _checkCertificateRevocationList; private ClientCertificateOption _clientCertificateOption = ClientCertificateOption.Manual; - private X509Certificate2Collection _clientCertificates = null; // Only create collection when required. - private ICredentials _serverCredentials = null; - private bool _preAuthenticate = false; + private X509Certificate2Collection _clientCertificates; // Only create collection when required. + private ICredentials _serverCredentials; + private bool _preAuthenticate; private WindowsProxyUsePolicy _windowsProxyUsePolicy = WindowsProxyUsePolicy.UseWinHttpProxy; - private ICredentials _defaultProxyCredentials = null; - private IWebProxy _proxy = null; + private ICredentials _defaultProxyCredentials; + private IWebProxy _proxy; private int _maxConnectionsPerServer = int.MaxValue; private TimeSpan _sendTimeout = TimeSpan.FromSeconds(30); private TimeSpan _receiveHeadersTimeout = TimeSpan.FromSeconds(30); diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestState.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestState.cs index 51865b34f2a38..dd9703902ab87 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestState.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestState.cs @@ -17,11 +17,11 @@ namespace System.Net.Http internal sealed class WinHttpRequestState : IDisposable { #if DEBUG - private static int s_dbg_allocated = 0; - private static int s_dbg_pin = 0; - private static int s_dbg_clearSendRequestState = 0; - private static int s_dbg_callDispose = 0; - private static int s_dbg_operationHandleFree = 0; + private static int s_dbg_allocated; + private static int s_dbg_pin; + private static int s_dbg_clearSendRequestState; + private static int s_dbg_callDispose; + private static int s_dbg_operationHandleFree; private IntPtr s_dbg_requestHandle; #endif @@ -30,7 +30,7 @@ internal sealed class WinHttpRequestState : IDisposable // This is owned by the callback and will be deallocated when the sessionHandle has been closed. private GCHandle _operationHandle; private WinHttpTransportContext _transportContext; - private volatile bool _disposed = false; // To detect redundant calls. + private volatile bool _disposed; // To detect redundant calls. public WinHttpRequestState() { diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpTransportContext.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpTransportContext.cs index adde27377f085..bfdc727116c47 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpTransportContext.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpTransportContext.cs @@ -11,7 +11,7 @@ namespace System.Net.Http { internal class WinHttpTransportContext : TransportContext { - private WinHttpChannelBinding _channelBinding = null; + private WinHttpChannelBinding _channelBinding; internal WinHttpTransportContext() { diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/DelegatingHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/DelegatingHandler.cs index 2aced67d2f1e0..51b699da69d1f 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/DelegatingHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/DelegatingHandler.cs @@ -14,8 +14,8 @@ namespace System.Net.Http public abstract class DelegatingHandler : HttpMessageHandler { private HttpMessageHandler? _innerHandler; - private volatile bool _operationStarted = false; - private volatile bool _disposed = false; + private volatile bool _operationStarted; + private volatile bool _disposed; [DisallowNull] public HttpMessageHandler? InnerHandler diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs index 5a7b7d63d4606..f89919a830033 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs @@ -64,7 +64,7 @@ internal sealed partial class Http2Connection : HttpConnectionBase, IDisposable // report a cancellation to the user, but also block the connection until // the write completes. We avoid actually canceling the write, as we would // then have to close the whole connection. - private Task? _inProgressWrite = null; + private Task? _inProgressWrite; private const int MaxStreamId = int.MaxValue; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs index 627aa06e3bb03..c454a2ecc09a7 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs @@ -46,9 +46,9 @@ internal sealed class Http3Connection : HttpConnectionBase, IDisposable private int _maximumHeadersLength = int.MaxValue; // TODO: this is not yet observed by Http3Stream when buffering headers. // Once the server's streams are received, these are set to 1. Further receipt of these streams results in a connection error. - private int _haveServerControlStream = 0; - private int _haveServerQpackDecodeStream = 0; - private int _haveServerQpackEncodeStream = 0; + private int _haveServerControlStream; + private int _haveServerQpackDecodeStream; + private int _haveServerQpackEncodeStream; // Manages MAX_STREAM count from server. private long _maximumRequestStreams; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs index 440437708e4ec..bd2aefed4f119 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs @@ -48,11 +48,11 @@ internal sealed class Http3RequestStream : IHttpHeadersHandler, IAsyncDisposable private List<(HeaderDescriptor name, string value)>? _trailingHeaders; // When reading response content, keep track of the number of bytes left in the current data frame. - private long _responseDataPayloadRemaining = 0; + private long _responseDataPayloadRemaining; // When our request content has a precomputed length, it is sent over a single DATA frame. // Keep track of how much is remaining in that frame. - private long _requestContentLengthRemaining = 0; + private long _requestContentLengthRemaining; public long StreamId { diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs index d649989fd03ec..c004b8b58277a 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs @@ -57,7 +57,7 @@ internal partial class HttpConnection : HttpConnectionBase, IDisposable private string[] _headerValues = Array.Empty(); private ValueTask? _readAheadTask; - private int _readAheadTaskLock = 0; // 0 == free, 1 == held + private int _readAheadTaskLock; // 0 == free, 1 == held private byte[] _readBuffer; private int _readOffset; private int _readLength; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpEnvironmentProxy.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpEnvironmentProxy.cs index 1147dee06a794..3c4c47d23d093 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpEnvironmentProxy.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpEnvironmentProxy.cs @@ -98,7 +98,7 @@ internal sealed partial class HttpEnvironmentProxy : IWebProxy private readonly Uri? _httpProxyUri; // String URI for HTTP requests private readonly Uri? _httpsProxyUri; // String URI for HTTPS requests - private readonly string[]? _bypass = null; // list of domains not to proxy + private readonly string[]? _bypass; // list of domains not to proxy private ICredentials? _credentials; private HttpEnvironmentProxy(Uri? httpProxy, Uri? httpsProxy, string? bypassList) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs index 277dd2711e906..5df2380606078 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs @@ -22,7 +22,7 @@ internal sealed class HttpWindowsProxy : IMultiWebProxy, IDisposable private readonly MultiProxy _secureProxy; // URI of the https system proxy if set private readonly FailedProxyCache _failedProxies = new FailedProxyCache(); private readonly List? _bypass; // list of domains not to proxy - private readonly bool _bypassLocal = false; // we should bypass domain considered local + private readonly bool _bypassLocal; // we should bypass domain considered local private readonly List? _localIp; private ICredentials? _credentials; private readonly WinInetProxyHelper _proxyHelper; diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/AsyncRequestContext.cs b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/AsyncRequestContext.cs index 138db12aff039..41b9f94c2a523 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/AsyncRequestContext.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/AsyncRequestContext.cs @@ -15,8 +15,8 @@ internal sealed unsafe class AsyncRequestContext : RequestContextBase private readonly ListenerAsyncResult _result; #if DEBUG - private volatile int _nativeOverlappedCounter = 0; - private volatile int _nativeOverlappedUsed = 0; + private volatile int _nativeOverlappedCounter; + private volatile int _nativeOverlappedUsed; private void DebugRefCountReleaseNativeOverlapped() { diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListenerRequest.Windows.cs b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListenerRequest.Windows.cs index b7ccc86a82586..bf455b157eb3a 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListenerRequest.Windows.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListenerRequest.Windows.cs @@ -35,7 +35,7 @@ public sealed unsafe partial class HttpListenerRequest private int _clientCertificateError; private RequestContextBase _memoryBlob; private readonly HttpListenerContext _httpContext; - private bool _isDisposed = false; + private bool _isDisposed; internal const uint CertBoblSize = 1500; private string _serviceName; diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpRequestStream.Windows.cs b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpRequestStream.Windows.cs index 0577c344c60e7..d0c625c3bee78 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpRequestStream.Windows.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpRequestStream.Windows.cs @@ -289,7 +289,7 @@ private sealed unsafe class HttpRequestStreamAsyncResult : LazyAsyncResult private readonly ThreadPoolBoundHandle _boundHandle; internal NativeOverlapped* _pOverlapped; internal void* _pPinnedBuffer; - internal uint _dataAlreadyRead = 0; + internal uint _dataAlreadyRead; private static readonly IOCompletionCallback s_IOCallback = new IOCompletionCallback(Callback); diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/RequestContextBase.cs b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/RequestContextBase.cs index 9dfab0c8447d5..99429126d75fc 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/RequestContextBase.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/RequestContextBase.cs @@ -13,7 +13,7 @@ internal abstract unsafe class RequestContextBase : IDisposable private Interop.HttpApi.HTTP_REQUEST* _memoryBlob; private Interop.HttpApi.HTTP_REQUEST* _originalBlobAddress; private IntPtr _backingBuffer = IntPtr.Zero; - private int _backingBufferLength = 0; + private int _backingBufferLength; // Must call this from derived class' constructors. protected void BaseConstruction(Interop.HttpApi.HTTP_REQUEST* requestBlob) diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketHttpListenerDuplexStream.cs b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketHttpListenerDuplexStream.cs index d3fe2399cf926..da289132149c1 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketHttpListenerDuplexStream.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketHttpListenerDuplexStream.cs @@ -844,8 +844,8 @@ internal class HttpListenerAsyncEventArgs : EventArgs, IDisposable private readonly WebSocketHttpListenerDuplexStream _currentStream; #if DEBUG - private volatile int _nativeOverlappedCounter = 0; - private volatile int _nativeOverlappedUsed = 0; + private volatile int _nativeOverlappedCounter; + private volatile int _nativeOverlappedUsed; private void DebugRefCountReleaseNativeOverlapped() { diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/AlternateViewCollection.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/AlternateViewCollection.cs index 87eb9000f633e..0affdd4084fb6 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/AlternateViewCollection.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/AlternateViewCollection.cs @@ -8,7 +8,7 @@ namespace System.Net.Mail { public sealed class AlternateViewCollection : Collection, IDisposable { - private bool _disposed = false; + private bool _disposed; internal AlternateViewCollection() { } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/Attachment.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/Attachment.cs index 91ffd95551706..4fdbb093cead3 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/Attachment.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/Attachment.cs @@ -11,7 +11,7 @@ namespace System.Net.Mail { public abstract class AttachmentBase : IDisposable { - internal bool disposed = false; + internal bool disposed; private readonly MimePart _part = new MimePart(); private static readonly char[] s_contentCIDInvalidChars = new char[] { '<', '>' }; diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/AttachmentCollection.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/AttachmentCollection.cs index f8f424f939529..a97ec9a41497d 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/AttachmentCollection.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/AttachmentCollection.cs @@ -12,7 +12,7 @@ namespace System.Net.Mail /// public sealed class AttachmentCollection : Collection, IDisposable { - private bool _disposed = false; + private bool _disposed; internal AttachmentCollection() { } public void Dispose() diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/LinkedResourceCollection.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/LinkedResourceCollection.cs index 86ea99bdf1cec..9e1e2f0b26183 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/LinkedResourceCollection.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/LinkedResourceCollection.cs @@ -9,7 +9,7 @@ namespace System.Net.Mail { public sealed class LinkedResourceCollection : Collection, IDisposable { - private bool _disposed = false; + private bool _disposed; internal LinkedResourceCollection() { } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/MailMessage.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/MailMessage.cs index 4bb5e9e8663d2..048c03fa56233 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/MailMessage.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/MailMessage.cs @@ -25,8 +25,8 @@ public class MailMessage : IDisposable private string? _body = string.Empty; private Encoding? _bodyEncoding; private TransferEncoding _bodyTransferEncoding = TransferEncoding.Unknown; - private bool _isBodyHtml = false; - private bool _disposed = false; + private bool _isBodyHtml; + private bool _disposed; private readonly Message _message; private DeliveryNotificationOptions _deliveryStatusNotification = DeliveryNotificationOptions.None; diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs index 54855afd21a2b..e0616e3b886d0 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs @@ -31,7 +31,6 @@ internal partial class SmtpConnection private readonly SmtpClient? _client; private NetworkStream? _networkStream; internal TcpClient? _tcpClient; - internal int _port = 0; private SmtpReplyReaderFactory? _responseReader; private readonly ICredentialsByHost? _credentials; diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpTransport.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpTransport.cs index 32e0bbd249d3b..83838905bcaf2 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpTransport.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpTransport.cs @@ -23,7 +23,7 @@ internal class SmtpTransport private bool _identityRequired; private bool _shouldAbort; - private bool _enableSsl = false; + private bool _enableSsl; private X509CertificateCollection? _clientCertificates; internal SmtpTransport(SmtpClient client) : this(client, SmtpAuthenticationManager.GetModules()) diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mime/EightBitStream.cs b/src/libraries/System.Net.Mail/src/System/Net/Mime/EightBitStream.cs index ec74c63c2d366..4711377e86151 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mime/EightBitStream.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mime/EightBitStream.cs @@ -28,7 +28,7 @@ internal class EightBitStream : DelegatedStream, IEncodableStream // Should we do RFC 2821 Section 4.5.2 encoding of leading dots on a line? // We make this optional because this stream may be used recursively and // the encoding should only be done once. - private readonly bool _shouldEncodeLeadingDots = false; + private readonly bool _shouldEncodeLeadingDots; private WriteStateInfoBase WriteState => _writeState ?? (_writeState = new WriteStateInfoBase()); diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mime/HeaderCollection.cs b/src/libraries/System.Net.Mail/src/System/Net/Mime/HeaderCollection.cs index 1b468f725477f..096819615ce86 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mime/HeaderCollection.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mime/HeaderCollection.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Collections.Specialized; -using System.Globalization; using System.Net.Mail; using System.Text; @@ -14,8 +13,6 @@ namespace System.Net.Mime /// internal class HeaderCollection : NameValueCollection { - private readonly MimeBasePart? _part = null; - // default constructor // intentionally override the default comparer in the derived base class internal HeaderCollection() : base(StringComparer.OrdinalIgnoreCase) @@ -36,17 +33,6 @@ public override void Remove(string name) throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(name)), nameof(name)); } - MailHeaderID id = MailHeaderInfo.GetID(name); - - if (id == MailHeaderID.ContentType && _part != null) - { - _part.ContentType = null!; // this throws ArgumentNullException - } - else if (id == MailHeaderID.ContentDisposition && _part is MimePart) - { - ((MimePart)_part).ContentDisposition = null; - } - base.Remove(name); } @@ -65,16 +51,6 @@ public override void Remove(string name) throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(name)), nameof(name)); } - MailHeaderID id = MailHeaderInfo.GetID(name); - - if (id == MailHeaderID.ContentType && _part != null) - { - _part.ContentType.PersistIfNeeded(this, false); - } - else if (id == MailHeaderID.ContentDisposition && _part is MimePart) - { - ((MimePart)_part!).ContentDisposition!.PersistIfNeeded(this, false); - } return base.Get(name); } @@ -92,16 +68,6 @@ public override void Remove(string name) throw new ArgumentException(SR.Format(SR.net_emptystringcall, nameof(name)), nameof(name)); } - MailHeaderID id = MailHeaderInfo.GetID(name); - - if (id == MailHeaderID.ContentType && _part != null) - { - _part.ContentType.PersistIfNeeded(this, false); - } - else if (id == MailHeaderID.ContentDisposition && _part is MimePart) - { - ((MimePart)_part).ContentDisposition!.PersistIfNeeded(this, false); - } return base.GetValues(name); } @@ -156,22 +122,9 @@ public override void Set(string name, string value) // normalize the case of well known headers name = MailHeaderInfo.NormalizeCase(name); - MailHeaderID id = MailHeaderInfo.GetID(name); - value = value.Normalize(NormalizationForm.FormC); - if (id == MailHeaderID.ContentType && _part != null) - { - _part.ContentType.Set(value.ToLowerInvariant(), this); - } - else if (id == MailHeaderID.ContentDisposition && _part is MimePart) - { - ((MimePart)_part).ContentDisposition!.Set(value.ToLowerInvariant(), this); - } - else - { - base.Set(name, value); - } + base.Set(name, value); } @@ -201,22 +154,9 @@ public override void Add(string name, string value) // normalize the case of well known headers name = MailHeaderInfo.NormalizeCase(name); - MailHeaderID id = MailHeaderInfo.GetID(name); - value = value.Normalize(NormalizationForm.FormC); - if (id == MailHeaderID.ContentType && _part != null) - { - _part.ContentType.Set(value.ToLowerInvariant(), this); - } - else if (id == MailHeaderID.ContentDisposition && _part is MimePart) - { - ((MimePart)_part).ContentDisposition!.Set(value.ToLowerInvariant(), this); - } - else - { - InternalAdd(name, value); - } + InternalAdd(name, value); } } } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mime/MimePart.cs b/src/libraries/System.Net.Mail/src/System/Net/Mime/MimePart.cs index cd2c3ddfdd486..a128d11320b28 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mime/MimePart.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mime/MimePart.cs @@ -18,8 +18,8 @@ namespace System.Net.Mime internal class MimePart : MimeBasePart, IDisposable { private Stream? _stream; - private bool _streamSet = false; - private bool _streamUsedOnce = false; + private bool _streamSet; + private bool _streamUsedOnce; private AsyncCallback? _readCallback; private AsyncCallback? _writeCallback; private const int maxBufferSize = 0x4400; //seems optimal for send based on perf analysis diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mime/SmtpDateTime.cs b/src/libraries/System.Net.Mail/src/System/Net/Mime/SmtpDateTime.cs index c338406967455..c69fd67ebbd88 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mime/SmtpDateTime.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mime/SmtpDateTime.cs @@ -108,7 +108,7 @@ internal static Dictionary InitializeShortHandLookups() // true if the time zone is unspecified i.e. -0000 // the time zone will usually be specified - private readonly bool _unknownTimeZone = false; + private readonly bool _unknownTimeZone; #endregion diff --git a/src/libraries/System.Net.Mail/src/System/Net/TrackingValidationObjectDictionary.cs b/src/libraries/System.Net.Mail/src/System/Net/TrackingValidationObjectDictionary.cs index 777e5f2d04ab9..09e0f1d9b82d5 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/TrackingValidationObjectDictionary.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/TrackingValidationObjectDictionary.cs @@ -22,7 +22,7 @@ internal sealed class TrackingValidationObjectDictionary : StringDictionary // even though validators may exist, we should not initialize this initially since by default it is empty // and it may never be populated with values if the user does not set them private readonly Dictionary _validators; - private Dictionary? _internalObjects = null; + private Dictionary? _internalObjects; #endregion diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs index dce7f0967ec54..f1de779ebfebf 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Unix.cs @@ -12,7 +12,7 @@ namespace System.Net.NetworkInformation // Linux implementation of NetworkChange public partial class NetworkChange { - private static volatile int s_socket = 0; + private static volatile int s_socket; // Lock controlling access to delegate subscriptions, socket initialization, availability-changed state and timer. private static readonly object s_gate = new object(); private static readonly Interop.Sys.NetworkChangeEvent s_networkChangeCallback = ProcessEvent; diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs index 6ccb5e6a030a9..e81f654973e55 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.Windows.cs @@ -41,7 +41,7 @@ public static event NetworkAddressChangedEventHandler? NetworkAddressChanged internal static class AvailabilityChangeListener { private static readonly NetworkAddressChangedEventHandler s_addressChange = ChangedAddress; - private static volatile bool s_isAvailable = false; + private static volatile bool s_isAvailable; private static void ChangedAddress(object? sender, EventArgs eventArgs) { @@ -125,12 +125,12 @@ internal static void Stop(NetworkAvailabilityChangedEventHandler? caller) internal static unsafe class AddressChangeListener { // Need to keep the reference so it isn't GC'd before the native call executes. - private static bool s_isListening = false; - private static bool s_isPending = false; - private static Socket? s_ipv4Socket = null; - private static Socket? s_ipv6Socket = null; - private static WaitHandle? s_ipv4WaitHandle = null; - private static WaitHandle? s_ipv6WaitHandle = null; + private static bool s_isListening; + private static bool s_isPending; + private static Socket? s_ipv4Socket; + private static Socket? s_ipv6Socket; + private static WaitHandle? s_ipv4WaitHandle; + private static WaitHandle? s_ipv6WaitHandle; // Callback fired when an address change occurs. private static void AddressChangedCallback(object? stateObject, bool signaled) diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs index 4c7581b8e5ed2..752d1465d2467 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs @@ -10,7 +10,7 @@ namespace System.Net.NetworkInformation public class PhysicalAddress { private readonly byte[] _address; - private int _hash = 0; + private int _hash; public static readonly PhysicalAddress None = new PhysicalAddress(Array.Empty()); diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs index 3b4e464393414..da16c434e7710 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalStatistics.cs @@ -9,7 +9,7 @@ namespace System.Net.NetworkInformation /// IP statistics. internal class SystemIPGlobalStatistics : IPGlobalStatistics { - private readonly Interop.IpHlpApi.MibIpStats _stats = default; + private readonly Interop.IpHlpApi.MibIpStats _stats; private SystemIPGlobalStatistics() { } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPInterfaceProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPInterfaceProperties.cs index 30b15b33a41bc..bfacfb6f84d86 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPInterfaceProperties.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPInterfaceProperties.cs @@ -13,8 +13,8 @@ namespace System.Net.NetworkInformation internal class SystemIPInterfaceProperties : IPInterfaceProperties { // These are valid for all interfaces. - private readonly bool _dnsEnabled = false; - private readonly bool _dynamicDnsEnabled = false; + private readonly bool _dnsEnabled; + private readonly bool _dynamicDnsEnabled; private readonly InternalIPAddressCollection _dnsAddresses; private readonly UnicastIPAddressInformationCollection _unicastAddresses; private readonly MulticastIPAddressInformationCollection _multicastAddresses; diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPv4InterfaceProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPv4InterfaceProperties.cs index eb47c6f4301d7..e91447315e617 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPv4InterfaceProperties.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPv4InterfaceProperties.cs @@ -14,10 +14,10 @@ internal class SystemIPv4InterfaceProperties : IPv4InterfaceProperties private readonly bool _haveWins; private readonly bool _dhcpEnabled; private readonly bool _routingEnabled; - private readonly uint _index = 0; - private readonly uint _mtu = 0; - private bool _autoConfigEnabled = false; - private bool _autoConfigActive = false; + private readonly uint _index; + private readonly uint _mtu; + private bool _autoConfigEnabled; + private bool _autoConfigActive; internal SystemIPv4InterfaceProperties(Interop.IpHlpApi.FIXED_INFO fixedInfo, Interop.IpHlpApi.IpAdapterAddresses ipAdapterAddresses) { diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemNetworkInterface.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemNetworkInterface.cs index 75e07964359e9..a767fb8be180c 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemNetworkInterface.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemNetworkInterface.cs @@ -22,8 +22,8 @@ internal class SystemNetworkInterface : NetworkInterface private readonly long _speed; // Any interface can have two completely different valid indexes for ipv4 and ipv6. - private readonly uint _index = 0; - private readonly uint _ipv6Index = 0; + private readonly uint _index; + private readonly uint _ipv6Index; private readonly Interop.IpHlpApi.AdapterFlags _adapterFlags; private readonly SystemIPInterfaceProperties _interfaceProperties; diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.cs index 2e10477c0c957..af914636463d1 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.cs @@ -16,7 +16,7 @@ internal abstract class UnixNetworkInterface : NetworkInterface internal List _unicastAddresses = new List(); internal List? _multicastAddresses; // If this is an ipv6 device, contains the Scope ID. - protected uint? _ipv6ScopeId = null; + protected uint? _ipv6ScopeId; protected UnixNetworkInterface(string name) { diff --git a/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Windows.cs b/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Windows.cs index 83a4ae6b1a4bb..2a63e3e9a4254 100644 --- a/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Windows.cs +++ b/src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Windows.cs @@ -21,8 +21,8 @@ public partial class Ping private static readonly object s_socketInitializationLock = new object(); private static bool s_socketInitialized; - private int _sendSize = 0; // Needed to determine what the reply size is for ipv6 in callback. - private bool _ipv6 = false; + private int _sendSize; // Needed to determine what the reply size is for ipv6 in callback. + private bool _ipv6; private ManualResetEvent? _pingEvent; private RegisteredWaitHandle? _registeredWait; private SafeLocalAllocHandle? _requestBuffer; diff --git a/src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs b/src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs index c362da13e751c..72e9425ce812a 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs @@ -47,9 +47,9 @@ public sealed class Cookie internal static readonly char[] ReservedToValue = new char[] { ';', ',' }; private string m_comment = string.Empty; // Do not rename (binary serialization) - private Uri? m_commentUri = null; // Do not rename (binary serialization) + private Uri? m_commentUri; // Do not rename (binary serialization) private CookieVariant m_cookieVariant = CookieVariant.Plain; // Do not rename (binary serialization) - private bool m_discard = false; // Do not rename (binary serialization) + private bool m_discard; // Do not rename (binary serialization) private string m_domain = string.Empty; // Do not rename (binary serialization) private bool m_domain_implicit = true; // Do not rename (binary serialization) private DateTime m_expires = DateTime.MinValue; // Do not rename (binary serialization) @@ -58,13 +58,13 @@ public sealed class Cookie private bool m_path_implicit = true; // Do not rename (binary serialization) private string m_port = string.Empty; // Do not rename (binary serialization) private bool m_port_implicit = true; // Do not rename (binary serialization) - private int[]? m_port_list = null; // Do not rename (binary serialization) - private bool m_secure = false; // Do not rename (binary serialization) + private int[]? m_port_list; // Do not rename (binary serialization) + private bool m_secure; // Do not rename (binary serialization) [System.Runtime.Serialization.OptionalField] private bool m_httpOnly = false; // Do not rename (binary serialization) private DateTime m_timeStamp = DateTime.Now; // Do not rename (binary serialization) private string m_value = string.Empty; // Do not rename (binary serialization) - private int m_version = 0; // Do not rename (binary serialization) + private int m_version; // Do not rename (binary serialization) private string m_domainKey = string.Empty; // Do not rename (binary serialization) diff --git a/src/libraries/System.Net.Primitives/src/System/Net/CookieContainer.cs b/src/libraries/System.Net.Primitives/src/System/Net/CookieContainer.cs index cd2595997f038..3c2e997456d9a 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/CookieContainer.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/CookieContainer.cs @@ -107,7 +107,7 @@ public class CookieContainer private int m_maxCookieSize = DefaultCookieLengthLimit; // Do not rename (binary serialization) private int m_maxCookies = DefaultCookieLimit; // Do not rename (binary serialization) private int m_maxCookiesPerDomain = DefaultPerDomainCookieLimit; // Do not rename (binary serialization) - private int m_count = 0; // Do not rename (binary serialization) + private int m_count; // Do not rename (binary serialization) private readonly string m_fqdnMyDomain = s_fqdnMyDomain; // Do not rename (binary serialization) public CookieContainer() diff --git a/src/libraries/System.Net.Requests/src/System/Net/CommandStream.cs b/src/libraries/System.Net.Requests/src/System/Net/CommandStream.cs index e013d8d21831a..9444fac4c1bb3 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/CommandStream.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/CommandStream.cs @@ -682,7 +682,7 @@ private void ReceiveCommandResponseCallback(ReceiveState state, int bytesRead) internal class ResponseDescription { internal const int NoStatus = -1; - internal bool Multiline = false; + internal bool Multiline; internal int Status = NoStatus; internal string? StatusDescription; diff --git a/src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs b/src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs index 3cd68e4ad068b..7348092477e36 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/FtpControlStream.cs @@ -38,7 +38,7 @@ internal class FtpControlStream : CommandStream private long _contentLength = -1; private DateTime _lastModified; - private bool _dataHandshakeStarted = false; + private bool _dataHandshakeStarted; private string? _loginDirectory; private string? _establishedServerDirectory; private string? _requestedServerDirectory; diff --git a/src/libraries/System.Net.Requests/src/System/Net/FtpDataStream.cs b/src/libraries/System.Net.Requests/src/System/Net/FtpDataStream.cs index b40457020acd3..fd511a0b6f913 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/FtpDataStream.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/FtpDataStream.cs @@ -19,8 +19,8 @@ internal class FtpDataStream : Stream, ICloseEx private readonly NetworkStream _networkStream; private bool _writeable; private bool _readable; - private bool _isFullyRead = false; - private bool _closing = false; + private bool _isFullyRead; + private bool _closing; private const int DefaultCloseTimeout = -1; diff --git a/src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs b/src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs index de94b5c088de6..1964886e9f264 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs @@ -191,8 +191,8 @@ public sealed class FtpWebRequest : WebRequest private DateTime _startTime; private int _timeout = s_DefaultTimeout; private int _remainingTimeout; - private long _contentLength = 0; - private long _contentOffset = 0; + private long _contentLength; + private long _contentOffset; private X509CertificateCollection? _clientCertificates; private bool _passive = true; private bool _binary = true; diff --git a/src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs b/src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs index 0192479aca7f6..bd460239e84a0 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs @@ -33,7 +33,7 @@ public class HttpWebRequest : WebRequest, ISerializable // as the underlying System.Net.Http API doesn't support it. private int _continueTimeout = DefaultContinueTimeout; - private bool _allowReadStreamBuffering = false; + private bool _allowReadStreamBuffering; private CookieContainer? _cookieContainer; private ICredentials? _credentials; private IWebProxy? _proxy = WebRequest.DefaultWebProxy; @@ -42,10 +42,10 @@ public class HttpWebRequest : WebRequest, ISerializable private static int _defaultMaxResponseHeadersLength = HttpHandlerDefaults.DefaultMaxResponseHeadersLength; - private int _beginGetRequestStreamCalled = 0; - private int _beginGetResponseCalled = 0; - private int _endGetRequestStreamCalled = 0; - private int _endGetResponseCalled = 0; + private int _beginGetRequestStreamCalled; + private int _beginGetResponseCalled; + private int _endGetRequestStreamCalled; + private int _endGetResponseCalled; private int _maximumAllowedRedirections = HttpHandlerDefaults.DefaultMaxAutomaticRedirections; private int _maximumResponseHeadersLen = _defaultMaxResponseHeadersLength; @@ -65,7 +65,7 @@ public class HttpWebRequest : WebRequest, ISerializable private TaskCompletionSource? _responseOperation; private AsyncCallback? _requestStreamCallback; private AsyncCallback? _responseCallback; - private int _abortCalled = 0; + private int _abortCalled; private CancellationTokenSource? _sendRequestCts; private X509CertificateCollection? _clientCertificates; private Booleans _booleans = Booleans.Default; diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStream.cs b/src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStream.cs index 5f27594d1a46c..5a990a32d1ec5 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStream.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/NegotiateStream.cs @@ -58,7 +58,7 @@ public partial class NegotiateStream : AuthenticatedStream /// SSPI does not send a server ack on successful auth. /// This is a state variable used to gracefully handle auth confirmation. /// - private bool _remoteOk = false; + private bool _remoteOk; public NegotiateStream(Stream innerStream) : this(innerStream, false) { diff --git a/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs b/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs index 515de077b833c..70c4c2db753ae 100644 --- a/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs +++ b/src/libraries/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs @@ -17,7 +17,7 @@ public class ServicePointManager private static readonly ConcurrentDictionary> s_servicePointTable = new ConcurrentDictionary>(); private static SecurityProtocolType s_securityProtocolType = SecurityProtocolType.SystemDefault; private static int s_connectionLimit = 2; - private static int s_maxServicePoints = 0; + private static int s_maxServicePoints; private static int s_maxServicePointIdleTime = 100 * 1000; private static int s_dnsRefreshTimeout = 2 * 60 * 1000; diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetworkStream.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetworkStream.cs index 077ad2d818d27..e1701a0698590 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetworkStream.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetworkStream.cs @@ -367,7 +367,7 @@ public void Close(int timeout) _closeTimeout = timeout; Dispose(); } - private volatile bool _disposed = false; + private volatile bool _disposed; protected override void Dispose(bool disposing) { // Mark this as disposed before changing anything else. diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.Unix.cs index a7d71a3a52390..016049f34042c 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.Unix.cs @@ -179,7 +179,7 @@ internal int SendTimeout } } - internal bool IsDisconnected { get; private set; } = false; + internal bool IsDisconnected { get; private set; } internal void SetToDisconnected() { diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs index dde23496cd038..20f1d105e3e1c 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs @@ -780,7 +780,7 @@ private class TaskSocketAsyncEventArgs : SocketAsyncEventArgs /// the pool. If it completes asynchronously, then it's the responsibility of whoever /// accesses this second, so we track whether it's already been accessed. /// - internal bool _accessed = false; + internal bool _accessed; internal TaskSocketAsyncEventArgs() : base(unsafeSuppressExecutionContextFlow: true) // avoid flowing context at lower layers as we only expose Task, which handles it diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs index 76521180c050a..6fe0de419f771 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs @@ -36,7 +36,7 @@ public partial class Socket : IDisposable // so we need to handle one of these cases at a time. private bool _willBlock = true; // Desired state of the socket from the user. private bool _willBlockInternal = true; // Actual win32 state of the socket. - private bool _isListening = false; + private bool _isListening; // Our internal state doesn't automatically get updated after a non-blocking connect // completes. Keep track of whether we're doing a non-blocking connect, and make sure diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UDPClient.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UDPClient.cs index 7daf3a58aeb91..5422349836047 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UDPClient.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UDPClient.cs @@ -198,7 +198,7 @@ public void AllowNatTraversal(bool allowed) _clientSocket.SetIPProtectionLevel(allowed ? IPProtectionLevel.Unrestricted : IPProtectionLevel.EdgeRestricted); } - private bool _disposed = false; + private bool _disposed; private bool IsAddressFamilyCompatible(AddressFamily family) { diff --git a/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs b/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs index ea4109ad607de..6288eb2122e7a 100644 --- a/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs +++ b/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs @@ -1949,11 +1949,11 @@ private static void ThrowIfNull(object argument, string parameterName) #region Supporting Types private sealed class ProgressData { - internal long BytesSent = 0; + internal long BytesSent; internal long TotalBytesToSend = -1; - internal long BytesReceived = 0; + internal long BytesReceived; internal long TotalBytesToReceive = -1; - internal bool HasUploadPhase = false; + internal bool HasUploadPhase; internal void Reset() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.cs index 2c90977297ba7..c01c30b081423 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/DebugProvider.cs @@ -110,7 +110,7 @@ private string GetIndentString() } // internal and not readonly so that the tests can swap this out. - internal static Action? s_FailCore = null; - internal static Action? s_WriteCore = null; + internal static Action? s_FailCore; + internal static Action? s_WriteCore; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs index 9f46e13c38305..795efbda22d71 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs @@ -604,7 +604,7 @@ private void ActivityChanging(AsyncLocalValueChangedArgs args) private static readonly ActivityTracker s_activityTrackerInstance = new ActivityTracker(); // Used to create unique IDs at the top level. Not used for nested Ids (each activity has its own id generator) - private static long m_nextId = 0; + private static long m_nextId; private const ushort MAX_ACTIVITY_DEPTH = 100; // Limit maximum depth of activities to be tracked at 100. // This will avoid leaking memory in case of activities that are never stopped. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.cs index 308c19ada6281..7d4bbd32bf95e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipe.cs @@ -177,7 +177,7 @@ internal void SetProfilerSamplingRate(TimeSpan minTimeBetweenSamples) internal static class EventPipe { - private static ulong s_sessionID = 0; + private static ulong s_sessionID; internal static void Enable(EventPipeConfiguration configuration) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs index f2d9b30bf85a5..c0607cd1c3307 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventPipeEventDispatcher.cs @@ -27,14 +27,14 @@ internal EventListenerSubscription(EventKeywords matchAnyKeywords, EventLevel le private readonly IntPtr m_RuntimeProviderID; - private ulong m_sessionID = 0; + private ulong m_sessionID; private DateTime m_syncTimeUtc; private long m_syncTimeQPC; private long m_timeQPCFrequency; private bool m_stopDispatchTask; private readonly EventPipeWaitHandle m_dispatchTaskWaitHandle = new EventPipeWaitHandle(); - private Task? m_dispatchTask = null; + private Task? m_dispatchTask; private readonly object m_dispatchControlLock = new object(); private readonly Dictionary m_subscriptions = new Dictionary(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index 0c9c2d18ad11d..ab5d0fef8ca68 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -4368,7 +4368,7 @@ private void CallBackForExistingEventSources(bool addToListenersList, EventHandl /// /// Used to disallow reentrancy. /// - private static bool s_CreatingListener = false; + private static bool s_CreatingListener; #if DEBUG /// @@ -4383,8 +4383,8 @@ private void CallBackForExistingEventSources(bool addToListenersList, EventHandl /// /// Used to register AD/Process shutdown callbacks. /// - private static bool s_EventSourceShutdownRegistered = false; -#endregion + private static bool s_EventSourceShutdownRegistered; + #endregion } /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSourceHelper.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSourceHelper.Windows.cs index ad198646debbf..95f540ecda763 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSourceHelper.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSourceHelper.Windows.cs @@ -6,10 +6,10 @@ namespace System.Diagnostics.Tracing { internal static class RuntimeEventSourceHelper { - private static long s_prevProcUserTime = 0; - private static long s_prevProcKernelTime = 0; - private static long s_prevSystemUserTime = 0; - private static long s_prevSystemKernelTime = 0; + private static long s_prevProcUserTime; + private static long s_prevProcKernelTime; + private static long s_prevSystemUserTime; + private static long s_prevSystemKernelTime; internal static int GetCpuUsage() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs index fe50eb4f07e5b..277cd465b64fc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs @@ -57,7 +57,7 @@ public abstract class Calendar : ICloneable private int _currentEraValue = -1; - private bool _isReadOnly = false; + private bool _isReadOnly; public virtual DateTime MinSupportedDateTime => DateTime.MinValue; diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.cs index 2d9ca30f617fd..909dfb986b567 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.cs @@ -42,7 +42,7 @@ internal partial class CalendarData // Integers at end to make marshaller happier internal int iTwoDigitYearMax = 2029; // Max 2 digit year (for Y2K bug data entry) - private int iCurrentEra = 0; // current era # (usually 1) + private int iCurrentEra; // current era # (usually 1) // Use overrides? internal bool bUseUserOverrides; // True if we want user overrides. diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormatInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormatInfo.cs index bf1689ce6da0a..d9b96e5ca94b1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormatInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormatInfo.cs @@ -58,29 +58,29 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable private readonly CultureData _cultureData; // The culture name used to create this DTFI. - private string? _name = null; + private string? _name; // The language name of the culture used to create this DTFI. - private string? _langName = null; + private string? _langName; // CompareInfo usually used by the parser. - private CompareInfo? _compareInfo = null; + private CompareInfo? _compareInfo; // Culture matches current DTFI. mainly used for string comparisons during parsing. - private CultureInfo? _cultureInfo = null; + private CultureInfo? _cultureInfo; - private string? amDesignator = null; - private string? pmDesignator = null; + private string? amDesignator; + private string? pmDesignator; - private string? dateSeparator = null; // derived from short date (whidbey expects, arrowhead doesn't) + private string? dateSeparator; // derived from short date (whidbey expects, arrowhead doesn't) - private string? generalShortTimePattern = null; // short date + short time (whidbey expects, arrowhead doesn't) + private string? generalShortTimePattern; // short date + short time (whidbey expects, arrowhead doesn't) - private string? generalLongTimePattern = null; // short date + long time (whidbey expects, arrowhead doesn't) + private string? generalLongTimePattern; // short date + long time (whidbey expects, arrowhead doesn't) - private string? timeSeparator = null; // derived from long time (whidbey expects, arrowhead doesn't) - private string? monthDayPattern = null; - private string? dateTimeOffsetPattern = null; + private string? timeSeparator; // derived from long time (whidbey expects, arrowhead doesn't) + private string? monthDayPattern; + private string? dateTimeOffsetPattern; private const string rfc1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"; @@ -93,26 +93,26 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable private int firstDayOfWeek = -1; private int calendarWeekRule = -1; - private string? fullDateTimePattern = null; // long date + long time (whidbey expects, arrowhead doesn't) + private string? fullDateTimePattern; // long date + long time (whidbey expects, arrowhead doesn't) - private string[]? abbreviatedDayNames = null; + private string[]? abbreviatedDayNames; - private string[]? m_superShortDayNames = null; + private string[]? m_superShortDayNames; - private string[]? dayNames = null; - private string[]? abbreviatedMonthNames = null; - private string[]? monthNames = null; + private string[]? dayNames; + private string[]? abbreviatedMonthNames; + private string[]? monthNames; // Cache the genitive month names that we retrieve from the data table. - private string[]? genitiveMonthNames = null; + private string[]? genitiveMonthNames; // Cache the abbreviated genitive month names that we retrieve from the data table. - private string[]? m_genitiveAbbreviatedMonthNames = null; + private string[]? m_genitiveAbbreviatedMonthNames; // Cache the month names of a leap year that we retrieve from the data table. - private string[]? leapYearMonthNames = null; + private string[]? leapYearMonthNames; // For our "patterns" arrays we have 2 variables, a string and a string[] // @@ -121,30 +121,30 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable // When we initially construct our string[], we set the string to string[0] // The "default" Date/time patterns - private string? longDatePattern = null; - private string? shortDatePattern = null; - private string? yearMonthPattern = null; - private string? longTimePattern = null; - private string? shortTimePattern = null; + private string? longDatePattern; + private string? shortDatePattern; + private string? yearMonthPattern; + private string? longTimePattern; + private string? shortTimePattern; - private string[]? allYearMonthPatterns = null; + private string[]? allYearMonthPatterns; - private string[]? allShortDatePatterns = null; - private string[]? allLongDatePatterns = null; - private string[]? allShortTimePatterns = null; - private string[]? allLongTimePatterns = null; + private string[]? allShortDatePatterns; + private string[]? allLongDatePatterns; + private string[]? allShortTimePatterns; + private string[]? allLongTimePatterns; // Cache the era names for this DateTimeFormatInfo instance. - private string[]? m_eraNames = null; - private string[]? m_abbrevEraNames = null; - private string[]? m_abbrevEnglishEraNames = null; + private string[]? m_eraNames; + private string[]? m_abbrevEraNames; + private string[]? m_abbrevEnglishEraNames; - private CalendarId[]? optionalCalendars = null; + private CalendarId[]? optionalCalendars; private const int DEFAULT_ALL_DATETIMES_SIZE = 132; // CultureInfo updates this - internal bool _isReadOnly = false; + internal bool _isReadOnly; // This flag gives hints about if formatting/parsing should perform special code path for things like // genitive form or leap year month names. diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs index 6398c5103e7a9..cd8fb6bb18d05 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs @@ -5218,7 +5218,7 @@ private static void Trace(string s) } // for testing; do not make this readonly - private static bool s_tracingEnabled = false; + private static bool s_tracingEnabled; #endif // _LOGGING } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendarHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendarHelper.cs index 2649eca9b6d45..76eec4d1b5dd4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendarHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GregorianCalendarHelper.cs @@ -102,7 +102,7 @@ internal class GregorianCalendarHelper internal Calendar m_Cal; internal EraInfo[] m_EraInfo; - internal int[]? m_eras = null; + internal int[]? m_eras; // Construct an instance of gregorian calendar. internal GregorianCalendarHelper(Calendar cal, EraInfo[] eraInfo) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/NumberFormatInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/NumberFormatInfo.cs index d5fa16edcdcb3..af9a82ba6ea11 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/NumberFormatInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/NumberFormatInfo.cs @@ -59,16 +59,16 @@ public sealed class NumberFormatInfo : IFormatProvider, ICloneable internal int _numberDecimalDigits = 2; internal int _currencyDecimalDigits = 2; - internal int _currencyPositivePattern = 0; - internal int _currencyNegativePattern = 0; + internal int _currencyPositivePattern; + internal int _currencyNegativePattern; internal int _numberNegativePattern = 1; - internal int _percentPositivePattern = 0; - internal int _percentNegativePattern = 0; + internal int _percentPositivePattern; + internal int _percentNegativePattern; internal int _percentDecimalDigits = 2; internal int _digitSubstitution = (int)DigitShapes.None; - internal bool _isReadOnly = false; + internal bool _isReadOnly; private bool _hasInvariantNumberSigns = true; diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.cs index 0481c684cd8a9..b14abb1f53491 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/TextInfo.cs @@ -27,7 +27,7 @@ private enum Tristate : byte } private string? _listSeparator; - private bool _isReadOnly = false; + private bool _isReadOnly; private readonly string _cultureName; private readonly CultureData _cultureData; diff --git a/src/libraries/System.Private.CoreLib/src/System/Guid.cs b/src/libraries/System.Private.CoreLib/src/System/Guid.cs index 47838475459d4..cc54f974d1517 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Guid.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Guid.cs @@ -19,7 +19,7 @@ namespace System [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public partial struct Guid : IFormattable, IComparable, IComparable, IEquatable, ISpanFormattable { - public static readonly Guid Empty = default; + public static readonly Guid Empty; private int _a; // Do not rename (binary serialization) private short _b; // Do not rename (binary serialization) diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.cs index 929ba1579af3a..aaae5d33c6f06 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileStream.cs @@ -54,7 +54,7 @@ public partial class FileStream : Stream private readonly bool _useAsyncIO; /// cached task for read ops that complete synchronously - private Task? _lastSynchronouslyCompletedTask = null; + private Task? _lastSynchronouslyCompletedTask; /// /// Currently cached position in the stream. This should always mirror the underlying file's actual position, @@ -67,7 +67,7 @@ public partial class FileStream : Stream private bool _exposedHandle; /// Caches whether Serialization Guard has been disabled for file writes - private static int s_cachedSerializationSwitch = 0; + private static int s_cachedSerializationSwitch; [Obsolete("This constructor has been deprecated. Please use new FileStream(SafeFileHandle handle, FileAccess access) instead. https://go.microsoft.com/fwlink/?linkid=14202")] public FileStream(IntPtr handle, FileAccess access) diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/StringWriter.cs b/src/libraries/System.Private.CoreLib/src/System/IO/StringWriter.cs index 6e874aeb572c5..cd0be937e9080 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/StringWriter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/StringWriter.cs @@ -13,7 +13,7 @@ namespace System.IO // the resulting sequence of characters to be presented as a string. public class StringWriter : TextWriter { - private static volatile UnicodeEncoding? s_encoding = null; + private static volatile UnicodeEncoding? s_encoding; private readonly StringBuilder _sb; private bool _isOpen; diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs index cba06116e14d6..4bc2c5608dca5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs @@ -209,7 +209,7 @@ public override string ToString() } // internal test hook - private static bool s_forceNullEntryPoint = false; + private static bool s_forceNullEntryPoint; public static Assembly? GetEntryAssembly() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/EventToken.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/EventToken.cs index 2342f6edeb096..691af1b2f0022 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/EventToken.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/EventToken.cs @@ -6,7 +6,7 @@ namespace System.Reflection.Emit { public struct EventToken { - public static readonly EventToken Empty = default; + public static readonly EventToken Empty; internal EventToken(int eventToken) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/FieldToken.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/FieldToken.cs index e695c0215286f..9fa1cb31c8450 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/FieldToken.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/FieldToken.cs @@ -12,7 +12,7 @@ namespace System.Reflection.Emit /// public struct FieldToken { - public static readonly FieldToken Empty = default; + public static readonly FieldToken Empty; private readonly object _class; diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/MethodToken.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/MethodToken.cs index eb8c15a9b318d..41ee716dbc4b1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/MethodToken.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/MethodToken.cs @@ -6,7 +6,7 @@ namespace System.Reflection.Emit { public struct MethodToken { - public static readonly MethodToken Empty = default; + public static readonly MethodToken Empty; internal MethodToken(int methodToken) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ParameterToken.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ParameterToken.cs index b03ddf082e6dd..2965c6f465a9c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ParameterToken.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/ParameterToken.cs @@ -10,7 +10,7 @@ namespace System.Reflection.Emit /// public struct ParameterToken { - public static readonly ParameterToken Empty = default; + public static readonly ParameterToken Empty; internal ParameterToken(int parameterToken) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/PropertyToken.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/PropertyToken.cs index 02d88ff79f62b..610538b836897 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/PropertyToken.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/PropertyToken.cs @@ -6,7 +6,7 @@ namespace System.Reflection.Emit { public struct PropertyToken { - public static readonly PropertyToken Empty = default; + public static readonly PropertyToken Empty; internal PropertyToken(int propertyToken) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/SignatureToken.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/SignatureToken.cs index 851dcd7ee4f2c..075db71c7daf6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/SignatureToken.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/SignatureToken.cs @@ -6,7 +6,7 @@ namespace System.Reflection.Emit { public struct SignatureToken { - public static readonly SignatureToken Empty = default; + public static readonly SignatureToken Empty; internal SignatureToken(int signatureToken) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeToken.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeToken.cs index 099b9e8472900..45b6ba5c99ff7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeToken.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/TypeToken.cs @@ -6,7 +6,7 @@ namespace System.Reflection.Emit { public struct TypeToken { - public static readonly TypeToken Empty = default; + public static readonly TypeToken Empty; internal TypeToken(int typeToken) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs index d6c29347d425d..3100c2299017e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs @@ -84,8 +84,8 @@ public sealed partial class MemoryFailPoint : CriticalFinalizerObject, IDisposab // walk once every 10 seconds, or when we will likely fail. This // amortization scheme can reduce the cost of a memory gate by about // a factor of 100. - private static long s_hiddenLastKnownFreeAddressSpace = 0; - private static long s_hiddenLastTimeCheckingAddressSpace = 0; + private static long s_hiddenLastKnownFreeAddressSpace; + private static long s_hiddenLastTimeCheckingAddressSpace; private const int CheckThreshold = 10 * 1000; // 10 seconds private static long LastKnownFreeAddressSpace diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Decoder.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Decoder.cs index 9de773cb67604..88a6d6bf0a965 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Decoder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Decoder.cs @@ -20,9 +20,9 @@ namespace System.Text // public abstract class Decoder { - internal DecoderFallback? _fallback = null; + internal DecoderFallback? _fallback; - internal DecoderFallbackBuffer? _fallbackBuffer = null; + internal DecoderFallbackBuffer? _fallbackBuffer; protected Decoder() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs b/src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs index 430ae62bbea3b..c55bdeedce9d7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/DecoderExceptionFallback.cs @@ -75,8 +75,8 @@ private void Throw(byte[] bytesUnknown, int index) [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public sealed class DecoderFallbackException : ArgumentException { - private readonly byte[]? _bytesUnknown = null; - private readonly int _index = 0; + private readonly byte[]? _bytesUnknown; + private readonly int _index; public DecoderFallbackException() : base(SR.Arg_ArgumentException) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Encoder.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Encoder.cs index 2d6d10cc86e9a..8a140ed34159b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Encoder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Encoder.cs @@ -20,9 +20,9 @@ namespace System.Text // public abstract class Encoder { - internal EncoderFallback? _fallback = null; + internal EncoderFallback? _fallback; - internal EncoderFallbackBuffer? _fallbackBuffer = null; + internal EncoderFallbackBuffer? _fallbackBuffer; protected Encoder() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/EncoderFallback.cs b/src/libraries/System.Private.CoreLib/src/System/Text/EncoderFallback.cs index f182edf3d9f4e..8fa5c29ac7e78 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/EncoderFallback.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/EncoderFallback.cs @@ -67,8 +67,8 @@ public virtual void Reset() internal EncoderNLS? encoder; // TODO: MAKE ME PRIVATE internal bool setEncoder; internal bool bUsedEncoder; - internal bool bFallingBack = false; - internal int iRecursionCount = 0; + internal bool bFallingBack; + internal int iRecursionCount; private const int iMaxRecursion = 250; private Encoding? encoding; private int originalCharCount; diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/EncoderLatin1BestFitFallback.cs b/src/libraries/System.Private.CoreLib/src/System/Text/EncoderLatin1BestFitFallback.cs index 08f2611d8725d..281909159eb8c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/EncoderLatin1BestFitFallback.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/EncoderLatin1BestFitFallback.cs @@ -30,7 +30,7 @@ public override EncoderFallbackBuffer CreateFallbackBuffer() => internal sealed partial class EncoderLatin1BestFitFallbackBuffer : EncoderFallbackBuffer { // Our variables - private char _cBestFit = '\0'; + private char _cBestFit; private int _iCount = -1; private int _iSize; diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs index 87f928a2e0418..c87e5ccda21d7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs @@ -110,9 +110,9 @@ public abstract partial class Encoding : ICloneable private const int CodePageUTF32 = 12000; private const int CodePageUTF32BE = 12001; - internal int _codePage = 0; + internal int _codePage; - internal CodePageDataItem? _dataItem = null; + internal CodePageDataItem? _dataItem; // Because of encoders we may be read only [OptionalField(VersionAdded = 2)] @@ -1263,7 +1263,7 @@ internal class EncodingCharBuffer private unsafe char* _chars; private readonly unsafe char* _charStart; private readonly unsafe char* _charEnd; - private int _charCountResult = 0; + private int _charCountResult; private readonly Encoding _enc; private readonly DecoderNLS? _decoder; private readonly unsafe byte* _byteStart; @@ -1414,7 +1414,7 @@ internal class EncodingByteBuffer private unsafe char* _chars; private readonly unsafe char* _charStart; private readonly unsafe char* _charEnd; - private int _byteCountResult = 0; + private int _byteCountResult; private readonly Encoding _enc; private readonly EncoderNLS? _encoder; internal EncoderFallbackBuffer fallbackBuffer; diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs index e300db5de3238..e38a956663e17 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/UTF32Encoding.cs @@ -37,9 +37,9 @@ 2 21 00000000 000xxxxx hhhhhhll llllllll internal static readonly UTF32Encoding s_default = new UTF32Encoding(bigEndian: false, byteOrderMark: true); internal static readonly UTF32Encoding s_bigEndianDefault = new UTF32Encoding(bigEndian: true, byteOrderMark: true); - private readonly bool _emitUTF32ByteOrderMark = false; - private readonly bool _isThrowException = false; - private readonly bool _bigEndian = false; + private readonly bool _emitUTF32ByteOrderMark; + private readonly bool _isThrowException; + private readonly bool _bigEndian; public UTF32Encoding() : this(false, true) { @@ -1167,8 +1167,8 @@ public override int GetHashCode() private sealed class UTF32Decoder : DecoderNLS { // Need a place to store any extra bytes we may have picked up - internal int iChar = 0; - internal int readByteCount = 0; + internal int iChar; + internal int readByteCount; public UTF32Decoder(UTF32Encoding encoding) : base(encoding) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/UTF7Encoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/UTF7Encoding.cs index feb7a3114c30f..50fd0ed4074a3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/UTF7Encoding.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/UTF7Encoding.cs @@ -854,7 +854,7 @@ public override DecoderFallbackBuffer CreateFallbackBuffer() => private sealed class DecoderUTF7FallbackBuffer : DecoderFallbackBuffer { // Store our default string - private char cFallback = (char)0; + private char cFallback; private int iCount = -1; private int iSize; diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/UTF8Encoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/UTF8Encoding.cs index a8b3626c90870..b697f9dc91e2e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/UTF8Encoding.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/UTF8Encoding.cs @@ -65,9 +65,9 @@ 4 21 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv // Yes, the idea of emitting U+FEFF as a UTF-8 identifier has made it into // the standard. - private readonly bool _emitUTF8Identifier = false; + private readonly bool _emitUTF8Identifier; - private readonly bool _isThrowException = false; + private readonly bool _isThrowException; public UTF8Encoding() : this(false) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs b/src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs index ff0ca61a38438..a12dc39be30e5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs @@ -24,10 +24,10 @@ public class UnicodeEncoding : Encoding internal static readonly UnicodeEncoding s_bigEndianDefault = new UnicodeEncoding(bigEndian: true, byteOrderMark: true); internal static readonly UnicodeEncoding s_littleEndianDefault = new UnicodeEncoding(bigEndian: false, byteOrderMark: true); - private readonly bool isThrowException = false; + private readonly bool isThrowException; - private readonly bool bigEndian = false; - private readonly bool byteOrderMark = false; + private readonly bool bigEndian; + private readonly bool byteOrderMark; // Unicode version 2.0 character size in bytes public const int CharSize = 2; @@ -1855,7 +1855,7 @@ public override int GetHashCode() private sealed class Decoder : System.Text.DecoderNLS { internal int lastByte = -1; - internal char lastChar = '\0'; + internal char lastChar; public Decoder(UnicodeEncoding encoding) : base(encoding) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs index c2e5f0014da2d..d3f6a46f839b1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/AbandonedMutexException.cs @@ -16,7 +16,7 @@ namespace System.Threading public class AbandonedMutexException : SystemException { private int _mutexIndex = -1; - private Mutex? _mutex = null; + private Mutex? _mutex; public AbandonedMutexException() : base(SR.Threading_AbandonedMutexException) diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index 635a955989071..5d6ff78c16c3b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -174,7 +174,7 @@ public class Task : IAsyncResult, IDisposable // Can be null, a single continuation, a list of continuations, or s_taskCompletionSentinel, // in that order. The logic arround this object assumes it will never regress to a previous state. - private volatile object? m_continuationObject = null; // SOS DumpAsync command depends on this name + private volatile object? m_continuationObject; // SOS DumpAsync command depends on this name // m_continuationObject is set to this when the task completes. private static readonly object s_taskCompletionSentinel = new object(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs index 572831f19c9e8..aa88f8607da04 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs @@ -621,7 +621,7 @@ protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQu public class UnobservedTaskExceptionEventArgs : EventArgs { private readonly AggregateException m_exception; - internal bool m_observed = false; + internal bool m_observed; /// /// Initializes a new instance of the class diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs index 592db0b3a6884..63a24594523f0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs @@ -682,7 +682,7 @@ internal LinkedSlot(LinkedSlotVolatile[]? slotArray) private class IdManager { // The next ID to try - private int _nextIdToTry = 0; + private int _nextIdToTry; // Stores whether each ID is free or not. Additionally, the object is also used as a lock for the IdManager. private readonly List _freeIds = new List(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs index 6d06533b1bcf3..7289d96324b23 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs @@ -384,7 +384,7 @@ public int Count private readonly Internal.PaddingFor32 pad1; - private volatile int numOutstandingThreadRequests = 0; + private volatile int numOutstandingThreadRequests; private readonly Internal.PaddingFor32 pad2; diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZone.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZone.cs index a1a5df6bb5f93..c43616dbd44b9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZone.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZone.cs @@ -26,7 +26,7 @@ namespace System [Obsolete("System.TimeZone has been deprecated. Please investigate the use of System.TimeZoneInfo instead.")] public abstract class TimeZone { - private static volatile TimeZone? currentTimeZone = null; + private static volatile TimeZone? currentTimeZone; // Private object for locking instead of locking on a public type for SQL reliability work. private static object? s_InternalSyncObject; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs index 6fc5bec9af0ff..e3be3156404a7 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs @@ -466,7 +466,7 @@ private class CollectionDataContractCriticalHelper : DataContract.DataContractCr private XmlFormatCollectionReaderDelegate _xmlFormatReaderDelegate; private XmlFormatGetOnlyCollectionReaderDelegate _xmlFormatGetOnlyCollectionReaderDelegate; private XmlFormatCollectionWriterDelegate _xmlFormatWriterDelegate; - private bool _isConstructorCheckRequired = false; + private bool _isConstructorCheckRequired; internal static Type[] KnownInterfaces { @@ -742,7 +742,7 @@ internal XmlFormatGetOnlyCollectionReaderDelegate XmlFormatGetOnlyCollectionRead private delegate void IncrementCollectionCountDelegate(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context); - private IncrementCollectionCountDelegate _incrementCollectionCountDelegate = null; + private IncrementCollectionCountDelegate _incrementCollectionCountDelegate; private static void DummyIncrementCollectionCount(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContext context) { } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataMember.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataMember.cs index 10a03af17d9b1..64f2eab9b11a0 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataMember.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataMember.cs @@ -161,7 +161,7 @@ private class CriticalHelper private bool _isRequired; private bool _emitDefaultValue; private bool _isNullable; - private bool _isGetOnlyCollection = false; + private bool _isGetOnlyCollection; private readonly MemberInfo _memberInfo; private bool _hasConflictingNameAndType; private DataMember _conflictingMember; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonDataContract.cs index b274fa84fff09..533e797e42711 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonDataContract.cs @@ -131,7 +131,7 @@ internal class JsonDataContractCriticalHelper private static readonly object s_createDataContractLock = new object(); private static JsonDataContract[] s_dataContractCache = new JsonDataContract[32]; - private static int s_dataContractID = 0; + private static int s_dataContractID; private static readonly TypeHandleRef s_typeHandleRef = new TypeHandleRef(); private static readonly Dictionary s_typeToIDCache = new Dictionary(new TypeHandleRefEqualityComparer()); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs index 027ba9dee63ff..9be2e99fbc4ef 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonFormatWriterGenerator.cs @@ -47,7 +47,7 @@ private class CriticalHelper // Used for classes private ArgBuilder _memberNamesArg; private int _typeIndex = 1; - private int _childElementIndex = 0; + private int _childElementIndex; internal JsonFormatClassWriterDelegate GenerateClassWriter(ClassDataContract classContract) { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlJsonReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlJsonReader.cs index c8873e2f03732..536c49391cfc9 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlJsonReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlJsonReader.cs @@ -280,8 +280,8 @@ internal class XmlJsonReader : XmlBaseReader, IXmlJsonReaderInitializer private bool _expectingFirstElementInNonPrimitiveChild; private int _maxBytesPerRead; private OnXmlDictionaryReaderClose _onReaderClose; - private bool _readServerTypeElement = false; - private int _scopeDepth = 0; + private bool _readServerTypeElement; + private int _scopeDepth; private JsonNodeType[] _scopes; private enum JsonComplexTextMode diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatWriterGenerator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatWriterGenerator.cs index 157cc9b7c40fd..03907d098e16e 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatWriterGenerator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlFormatWriterGenerator.cs @@ -61,7 +61,7 @@ private class CriticalHelper private LocalBuilder _memberNamesLocal; private LocalBuilder _childElementNamespacesLocal; private int _typeIndex = 1; - private int _childElementIndex = 0; + private int _childElementIndex; #endif private XmlFormatClassWriterDelegate CreateReflectionXmlFormatClassWriterDelegate() diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlReaderDelegator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlReaderDelegator.cs index a2a720ff2b917..79ad6c5fee79c 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlReaderDelegator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlReaderDelegator.cs @@ -18,7 +18,7 @@ internal class XmlReaderDelegator { protected XmlReader reader; protected XmlDictionaryReader dictionaryReader; - protected bool isEndOfEmptyElement = false; + protected bool isEndOfEmptyElement; public XmlReaderDelegator(XmlReader reader) { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableWriter.cs index e770d97c26353..afa8ac2a4c6ad 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableWriter.cs @@ -11,7 +11,7 @@ namespace System.Runtime.Serialization internal class XmlSerializableWriter : XmlWriter { private XmlWriter _xmlWriter; - private int _depth = 0; + private int _depth; private object _obj; internal void BeginWrite(XmlWriter xmlWriter, object obj) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryAsyncCheckWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryAsyncCheckWriter.cs index e986825b422e2..211482a443eb6 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryAsyncCheckWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryAsyncCheckWriter.cs @@ -14,7 +14,7 @@ namespace System.Xml { internal class XmlDictionaryAsyncCheckWriter : XmlDictionaryWriter { - private readonly XmlDictionaryWriter _coreWriter = null; + private readonly XmlDictionaryWriter _coreWriter; private Task _lastTask; public XmlDictionaryAsyncCheckWriter(XmlDictionaryWriter writer) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReaderQuotas.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReaderQuotas.cs index cd6defddf6170..cf5c0dc2f6b83 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReaderQuotas.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReaderQuotas.cs @@ -26,7 +26,7 @@ public sealed class XmlDictionaryReaderQuotas private int _maxDepth; private int _maxNameTableCharCount; private int _maxBytesPerRead; - private XmlDictionaryReaderQuotaTypes _modifiedQuotas = 0x00; + private XmlDictionaryReaderQuotaTypes _modifiedQuotas; private const int DefaultMaxDepth = 32; private const int DefaultMaxStringContentLength = 8192; private const int DefaultMaxArrayLength = 16384; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlAsyncCheckReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlAsyncCheckReader.cs index fca2ca2748b98..24038b5495d55 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlAsyncCheckReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlAsyncCheckReader.cs @@ -11,7 +11,7 @@ namespace System.Xml { internal class XmlAsyncCheckReader : XmlReader { - private readonly XmlReader _coreReader = null; + private readonly XmlReader _coreReader; private Task _lastTask = Task.CompletedTask; internal XmlReader CoreReader diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlAsyncCheckWriter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlAsyncCheckWriter.cs index 78dc6ac0bde4e..1304581aff510 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlAsyncCheckWriter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlAsyncCheckWriter.cs @@ -9,7 +9,7 @@ namespace System.Xml { internal class XmlAsyncCheckWriter : XmlWriter { - private readonly XmlWriter _coreWriter = null; + private readonly XmlWriter _coreWriter; private Task _lastTask = Task.CompletedTask; internal XmlWriter CoreWriter diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlParserContext.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlParserContext.cs index 252d39c678fb2..90df6e7d8d711 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlParserContext.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlParserContext.cs @@ -13,8 +13,8 @@ namespace System.Xml // Specifies the context that the XmLReader will use for xml fragment public class XmlParserContext { - private XmlNameTable? _nt = null; - private XmlNamespaceManager? _nsMgr = null; + private XmlNameTable? _nt; + private XmlNamespaceManager? _nsMgr; private string _docTypeName = string.Empty; private string _pubId = string.Empty; private string _sysId = string.Empty; @@ -22,7 +22,7 @@ public class XmlParserContext private string _xmlLang = string.Empty; private XmlSpace _xmlSpace; private string _baseURI = string.Empty; - private Encoding? _encoding = null; + private Encoding? _encoding; public XmlParserContext(XmlNameTable? nt, XmlNamespaceManager? nsMgr, string? xmlLang, XmlSpace xmlSpace) : this(nt, nsMgr, null, null, null, null, string.Empty, xmlLang, xmlSpace) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs index 67d70187bd0a8..6006ac4dfd331 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs @@ -27,7 +27,7 @@ public sealed class XmlReaderSettings private XmlNameTable? _nameTable; // XmlResolver - private XmlResolver? _xmlResolver = null; + private XmlResolver? _xmlResolver; // Text settings private int _lineNumberOffset; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs index 9eef834bfad45..3957d7c39222d 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs @@ -119,7 +119,7 @@ private enum IncrementalReadState //the purpose is to make the Create of XmlReader do not block on IO. private class LaterInitParam { - public bool useAsync = false; + public bool useAsync; public Stream? inputStream; public byte[]? inputBytes; @@ -133,7 +133,7 @@ private class LaterInitParam public InitInputType initType = InitInputType.Invalid; } - private LaterInitParam? _laterInitParam = null; + private LaterInitParam? _laterInitParam; private enum InitInputType { @@ -163,7 +163,7 @@ private enum InitInputType private NodeData _curNode; // current index - private int _index = 0; + private int _index; // attributes info private int _curAttrIndex = -1; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs index 132f7daaf693f..3bbde85b2b4b3 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs @@ -86,7 +86,7 @@ private enum ValidatingReaderState private ArrayList _defaultAttributes; // Inline Schema - private Parser? _inlineSchemaParser = null; + private Parser? _inlineSchemaParser; // Typed Value & PSVI private object? _atomicValue; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlElementList.cs b/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlElementList.cs index bcb4dbabd8fdc..3711eee8c3b7a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlElementList.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlElementList.cs @@ -349,7 +349,7 @@ internal class XmlElementListListener { private WeakReference _elemList; private readonly XmlDocument _doc; - private readonly XmlNodeChangedEventHandler _nodeChangeHandler = null; + private readonly XmlNodeChangedEventHandler _nodeChangeHandler; internal XmlElementListListener(XmlDocument doc, XmlElementList elemList) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlUnspecifiedAttribute.cs b/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlUnspecifiedAttribute.cs index d57bc6e142b07..4534c2f87250e 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlUnspecifiedAttribute.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlUnspecifiedAttribute.cs @@ -6,7 +6,7 @@ namespace System.Xml { internal class XmlUnspecifiedAttribute : XmlAttribute { - private bool _fSpecified = false; + private bool _fSpecified; protected internal XmlUnspecifiedAttribute(string prefix, string localName, string namespaceURI, XmlDocument doc) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/BaseProcessor.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/BaseProcessor.cs index 0fa89f2c57063..d9e29056c3cf7 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/BaseProcessor.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/BaseProcessor.cs @@ -15,7 +15,7 @@ internal class BaseProcessor private SchemaNames? _schemaNames; private readonly ValidationEventHandler? _eventHandler; private readonly XmlSchemaCompilationSettings? _compilationSettings; - private int _errorCount = 0; + private int _errorCount; private readonly string _nsXml; public BaseProcessor(XmlNameTable nameTable, SchemaNames? schemaNames, ValidationEventHandler? eventHandler) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/ConstraintStruct.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/ConstraintStruct.cs index 22afbcc04cff8..17c67e137cd3d 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/ConstraintStruct.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/ConstraintStruct.cs @@ -81,7 +81,7 @@ internal class SelectorActiveAxis : ActiveAxis { private readonly ConstraintStruct _cs; // pointer of constraintstruct, to enable 6 private readonly ArrayList _KSs; // stack of KSStruct, will not become less - private int _KSpointer = 0; // indicate current stack top (next available element); + private int _KSpointer; // indicate current stack top (next available element); public int lastDepth { @@ -163,7 +163,7 @@ internal class TypedObject { private class DecimalStruct { - private bool _isDecimal = false; // rare case it will be used... + private bool _isDecimal; // rare case it will be used... private readonly decimal[] _dvalue; // to accelerate equals operation. array <-> list public bool IsDecimal @@ -188,12 +188,12 @@ public DecimalStruct(int dim) } } - private DecimalStruct? _dstruct = null; + private DecimalStruct? _dstruct; private object? _ovalue; private readonly string _svalue; // only for output private XmlSchemaDatatype _xsdtype; private readonly int _dim = 1; - private readonly bool _isList = false; + private readonly bool _isList; public int Dim { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs index c3bac37e8739e..be96713faadbd 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/ContentValidator.cs @@ -40,11 +40,11 @@ public UpaException(object? particle1, object? particle2) /// internal class SymbolsDictionary { - private int _last = 0; + private int _last; private readonly Hashtable _names; - private Hashtable? _wildcards = null; + private Hashtable? _wildcards; private readonly ArrayList _particles; - private object? _particleLast = null; + private object? _particleLast; private bool _isUpaEnforced = true; public SymbolsDictionary() @@ -2159,7 +2159,7 @@ internal sealed class AllElementsContentValidator : ContentValidator private readonly Hashtable _elements; // unique terminal names to positions in Bitset mapping private readonly object[] _particles; private readonly BitSet _isRequired; // required flags - private int _countRequired = 0; + private int _countRequired; public AllElementsContentValidator(XmlSchemaContentType contentType, int size, bool isEmptiable) : base(contentType, false, isEmptiable) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/DataTypeImplementation.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/DataTypeImplementation.cs index 8d400f2d508f6..e8b3bc5f12059 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/DataTypeImplementation.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/DataTypeImplementation.cs @@ -91,15 +91,15 @@ internal class RestrictionFacets internal object? MinExclusive; internal int TotalDigits; internal int FractionDigits; - internal RestrictionFlags Flags = 0; - internal RestrictionFlags FixedFlags = 0; + internal RestrictionFlags Flags; + internal RestrictionFlags FixedFlags; } internal abstract class DatatypeImplementation : XmlSchemaDatatype { private XmlSchemaDatatypeVariety _variety = XmlSchemaDatatypeVariety.Atomic; - private RestrictionFacets? _restriction = null; - private DatatypeImplementation? _baseType = null; + private RestrictionFacets? _restriction; + private DatatypeImplementation? _baseType; private XmlValueConverter? _valueConverter; private XmlSchemaType? _parentSchemaType; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/DtdParser.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/DtdParser.cs index 42d4d7caec9f6..b218c2701363b 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/DtdParser.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/DtdParser.cs @@ -155,9 +155,9 @@ internal UndeclaredNotation(string name, int lineNo, int linePos) // flags private bool _normalize = true; - private bool _validate = false; + private bool _validate; private bool _supportNamespaces = true; - private bool _v1Compat = false; + private bool _v1Compat; // cached character buffer private char[] _chars = null!; @@ -179,26 +179,26 @@ internal UndeclaredNotation(string name, int lineNo, int linePos) private int _colonPos; // value of the internal subset - private StringBuilder? _internalSubsetValueSb = null; + private StringBuilder? _internalSubsetValueSb; // entities - private int _externalEntitiesDepth = 0; - private int _currentEntityId = 0; + private int _externalEntitiesDepth; + private int _currentEntityId; // free-floating DTD support - private bool _freeFloatingDtd = false; - private bool _hasFreeFloatingInternalSubset = false; + private bool _freeFloatingDtd; + private bool _hasFreeFloatingInternalSubset; // misc private StringBuilder _stringBuilder = null!; - private int _condSectionDepth = 0; + private int _condSectionDepth; private LineInfo _literalLineInfo = new LineInfo(0, 0); private char _literalQuoteChar = '"'; private string _documentBaseUri = string.Empty; private string _externalDtdBaseUri = string.Empty; - private Dictionary? _undeclaredNotations = null; - private int[]? _condSectionEntityIds = null; + private Dictionary? _undeclaredNotations; + private int[]? _condSectionEntityIds; private const int CondSectionEntityIdsInitialSize = 2; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs index 44b9b79782f81..d55d57500e035 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs @@ -103,7 +103,7 @@ public sealed class XmlSchemaInference internal const int TF_gYearMonth = 1 << HC_ST_gYearMonth; internal const int TF_string = 1 << HC_ST_string; - private XmlSchema? _rootSchema = null; //(XmlSchema) xsc[TargetNamespace]; + private XmlSchema? _rootSchema; //(XmlSchema) xsc[TargetNamespace]; private XmlSchemaSet? _schemaSet; private XmlReader? _xtr; private readonly NameTable _nametable; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/NamespaceList.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/NamespaceList.cs index 6416e9e765fac..d048fd19e9ac3 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/NamespaceList.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/NamespaceList.cs @@ -19,7 +19,7 @@ public enum ListType }; private ListType _type = ListType.Any; - private Hashtable? _set = null; + private Hashtable? _set; private readonly string? _targetNamespace; public NamespaceList() diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Parser.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Parser.cs index 9d5c9984ef3c9..703978a52fd30 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Parser.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Parser.cs @@ -23,12 +23,12 @@ internal sealed partial class Parser private XmlReader? _reader; private PositionInfo? _positionInfo; private bool _isProcessNamespaces; - private int _schemaXmlDepth = 0; + private int _schemaXmlDepth; private int _markupDepth; private SchemaBuilder? _builder; private XmlSchema? _schema; private SchemaInfo? _xdrSchema; - private XmlResolver? _xmlResolver = null; //to be used only by XDRBuilder + private XmlResolver? _xmlResolver; //to be used only by XDRBuilder //xs:Annotation perf fix private readonly XmlDocument _dummyDocument; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Preprocessor.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Preprocessor.cs index 0f598f945299d..ae4d3677226d8 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/Preprocessor.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/Preprocessor.cs @@ -59,7 +59,7 @@ internal sealed class Preprocessor : BaseProcessor private XmlReaderSettings? _readerSettings; // For redefines - private XmlSchema? _rootSchemaForRedefine = null; + private XmlSchema? _rootSchemaForRedefine; private ArrayList? _redefinedList; private static XmlSchema? s_builtInSchemaForXmlNS; @@ -72,7 +72,7 @@ internal sealed class Preprocessor : BaseProcessor private const XmlSchemaDerivationMethod complexTypeBlockAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; private const XmlSchemaDerivationMethod complexTypeFinalAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; - private XmlResolver? _xmlResolver = null; + private XmlResolver? _xmlResolver; public Preprocessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler? eventHandler) : this(nameTable, schemaNames, eventHandler, new XmlSchemaCompilationSettings()) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionpreProcessor.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionpreProcessor.cs index e6b04b156f454..d195a38369169 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionpreProcessor.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionpreProcessor.cs @@ -23,7 +23,7 @@ private enum Compositor private XmlSchema? _schema; private string? _targetNamespace; - private bool _buildinIncluded = false; + private bool _buildinIncluded; private XmlSchemaForm _elementFormDefault; private XmlSchemaForm _attributeFormDefault; private XmlSchemaDerivationMethod _blockDefault; @@ -41,7 +41,7 @@ private enum Compositor private const XmlSchemaDerivationMethod complexTypeBlockAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; private const XmlSchemaDerivationMethod complexTypeFinalAllowed = XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.Extension; - private XmlResolver? _xmlResolver = null; + private XmlResolver? _xmlResolver; public SchemaCollectionPreprocessor(XmlNameTable nameTable, SchemaNames? schemaNames, ValidationEventHandler? eventHandler) : base(nameTable, schemaNames, eventHandler) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaDeclBase.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaDeclBase.cs index 5edbb75227901..c368a9815e3b9 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaDeclBase.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaDeclBase.cs @@ -22,7 +22,7 @@ internal enum Use protected XmlQualifiedName name = XmlQualifiedName.Empty; protected string? prefix; - protected bool isDeclaredInExternal = false; + protected bool isDeclaredInExternal; protected Use presence; // the presence, such as fixed, implied, etc protected XmlSchemaType? schemaType; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaElementDecl.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaElementDecl.cs index 1812730c9ce65..b7636abce4cac 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaElementDecl.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaElementDecl.cs @@ -15,11 +15,11 @@ internal sealed class SchemaElementDecl : SchemaDeclBase, IDtdAttributeListInfo private readonly Dictionary _attdefs = new Dictionary(); private List? _defaultAttdefs; private bool _isIdDeclared; - private bool _hasNonCDataAttribute = false; + private bool _hasNonCDataAttribute; - private bool _isAbstract = false; - private bool _isNillable = false; - private bool _hasRequiredAttribute = false; + private bool _isAbstract; + private bool _isNillable; + private bool _hasRequiredAttribute; private bool _isNotationDeclared; private readonly Dictionary _prohibitedAttributes = new Dictionary(); private ContentValidator? _contentValidator; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaInfo.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaInfo.cs index 893b158c0531d..5efe90ac4fbfe 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaInfo.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaInfo.cs @@ -34,8 +34,8 @@ internal class SchemaInfo : IDtdInfo private XmlQualifiedName _docTypeName = XmlQualifiedName.Empty; private string _internalDtdSubset = string.Empty; - private bool _hasNonCDataAttributes = false; - private bool _hasDefaultAttributes = false; + private bool _hasNonCDataAttributes; + private bool _hasDefaultAttributes; private readonly Dictionary _targetNamespaces = new Dictionary(); private readonly Dictionary _attributeDecls = new Dictionary(); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XdrBuilder.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XdrBuilder.cs index 0b7d0dd303609..ebc2ae77eb36c 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XdrBuilder.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XdrBuilder.cs @@ -393,7 +393,7 @@ internal XdrEntry(SchemaNames.Token n, private const string x_schema = "x-schema:"; - private XmlResolver? _xmlResolver = null; + private XmlResolver? _xmlResolver; internal XdrBuilder( XmlReader reader, diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XdrValidator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XdrValidator.cs index e675ddd398779..29b4372c3d70d 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XdrValidator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XdrValidator.cs @@ -21,10 +21,10 @@ internal sealed class XdrValidator : BaseValidator private Hashtable _attPresence; private XmlQualifiedName _name = XmlQualifiedName.Empty; private XmlNamespaceManager _nsManager; - private bool _isProcessContents = false; + private bool _isProcessContents; private Hashtable? _IDs; private IdRefNode? _idRefListHead; - private Parser? _inlineSchemaParser = null; + private Parser? _inlineSchemaParser; private const string x_schema = "x-schema:"; internal XdrValidator(BaseValidator validator) : base(validator) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchema.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchema.cs index b607b919389f1..549a6860df272 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchema.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchema.cs @@ -31,11 +31,11 @@ public class XmlSchema : XmlSchemaObject private XmlAttribute[]? _moreAttributes; // compiled info - private bool _isCompiled = false; - private bool _isCompiledBySet = false; - private bool _isPreprocessed = false; - private bool _isRedefined = false; - private int _errorCount = 0; + private bool _isCompiled; + private bool _isCompiledBySet; + private bool _isPreprocessed; + private bool _isRedefined; + private int _errorCount; private XmlSchemaObjectTable? _attributes; private XmlSchemaObjectTable _attributeGroups = new XmlSchemaObjectTable(); private XmlSchemaObjectTable _elements = new XmlSchemaObjectTable(); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaCollection.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaCollection.cs index c73c7ee6222c1..759636fda315a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaCollection.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaCollection.cs @@ -29,8 +29,8 @@ public sealed class XmlSchemaCollection : ICollection private SchemaNames? _schemaNames; private readonly object? _wLock; private readonly bool _isThreadSafe = true; - private ValidationEventHandler? _validationEventHandler = null; - private XmlResolver? _xmlResolver = null; + private ValidationEventHandler? _validationEventHandler; + private XmlResolver? _xmlResolver; /// diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaElement.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaElement.cs index 70dd7259e0d16..84a4bed5c3355 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaElement.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaElement.cs @@ -27,7 +27,7 @@ public class XmlSchemaElement : XmlSchemaParticle private XmlQualifiedName _refName = XmlQualifiedName.Empty; private XmlQualifiedName _substitutionGroup = XmlQualifiedName.Empty; private XmlQualifiedName _typeName = XmlQualifiedName.Empty; - private XmlSchemaType? _type = null; + private XmlSchemaType? _type; private XmlQualifiedName _qualifiedName = XmlQualifiedName.Empty; private XmlSchemaType? _elementType; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaIdEntityConstraint.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaIdEntityConstraint.cs index fc455c852513a..f63b40f7fd0ac 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaIdEntityConstraint.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaIdEntityConstraint.cs @@ -15,7 +15,7 @@ public class XmlSchemaIdentityConstraint : XmlSchemaAnnotated private XmlSchemaXPath? _selector; private readonly XmlSchemaObjectCollection _fields = new XmlSchemaObjectCollection(); private XmlQualifiedName _qualifiedName = XmlQualifiedName.Empty; - private CompiledIdentityConstraint? _compiledConstraint = null; + private CompiledIdentityConstraint? _compiledConstraint; [XmlAttribute("name")] public string? Name diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaObject.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaObject.cs index 47146fd7071a0..274bad57d06d5 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaObject.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaObject.cs @@ -10,8 +10,8 @@ namespace System.Xml.Schema public abstract class XmlSchemaObject { - private int _lineNum = 0; - private int _linePos = 0; + private int _lineNum; + private int _linePos; private string? _sourceUri; private XmlSerializerNamespaces? _namespaces; private XmlSchemaObject? _parent; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaSet.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaSet.cs index 8a92e01ac1b65..5a7095a2a6c37 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaSet.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaSet.cs @@ -31,7 +31,7 @@ public class XmlSchemaSet private readonly ValidationEventHandler _internalEventHandler; private ValidationEventHandler? _eventHandler; - private bool _isCompiled = false; + private bool _isCompiled; //Dictionary schemaLocations; //Dictionary chameleonSchemas; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdValidator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdValidator.cs index 8201aee039436..a7d37f99375d3 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdValidator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdValidator.cs @@ -24,10 +24,10 @@ internal sealed class XsdValidator : BaseValidator private Hashtable _attPresence; private XmlNamespaceManager _nsManager; - private bool _bManageNamespaces = false; + private bool _bManageNamespaces; private Hashtable? _IDs; private IdRefNode? _idRefListHead; - private Parser? _inlineSchemaParser = null; + private Parser? _inlineSchemaParser; private XmlSchemaContentProcessing _processContents; private static readonly XmlSchemaDatatype s_dtCDATA = XmlSchemaDatatype.FromXmlTokenizedType(XmlTokenizedType.CDATA)!; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs index 4e2649aa3585b..e48b89037b6fd 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs @@ -17,8 +17,8 @@ namespace System.Xml.Serialization internal class TempAssembly { internal const string GeneratedAssemblyNamespace = "Microsoft.Xml.Serialization.GeneratedAssembly"; - private readonly Assembly _assembly = null; - private XmlSerializerImplementation _contract = null; + private readonly Assembly _assembly; + private XmlSerializerImplementation _contract; private IDictionary _writerMethods; private IDictionary _readerMethods; private TempMethodDictionary _methods; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs index 4ed0e5e5e7215..7a83e9010ee9a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Mappings.cs @@ -20,7 +20,7 @@ namespace System.Xml.Serialization internal abstract class Accessor { private string _name; - private object _defaultValue = null; + private object _defaultValue; private string _ns; private TypeMapping _mapping; private bool _any; @@ -139,7 +139,7 @@ internal class ElementAccessor : Accessor { private bool _nullable; private bool _isSoap; - private bool _unbounded = false; + private bool _unbounded; internal bool IsSoap { @@ -283,7 +283,7 @@ internal abstract class TypeMapping : Mapping private bool _referencedByElement; private bool _referencedByTopLevelElement; private bool _includeInSchema = true; - private bool _reference = false; + private bool _reference; internal bool ReferencedByTopLevelElement { @@ -461,7 +461,7 @@ internal class StructMapping : TypeMapping, INameScope private StructMapping _baseMapping; private StructMapping _derivedMappings; private StructMapping _nextDerivedMapping; - private MemberMapping _xmlnsMember = null; + private MemberMapping _xmlnsMember; private bool _hasSimpleContent; private bool _openModel; private bool _isSequence; @@ -909,7 +909,7 @@ internal class MemberMapping : AccessorMapping private bool _checkShouldPersist; private SpecifiedAccessor _checkSpecified; private bool _isReturnValue; - private bool _readOnly = false; + private bool _readOnly; private int _sequenceId = -1; private MemberInfo _memberInfo; private MemberInfo _checkSpecifiedMemberInfo; @@ -1014,7 +1014,7 @@ internal class MembersMapping : TypeMapping private bool _hasWrapperElement = true; private bool _validateRpcWrapperElement; private bool _writeAccessors = true; - private MemberMapping _xmlnsMember = null; + private MemberMapping _xmlnsMember; internal MemberMapping[] Members { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs index 6f80244d04866..5246457c8b288 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Models.cs @@ -255,8 +255,8 @@ internal class FieldModel private readonly MemberInfo _checkSpecifiedMemberInfo; private readonly MethodInfo _checkShouldPersistMethodInfo; private readonly bool _checkShouldPersist; - private readonly bool _readOnly = false; - private readonly bool _isProperty = false; + private readonly bool _readOnly; + private readonly bool _isProperty; private readonly Type _fieldType; private readonly string _name; private readonly TypeDesc _fieldTypeDesc; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs index b3c2ada848d3e..396bdaaf12352 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs @@ -2031,7 +2031,7 @@ internal class Member public MemberMapping Mapping; public CollectionMember Collection; public int FixupIndex = -1; - public bool MultiRef = false; + public bool MultiRef; public Action Source; public Func GetSource; public Action ArraySource; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SoapAttributes.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SoapAttributes.cs index 888e17e7ff6bc..9b7de9abfd234 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SoapAttributes.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/SoapAttributes.cs @@ -25,7 +25,7 @@ public class SoapAttributes private SoapElementAttribute _soapElement; private SoapAttributeAttribute _soapAttribute; private SoapEnumAttribute _soapEnum; - private object _soapDefaultValue = null; + private object _soapDefaultValue; public SoapAttributes() { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAnyElementAttribute.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAnyElementAttribute.cs index 6d72d2b16dc60..f4b67cd075726 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAnyElementAttribute.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAnyElementAttribute.cs @@ -17,7 +17,7 @@ public class XmlAnyElementAttribute : System.Attribute private string _name; private string _ns; private int _order = -1; - private bool _nsSpecified = false; + private bool _nsSpecified; /// /// [To be supplied.] diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlArrayItemAttribute.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlArrayItemAttribute.cs index 76bd2bde586c1..ae5daa5b03b7b 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlArrayItemAttribute.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlArrayItemAttribute.cs @@ -19,7 +19,7 @@ public class XmlArrayItemAttribute : System.Attribute private string _ns; private string _dataType; private bool _nullable; - private bool _nullableSpecified = false; + private bool _nullableSpecified; private XmlSchemaForm _form = XmlSchemaForm.None; private int _nestingLevel; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAttributes.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAttributes.cs index e1ea808aa7cc5..a1639f692e3d7 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAttributes.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlAttributes.cs @@ -42,7 +42,7 @@ public class XmlAttributes private XmlEnumAttribute _xmlEnum; private bool _xmlIgnore; private bool _xmlns; - private object _xmlDefaultValue = null; + private object _xmlDefaultValue; private XmlRootAttribute _xmlRoot; private XmlTypeAttribute _xmlType; private XmlAnyAttributeAttribute _xmlAnyAttribute; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlMapping.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlMapping.cs index 2c8ac6a0898dd..08449ecbf4330 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlMapping.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlMapping.cs @@ -26,11 +26,11 @@ public enum XmlMappingAccess public abstract class XmlMapping { private readonly TypeScope _scope; - private bool _generateSerializer = false; + private bool _generateSerializer; private bool _isSoap; private readonly ElementAccessor _accessor; private string _key; - private readonly bool _shallow = false; + private readonly bool _shallow; private readonly XmlMappingAccess _access; internal XmlMapping(TypeScope scope, ElementAccessor accessor) : this(scope, accessor, XmlMappingAccess.Read | XmlMappingAccess.Write) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemas.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemas.cs index 9e6fdb96e6293..734ba6ed0ac73 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemas.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemas.cs @@ -26,7 +26,7 @@ public class XmlSchemas : CollectionBase, IEnumerable private bool _shareTypes; private Hashtable _mergedSchemas; internal Hashtable delayedSchemas = new Hashtable(); - private bool _isCompiled = false; + private bool _isCompiled; private static volatile XmlSchema s_xsd; private static volatile XmlSchema s_xml; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationGeneratedCode.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationGeneratedCode.cs index 2df87b99ff28e..0811f03600b7f 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationGeneratedCode.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationGeneratedCode.cs @@ -28,16 +28,16 @@ internal void Dispose() internal class XmlSerializationCodeGen { private readonly IndentedWriter _writer; - private int _nextMethodNumber = 0; + private int _nextMethodNumber; private readonly Hashtable _methodNames = new Hashtable(); private readonly ReflectionAwareCodeGen _raCodeGen; private readonly TypeScope[] _scopes; - private readonly TypeDesc _stringTypeDesc = null; - private readonly TypeDesc _qnameTypeDesc = null; + private readonly TypeDesc _stringTypeDesc; + private readonly TypeDesc _qnameTypeDesc; private readonly string _access; private readonly string _className; private TypeMapping[] _referencedMethods; - private int _references = 0; + private int _references; private readonly Hashtable _generatedMethods = new Hashtable(); internal XmlSerializationCodeGen(IndentedWriter writer, TypeScope[] scopes, string access, string className) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationILGen.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationILGen.cs index a43228f40ea95..4dc4fc14a801a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationILGen.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationILGen.cs @@ -14,7 +14,7 @@ namespace System.Xml.Serialization internal class XmlSerializationILGen { - private int _nextMethodNumber = 0; + private int _nextMethodNumber; private readonly Dictionary _methodNames = new Dictionary(); // Lookup name->created Method private readonly Dictionary _methodBuilders = new Dictionary(); @@ -24,11 +24,11 @@ internal class XmlSerializationILGen internal Dictionary memberInfos = new Dictionary(); private readonly ReflectionAwareILGen _raCodeGen; private readonly TypeScope[] _scopes; - private readonly TypeDesc _stringTypeDesc = null; - private readonly TypeDesc _qnameTypeDesc = null; + private readonly TypeDesc _stringTypeDesc; + private readonly TypeDesc _qnameTypeDesc; private readonly string _className; private TypeMapping[] _referencedMethods; - private int _references = 0; + private int _references; private readonly HashSet _generatedMethods = new HashSet(); private ModuleBuilder _moduleBuilder; private readonly TypeAttributes _typeAttributes; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs index 1b80225df360f..0cb982b716e09 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs @@ -2028,8 +2028,8 @@ internal class XmlSerializationReaderCodeGen : XmlSerializationCodeGen private readonly Hashtable _idNames = new Hashtable(); private Hashtable _enums; private readonly Hashtable _createMethods = new Hashtable(); - private int _nextCreateMethodNumber = 0; - private int _nextIdNumber = 0; + private int _nextCreateMethodNumber; + private int _nextIdNumber; internal Hashtable Enums { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs index e079b8ca4bc9f..9f70295400341 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReaderILGen.cs @@ -24,7 +24,7 @@ internal class XmlSerializationReaderILGen : XmlSerializationILGen // Mapping name->id_XXXNN field private readonly Dictionary _idNameFields = new Dictionary(); private Dictionary _enums; - private int _nextIdNumber = 0; + private int _nextIdNumber; internal Dictionary Enums { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs index 6066e533a0724..41a256b894e13 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs @@ -1544,8 +1544,8 @@ internal class ReflectionAwareCodeGen // ArrayAccessor "0:"+CodeIdentifier.EscapedKeywords(typeof(Array).FullName) // MyCollectionAccessor "0:"+CodeIdentifier.EscapedKeywords(typeof(MyCollection).FullName) // ---------------------------------------------------------------------------------- - private Hashtable _reflectionVariables = null; - private int _nextReflectionVariableNumber = 0; + private Hashtable _reflectionVariables; + private int _nextReflectionVariableNumber; private readonly IndentedWriter _writer; internal ReflectionAwareCodeGen(IndentedWriter writer) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs index b68eaa48570ae..7a1f8ab28ff7f 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs @@ -126,9 +126,9 @@ private static bool ReflectionMethodEnabled private readonly Type _primitiveType; private XmlMapping _mapping; private XmlDeserializationEvents _events; - internal string DefaultNamespace = null; + internal string DefaultNamespace; private Type _rootType; - private bool _isReflectionBasedSerializer = false; + private bool _isReflectionBasedSerializer; private static readonly TempAssemblyCache s_cache = new TempAssemblyCache(); private static volatile XmlSerializerNamespaces s_defaultNamespaces; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializerNamespaces.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializerNamespaces.cs index ebcf8c14bd23e..e4dd78494f00a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializerNamespaces.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializerNamespaces.cs @@ -18,7 +18,7 @@ namespace System.Xml.Serialization /// public class XmlSerializerNamespaces { - private Dictionary _namespaces = null; + private Dictionary _namespaces; /// /// [To be supplied.] diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/AttributeQuery.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/AttributeQuery.cs index f42855642e1fa..6dad28a8a9bc5 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/AttributeQuery.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/AttributeQuery.cs @@ -10,7 +10,7 @@ namespace MS.Internal.Xml.XPath { internal sealed class AttributeQuery : BaseAxisQuery { - private bool _onAttribute = false; + private bool _onAttribute; public AttributeQuery(Query qyParent, string Name, string Prefix, XPathNodeType Type) : base(qyParent, Name, Prefix, Type) { } private AttributeQuery(AttributeQuery other) : base(other) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/CacheChildrenQuery.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/CacheChildrenQuery.cs index 4c4415e947247..98151d2c94011 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/CacheChildrenQuery.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/CacheChildrenQuery.cs @@ -17,12 +17,12 @@ namespace MS.Internal.Xml.XPath // So we don't need to call DecideNextNode() when needInput == true && stack is empty. internal sealed class CacheChildrenQuery : ChildrenQuery { - private XPathNavigator _nextInput = null; + private XPathNavigator _nextInput; private readonly StackNav _elementStk; private readonly StackInt _positionStk; private bool _needInput; #if DEBUG - private XPathNavigator _lastNode = null; + private XPathNavigator _lastNode; #endif public CacheChildrenQuery(Query qyInput, string name, string prefix, XPathNodeType type) : base(qyInput, name, prefix, type) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/DescendantoverDescendantQuery.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/DescendantoverDescendantQuery.cs index 2a094c1f7ce21..93934a5c0d189 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/DescendantoverDescendantQuery.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/DescendantoverDescendantQuery.cs @@ -13,7 +13,7 @@ namespace MS.Internal.Xml.XPath // It doesn't generate DOD of the output even when input is DOD. internal sealed class DescendantOverDescendantQuery : DescendantBaseQuery { - private int _level = 0; + private int _level; public DescendantOverDescendantQuery(Query qyParent, bool matchSelf, string name, string prefix, XPathNodeType typeTest, bool abbrAxis) : base(qyParent, name, prefix, typeTest, matchSelf, abbrAxis) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/Function.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/Function.cs index e832436b3a9e0..5de3ab21fef86 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/Function.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/Function.cs @@ -44,8 +44,8 @@ public enum FunctionType private readonly FunctionType _functionType; private readonly List _argumentList; - private readonly string _name = null; - private readonly string _prefix = null; + private readonly string _name; + private readonly string _prefix; public Function(FunctionType ftype, List argumentList) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/IteratorFilter.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/IteratorFilter.cs index 783e75e2fef51..22b9c5c69b31b 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/IteratorFilter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/IteratorFilter.cs @@ -10,7 +10,7 @@ internal class IteratorFilter : XPathNodeIterator { private readonly XPathNodeIterator _innerIterator; private readonly string _name; - private int _position = 0; + private int _position; internal IteratorFilter(XPathNodeIterator innerIterator, string name) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/NodeFunctions.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/NodeFunctions.cs index a0960108bbdf8..ef511d7e1770c 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/NodeFunctions.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/NodeFunctions.cs @@ -11,7 +11,7 @@ namespace MS.Internal.Xml.XPath { internal sealed class NodeFunctions : ValueQuery { - private readonly Query _arg = null; + private readonly Query _arg; private readonly FT _funcType; private XsltContext _xsltContext; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/NumberFunctions.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/NumberFunctions.cs index 35384690ad4a9..f9b45a043a803 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/NumberFunctions.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/NumberFunctions.cs @@ -12,7 +12,7 @@ namespace MS.Internal.Xml.XPath { internal sealed class NumberFunctions : ValueQuery { - private readonly Query _arg = null; + private readonly Query _arg; private readonly FT _ftype; public NumberFunctions(FT ftype, Query arg) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/QueryBuilder.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/QueryBuilder.cs index 112789c8f1560..9f51e1981adf8 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/QueryBuilder.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/QueryBuilder.cs @@ -452,7 +452,7 @@ private List ProcessArguments(List args, out Props props) return argList; } - private int _parseDepth = 0; + private int _parseDepth; private const int MaxParseDepth = 1024; private Query ProcessNode(AstNode root, Flags flags, out Props props) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/XPathDescendantIterator.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/XPathDescendantIterator.cs index c139ac7f3e4ef..b13d34702ab76 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/XPathDescendantIterator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/XPathDescendantIterator.cs @@ -8,7 +8,7 @@ namespace MS.Internal.Xml.XPath { internal class XPathDescendantIterator : XPathAxisIterator { - private int _level = 0; + private int _level; public XPathDescendantIterator(XPathNavigator nav, XPathNodeType type, bool matchSelf) : base(nav, type, matchSelf) { } public XPathDescendantIterator(XPathNavigator nav, string name, string namespaceURI, bool matchSelf) : base(nav, name, namespaceURI, matchSelf) { } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/XPathParser.cs b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/XPathParser.cs index 23b47aa0b890d..20cd9fb5c3ab3 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/XPathParser.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XPath/Internal/XPathParser.cs @@ -49,7 +49,7 @@ public static AstNode ParseXPathPattern(string xpathPattern) //The recursive is like //ParseOrExpr->ParseAndExpr->ParseEqualityExpr->ParseRelationalExpr...->ParseFilterExpr->ParsePredicate->ParseExpression //So put 200 limitation here will max cause about 2000~3000 depth stack. - private int _parseDepth = 0; + private int _parseDepth; private const int MaxParseDepth = 200; private AstNode ParseExpression(AstNode qyInput) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XmlEncoding.cs b/src/libraries/System.Private.Xml/src/System/Xml/XmlEncoding.cs index 78fcdfc4f1e25..41f638ced9652 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XmlEncoding.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XmlEncoding.cs @@ -411,7 +411,7 @@ public override byte[] GetPreamble() internal abstract class Ucs4Decoder : Decoder { internal byte[] lastBytes = new byte[4]; - internal int lastBytesCount = 0; + internal int lastBytesCount; public override int GetCharCount(byte[] bytes, int index, int count) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/XmlNamespacemanager.cs b/src/libraries/System.Private.Xml/src/System/Xml/XmlNamespacemanager.cs index 3f1ff9f282ada..fec070dcb0898 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/XmlNamespacemanager.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/XmlNamespacemanager.cs @@ -33,7 +33,7 @@ public void Set(string prefix, string uri, int scopeId, int previousNsIndex) private NamespaceDeclaration[]? _nsdecls; // index of last declaration - private int _lastDecl = 0; + private int _lastDecl; // name table private readonly XmlNameTable? _nameTable; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs index ab9890ee90ac4..3e34711a91682 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs @@ -1448,8 +1448,8 @@ public void DebugSequencePoint(ISourceLineInfo sourceInfo) MarkSequencePoint(sourceInfo); } - private string _lastUriString = null; - private string _lastFileName = null; + private string _lastUriString; + private string _lastFileName; // SQLBUDT 278010: debugger does not work with network paths in uri format, like file://server/share/dir/file private string GetFileName(ISourceLineInfo sourceInfo) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlILTrace.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlILTrace.cs index 604c8683c50ca..02652aa589f8b 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlILTrace.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlILTrace.cs @@ -25,8 +25,8 @@ internal static class XmlILTrace /// Check environment variable in order to determine whether to write out trace files. This really should be a /// check of the configuration file, but System.Xml does not yet have a good tracing story. /// - private static volatile string s_dirName = null; - private static volatile bool s_alreadyCheckedEnabled = false; + private static volatile string s_dirName; + private static volatile bool s_alreadyCheckedEnabled; /// /// True if tracing has been enabled (environment variable set). diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPath/XPathParser.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPath/XPathParser.cs index ccac27ece55b3..f93f5ccdc6ce2 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPath/XPathParser.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPath/XPathParser.cs @@ -115,7 +115,7 @@ private Node ParseLocationPath() */ //Max depth to avoid StackOverflow private const int MaxParseRelativePathDepth = 1024; - private int _parseRelativePath = 0; + private int _parseRelativePath; private Node ParseRelativeLocationPath() { if (++_parseRelativePath > MaxParseRelativePathDepth) @@ -343,7 +343,7 @@ private Node ParseExpr() //limit the recursive call from ParseSubExpr -> ParseSubExpr //and also ParseSubExpr->ParseUnionExpr->ParsePathExpr->...->ParseExpr->ParseSubExpr private const int MaxParseSubExprDepth = 1024; - private int _parseSubExprDepth = 0; + private int _parseSubExprDepth; private Node ParseSubExpr(int callerPrec) { if (++_parseSubExprDepth > MaxParseSubExprDepth) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Compiler.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Compiler.cs index e1ecc51d21e08..4d44d9eb050c4 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Compiler.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Compiler.cs @@ -47,7 +47,7 @@ internal class Compiler public string inputTypeAnnotations; // null - "unspecified"; "preserve"; "strip" public CompilerErrorCollection CompilerErrorColl; // Results of the compilation - public int CurrentPrecedence = 0; // Decreases by 1 with each import + public int CurrentPrecedence; // Decreases by 1 with each import public XslNode StartApplyTemplates; public RootLevel Root; public Scripts Scripts; @@ -255,7 +255,7 @@ public void ValidatePiName(string name, IErrorHelper errorHelper) } public readonly string PhantomNCName = "error"; - private int _phantomNsCounter = 0; + private int _phantomNsCounter; public string CreatePhantomNamespace() { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs index 208a8cef99c2a..3ddfe8d7f406f 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/CompilerScopeManager.cs @@ -51,7 +51,7 @@ public struct ScopeRecord // This is cache of records[lastRecord].scopeCount field; // most often we will have PushScope()/PopScope pare over the same record. // It has sence to avoid adresing this field through array access. - private int _lastScopes = 0; + private int _lastScopes; public CompilerScopeManager() { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/KeyMatchBuilder.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/KeyMatchBuilder.cs index a6841368186cc..72451622ad9c0 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/KeyMatchBuilder.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/KeyMatchBuilder.cs @@ -16,7 +16,7 @@ namespace System.Xml.Xsl.Xslt { internal class KeyMatchBuilder : XPathBuilder, XPathPatternParser.IPatternBuilder { - private int _depth = 0; + private int _depth; private readonly PathConvertor _convertor; public KeyMatchBuilder(IXPathEnvironment env) : base(env) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/OutputScopeManager.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/OutputScopeManager.cs index 97138a4035cfd..38856ca79be28 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/OutputScopeManager.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/OutputScopeManager.cs @@ -18,10 +18,10 @@ public struct ScopeReord public string nsUri; } private ScopeReord[] _records = new ScopeReord[32]; - private int _lastRecord = 0; - private int _lastScopes = 0; // This is cash of records[lastRecord].scopeCount field; - // most often we will have PushScope()/PopScope pare over the same record. - // It has sence to avoid adresing this field through array access. + private int _lastRecord; + private int _lastScopes; // Cache of records[lastRecord].scopeCount field; + // most often we will have PushScope()/PopScope over the same record. + // It makes sense to avoid accessing this field through the array. public OutputScopeManager() { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilStrConcatenator.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilStrConcatenator.cs index 141d11f79ebfe..83b561aaf2c9a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilStrConcatenator.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/QilStrConcatenator.cs @@ -16,7 +16,7 @@ internal class QilStrConcatenator private readonly XPathQilFactory _f; private readonly StringBuilder _builder; private QilList _concat; - private bool _inUse = false; + private bool _inUse; public QilStrConcatenator(XPathQilFactory f) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Stylesheet.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Stylesheet.cs index bc6f226f826f4..e693013407dd4 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Stylesheet.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/Stylesheet.cs @@ -10,7 +10,7 @@ namespace System.Xml.Xsl.Xslt { internal class StylesheetLevel { - public Stylesheet[] Imports = null; + public Stylesheet[] Imports; // If (this is Stylesheet) { // ModeFlags and ApplyFunctions are abblout apply-imports @@ -33,7 +33,7 @@ internal class Stylesheet : StylesheetLevel public Dictionary AttributeSets = new Dictionary(); private readonly int _importPrecedence; - private int _orderNumber = 0; + private int _orderNumber; /* WhitespaceRules[0] - rules with default priority 0 diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XPathPatternParser.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XPathPatternParser.cs index c4072f92572ce..2e7cc37e1ec4a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XPathPatternParser.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XPathPatternParser.cs @@ -159,7 +159,7 @@ private QilNode ParseIdKeyPattern() */ //Max depth to avoid StackOverflow private const int MaxParseRelativePathDepth = 1024; - private int _parseRelativePath = 0; + private int _parseRelativePath; private QilNode ParseRelativePathPattern() { if (++_parseRelativePath > MaxParseRelativePathDepth) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XslAstAnalyzer.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XslAstAnalyzer.cs index 29573ca87d5ea..6ca1b3adccc82 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XslAstAnalyzer.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XslAstAnalyzer.cs @@ -26,7 +26,7 @@ internal class XslAstAnalyzer : XslVisitor // List of all variables and parameters private readonly List _allVarPars = new List(); #endif - private int _forEachDepth = 0; + private int _forEachDepth; private XPathAnalyzer _xpathAnalyzer; private ProtoTemplate _currentTemplate; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltInput.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltInput.cs index 182e7be8af25d..ba8e786017063 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltInput.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltInput.cs @@ -700,7 +700,7 @@ public XsltAttribute(string name, int flags) } } - private XsltAttribute[] _attributes = null; + private XsltAttribute[] _attributes; // Mapping of attribute names as they ordered in 'attributes' array // to there's numbers in actual stylesheet as they ordered in 'records' array private readonly int[] _xsltAttributeNumber = new int[21]; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs index 4aace377cf04f..a1fe391335375 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XsltLoader.cs @@ -1354,7 +1354,7 @@ private List LoadInstructions(List content) } private const int MAX_LOADINSTRUCTIONS_DEPTH = 1024; - private int _loadInstructionsDepth = 0; + private int _loadInstructionsDepth; private List LoadInstructions(List content, InstructionFlags flags) { if (++_loadInstructionsDepth > MAX_LOADINSTRUCTIONS_DEPTH) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/BuilderInfo.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/BuilderInfo.cs index 7514e655c67cb..e9217b472b668 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/BuilderInfo.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/BuilderInfo.cs @@ -23,7 +23,7 @@ internal class BuilderInfo private bool _isEmptyTag; internal string[] TextInfo = new string[4]; - internal int TextInfoCount = 0; + internal int TextInfoCount; internal bool search; internal HtmlElementProps htmlProps; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Compiler.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Compiler.cs index 827de039f471f..333bb78eb44c0 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Compiler.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Compiler.cs @@ -89,7 +89,7 @@ internal class Compiler private RootAction _rootAction; private List _queryStore; private readonly QueryBuilder _queryBuilder = new QueryBuilder(); - private int _rtfCount = 0; + private int _rtfCount; // Used to load Built In templates public bool AllowBuiltInMode; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ContainerAction.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ContainerAction.cs index d6f00797d80a7..cf57902cdb7ed 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ContainerAction.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ContainerAction.cs @@ -34,7 +34,7 @@ internal class ContainerAction : CompiledAction internal ArrayList containedActions; internal CopyCodeAction lastCopyCodeAction; // non null if last action is CopyCodeAction; - private int _maxid = 0; + private int _maxid; // Local execution states protected const int ProcessingChildren = 1; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Processor.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Processor.cs index eebbf46772380..690cafce45925 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Processor.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/Processor.cs @@ -268,7 +268,7 @@ internal XPathNavigator Document } #if DEBUG - private bool _stringBuilderLocked = false; + private bool _stringBuilderLocked; #endif internal StringBuilder GetSharedStringBuilder() diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ReaderOutput.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ReaderOutput.cs index 82fe695fd3b10..f3d60e96ef9f8 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ReaderOutput.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ReaderOutput.cs @@ -695,8 +695,8 @@ private void CheckCurrentInfo() private class XmlEncoder { - private StringBuilder _buffer = null; - private XmlTextEncoder _encoder = null; + private StringBuilder _buffer; + private XmlTextEncoder _encoder; private void Init() { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XslCompiledTransform.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XslCompiledTransform.cs index c67af0d72dcb4..392bbbd53134a 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XslCompiledTransform.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XslCompiledTransform.cs @@ -51,16 +51,16 @@ public sealed class XslCompiledTransform #endif // Options of compilation - private readonly bool _enableDebug = false; + private readonly bool _enableDebug; // Results of compilation - private CompilerErrorCollection _compilerErrorColl = null; - private XmlWriterSettings _outputSettings = null; - private QilExpression _qil = null; + private CompilerErrorCollection _compilerErrorColl; + private XmlWriterSettings _outputSettings; + private QilExpression _qil; #if FEATURE_COMPILED_XSL // Executable command for the compiled stylesheet - private XmlILCommand _command = null; + private XmlILCommand _command; #endif public XslCompiledTransform() { } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XslTransform.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XslTransform.cs index f690f776d2d7c..14575968b44e1 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XslTransform.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XslTransform.cs @@ -13,8 +13,8 @@ namespace System.Xml.Xsl public sealed class XslTransform { - private XmlResolver _documentResolver = null; - private bool _isDocumentResolverSet = false; + private XmlResolver _documentResolver; + private bool _isDocumentResolverSet; private XmlResolver _DocumentResolver { get diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XsltArgumentList.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XsltArgumentList.cs index ceba6447a2f4d..d85469a859226 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XsltArgumentList.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xslt/XsltArgumentList.cs @@ -19,7 +19,7 @@ public class XsltArgumentList private readonly Hashtable _extensions = new Hashtable(); // Used for reporting xsl:message's during execution - internal XsltMessageEncounteredEventHandler xsltMessageEncountered = null; + internal XsltMessageEncounteredEventHandler xsltMessageEncountered; public XsltArgumentList() { } diff --git a/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs b/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs index 94bf847cee682..25208238d1b3a 100644 --- a/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs +++ b/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs @@ -189,7 +189,7 @@ private class ProxyAssembly { private readonly AssemblyBuilder _ab; private readonly ModuleBuilder _mb; - private int _typeId = 0; + private int _typeId; // Maintain a MethodBase-->int, int-->MethodBase mapping to permit generated code // to pass methods by token diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.cs index b2357f39a20e4..f19b2982bd2e4 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/FileStreamReadLightUp.cs @@ -12,7 +12,7 @@ internal static class FileStreamReadLightUp { // internal for testing internal static bool readFileNotAvailable = Path.DirectorySeparatorChar != '\\'; // Available on Windows only - internal static bool safeFileHandleNotAvailable = false; + internal static bool safeFileHandleNotAvailable; internal static bool IsFileStream(Stream stream) => stream is FileStream; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/MetadataLoadContext.CoreAssembly.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/MetadataLoadContext.CoreAssembly.cs index 9ced84e5a9e4b..99d3da539c15c 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/MetadataLoadContext.CoreAssembly.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/MetadataLoadContext.CoreAssembly.cs @@ -49,7 +49,7 @@ public sealed partial class MetadataLoadContext return null; } - private RoAssembly? _coreAssembly = null; + private RoAssembly? _coreAssembly; /// /// Returns a lazily created and cached Type instance corresponding to the indicated core type. This method throws diff --git a/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs b/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs index 972f20378b1b5..1fee38df30fcb 100644 --- a/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs +++ b/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/DeserializingResourceReader.cs @@ -12,8 +12,8 @@ namespace System.Resources.Extensions { public partial class DeserializingResourceReader { - private bool _assumeBinaryFormatter = false; - private BinaryFormatter? _formatter = null; + private bool _assumeBinaryFormatter; + private BinaryFormatter? _formatter; private bool ValidateReaderType(string readerType) { diff --git a/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/PreserializedResourceWriter.cs b/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/PreserializedResourceWriter.cs index c1017736d01d2..535842a9a1a07 100644 --- a/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/PreserializedResourceWriter.cs +++ b/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/PreserializedResourceWriter.cs @@ -16,7 +16,7 @@ public partial class PreserializedResourceWriter { // indicates if the types of resources saved will require the DeserializingResourceReader // in order to read them. - private bool _requiresDeserializingResourceReader = false; + private bool _requiresDeserializingResourceReader; // use hard-coded strings rather than typeof so that the version doesn't leak into resources files internal const string DeserializingResourceReaderFullyQualifiedName = "System.Resources.Extensions.DeserializingResourceReader, System.Resources.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"; diff --git a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryMonitor.cs b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryMonitor.cs index dea2a39b6a174..2b4df538a8904 100644 --- a/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryMonitor.cs +++ b/src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/MemoryMonitor.cs @@ -36,10 +36,10 @@ internal abstract partial class MemoryMonitor protected int[] _pressureHist; protected int _pressureTotal; -#pragma warning disable CA1802 // some builds initialize these to other values in a static cctor - private static readonly long s_totalPhysical = 0; - private static readonly long s_totalVirtual = 0; -#pragma warning restore CA1802 +#pragma warning disable CA1802, CS0649 // some builds initialize these to other values in a static cctor + private static readonly long s_totalPhysical; + private static readonly long s_totalVirtual; +#pragma warning restore CA1802, CS0649 internal static long TotalPhysical => s_totalPhysical; internal static long TotalVirtual => s_totalVirtual; diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Map.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Map.cs index 211c17a195e20..bc21965b9784f 100644 --- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Map.cs +++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Map.cs @@ -138,7 +138,7 @@ public void Reset() } #region IDisposable Support - private bool _disposedValue = false; // To detect redundant calls + private bool _disposedValue; // To detect redundant calls private void Dispose(bool disposing) { @@ -230,7 +230,7 @@ public void Reset() } #region IDisposable Support - private bool _disposedValue = false; // To detect redundant calls + private bool _disposedValue; // To detect redundant calls private void Dispose(bool disposing) { diff --git a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs index c5818719918e6..bbda80e643f10 100644 --- a/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs +++ b/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/RuntimeInformation.Windows.cs @@ -8,11 +8,11 @@ namespace System.Runtime.InteropServices { public static partial class RuntimeInformation { - private static string? s_osDescription = null; + private static string? s_osDescription; private static readonly object s_osLock = new object(); private static readonly object s_processLock = new object(); - private static Architecture? s_osArch = null; - private static Architecture? s_processArch = null; + private static Architecture? s_osArch; + private static Architecture? s_processArch; public static bool IsOSPlatform(OSPlatform osPlatform) { diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/HandleCollector.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/HandleCollector.cs index 07bb1b7567026..c2547e48a1475 100644 --- a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/HandleCollector.cs +++ b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/HandleCollector.cs @@ -14,7 +14,7 @@ public sealed class HandleCollector private int _handleCount; private readonly int[] _gcCounts = new int[3]; - private int _gcGeneration = 0; + private int _gcGeneration; public HandleCollector(string? name, int initialThreshold) : this(name, initialThreshold, int.MaxValue) diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs index 5534bffb4809a..55172d886ae90 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs @@ -840,7 +840,7 @@ private static bool RemoveInheritanceBits(AceFlags existing, AceFlags remove, bo #region Private Members private readonly RawAcl _acl; - private bool _isDirty = false; + private bool _isDirty; private readonly bool _isCanonical; private readonly bool _isContainer; @@ -3061,7 +3061,7 @@ public sealed class DiscretionaryAcl : CommonAcl { #region private static readonly SecurityIdentifier _sidEveryone = new SecurityIdentifier(WellKnownSidType.WorldSid, null); - private bool everyOneFullAccessForNullDacl = false; + private bool everyOneFullAccessForNullDacl; #endregion #region Constructors diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/NativeObjectSecurity.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/NativeObjectSecurity.cs index b77e4a095a570..7dc4a401d943f 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/NativeObjectSecurity.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/NativeObjectSecurity.cs @@ -27,8 +27,8 @@ public abstract class NativeObjectSecurity : CommonObjectSecurity #region Private Members private readonly ResourceType _resourceType; - private readonly ExceptionFromErrorCode? _exceptionFromErrorCode = null; - private readonly object? _exceptionContext = null; + private readonly ExceptionFromErrorCode? _exceptionFromErrorCode; + private readonly object? _exceptionContext; private readonly uint ProtectedDiscretionaryAcl = 0x80000000; private readonly uint ProtectedSystemAcl = 0x40000000; private readonly uint UnprotectedDiscretionaryAcl = 0x20000000; diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs index 6e220a5743031..7f7bcbc6710e5 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs @@ -37,10 +37,10 @@ public abstract class ObjectSecurity internal readonly CommonSecurityDescriptor _securityDescriptor = null!; - private bool _ownerModified = false; - private bool _groupModified = false; - private bool _saclModified = false; - private bool _daclModified = false; + private bool _ownerModified; + private bool _groupModified; + private bool _saclModified; + private bool _daclModified; // only these SACL control flags will be automatically carry forward // when update with new security descriptor. diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Privilege.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Privilege.cs index e0365a4bd6296..2744259507643 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Privilege.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Privilege.cs @@ -40,12 +40,12 @@ internal sealed class Privilege private static readonly Dictionary luids = new Dictionary(); private static readonly ReaderWriterLockSlim privilegeLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); - private bool needToRevert = false; - private bool initialState = false; - private bool stateWasChanged = false; + private bool needToRevert; + private bool initialState; + private bool stateWasChanged; private Luid luid; private readonly Thread currentThread = Thread.CurrentThread; - private TlsContents? tlsContents = null; + private TlsContents? tlsContents; public const string CreateToken = "SeCreateTokenPrivilege"; public const string AssignPrimaryToken = "SeAssignPrimaryTokenPrivilege"; @@ -161,10 +161,10 @@ private static Luid LuidFromPrivilege(string privilege) private sealed class TlsContents : IDisposable { - private bool disposed = false; + private bool disposed; private int referenceCount = 1; private SafeTokenHandle? threadHandle = new SafeTokenHandle(IntPtr.Zero); - private readonly bool isImpersonating = false; + private readonly bool isImpersonating; private static volatile SafeTokenHandle processHandle = new SafeTokenHandle(IntPtr.Zero); private static readonly object syncRoot = new object(); diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs index a31e26c9620ac..3427de0025585 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs @@ -12,7 +12,7 @@ namespace System.Security.AccessControl [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public sealed class PrivilegeNotHeldException : UnauthorizedAccessException, ISerializable { - private readonly string? _privilegeName = null; + private readonly string? _privilegeName; public PrivilegeNotHeldException() : base(SR.PrivilegeNotHeld_Default) diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/DSACryptoServiceProvider.Windows.cs b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/DSACryptoServiceProvider.Windows.cs index 567ce989bd7a5..bf90461315f2a 100644 --- a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/DSACryptoServiceProvider.Windows.cs +++ b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/DSACryptoServiceProvider.Windows.cs @@ -17,7 +17,7 @@ public sealed class DSACryptoServiceProvider : DSA, ICspAsymmetricAlgorithm private SafeKeyHandle? _safeKeyHandle; private SafeProvHandle? _safeProvHandle; private readonly SHA1 _sha1; - private static volatile CspProviderFlags s_useMachineKeyStore = 0; + private static volatile CspProviderFlags s_useMachineKeyStore; private bool _disposed; /// diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/PasswordDeriveBytes.Windows.cs b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/PasswordDeriveBytes.Windows.cs index 76dc4dede0c25..a4008f9b1db24 100644 --- a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/PasswordDeriveBytes.Windows.cs +++ b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/PasswordDeriveBytes.Windows.cs @@ -10,7 +10,7 @@ namespace System.Security.Cryptography { public partial class PasswordDeriveBytes : DeriveBytes { - private SafeProvHandle? _safeProvHandle = null; + private SafeProvHandle? _safeProvHandle; public byte[] CryptDeriveKey(string? algname, string? alghashname, int keySize, byte[] rgbIV) { diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs index 28071c2882ce5..3c4d455570de3 100644 --- a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs +++ b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RC2CryptoServiceProvider.Windows.cs @@ -11,7 +11,7 @@ namespace System.Security.Cryptography [EditorBrowsable(EditorBrowsableState.Never)] public sealed class RC2CryptoServiceProvider : RC2 { - private bool _use40bitSalt = false; + private bool _use40bitSalt; private const int BitsPerByte = 8; private static readonly KeySizes[] s_legalKeySizes = diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs index 2b272dc79e59d..bef4196c6bcbc 100644 --- a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs +++ b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RSACryptoServiceProvider.Windows.cs @@ -18,7 +18,7 @@ public sealed partial class RSACryptoServiceProvider : RSA, ICspAsymmetricAlgori private readonly bool _randomKeyContainer; private SafeKeyHandle? _safeKeyHandle; private SafeProvHandle? _safeProvHandle; - private static volatile CspProviderFlags s_useMachineKeyStore = 0; + private static volatile CspProviderFlags s_useMachineKeyStore; private bool _disposed; public RSACryptoServiceProvider() diff --git a/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/AsnEncodedData.cs b/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/AsnEncodedData.cs index d3798248a95a2..20c707b47776c 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/AsnEncodedData.cs +++ b/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/AsnEncodedData.cs @@ -87,7 +87,7 @@ private void Reset(Oid? oid, byte[] rawData) this.RawData = rawData; } - private Oid? _oid = null; + private Oid? _oid; private byte[] _rawData; } } diff --git a/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/Oid.cs b/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/Oid.cs index 19245f33f111e..8b12cf2e06eac 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/Oid.cs +++ b/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/Oid.cs @@ -144,8 +144,8 @@ private Oid(string value, string friendlyName, OidGroup group) _group = group; } - private string? _value = null; - private string? _friendlyName = null; + private string? _value; + private string? _friendlyName; private readonly OidGroup _group = OidGroup.All; } } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/KeyAgreeRecipientInfo.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/KeyAgreeRecipientInfo.cs index 701dfdcb4853e..a4d606d9c7ac1 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/KeyAgreeRecipientInfo.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/KeyAgreeRecipientInfo.cs @@ -86,11 +86,11 @@ public CryptographicAttributeObject? OtherKeyAttribute } } - private volatile SubjectIdentifier? _lazyRecipientIdentifier = null; - private volatile AlgorithmIdentifier? _lazyKeyEncryptionAlgorithm = null; - private volatile byte[]? _lazyEncryptedKey = null; - private volatile SubjectIdentifierOrKey? _lazyOriginatorIdentifierKey = null; - private DateTime? _lazyDate = default(DateTime?); - private volatile CryptographicAttributeObject? _lazyOtherKeyAttribute = null; + private volatile SubjectIdentifier? _lazyRecipientIdentifier; + private volatile AlgorithmIdentifier? _lazyKeyEncryptionAlgorithm; + private volatile byte[]? _lazyEncryptedKey; + private volatile SubjectIdentifierOrKey? _lazyOriginatorIdentifierKey; + private DateTime? _lazyDate; + private volatile CryptographicAttributeObject? _lazyOtherKeyAttribute; } } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/KeyTransRecipientInfo.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/KeyTransRecipientInfo.cs index bf8c1333ddefc..dd836abdb1e40 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/KeyTransRecipientInfo.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/KeyTransRecipientInfo.cs @@ -56,8 +56,8 @@ public override byte[] EncryptedKey } } - private volatile SubjectIdentifier? _lazyRecipientIdentifier = null; - private volatile AlgorithmIdentifier? _lazyKeyEncryptionAlgorithm = null; - private volatile byte[]? _lazyEncryptedKey = null; + private volatile SubjectIdentifier? _lazyRecipientIdentifier; + private volatile AlgorithmIdentifier? _lazyKeyEncryptionAlgorithm; + private volatile byte[]? _lazyEncryptedKey; } } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9ContentType.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9ContentType.cs index 56f55b0c3e7ad..2216a66af5834 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9ContentType.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9ContentType.cs @@ -52,6 +52,6 @@ public override void CopyFrom(AsnEncodedData asnEncodedData) return new Oid(contentTypeValue); } - private volatile Oid? _lazyContentType = null; + private volatile Oid? _lazyContentType; } } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9DocumentDescription.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9DocumentDescription.cs index 8104f833b9961..466e35bc1e6d5 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9DocumentDescription.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9DocumentDescription.cs @@ -74,6 +74,6 @@ private static byte[] Encode(string documentDescription) return PkcsHelpers.EncodeOctetString(octets); } - private volatile string? _lazyDocumentDescription = null; + private volatile string? _lazyDocumentDescription; } } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9DocumentName.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9DocumentName.cs index 340a320ff7b01..30fe1963f0d31 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9DocumentName.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9DocumentName.cs @@ -74,6 +74,6 @@ private static byte[] Encode(string documentName) return PkcsHelpers.EncodeOctetString(octets); } - private volatile string? _lazyDocumentName = null; + private volatile string? _lazyDocumentName; } } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9MessageDigest.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9MessageDigest.cs index 05c3875e6e267..a7282085e4665 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9MessageDigest.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9MessageDigest.cs @@ -57,6 +57,6 @@ public override void CopyFrom(AsnEncodedData asnEncodedData) return PkcsHelpers.DecodeOctetString(rawData); } - private volatile byte[]? _lazyMessageDigest = null; + private volatile byte[]? _lazyMessageDigest; } } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9SigningTime.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9SigningTime.cs index 24d398ca62807..d996f750a1b35 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9SigningTime.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs9SigningTime.cs @@ -72,6 +72,6 @@ private static byte[] Encode(DateTime signingTime) return PkcsHelpers.EncodeUtcTime(signingTime); } - private DateTime? _lazySigningTime = default(DateTime?); + private DateTime? _lazySigningTime; } } diff --git a/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs b/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs index 6c91470e56bc9..2a7014238752f 100644 --- a/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs +++ b/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs @@ -14,7 +14,7 @@ public abstract class HashAlgorithm : IDisposable, ICryptoTransform private bool _disposed; protected int HashSizeValue; protected internal byte[]? HashValue; - protected int State = 0; + protected int State; protected HashAlgorithm() { } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/DirectoryBasedStoreProvider.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/DirectoryBasedStoreProvider.cs index aeca94808582a..cf8505fcf642d 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/DirectoryBasedStoreProvider.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/DirectoryBasedStoreProvider.cs @@ -485,7 +485,7 @@ public void Remove(ICertificatePal cert) // Since CloneTo always says the store is empty, no measurable work is ever done. } - SafeHandle? IStorePal.SafeHandle { get; } = null; + SafeHandle? IStorePal.SafeHandle { get; } } } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/PublicKey.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/PublicKey.cs index 98897213d78d6..de09da821713a 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/PublicKey.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/PublicKey.cs @@ -10,7 +10,7 @@ namespace System.Security.Cryptography.X509Certificates public sealed class PublicKey { private readonly Oid _oid; - private AsymmetricAlgorithm? _key = null; + private AsymmetricAlgorithm? _key; public PublicKey(Oid oid, AsnEncodedData parameters, AsnEncodedData keyValue) { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CipherData.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CipherData.cs index 1b49037abca10..460f5cd6a8199 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CipherData.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CipherData.cs @@ -8,9 +8,9 @@ namespace System.Security.Cryptography.Xml { public sealed class CipherData { - private XmlElement _cachedXml = null; - private CipherReference _cipherReference = null; - private byte[] _cipherValue = null; + private XmlElement _cachedXml; + private CipherReference _cipherReference; + private byte[] _cipherValue; public CipherData() { } diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedReference.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedReference.cs index 599fb2fd7247c..5d638e8055939 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedReference.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedReference.cs @@ -11,7 +11,7 @@ public abstract class EncryptedReference private string _uri; private string _referenceType; private TransformChain _transformChain; - internal XmlElement _cachedXml = null; + internal XmlElement _cachedXml; protected EncryptedReference() : this(string.Empty, new TransformChain()) { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedType.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedType.cs index 4ef6c560c9997..5a31d27fd63a6 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedType.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedType.cs @@ -16,7 +16,7 @@ public abstract class EncryptedType private CipherData _cipherData; private EncryptionPropertyCollection _props; private KeyInfo _keyInfo; - internal XmlElement _cachedXml = null; + internal XmlElement _cachedXml; internal bool CacheValid { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedXml.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedXml.cs index 2e1212e50b765..9f5997625d983 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedXml.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedXml.cs @@ -70,7 +70,7 @@ public class EncryptedXml private CipherMode _mode; private Encoding _encoding; private string _recipient; - private int _xmlDsigSearchDepthCounter = 0; + private int _xmlDsigSearchDepthCounter; private int _xmlDsigSearchDepth; // diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptionMethod.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptionMethod.cs index b4fe3ea6b9d32..461dfecdaf8b3 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptionMethod.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptionMethod.cs @@ -8,8 +8,8 @@ namespace System.Security.Cryptography.Xml { public class EncryptionMethod { - private XmlElement _cachedXml = null; - private int _keySize = 0; + private XmlElement _cachedXml; + private int _keySize; private string _algorithm; public EncryptionMethod() diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptionProperty.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptionProperty.cs index f1d41e579fda7..b351fc7d63989 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptionProperty.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptionProperty.cs @@ -11,7 +11,7 @@ public sealed class EncryptionProperty private string _target; private string _id; private XmlElement _elemProp; - private XmlElement _cachedXml = null; + private XmlElement _cachedXml; // We are being lax here as per the spec public EncryptionProperty() { } diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/ExcAncestralNamespaceContextManager.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/ExcAncestralNamespaceContextManager.cs index 9ef45368d28d8..1d89df5d4d241 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/ExcAncestralNamespaceContextManager.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/ExcAncestralNamespaceContextManager.cs @@ -11,7 +11,7 @@ namespace System.Security.Cryptography.Xml // object also maintains the inclusive prefix list in a tokenized form. internal class ExcAncestralNamespaceContextManager : AncestralNamespaceContextManager { - private readonly Hashtable _inclusivePrefixSet = null; + private readonly Hashtable _inclusivePrefixSet; internal ExcAncestralNamespaceContextManager(string inclusiveNamespacesPrefixList) { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfo.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfo.cs index 5838986192c44..1dbcbb31abc47 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfo.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfo.cs @@ -9,7 +9,7 @@ namespace System.Security.Cryptography.Xml { public class KeyInfo : IEnumerable { - private string _id = null; + private string _id; private readonly ArrayList _keyInfoClauses; // diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs index acda861b6b297..087557f43f258 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs @@ -13,15 +13,15 @@ namespace System.Security.Cryptography.Xml public class KeyInfoX509Data : KeyInfoClause { // An array of certificates representing the certificate chain - private ArrayList _certificates = null; + private ArrayList _certificates; // An array of issuer serial structs - private ArrayList _issuerSerials = null; + private ArrayList _issuerSerials; // An array of SKIs - private ArrayList _subjectKeyIds = null; + private ArrayList _subjectKeyIds; // An array of subject names - private ArrayList _subjectNames = null; + private ArrayList _subjectNames; // A raw byte data representing a certificate revocation list - private byte[] _CRL = null; + private byte[] _CRL; // // public constructors diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Reference.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Reference.cs index aad5bf633ef77..773baa8ad842b 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Reference.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Reference.cs @@ -22,8 +22,8 @@ public class Reference private readonly object _refTarget; private readonly ReferenceTargetType _refTargetType; private XmlElement _cachedXml; - private SignedXml _signedXml = null; - internal CanonicalXmlNodeList _namespaces = null; + private SignedXml _signedXml; + internal CanonicalXmlNodeList _namespaces; // // public constructors diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Signature.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Signature.cs index 484f9adf71320..388cb9ee26545 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Signature.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Signature.cs @@ -16,7 +16,7 @@ public class Signature private KeyInfo _keyInfo; private IList _embeddedObjects; private readonly CanonicalXmlNodeList _referencedItems; - private SignedXml _signedXml = null; + private SignedXml _signedXml; internal SignedXml SignedXml { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedInfo.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedInfo.cs index 4dc20cdc28d10..109405638b733 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedInfo.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedInfo.cs @@ -14,9 +14,9 @@ public class SignedInfo : ICollection private string _signatureMethod; private string _signatureLength; private readonly ArrayList _references; - private XmlElement _cachedXml = null; - private SignedXml _signedXml = null; - private Transform _canonicalizationMethodTransform = null; + private XmlElement _cachedXml; + private SignedXml _signedXml; + private Transform _canonicalizationMethodTransform; internal SignedXml SignedXml { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs index 098abf1b6282d..39d6613e2631e 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXml.cs @@ -17,25 +17,25 @@ public class SignedXml protected string m_strSigningKeyName; private AsymmetricAlgorithm _signingKey; - private XmlDocument _containingDocument = null; - private IEnumerator _keyInfoEnum = null; - private X509Certificate2Collection _x509Collection = null; - private IEnumerator _x509Enum = null; + private XmlDocument _containingDocument; + private IEnumerator _keyInfoEnum; + private X509Certificate2Collection _x509Collection; + private IEnumerator _x509Enum; - private bool[] _refProcessed = null; - private int[] _refLevelCache = null; + private bool[] _refProcessed; + private int[] _refLevelCache; - internal XmlResolver _xmlResolver = null; - internal XmlElement _context = null; - private bool _bResolverSet = false; + internal XmlResolver _xmlResolver; + internal XmlElement _context; + private bool _bResolverSet; private Func _signatureFormatValidator = DefaultSignatureFormatValidator; private Collection _safeCanonicalizationMethods; // Built in canonicalization algorithm URIs - private static IList s_knownCanonicalizationMethods = null; + private static IList s_knownCanonicalizationMethods; // Built in transform algorithm URIs (excluding canonicalization URIs) - private static IList s_defaultSafeTransformMethods = null; + private static IList s_defaultSafeTransformMethods; // additional HMAC Url identifiers private const string XmlDsigMoreHMACMD5Url = "http://www.w3.org/2001/04/xmldsig-more#hmac-md5"; @@ -45,7 +45,7 @@ public class SignedXml private const string XmlDsigMoreHMACRIPEMD160Url = "http://www.w3.org/2001/04/xmldsig-more#hmac-ripemd160"; // defines the XML encryption processing rules - private EncryptedXml _exml = null; + private EncryptedXml _exml; // // public constant Url identifiers most frequently used within the XML Signature classes @@ -603,8 +603,8 @@ internal static XmlElement DefaultGetIdElement(XmlDocument document, string idVa // private methods // - private bool _bCacheValid = false; - private byte[] _digestedSignedInfo = null; + private bool _bCacheValid; + private byte[] _digestedSignedInfo; private static bool DefaultSignatureFormatValidator(SignedXml signedXml) { @@ -836,7 +836,7 @@ private int GetReferenceLevel(int index, ArrayList references) private class ReferenceLevelSortOrder : IComparer { - private ArrayList _references = null; + private ArrayList _references; public ReferenceLevelSortOrder() { } public ArrayList References diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Transform.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Transform.cs index a81ed74504785..959065fe31f82 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Transform.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Transform.cs @@ -23,13 +23,13 @@ namespace System.Security.Cryptography.Xml public abstract class Transform { private string _algorithm; - private string _baseUri = null; - internal XmlResolver _xmlResolver = null; - private bool _bResolverSet = false; - private SignedXml _signedXml = null; - private Reference _reference = null; - private Hashtable _propagatedNamespaces = null; - private XmlElement _context = null; + private string _baseUri; + internal XmlResolver _xmlResolver; + private bool _bResolverSet; + private SignedXml _signedXml; + private Reference _reference; + private Hashtable _propagatedNamespaces; + private XmlElement _context; internal string BaseURI { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDecryptionTransform.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDecryptionTransform.cs index 8ace6d33aa27d..3dd4722e40337 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDecryptionTransform.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDecryptionTransform.cs @@ -15,11 +15,11 @@ public class XmlDecryptionTransform : Transform { private readonly Type[] _inputTypes = { typeof(Stream), typeof(XmlDocument) }; private readonly Type[] _outputTypes = { typeof(XmlDocument) }; - private XmlNodeList _encryptedDataList = null; - private ArrayList _arrayListUri = null; // this ArrayList object represents the Uri's to be excluded - private EncryptedXml _exml = null; // defines the XML encryption processing rules - private XmlDocument _containingDocument = null; - private XmlNamespaceManager _nsm = null; + private XmlNodeList _encryptedDataList; + private ArrayList _arrayListUri; // this ArrayList object represents the Uri's to be excluded + private EncryptedXml _exml; // defines the XML encryption processing rules + private XmlDocument _containingDocument; + private XmlNamespaceManager _nsm; private const string XmlDecryptionTransformNamespaceUrl = "http://www.w3.org/2002/07/decrypt#"; public XmlDecryptionTransform() diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigBase64Transform.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigBase64Transform.cs index caf25a1d1a470..dbc6a9c11ff0a 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigBase64Transform.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigBase64Transform.cs @@ -13,7 +13,7 @@ public class XmlDsigBase64Transform : Transform { private readonly Type[] _inputTypes = { typeof(Stream), typeof(XmlNodeList), typeof(XmlDocument) }; private readonly Type[] _outputTypes = { typeof(Stream) }; - private CryptoStream _cs = null; + private CryptoStream _cs; public XmlDsigBase64Transform() { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigC14NTransform.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigC14NTransform.cs index 10c152bcdff18..1d5022d23d2ae 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigC14NTransform.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigC14NTransform.cs @@ -12,7 +12,7 @@ public class XmlDsigC14NTransform : Transform private readonly Type[] _inputTypes = { typeof(Stream), typeof(XmlDocument), typeof(XmlNodeList) }; private readonly Type[] _outputTypes = { typeof(Stream) }; private CanonicalXml _cXml; - private readonly bool _includeComments = false; + private readonly bool _includeComments; public XmlDsigC14NTransform() { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigEnvelopedSignatureTransform.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigEnvelopedSignatureTransform.cs index 162905fe9d631..5f70a97f03117 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigEnvelopedSignatureTransform.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigEnvelopedSignatureTransform.cs @@ -12,10 +12,10 @@ public class XmlDsigEnvelopedSignatureTransform : Transform private readonly Type[] _inputTypes = { typeof(Stream), typeof(XmlNodeList), typeof(XmlDocument) }; private readonly Type[] _outputTypes = { typeof(XmlNodeList), typeof(XmlDocument) }; private XmlNodeList _inputNodeList; - private readonly bool _includeComments = false; - private XmlNamespaceManager _nsm = null; - private XmlDocument _containingDocument = null; - private int _signaturePosition = 0; + private readonly bool _includeComments; + private XmlNamespaceManager _nsm; + private XmlDocument _containingDocument; + private int _signaturePosition; internal int SignaturePosition { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigExcC14NTransform.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigExcC14NTransform.cs index 1e73725195096..b7c8dded36b57 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigExcC14NTransform.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigExcC14NTransform.cs @@ -11,7 +11,7 @@ public class XmlDsigExcC14NTransform : Transform { private readonly Type[] _inputTypes = { typeof(Stream), typeof(XmlDocument), typeof(XmlNodeList) }; private readonly Type[] _outputTypes = { typeof(Stream) }; - private readonly bool _includeComments = false; + private readonly bool _includeComments; private string _inclusiveNamespacesPrefixList; private ExcCanonicalXml _excCanonicalXml; diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigXsltTransform.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigXsltTransform.cs index e2ee3cde360c7..191b7954ab039 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigXsltTransform.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigXsltTransform.cs @@ -16,7 +16,7 @@ public class XmlDsigXsltTransform : Transform private XmlNodeList _xslNodes; private string _xslFragment; private Stream _inputStream; - private readonly bool _includeComments = false; + private readonly bool _includeComments; public XmlDsigXsltTransform() { diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlLicenseTransform.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlLicenseTransform.cs index ccc9a5b5e12f6..8fb886303264d 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlLicenseTransform.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlLicenseTransform.cs @@ -11,9 +11,9 @@ public class XmlLicenseTransform : Transform { private readonly Type[] _inputTypes = { typeof(XmlDocument) }; private readonly Type[] _outputTypes = { typeof(XmlDocument) }; - private XmlNamespaceManager _namespaceManager = null; - private XmlDocument _license = null; - private IRelDecryptor _relDecryptor = null; + private XmlNamespaceManager _namespaceManager; + private XmlDocument _license; + private IRelDecryptor _relDecryptor; private const string ElementIssuer = "issuer"; private const string NamespaceUriCore = "urn:mpeg:mpeg21:2003:01-REL-R-NS"; diff --git a/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs b/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs index 5cdb393cc862d..a9f266b49a477 100644 --- a/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs +++ b/src/libraries/System.Security.Permissions/src/System/Security/HostProtectionException.cs @@ -49,9 +49,9 @@ protected HostProtectionException(SerializationInfo info, StreamingContext conte DemandedResources = (HostProtectionResource)info.GetValue(DemandedResourcesName, typeof(HostProtectionResource)); } - public HostProtectionResource DemandedResources { get; } = default; + public HostProtectionResource DemandedResources { get; } - public HostProtectionResource ProtectedResources { get; } = default; + public HostProtectionResource ProtectedResources { get; } private void AppendResourceString(string resourceString, object attr, StringBuilder sb) { diff --git a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceProcessDescriptionAttribute.cs b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceProcessDescriptionAttribute.cs index ff716f8837d0b..6a3407d1b1ca6 100644 --- a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceProcessDescriptionAttribute.cs +++ b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceProcessDescriptionAttribute.cs @@ -14,7 +14,7 @@ namespace System.ServiceProcess [AttributeUsage(AttributeTargets.All)] public class ServiceProcessDescriptionAttribute : DescriptionAttribute { - private bool replaced = false; + private bool replaced; /// /// Constructs a new sys description diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs index 5d26bfff272e9..af83d7a4956b6 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/BaseCodePageEncoding.cs @@ -48,7 +48,7 @@ internal abstract partial class BaseCodePageEncoding : EncodingNLS, ISerializabl protected int dataTableCodePage; // Variables to help us allocate/mark our memory section correctly - protected int iExtraBytes = 0; + protected int iExtraBytes; // Our private unicode-to-bytes best-fit-array, and vice versa. protected char[]? arrayUnicodeBestFit; diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DBCSCodePageEncoding.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DBCSCodePageEncoding.cs index 6b23343e95efd..17e6a22dd2c37 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DBCSCodePageEncoding.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DBCSCodePageEncoding.cs @@ -28,7 +28,7 @@ internal class DBCSCodePageEncoding : BaseCodePageEncoding // They aren't actually used because of the fallback mechanism. (char is though) private ushort _bytesUnknown; private int _byteCountUnknown; - protected char charUnknown = (char)0; + protected char charUnknown; public DBCSCodePageEncoding(int codePage) : this(codePage, codePage) { @@ -1147,7 +1147,7 @@ public override Decoder GetDecoder() internal class DBCSDecoder : DecoderNLS { // Need a place for the last left over byte - internal byte bLeftOver = 0; + internal byte bLeftOver; public DBCSDecoder(DBCSCodePageEncoding encoding) : base(encoding) { diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DecoderBestFitFallback.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DecoderBestFitFallback.cs index f6c41a8ba7e03..efe4d9de084a4 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DecoderBestFitFallback.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DecoderBestFitFallback.cs @@ -17,7 +17,7 @@ internal sealed class InternalDecoderBestFitFallback : DecoderFallback { // Our variables internal BaseCodePageEncoding encoding; - internal char[]? arrayBestFit = null; + internal char[]? arrayBestFit; internal char cReplacement = '?'; internal InternalDecoderBestFitFallback(BaseCodePageEncoding _encoding) @@ -41,7 +41,7 @@ public override bool Equals(object? value) => internal sealed class InternalDecoderBestFitFallbackBuffer : DecoderFallbackBuffer { // Our variables - internal char cBestFit = '\0'; + internal char cBestFit; internal int iCount = -1; internal int iSize; private readonly InternalDecoderBestFitFallback _oFallback; diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncoderBestFitFallback.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncoderBestFitFallback.cs index f85c4b7e527f1..f38c4e3dc51f9 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncoderBestFitFallback.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncoderBestFitFallback.cs @@ -41,7 +41,7 @@ public override bool Equals(object? value) => internal sealed class InternalEncoderBestFitFallbackBuffer : EncoderFallbackBuffer { // Our variables - private char _cBestFit = '\0'; + private char _cBestFit; private readonly InternalEncoderBestFitFallback _oFallback; private int _iCount = -1; private int _iSize; diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingByteBuffer.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingByteBuffer.cs index d37665d290bfe..87b9617d27dfd 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingByteBuffer.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingByteBuffer.cs @@ -14,7 +14,7 @@ internal class EncodingByteBuffer private unsafe char* _chars; private readonly unsafe char* _charStart; private readonly unsafe char* _charEnd; - private int _byteCountResult = 0; + private int _byteCountResult; private readonly EncodingNLS _enc; private readonly EncoderNLS? _encoder; internal EncoderFallbackBuffer fallbackBuffer; diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingCharBuffer.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingCharBuffer.cs index 99d94c824b69b..16f5fbd8d2836 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingCharBuffer.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingCharBuffer.cs @@ -11,7 +11,7 @@ internal class EncodingCharBuffer private unsafe char* _chars; private readonly unsafe char* _charStart; private readonly unsafe char* _charEnd; - private int _charCountResult = 0; + private int _charCountResult; private readonly EncodingNLS _enc; private readonly DecoderNLS? _decoder; private readonly unsafe byte* _byteStart; diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs index db6e4d0d14853..ef0bed8d611ac 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs @@ -695,13 +695,13 @@ public override int GetHashCode() internal class ISCIIEncoder : EncoderNLS { // Need to remember the default code page (for HasState) - internal int defaultCodePage = 0; + internal int defaultCodePage; // Need a place for the current code page - internal int currentCodePage = 0; + internal int currentCodePage; // Was the last character a virama? (Because ZWJ and ZWNJ are different then) - internal bool bLastVirama = false; + internal bool bLastVirama; public ISCIIEncoder(EncodingNLS encoding) : base(encoding) { @@ -733,12 +733,12 @@ internal override bool HasState internal class ISCIIDecoder : DecoderNLS { // Need a place to store any our current code page and last ATR flag - internal int currentCodePage = 0; - internal bool bLastATR = false; - internal bool bLastVirama = false; - internal bool bLastDevenagariStressAbbr = false; - internal char cLastCharForNextNukta = '\0'; - internal char cLastCharForNoNextNukta = '\0'; + internal int currentCodePage; + internal bool bLastATR; + internal bool bLastVirama; + internal bool bLastDevenagariStressAbbr; + internal char cLastCharForNextNukta; + internal char cLastCharForNoNextNukta; public ISCIIDecoder(EncodingNLS encoding) : base(encoding) { diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonPropertyInfo.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonPropertyInfo.cs index 471321029c82a..f7fcf4d869a67 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonPropertyInfo.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonPropertyInfo.cs @@ -316,7 +316,7 @@ public JsonClassInfo RuntimeClassInfo } } - public Type? RuntimePropertyType { get; private set; } = null; + public Type? RuntimePropertyType { get; private set; } public abstract void SetExtensionDictionaryAsObject(object obj, object? extensionDict); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs index 66666db839628..05b6c32d07b29 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs @@ -32,7 +32,7 @@ public sealed partial class JsonSerializerOptions private JsonNamingPolicy? _jsonPropertyNamingPolicy; private JsonCommentHandling _readCommentHandling; private ReferenceHandler? _referenceHandler; - private JavaScriptEncoder? _encoder = null; + private JavaScriptEncoder? _encoder; private JsonIgnoreCondition _defaultIgnoreCondition; private int _defaultBufferSize = BufferSizeDefault; diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs index 9eaed16592f32..5a8bad906b8b4 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs @@ -33,7 +33,7 @@ public partial class Regex : ISerializable internal WeakReference? _replref; // cached parsed replacement pattern private volatile RegexRunner? _runner; // cached runner private RegexCode? _code; // if interpreted, this is the code for RegexInterpreter - private bool _refsInitialized = false; + private bool _refsInitialized; protected Regex() { diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexAssemblyCompiler.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexAssemblyCompiler.cs index 1d40cf67920fb..1f695990182e0 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexAssemblyCompiler.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexAssemblyCompiler.cs @@ -14,7 +14,7 @@ namespace System.Text.RegularExpressions internal sealed class RegexAssemblyCompiler : RegexCompiler { /// Type count used to augment generated type names to create unique names. - private static int s_typeCount = 0; + private static int s_typeCount; private AssemblyBuilder _assembly; private ModuleBuilder _module; diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs index 7f3fa4001a797..db259a0090dde 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs @@ -28,7 +28,7 @@ internal sealed class RegexLWCGCompiler : RegexCompiler private static readonly Type[] s_paramTypes = new Type[] { typeof(RegexRunner) }; /// Id number to use for the next compiled regex. - private static int s_regexCount = 0; + private static int s_regexCount; public RegexLWCGCompiler() : base(persistsAssembly: false) { diff --git a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.cs b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.cs index 3d08945b9c0f6..1a7a18d0b5936 100644 --- a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.cs +++ b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/AsyncOperation.cs @@ -50,7 +50,7 @@ internal partial class AsyncOperation : AsyncOperation, IValueTaskSourc private readonly bool _runContinuationsAsynchronously; /// Only relevant to cancelable operations; 0 if the operation hasn't had completion reserved, 1 if it has. - private volatile int _completionReserved = 0; + private volatile int _completionReserved; /// The result of the operation. [MaybeNull, AllowNull] private TResult _result = default; diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlockOptions.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlockOptions.cs index cb9ce5442c2a3..fa5a98db3b4fe 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlockOptions.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowBlockOptions.cs @@ -278,7 +278,7 @@ public class ExecutionDataflowBlockOptions : DataflowBlockOptions /// The maximum number of tasks that may be used concurrently to process messages. private int _maxDegreeOfParallelism = 1; /// Whether the code using this block will only ever have a single producer accessing the block at any given time. - private bool _singleProducerConstrained = false; + private bool _singleProducerConstrained; /// Initializes the . public ExecutionDataflowBlockOptions() { } diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowLinkOptions.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowLinkOptions.cs index 0df56b8cf35b1..29325a8d2c7c1 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowLinkOptions.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Base/DataflowLinkOptions.cs @@ -54,7 +54,7 @@ public class DataflowLinkOptions internal const int Unbounded = DataflowBlockOptions.Unbounded; /// Whether the linked target will have completion and faulting notification propagated to it automatically. - private bool _propagateCompletion = false; + private bool _propagateCompletion; /// The maximum number of messages that may be consumed across the link. private int _maxNumberOfMessages = Unbounded; /// Whether the link should be appended to the source?s list of links, or whether it should be prepended. diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ReorderingBuffer.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ReorderingBuffer.cs index 7181bf800c857..fd5b53b7b33d2 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ReorderingBuffer.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/ReorderingBuffer.cs @@ -46,7 +46,7 @@ internal sealed class ReorderingBuffer : IReorderingBuffer /// Action used to output items in order. private readonly Action _outputAction; /// The ID of the next item that should be released from the reordering buffer. - private long _nextReorderedIdToOutput = 0; + private long _nextReorderedIdToOutput; /// Gets the object used to synchronize all access to the reordering buffer's internals. private object ValueLock { get { return _reorderingBuffer; } } diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelLoopState.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelLoopState.cs index 44c3b1ee591c4..4c9752337d8d5 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelLoopState.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelLoopState.cs @@ -266,7 +266,7 @@ internal static void Break(long iteration, ParallelLoopStateFlags64 pflags) internal class ParallelLoopState32 : ParallelLoopState { private readonly ParallelLoopStateFlags32 _sharedParallelStateFlags; - private int _currentIteration = 0; + private int _currentIteration; /// /// Internal constructor to ensure an instance isn't created by users. @@ -330,7 +330,7 @@ internal override void InternalBreak() internal class ParallelLoopState64 : ParallelLoopState { private readonly ParallelLoopStateFlags64 _sharedParallelStateFlags; - private long _currentIteration = 0; + private long _currentIteration; /// /// Internal constructor to ensure an instance isn't created by users. diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs index 8c5a2649a5ae6..8ea0935ca379d 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs @@ -9,8 +9,6 @@ namespace System.Transactions { public sealed class CommittableTransaction : Transaction, IAsyncResult { - internal bool _completedSynchronously = false; - // Create a transaction with defaults public CommittableTransaction() : this(TransactionManager.DefaultIsolationLevel, TransactionManager.DefaultTimeout) { @@ -194,7 +192,7 @@ public void EndCommit(IAsyncResult asyncResult) object? IAsyncResult.AsyncState => _internalTransaction._asyncState; - bool IAsyncResult.CompletedSynchronously => _completedSynchronously; + bool IAsyncResult.CompletedSynchronously => false; WaitHandle IAsyncResult.AsyncWaitHandle { diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/Configuration/AppSettings.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/Configuration/AppSettings.cs index 8033b75994afe..927e918245074 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/Configuration/AppSettings.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/Configuration/AppSettings.cs @@ -6,7 +6,7 @@ namespace System.Transactions.Configuration { internal static class AppSettings { - private static bool s_settingsInitalized = false; + private static volatile bool s_settingsInitalized; private static readonly object s_appSettingsLock = new object(); private static bool s_includeDistributedTxIdInExceptionMessage; @@ -22,6 +22,7 @@ private static void EnsureSettingsLoaded() // This uses System.Configuration on .NET Framework to load: // Transactions:IncludeDistributedTransactionIdInExceptionMessage s_includeDistributedTxIdInExceptionMessage = false; + s_settingsInitalized = true; } } } diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/EnterpriseServices.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/EnterpriseServices.cs index 3e04af4f98eb1..2a534635a5982 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/EnterpriseServices.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/EnterpriseServices.cs @@ -26,7 +26,7 @@ internal static void VerifyEnterpriseServicesOk() return null; } - internal static bool CreatedServiceDomain { get; set; } = false; + internal static bool CreatedServiceDomain { get; set; } internal static bool UseServiceDomainForCurrent() => false; diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/InternalTransaction.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/InternalTransaction.cs index 8071fac7e88d6..410e2b3d16137 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/InternalTransaction.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/InternalTransaction.cs @@ -133,13 +133,13 @@ internal DistributedTransaction? PromotedTransaction // If there was an exception that happened during promotion save that exception so that it // can be used as an inner exception to the transaciton aborted exception. - internal Exception? _innerException = null; + internal Exception? _innerException; // Note the number of Transaction objects supported by this object internal int _cloneCount; // The number of enlistments on this transaction. - internal int _enlistmentCount = 0; + internal int _enlistmentCount; // Double-checked locking pattern requires volatile for read/write synchronization // Manual Reset event for IAsyncResult support @@ -172,7 +172,7 @@ internal DistributedTransaction? PromotedTransaction LazyInitializer.EnsureInitialized(ref s_instanceIdentifier, ref s_classSyncObject, () => Guid.NewGuid().ToString() + ":"); // Double-checked locking pattern requires volatile for read/write synchronization - private volatile bool _traceIdentifierInited = false; + private volatile bool _traceIdentifierInited; // The trace identifier for the internal transaction. private TransactionTraceIdentifier _traceIdentifier; @@ -205,7 +205,7 @@ internal TransactionTraceIdentifier TransactionTraceId // Promote call is made and set back to false after the call returns (or an exception is thrown). The value is // checked for true in TransactionStatePSPEOperation.PSPEPromoteAndConvertToEnlistDurable to make sure the transaction // is in the process of promoting via a PSPE enlistment. - internal bool _attemptingPSPEPromote = false; + internal bool _attemptingPSPEPromote; // This is called from TransactionStatePromoted.EnterState. We assume we are promoting to MSDTC. internal void SetPromoterTypeToMSDTC() diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/Transaction.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/Transaction.cs index 89666616e0a20..0f0ec5802cae0 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/Transaction.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/Transaction.cs @@ -212,14 +212,14 @@ public static Transaction? Current internal IsolationLevel _isoLevel; // Storage for the consistent flag - internal bool _complete = false; + internal bool _complete; // Record an identifier for this clone internal int _cloneId; // Storage for a disposed flag internal const int _disposedTrueValue = 1; - internal int _disposed = 0; + internal int _disposed; internal bool Disposed { get { return _disposed == Transaction._disposedTrueValue; } } internal Guid DistributedTxId diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionManager.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionManager.cs index a6f3d00da1387..a90e27bcc5ff9 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionManager.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionManager.cs @@ -93,8 +93,8 @@ internal static void FireDistributedTransactionStarted(Transaction transaction) } // Data storage for current delegate - internal static HostCurrentTransactionCallback? s_currentDelegate = null; - internal static bool s_currentDelegateSet = false; + internal static HostCurrentTransactionCallback? s_currentDelegate; + internal static bool s_currentDelegateSet; // CurrentDelegate // diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs index acd51f7c186fc..ebc6c20b56b51 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionScope.cs @@ -1231,7 +1231,7 @@ internal bool ScopeComplete private Thread? _scopeThread; // Store the interop mode for this transaction scope. - private bool _interopModeSpecified = false; + private bool _interopModeSpecified; private EnterpriseServicesInteropOption _interopOption; internal EnterpriseServicesInteropOption InteropMode { diff --git a/src/libraries/System.Utf8String.Experimental/src/System/Globalization/GlobalizationMode.cs b/src/libraries/System.Utf8String.Experimental/src/System/Globalization/GlobalizationMode.cs index 2f653ee75e970..1c2154022a060 100644 --- a/src/libraries/System.Utf8String.Experimental/src/System/Globalization/GlobalizationMode.cs +++ b/src/libraries/System.Utf8String.Experimental/src/System/Globalization/GlobalizationMode.cs @@ -6,6 +6,6 @@ namespace System.Globalization { internal static partial class GlobalizationMode { - internal static bool Invariant { get; } = false; // TODO: should we enable this? + internal static bool Invariant { get; } // TODO: should we enable this? } } diff --git a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs index ae9cd72ae2e24..bd9cfe1965851 100644 --- a/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs +++ b/src/libraries/System.Windows.Extensions/src/System/Media/SoundPlayer.cs @@ -18,7 +18,7 @@ public class SoundPlayer : Component, ISerializable private const int BlockSize = 1024; private const int DefaultLoadTimeout = 10000; // 10 secs - private Uri _uri = null; + private Uri _uri; private string _soundLocation = string.Empty; private int _loadTimeout = DefaultLoadTimeout; @@ -28,16 +28,16 @@ public class SoundPlayer : Component, ISerializable // the worker copyTask // we start the worker copyTask ONLY from entry points in the SoundPlayer API // we also set the tread to null only from the entry points in the SoundPlayer API - private Task _copyTask = null; - private CancellationTokenSource _copyTaskCancellation = null; + private Task _copyTask; + private CancellationTokenSource _copyTaskCancellation; // local buffer information - private int _currentPos = 0; - private Stream _stream = null; - private Exception _lastLoadException = null; - private bool _doesLoadAppearSynchronous = false; - private byte[] _streamData = null; - private AsyncOperation _asyncOperation = null; + private int _currentPos; + private Stream _stream; + private Exception _lastLoadException; + private bool _doesLoadAppearSynchronous; + private byte[] _streamData; + private AsyncOperation _asyncOperation; private readonly SendOrPostCallback _loadAsyncOperationCompleted; // event @@ -124,9 +124,9 @@ public Stream Stream } } - public bool IsLoadCompleted { get; private set; } = false; + public bool IsLoadCompleted { get; private set; } - public object Tag { get; set; } = null; + public object Tag { get; set; } public void LoadAsync() {