Clean up lots of string.Format / SR.Format usage (dotnet/corefx#35777)
authorStephen Toub <stoub@microsoft.com>
Wed, 6 Mar 2019 20:03:00 +0000 (12:03 -0800)
committerGitHub <noreply@github.com>
Wed, 6 Mar 2019 20:03:00 +0000 (12:03 -0800)
* Clean up lots of string.Format usage

This PR does a few things:
- Adds new SR.Format overloads, in particular to support accepting an IFormatProvider as the first argument.
- Fixes a bunch of calls to string.Format that should have been using SR.Format.  This not only helps in AOT builds where we want to be able to more cleanly remove resource strings, it enables easier auditing of the remaining string.Format uses to determine whether there are more appropriate implementations.
- Replaces some string.Format uses, in particular in asserts, with easier to read and maintain string interpolation
- Replaces some string.Format uses with string concatenation where it's simple and cheaper
- Fixes a bunch of SR.Format(SR.Something) calls where the SR.Format part is extraneous and should just be removed.
- Replaces a bunch of Debug.Assert(false, ...) calls with Debug.Fail(...).  This isn't directly related to string.Format, but I started this cleanup as part of cleaning up asserts that were using string.Format, and then ended up accidentally merging the chain into the same commit, and decided it was simple enough that I should just leave it rather than trying to separate it out again.

* Address PR feedback

* Fix breaks due to lower netstandard builds

Commit migrated from https://github.com/dotnet/corefx/commit/a6f76f4f620cbe74821c6445af3f13e048361658

463 files changed:
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetDomainName.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetNodeName.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcKey.cs
src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs
src/libraries/Common/src/System/SR.cs
src/libraries/Common/src/System/Security/Cryptography/Asn1V2.Serializer.cs
src/libraries/Common/src/System/Security/Cryptography/ECCng.HashAlgorithm.cs
src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs
src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanCng.ImportExport.cs
src/libraries/Common/src/System/Security/Cryptography/ECDsaCng.ImportExport.cs
src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.ImportExport.cs
src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorFacts.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorHandling.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/UserStringBuilder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ExpressionTreeCallRewriter.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/RuntimeBinder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Binding/Better.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/MethodSymbol.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Symbols/Symbol.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/TypeBind.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Types/TypeManager.cs
src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs
src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs
src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs
src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CodeGenerator.cs
src/libraries/System.CodeDom/src/System/CodeDom/Compiler/CompilerInfo.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableDictionary_2.HashBucket.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.Node.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableSortedDictionary_2.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/SortedInt32KeyNode.cs
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/GenerationServices.cs
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/LazyServices.cs
src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Requires.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModel/AttributedModelDiscovery.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ChangeRejectedException.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ExceptionBuilder.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ExportServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AssemblyCatalog.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CatalogExportProvider.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ExportProvider.GetExportOverrides.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ExportProvider.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/TypeCatalog.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewGenerator.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewProvider.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ContractBasedImportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ImportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportingMember.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportingItem.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ImportingMember.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/LazyMemberInfo.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/PartCreatorMemberImportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/PartCreatorParameterImportDefinition.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServices.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerOptionService.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ExtendedPropertyDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicFileLicenseProvider.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/NestedContainer.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/ExportDescriptorRegistry.cs
src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/TypeInspector.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/AppSettingsReader.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/AppSettingsSection.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ApplicationSettingsBase.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/CallbackValidatorAttribute.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientSettingsStore.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationConverterBase.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationElement.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationElementCollection.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationFileMap.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationLockCollection.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationProperty.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationSectionGroup.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationValidatorAttribute.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/DpapiProtectedConfigurationProvider.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ExceptionUtil.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/GenericEnumConverter.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/HandlerBase.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/InternalConfigHost.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/WriteFileContext.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/LocalFileSettingsProvider.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/MgmtConfigurationRecord.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/NameValueFileSectionHandler.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/OverrideModeSetting.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ProtectedConfigurationProviderCollection.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ProtectedConfigurationSection.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/RegexStringValidator.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/RsaProtectedConfigurationProvider.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/RuntimeConfigurationRecord.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SectionInformation.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsBase.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsPropertyValue.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SettingsProviderCollection.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/StringAttributeCollection.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/StringValidator.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/SubclassTypeValidator.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/TypeNameConverter.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/TypeUtil.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ValidatorUtils.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/XmlUtil.cs
src/libraries/System.Console/src/System/ConsolePal.Windows.cs
src/libraries/System.Data.Common/src/System/Data/Common/AdapterUtil.Common.cs
src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs
src/libraries/System.Data.Common/src/System/Data/Common/DataStorage.cs
src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs
src/libraries/System.Data.Common/src/System/Data/DataException.cs
src/libraries/System.Data.Common/src/System/Data/DataKey.cs
src/libraries/System.Data.Common/src/System/Data/DataTable.cs
src/libraries/System.Data.Common/src/System/Data/DataView.cs
src/libraries/System.Data.Common/src/System/Data/Filter/BinaryNode.cs
src/libraries/System.Data.Common/src/System/Data/Filter/ConstNode.cs
src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs
src/libraries/System.Data.Common/src/System/Data/Filter/FilterException.cs
src/libraries/System.Data.Common/src/System/Data/Filter/UnaryNode.cs
src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs
src/libraries/System.Data.Common/src/System/Data/ProviderBase/SchemaMapping.cs
src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs
src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs
src/libraries/System.Data.Common/src/System/Xml/RegionIterator.cs
src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs
src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs
src/libraries/System.Data.DataSetExtensions/src/System/Data/DataRowExtensions.cs
src/libraries/System.Data.DataSetExtensions/src/System/Data/DataSetUtil.cs
src/libraries/System.Data.Odbc/src/Common/System/Data/Common/AdapterUtil.Odbc.cs
src/libraries/System.Data.Odbc/src/Common/System/Data/Common/DBConnectionString.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommand.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommandBuilder.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionHelper.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionStringbuilder.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcHandle.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameter.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcReferenceCollection.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcUtils.cs
src/libraries/System.Data.SqlClient/src/Microsoft/SqlServer/Server/SmiMetaData.cs
src/libraries/System.Data.SqlClient/src/Microsoft/SqlServer/Server/ValueUtilsSmi.cs
src/libraries/System.Data.SqlClient/src/System/Data/Common/AdapterUtil.SqlClient.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/LocalDBAPI.Common.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnection.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnectionHelper.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnectionStringBuilder.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDataReader.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalConnectionTds.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlInternalTransaction.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlMetadataFactory.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlParameter.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlSequentialTextReader.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlUtil.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserHelperClasses.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObject.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObjectNative.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsValueSetter.cs
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLog.cs
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogInternal.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/CounterCreationDataCollection.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/CounterSampleCalculator.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounter.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterCategory.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceData/CounterSet.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/SharedPerformanceCounter.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs
src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/DefaultTraceListener.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_Query.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/SDSUtils.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/SidList.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AccountInfo.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthZSet.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Context.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/GlobalDebug.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PasswordInfo.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Principal.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/PrincipalCollectionEnumerator.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMMembersSet.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMQuerySet.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx_LoadStore.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx_Query.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMUtils.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/StoreCtx.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/Utils.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/BerConverter.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/DirectoryConnection.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectoryInterSiteTransport.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ConfigSet.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Forest.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Utils.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs
src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphicsContext.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathGradientBrush.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Font.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Image.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Image.cs
src/libraries/System.Drawing.Common/src/System/Drawing/ImageInfo.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Pen.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs
src/libraries/System.Drawing.Common/src/System/Drawing/PointConverter.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSize.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintingServices.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs
src/libraries/System.Drawing.Common/src/System/Drawing/RectangleConverter.cs
src/libraries/System.Drawing.Common/src/System/Drawing/SizeConverter.cs
src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContext.cs
src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorage.cs
src/libraries/System.IO.IsolatedStorage/src/System/IO/IsolatedStorage/IsolatedStorageFile.cs
src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs
src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackageRelationshipSelector.cs
src/libraries/System.IO.Packaging/src/System/IO/Packaging/PartBasedPackageProperties.cs
src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs
src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.Unix.cs
src/libraries/System.IO.Ports/src/System/IO/Ports/SafeSerialDeviceHandle.Unix.cs
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialPort.cs
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Unix.cs
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs
src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/ContractUtils.cs
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/DebugViewWriter.cs
src/libraries/System.Management/src/System/Management/ManagementScope.cs
src/libraries/System.Management/src/System/Management/WMIGenerator.cs
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestCallback.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/ContentDispositionHeaderValue.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/HeaderUtilities.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpHeaderParser.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpHeaders.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/MediaTypeHeaderValue.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/NameValueHeaderValue.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/ProductInfoHeaderValue.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/ViaHeaderValue.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/WarningHeaderValue.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.Core.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpContent.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpResponseMessage.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs
src/libraries/System.Net.Http/src/System/Net/Http/MultipartContent.cs
src/libraries/System.Net.Http/src/uap/System/Net/HttpClientHandler.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBase.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBuffer.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketHttpListenerDuplexStream.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketProtocolComponent.cs
src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpConnection.cs
src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpException.cs
src/libraries/System.Net.Mail/src/System/Net/Mail/SmtpFailedRecipientsException.cs
src/libraries/System.Net.Mail/src/System/Net/Mime/HeaderCollection.cs
src/libraries/System.Net.Mail/src/System/Net/Mime/SmtpDateTime.cs
src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.Windows.Uap.cs
src/libraries/System.Net.Primitives/src/System/Net/CookieContainer.cs
src/libraries/System.Net.Requests/src/System/Net/WebException.cs
src/libraries/System.Net.Security/src/System/Net/StreamFramer.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs
src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WinRTWebSocket.cs
src/libraries/System.Numerics.Vectors/src/System/Numerics/Matrix3x2.cs
src/libraries/System.Numerics.Vectors/src/System/Numerics/Matrix4x4.cs
src/libraries/System.Numerics.Vectors/src/System/Numerics/Quaternion.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CodeGenerator.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContract.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataMemberAttribute.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ExtensionDataObject.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonClassDataContract.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonCollectionDataContract.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonDataContract.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/XmlJsonWriter.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ObjectToIdCache.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XPathQueryGenerator.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlReaderDelegator.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableReader.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlSerializableWriter.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XsdDataContractExporter.cs
src/libraries/System.Private.DataContractSerialization/src/System/Text/Base64Encoding.cs
src/libraries/System.Private.DataContractSerialization/src/System/Text/BinHexEncoding.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/UniqueId.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBaseReader.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBaseWriter.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryReader.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryReaderSession.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriter.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBinaryWriterSession.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlCanonicalWriter.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReaderQuotas.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryWriter.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlExceptionHelper.cs
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlUTF8TextReader.cs
src/libraries/System.Private.Uri/src/System/Uri.cs
src/libraries/System.Private.Uri/src/System/UriExt.cs
src/libraries/System.Private.Uri/src/System/UriScheme.cs
src/libraries/System.Private.Xml.Linq/src/System/Xml/Schema/XNodeValidator.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/ReadContentAsBinaryHelper.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/ReadContentAsBinaryHelperAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlCharCheckingReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlCharCheckingReaderAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlCharCheckingWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEventCache.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlSubtreeReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlSubtreeReaderAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImpl.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplHelpers.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlValidatingReaderImpl.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlValidatingReaderImplAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWellFormedWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWellFormedWriterAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWellFormedWriterHelpers.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWellFormedWriterHelpersAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWriterAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWriterSettings.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XsdValidatingReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Dom/DocumentSchemaValidator.cs
src/libraries/System.Private.Xml/src/System/Xml/Dom/DocumentXPathNavigator.cs
src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlDocument.cs
src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlLoader.cs
src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlNode.cs
src/libraries/System.Private.Xml/src/System/Xml/Ref.cs
src/libraries/System.Private.Xml/src/System/Xml/Resolvers/XmlPreloadedResolver.cs
src/libraries/System.Private.Xml/src/System/Xml/Resolvers/XmlPreloadedResolverAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/DataTypeImplementation.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/DtdParser.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/DtdParserAsync.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/FacetChecker.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/Inference/Infer.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/NamespaceList.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/Parser.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/Preprocessor.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionCompiler.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaInfo.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaSetCompiler.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlAtomicValue.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaComplexType.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaElement.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaGroup.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaObject.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaValidator.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlValueConverter.cs
src/libraries/System.Private.Xml/src/System/Xml/Schema/XsdBuilder.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeGenerator.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/Globals.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/Types.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemaExporter.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSchemaImporter.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/IteratorDescriptor.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/OptimizerPatterns.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlILConstructAnalyzer.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlILOptimizerVisitor.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/XmlIlVisitor.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/QIL/QilValidationVisitor.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/ContentIterators.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XmlAttributeCache.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XmlQueryOutput.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XmlSequenceWriter.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XPathConvert.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XmlQueryType.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XmlQueryTypeFactory.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/Xslt/XPathPatternBuilder.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/ContainerAction.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/WriterOutput.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/XsltCompileContext.cs
src/libraries/System.Private.Xml/src/System/Xml/Xsl/XsltOld/XsltOutput.cs
src/libraries/System.Reflection.Context/src/System/Reflection/Context/Custom/AttributeUtils.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/Internal/Utilities/LightUpHelper.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Internal/BlobHeap.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/MetadataReader.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/ImportDefinitionCollection.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/CustomAttribute.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/Throw.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/MetadataLoadContext.CoreAssembly.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Ecma/EcmaHelpers.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Ecma/EcmaToStringHelpers.cs
src/libraries/System.Resources.Writer/src/System/Resources/ResourceWriter.cs
src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/CacheMemoryMonitor.cs
src/libraries/System.Runtime.Caching/src/System/Runtime/Caching/PhysicalMemoryMonitor.cs
src/libraries/System.Runtime.Extensions/src/System/Runtime/CompilerServices/SwitchExpressionException.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/StandardOleMarshalObject.cs
src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryObjectReader.cs
src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/ObjectManager.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/IO/NetFxToWinRtStreamAdapter.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/IO/WinRtToNetFxStreamAdapter.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/Runtime/InteropServices/WindowsRuntime/MarshalingHelpers.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/Threading/Tasks/AsyncInfoToTaskBridge.CoreCLR.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/Threading/Tasks/AsyncInfoToTaskBridge.CoreRT.cs
src/libraries/System.Runtime.WindowsRuntime/src/System/Threading/Tasks/TaskToAsyncInfoAdapter.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACE.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/CommonObjectSecurity.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/NativeObjectSecurity.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Privilege.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/PrivilegeNotHeldException.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/SecurityDescriptor.cs
src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Win32.cs
src/libraries/System.Security.Claims/src/System/Security/Claims/ClaimsIdentity.cs
src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/ECCngKey.cs
src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/ECCurve.cs
src/libraries/System.Security.Cryptography.Cng/src/Internal/Cryptography/CngAlgorithmCore.cs
src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/CngKey.EC.cs
src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/ECDiffieHellmanCng.Key.cs
src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/ECDsaCng.Key.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CapiHelper.Windows.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/DSACryptoServiceProvider.Unix.cs
src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/DSACryptoServiceProvider.Windows.cs
src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/X500NameEncoder.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X500DistinguishedName.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509ChainPolicy.cs
src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Store.cs
src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Reference.cs
src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedInfo.cs
src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedXmlDebugLog.cs
src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/IRCollection.cs
src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/NTAccount.cs
src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/SID.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs
src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs
src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceController.cs
src/libraries/System.Text.Encoding.CodePages/src/System/Text/ISCIIEncoding.cs
src/libraries/System.Text.Encoding.CodePages/src/System/Text/SBCSCodePageEncoding.cs
src/libraries/System.Text.Json/src/System/Text/Json/ThrowHelper.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCode.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParser.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexWriter.cs
src/libraries/System.Transactions.Local/src/System/Transactions/Enlistment.cs
src/libraries/System.Transactions.Local/src/System/Transactions/EnlistmentState.cs
src/libraries/System.Transactions.Local/src/System/Transactions/InternalTransaction.cs
src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs
src/libraries/System.Transactions.Local/src/System/Transactions/TransactionState.cs
src/libraries/System.Windows.Extensions/src/System/Drawing/Printing/MarginsConverter.cs

index 01e5f46..4466d63 100644 (file)
@@ -28,8 +28,8 @@ internal static partial class Interop
                 // which should only happen if the buffer we supply isn't big
                 // enough, and we're using a buffer size that the man page
                 // says is the max for POSIX (and larger than the max for Linux).
-                Debug.Fail("getdomainname failed");
-                throw new InvalidOperationException(string.Format("getdomainname returned {0}", err));
+                Debug.Fail($"{nameof(GetDomainName)} failed with error {err}");
+                throw new InvalidOperationException($"{nameof(GetDomainName)}: {err}");
             }
 
             // Marshal.PtrToStringAnsi uses UTF8 on Unix.
index 5dfe3ad..2ba3a3a 100644 (file)
@@ -24,8 +24,8 @@ internal static partial class Interop
             if (err != 0)
             {
                 // max domain name can be 255 chars. 
-                Debug.Fail("getnodename failed");
-                throw new InvalidOperationException(string.Format("getnodename returned {0}", err));
+                Debug.Fail($"{nameof(GetNodeName)} failed with error {err}");
+                throw new InvalidOperationException($"{nameof(GetNodeName)}: {err}");
             }
 
             // Marshal.PtrToStringAnsi uses UTF8 on Unix.
index 5c079ae..5f72e26 100644 (file)
@@ -36,7 +36,7 @@ internal static partial class Interop
                 key?.Dispose();
                 Interop.Crypto.ErrClearError();
                 
-                throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, oid));
+                throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, oid));
             }
             return key;
         }
@@ -69,7 +69,7 @@ internal static partial class Interop
             }
             else
             {
-                throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
+                throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
             }
 
             SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByExplicitParameters(
index 2ac1129..b9e7c91 100644 (file)
@@ -59,7 +59,7 @@ internal static partial class Interop
             {
                 if (nidCurveName == Interop.Crypto.NID_undef)
                 {
-                    Debug.Assert(false); // Key is invalid or doesn't have a curve
+                    Debug.Fail("Key is invalid or doesn't have a curve");
                     return string.Empty;
                 }
 
index 22eb17d..66f90e2 100644 (file)
@@ -530,13 +530,13 @@ namespace System.Data.Common
                 }
                 else
                 {
-                    Debug.Assert(false, "ParseInternal code vs regex throw mismatch " + f.Message);
+                    Debug.Fail("ParseInternal code vs regex throw mismatch " + f.Message);
                 }
                 e = null;
             }
             if (null != e)
             {
-                Debug.Assert(false, "ParseInternal code threw exception vs regex mismatch");
+                Debug.Fail("ParseInternal code threw exception vs regex mismatch");
             }
         }
 #endif
index 32c7f48..fcccb94 100644 (file)
@@ -16,21 +16,23 @@ namespace System
         // could compile each module with a different setting for this. We want to make sure there's a consistent behavior
         // that doesn't depend on which native module this method got inlined into.
         [MethodImpl(MethodImplOptions.NoInlining)]
-        private static bool UsingResourceKeys()
-        {
-            return false;
-        }
+        private static bool UsingResourceKeys() => false;
 
         internal static string GetResourceString(string resourceKey, string defaultString = null)
         {
             if (UsingResourceKeys())
+            {
                 return defaultString ?? resourceKey;
+            }
 
             string resourceString = null;
-            try { resourceString = ResourceManager.GetString(resourceKey); }
+            try
+            {
+                resourceString = ResourceManager.GetString(resourceKey);
+            }
             catch (MissingManifestResourceException) { }
 
-            if (defaultString != null && resourceKey.Equals(resourceString, StringComparison.Ordinal))
+            if (defaultString != null && resourceKey.Equals(resourceString))
             {
                 return defaultString;
             }
@@ -38,13 +40,43 @@ namespace System
             return resourceString;
         }
 
+        internal static string Format(string resourceFormat, object p1)
+        {
+            if (UsingResourceKeys())
+            {
+                return string.Join(", ", resourceFormat, p1);
+            }
+
+            return string.Format(resourceFormat, p1);
+        }
+
+        internal static string Format(string resourceFormat, object p1, object p2)
+        {
+            if (UsingResourceKeys())
+            {
+                return string.Join(", ", resourceFormat, p1, p2);
+            }
+
+            return string.Format(resourceFormat, p1, p2);
+        }
+
+        internal static string Format(string resourceFormat, object p1, object p2, object p3)
+        {
+            if (UsingResourceKeys())
+            {
+                return string.Join(", ", resourceFormat, p1, p2, p3);
+            }
+
+            return string.Format(resourceFormat, p1, p2, p3);
+        }
+
         internal static string Format(string resourceFormat, params object[] args)
         {
             if (args != null)
             {
                 if (UsingResourceKeys())
                 {
-                    return resourceFormat + string.Join(", ", args);
+                    return resourceFormat + ", " + string.Join(", ", args);
                 }
 
                 return string.Format(resourceFormat, args);
@@ -53,34 +85,49 @@ namespace System
             return resourceFormat;
         }
 
-        internal static string Format(string resourceFormat, object p1)
+        internal static string Format(IFormatProvider provider, string resourceFormat, object p1)
         {
             if (UsingResourceKeys())
             {
                 return string.Join(", ", resourceFormat, p1);
             }
 
-            return string.Format(resourceFormat, p1);
+            return string.Format(provider, resourceFormat, p1);
         }
 
-        internal static string Format(string resourceFormat, object p1, object p2)
+        internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2)
         {
             if (UsingResourceKeys())
             {
                 return string.Join(", ", resourceFormat, p1, p2);
             }
 
-            return string.Format(resourceFormat, p1, p2);
+            return string.Format(provider, resourceFormat, p1, p2);
         }
 
-        internal static string Format(string resourceFormat, object p1, object p2, object p3)
+        internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3)
         {
             if (UsingResourceKeys())
             {
                 return string.Join(", ", resourceFormat, p1, p2, p3);
             }
 
-            return string.Format(resourceFormat, p1, p2, p3);
+            return string.Format(provider, resourceFormat, p1, p2, p3);
+        }
+
+        internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args)
+        {
+            if (args != null)
+            {
+                if (UsingResourceKeys())
+                {
+                    return resourceFormat + ", " + string.Join(", ", args);
+                }
+
+                return string.Format(provider, resourceFormat, args);
+            }
+
+            return resourceFormat;
         }
     }
 }
index d6c028e..141df42 100644 (file)
@@ -1075,6 +1075,7 @@ namespace System.Security.Cryptography.Asn1
             {
                 throw new AsnSerializationConstraintException(
                     SR.Format(
+                        SR.Cryptography_AsnSerializer_MultipleAsnTypeAttributes,
                         fieldInfo.Name,
                         fieldInfo.DeclaringType.FullName,
                         typeof(AsnTypeAttribute).FullName));
index 2772a47..42cff0a 100644 (file)
@@ -80,7 +80,7 @@ namespace System.Security.Cryptography
             }
             
             Debug.Fail($"Unknown curve {algorithm}");
-            throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, algorithm));
+            throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, algorithm));
         }
     }
 }
index 34f8fb7..4b7e1a8 100644 (file)
@@ -522,7 +522,7 @@ namespace System.Security.Cryptography
                 Exception e = errorCode.ToCryptographicException();
                 if (errorCode == ErrorCode.NTE_INVALID_PARAMETER)
                 {
-                    throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, curveName), e);
+                    throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, curveName), e);
                 }
                 throw e;
             }
index 7442bee..92e2827 100644 (file)
@@ -29,7 +29,7 @@ namespace System.Security.Cryptography
                     if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
                     {
                         throw new PlatformNotSupportedException(
-                            string.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
+                            SR.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
                     }
 
                     byte[] ecNamedCurveBlob = ECCng.GetNamedCurveBlob(ref parameters, ecdh: true);
@@ -38,7 +38,7 @@ namespace System.Security.Cryptography
                 else
                 {
                     throw new PlatformNotSupportedException(
-                        string.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
+                        SR.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
                 }
             }
 
index 9b164da..c229a14 100644 (file)
@@ -42,14 +42,14 @@ namespace System.Security.Cryptography
                 {
                     // FriendlyName is required; an attempt was already made to default it in ECCurve
                     if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
-                        throw new PlatformNotSupportedException(string.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value.ToString()));
+                        throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value.ToString()));
 
                     byte[] ecNamedCurveBlob = ECCng.GetNamedCurveBlob(ref parameters, ecdh: false);
                     ImportKeyBlob(ecNamedCurveBlob, curve.Oid.FriendlyName, includePrivateParameters);
                 }
                 else
                 {
-                    throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
+                    throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
                 }
             }
 
index 0c0616f..f6b4bcb 100644 (file)
@@ -34,7 +34,7 @@ namespace System.Security.Cryptography
             else
             {
                 throw new PlatformNotSupportedException(
-                    string.Format(SR.Cryptography_CurveNotSupported, parameters.Curve.CurveType.ToString()));
+                    SR.Format(SR.Cryptography_CurveNotSupported, parameters.Curve.CurveType.ToString()));
             }
 
             if (key == null || key.IsInvalid)
@@ -184,7 +184,7 @@ namespace System.Security.Cryptography
             SafeEcKeyHandle key = Interop.Crypto.EcKeyCreateByOid(oid);
 
             if (key == null || key.IsInvalid)
-                throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, oid));
+                throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, oid));
 
             if (!Interop.Crypto.EcKeyGenerateKey(key))
                 throw Interop.Crypto.CreateOpenSslCryptographicException();
index e78787d..b2e2eb4 100644 (file)
@@ -95,7 +95,7 @@ namespace System.Security.Cryptography
 
                 if (key == null || key.IsInvalid)
                 {
-                    throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, oid));
+                    throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, oid));
                 }
 
                 if (!Interop.Crypto.EcKeyGenerateKey(key))
@@ -117,7 +117,7 @@ namespace System.Security.Cryptography
             else
             {
                 throw new PlatformNotSupportedException(
-                    string.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
+                    SR.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
             }
 
             return KeySize;
index c6a40f6..a339a97 100644 (file)
@@ -194,7 +194,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors
 
                 default:
                     // means missing resources match the code entry
-                    Debug.Assert(false, "Missing resources for the error " + code.ToString());
+                    Debug.Fail("Missing resources for the error " + code.ToString());
                     codeStr = null;
                     break;
             }
index d7f9503..aa78660 100644 (file)
@@ -89,7 +89,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors
                             sym = arg.mpwiMemo.sym;
                             break;
                         default:
-                            Debug.Assert(false, "Shouldn't be here!");
+                            Debug.Fail("Shouldn't be here!");
                             continue;
                     }
 
@@ -133,7 +133,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors
                                 sym2 = arg2.mpwiMemo.sym;
                                 break;
                             default:
-                                Debug.Assert(false, "Shouldn't be here!");
+                                Debug.Fail("Shouldn't be here!");
                                 continue;
                         }
 
index ba0b90b..c68b0da 100644 (file)
@@ -61,7 +61,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors
                     id = MessageID.SK_TYVAR;
                     break;
                 default:
-                    Debug.Assert(false, "impossible sk");
+                    Debug.Fail("impossible sk");
                     id = MessageID.SK_UNKNOWN;
                     break;
             }
@@ -387,7 +387,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors
 
                 default:
                     // Shouldn't happen.
-                    Debug.Assert(false, $"Bad symbol kind: {sym.getKind()}");
+                    Debug.Fail($"Bad symbol kind: {sym.getKind()}");
                     break;
             }
         }
@@ -533,7 +533,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors
 
                 default:
                     // Shouldn't happen.
-                    Debug.Assert(false, "Bad type kind");
+                    Debug.Fail("Bad type kind");
                     break;
             }
         }
index 0cbde82..a406c6a 100644 (file)
@@ -201,7 +201,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                     break;
 
                 default:
-                    Debug.Assert(false, "Invalid Predefined Method in VisitCALL");
+                    Debug.Fail("Invalid Predefined Method in VisitCALL");
                     throw Error.InternalCompilerError();
             }
 
@@ -263,7 +263,7 @@ namespace Microsoft.CSharp.RuntimeBinder
 
             if (m == null)
             {
-                Debug.Assert(false, "How did we get a call that doesn't have a methodinfo?");
+                Debug.Fail("How did we get a call that doesn't have a methodinfo?");
                 throw Error.InternalCompilerError();
             }
 
@@ -397,7 +397,7 @@ namespace Microsoft.CSharp.RuntimeBinder
 
             if (p == null)
             {
-                Debug.Assert(false, "How did we get a prop that doesn't have a propinfo?");
+                Debug.Fail("How did we get a prop that doesn't have a propinfo?");
                 throw Error.InternalCompilerError();
             }
 
@@ -536,7 +536,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                     return Expression.SubtractChecked(arg1, arg2);
 
                 default:
-                    Debug.Assert(false, "Invalid Predefined Method in GenerateBinaryOperator");
+                    Debug.Fail("Invalid Predefined Method in GenerateBinaryOperator");
                     throw Error.InternalCompilerError();
             }
         }
@@ -612,7 +612,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                     return Expression.SubtractChecked(arg1, arg2, methodInfo);
 
                 default:
-                    Debug.Assert(false, "Invalid Predefined Method in GenerateUserDefinedBinaryOperator");
+                    Debug.Fail("Invalid Predefined Method in GenerateUserDefinedBinaryOperator");
                     throw Error.InternalCompilerError();
             }
         }
@@ -636,7 +636,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                     return Expression.NegateChecked(arg);
 
                 default:
-                    Debug.Assert(false, "Invalid Predefined Method in GenerateUnaryOperator");
+                    Debug.Fail("Invalid Predefined Method in GenerateUnaryOperator");
                     throw Error.InternalCompilerError();
             }
         }
@@ -665,7 +665,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                     return Expression.NegateChecked(arg, methodInfo);
 
                 default:
-                    Debug.Assert(false, "Invalid Predefined Method in GenerateUserDefinedUnaryOperator");
+                    Debug.Fail("Invalid Predefined Method in GenerateUserDefinedUnaryOperator");
                     throw Error.InternalCompilerError();
             }
         }
@@ -862,7 +862,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                         return GenerateUserDefinedUnaryOperator(call);
 
                     default:
-                        Debug.Assert(false, "Invalid Predefined Method in GetExpression");
+                        Debug.Fail("Invalid Predefined Method in GetExpression");
                         throw Error.InternalCompilerError();
                 }
             }
index e6dbce5..9903e5e 100644 (file)
@@ -544,7 +544,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                     mask = symbmask_t.MASK_MethodSymbol;
                     break;
                 default:
-                    Debug.Assert(false, "Unhandled kind");
+                    Debug.Fail("Unhandled kind");
                     break;
             }
 
@@ -739,7 +739,7 @@ namespace Microsoft.CSharp.RuntimeBinder
 
             if (swt.Sym.getKind() != SYMKIND.SK_MethodSymbol)
             {
-                Debug.Assert(false, "Unexpected type returned from lookup");
+                Debug.Fail("Unexpected type returned from lookup");
                 throw Error.InternalCompilerError();
             }
 
@@ -1061,7 +1061,7 @@ namespace Microsoft.CSharp.RuntimeBinder
             switch (p)
             {
                 default:
-                    Debug.Assert(false, "Unknown operator: " + p);
+                    Debug.Fail("Unknown operator: " + p);
                     throw Error.InternalCompilerError();
 
                 // Binary Operators
@@ -1222,7 +1222,7 @@ namespace Microsoft.CSharp.RuntimeBinder
                     throw Error.BindPropertyFailedEvent(name);
 
                 default:
-                    Debug.Assert(false, "Unexpected type returned from lookup");
+                    Debug.Fail("Unexpected type returned from lookup");
                     throw Error.InternalCompilerError();
             }
         }
index de077e9..d6d7eed 100644 (file)
@@ -139,7 +139,7 @@ LAgain:
                     switch (type1.TypeKind)
                     {
                         default:
-                            Debug.Assert(false, "Bad kind in CompareTypes");
+                            Debug.Fail("Bad kind in CompareTypes");
                             break;
                         case TypeKind.TK_TypeParameterType:
                             break;
index 95f374b..700af7a 100644 (file)
@@ -164,7 +164,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
 
             if (property == null)
             {
-                Debug.Assert(false, "cannot find property for accessor");
+                Debug.Fail("cannot find property for accessor");
                 return false;
             }
 
index 6686640..9c7d6da 100644 (file)
@@ -167,7 +167,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
 
                 default:
                     // Should never call this with any other kind.
-                    Debug.Assert(false, "GetAssemblyID called on bad sym kind");
+                    Debug.Fail("GetAssemblyID called on bad sym kind");
                     return null;
             }
         }
@@ -190,7 +190,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
                     return ((AggregateSymbol)this).InternalsVisibleTo(assembly);
                 default:
                     // Should never call this with any other kind.
-                    Debug.Assert(false, "InternalsVisibleTo called on bad sym kind");
+                    Debug.Fail("InternalsVisibleTo called on bad sym kind");
                     return false;
             }
         }
index 3f21c17..962e98a 100644 (file)
@@ -307,7 +307,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
             switch (typeBnd.TypeKind)
             {
                 default:
-                    Debug.Assert(false, "Unexpected type.");
+                    Debug.Fail("Unexpected type.");
                     return false;
 
                 case TypeKind.TK_VoidType:
index f041688..6aa92d4 100644 (file)
@@ -257,7 +257,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
             switch (type.TypeKind)
             {
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail("Unknown type kind");
                     return type;
 
                 case TypeKind.TK_NullType:
@@ -372,7 +372,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
             switch (typeSrc.TypeKind)
             {
                 default:
-                    Debug.Assert(false, "Bad Symbol kind in SubstEqualTypesCore");
+                    Debug.Fail("Bad Symbol kind in SubstEqualTypesCore");
                     return false;
 
                 case TypeKind.TK_NullType:
@@ -468,7 +468,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
             switch (type.TypeKind)
             {
                 default:
-                    Debug.Assert(false, "Bad Symbol kind in TypeContainsType");
+                    Debug.Fail("Bad Symbol kind in TypeContainsType");
                     return false;
 
                 case TypeKind.TK_NullType:
@@ -507,7 +507,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
             switch (type.TypeKind)
             {
                 default:
-                    Debug.Assert(false, "Bad Symbol kind in TypeContainsTyVars");
+                    Debug.Fail("Bad Symbol kind in TypeContainsTyVars");
                     return false;
 
                 case TypeKind.TK_NullType:
index 33d8d59..f430e14 100644 (file)
@@ -411,13 +411,12 @@ namespace Microsoft.Win32
             {
                 if (s_staticwndclass == null)
                 {
-                    const string classNameFormat = ".NET-BroadcastEventWindow.{0}.{1}";
-
                     IntPtr hInstance = Interop.Kernel32.GetModuleHandle(null);
 
-                    s_className = string.Format(System.Globalization.CultureInfo.InvariantCulture,
-                        classNameFormat,
-                        Convert.ToString(AppDomain.CurrentDomain.GetHashCode(), 16),
+                    s_className = string.Format(
+                        System.Globalization.CultureInfo.InvariantCulture,
+                        ".NET-BroadcastEventWindow.{0:x}.{1}",
+                        AppDomain.CurrentDomain.GetHashCode(),
                         s_domainQualifier);
 
                     Interop.User32.WNDCLASS tempwndclass = new Interop.User32.WNDCLASS();
@@ -1285,7 +1284,7 @@ namespace Microsoft.Win32
                         }
                         catch (Exception e)
                         {
-                            Debug.Assert(false, "Exception occurred while freeing memory: " + e.ToString());
+                            Debug.Fail("Exception occurred while freeing memory: " + e.ToString());
                         }
                     }
                     break;
index 7d9d7d5..d722302 100644 (file)
@@ -456,16 +456,16 @@ namespace Microsoft.XmlSerializer.Generator
 
         private void WriteHelp()
         {
-            Console.Out.WriteLine(SR.Format(SR.HelpDescription));
+            Console.Out.WriteLine(SR.HelpDescription);
             Console.Out.WriteLine(SR.Format(SR.HelpUsage, this.GetType().Assembly.GetName().Name.Substring("dotnet-".Length)));
-            Console.Out.WriteLine(SR.Format(SR.HelpDevOptions));
+            Console.Out.WriteLine(SR.HelpDevOptions);
             Console.Out.WriteLine(SR.Format(SR.HelpAssembly, "-a", "--assembly"));
             Console.Out.WriteLine(SR.Format(SR.HelpType, "--type"));
             Console.Out.WriteLine(SR.Format(SR.HelpProxy, "--proxytypes"));
             Console.Out.WriteLine(SR.Format(SR.HelpForce, "--force"));
             Console.Out.WriteLine(SR.Format(SR.HelpOut, "-o", "--out"));
 
-            Console.Out.WriteLine(SR.Format(SR.HelpMiscOptions));
+            Console.Out.WriteLine(SR.HelpMiscOptions);
             Console.Out.WriteLine(SR.Format(SR.HelpHelp, "-h", "--help"));
         }
 
index be4185a..b102ab5 100644 (file)
@@ -847,7 +847,7 @@ namespace Microsoft.CSharp
             }
             else
             {
-                throw new ArgumentException(SR.Format(SR.InvalidPrimitiveType, e.Value.GetType().ToString()));
+                throw new ArgumentException(SR.Format(SR.InvalidPrimitiveType, e.Value.GetType()));
             }
         }
 
index 38514df..046eab3 100644 (file)
@@ -1391,7 +1391,7 @@ namespace System.CodeDom.Compiler
             }
             else
             {
-                throw new ArgumentException(SR.Format(SR.InvalidPrimitiveType, e.Value.GetType().ToString()));
+                throw new ArgumentException(SR.Format(SR.InvalidPrimitiveType, e.Value.GetType()));
             }
         }
 
index 3c24c97..14d24ac 100644 (file)
@@ -78,7 +78,7 @@ namespace System.CodeDom.Compiler
             }
             else
             {
-                throw new InvalidOperationException(SR.Format(SR.Provider_does_not_support_options, CodeDomProviderType.ToString()));
+                throw new InvalidOperationException(SR.Format(SR.Provider_does_not_support_options, CodeDomProviderType));
             }
         }
 
index bf85929..e29f1f6 100644 (file)
@@ -1756,7 +1756,7 @@ nameof(collections), SR.BlockingCollection_ValidateCollectionsArray_DispElems);
             if ((totalMilliseconds < 0 || totalMilliseconds > int.MaxValue) && (totalMilliseconds != Timeout.Infinite))
             {
                 throw new ArgumentOutOfRangeException(nameof(timeout), timeout,
-                    string.Format(CultureInfo.InvariantCulture, SR.BlockingCollection_TimeoutInvalid, int.MaxValue));
+                    SR.Format(CultureInfo.InvariantCulture, SR.BlockingCollection_TimeoutInvalid, int.MaxValue));
             }
         }
 
@@ -1770,7 +1770,7 @@ nameof(collections), SR.BlockingCollection_ValidateCollectionsArray_DispElems);
             if ((millisecondsTimeout < 0) && (millisecondsTimeout != Timeout.Infinite))
             {
                 throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), millisecondsTimeout,
-                    string.Format(CultureInfo.InvariantCulture, SR.BlockingCollection_TimeoutInvalid, int.MaxValue));
+                    SR.Format(CultureInfo.InvariantCulture, SR.BlockingCollection_TimeoutInvalid, int.MaxValue));
             }
         }
 
index e36670f..d00db01 100644 (file)
@@ -157,13 +157,13 @@ namespace System.Collections.Immutable
                         case KeyCollisionBehavior.ThrowIfValueDifferent:
                             if (!valueComparer.Equals(_firstValue.Value, value))
                             {
-                                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.DuplicateKey, key));
+                                throw new ArgumentException(SR.Format(SR.DuplicateKey, key));
                             }
 
                             result = OperationResult.NoChangeRequired;
                             return this;
                         case KeyCollisionBehavior.ThrowAlways:
-                            throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.DuplicateKey, key));
+                            throw new ArgumentException(SR.Format(SR.DuplicateKey, key));
                         default:
                             throw new InvalidOperationException(); // unreachable
                     }
@@ -193,13 +193,13 @@ namespace System.Collections.Immutable
 #endif
                             if (!valueComparer.Equals(existingEntry.Value, value))
                             {
-                                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.DuplicateKey, key));
+                                throw new ArgumentException(SR.Format(SR.DuplicateKey, key));
                             }
 
                             result = OperationResult.NoChangeRequired;
                             return this;
                         case KeyCollisionBehavior.ThrowAlways:
-                            throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.DuplicateKey, key));
+                            throw new ArgumentException(SR.Format(SR.DuplicateKey, key));
                         default:
                             throw new InvalidOperationException(); // unreachable
                     }
index 500aa39..399a549 100644 (file)
@@ -728,7 +728,7 @@ namespace System.Collections.Immutable
                         }
                         else
                         {
-                            throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.DuplicateKey, key));
+                            throw new ArgumentException(SR.Format(SR.DuplicateKey, key));
                         }
                     }
 
index 558a8d4..3d75a0f 100644 (file)
@@ -922,7 +922,7 @@ namespace System.Collections.Immutable
                         {
                             if (!_valueComparer.Equals(value, item.Value))
                             {
-                                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.DuplicateKey, item.Key));
+                                throw new ArgumentException(SR.Format(SR.DuplicateKey, item.Key));
                             }
                         }
                         else
index 4a35d8e..449d4b8 100644 (file)
@@ -470,7 +470,7 @@ namespace System.Collections.Immutable
                     }
                     else
                     {
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.DuplicateKey, key));
+                        throw new ArgumentException(SR.Format(SR.DuplicateKey, key));
                     }
                 }
 
index e807f9b..eca593d 100644 (file)
@@ -155,7 +155,7 @@ namespace Microsoft.Internal
             else
             {
                 throw new InvalidOperationException(
-                    string.Format(CultureInfo.CurrentCulture, SR.InvalidMetadataValue, value.GetType().FullName));
+                    SR.Format(SR.InvalidMetadataValue, value.GetType().FullName));
             }
         }
 
index 0d42670..5c6cece 100644 (file)
@@ -20,8 +20,7 @@ namespace Microsoft.Internal
             T value = lazy.Value;
             if (value == null)
             {
-                throw new InvalidOperationException(
-                    string.Format(CultureInfo.CurrentCulture, SR.LazyServices_LazyResolvesToNull, typeof(T), argument));
+                throw new InvalidOperationException(SR.Format(SR.LazyServices_LazyResolvesToNull, typeof(T), argument));
             }
 
             return value;
index ce70225..c8da226 100644 (file)
@@ -92,7 +92,7 @@ namespace Microsoft.Internal
             if ((value & enumFlagSet) != value || // Ensure the member is in the set
                 (value & (value - 1)) != 0) // Ensure that there is only one flag in the value (i.e. value is a power of 2).
             {
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_InvalidEnumInSet, parameterName, value, enumFlagSet.ToString()), parameterName);
+                throw new ArgumentException(SR.Format(SR.ArgumentOutOfRange_InvalidEnumInSet, parameterName, value, enumFlagSet.ToString()), parameterName);
             }
             Contract.EndContractBlock();
         }
@@ -112,7 +112,7 @@ namespace Microsoft.Internal
 
             if (value.Length == 0)
             {
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ArgumentException_EmptyString, parameterName), parameterName);
+                throw new ArgumentException(SR.Format(SR.ArgumentException_EmptyString, parameterName), parameterName);
             }
         }
 
index b122e8f..d299c43 100644 (file)
@@ -66,7 +66,7 @@ namespace System.ComponentModel.Composition.AttributedModel
             var mappedType = reflectionContext.MapType(IntrospectionExtensions.GetTypeInfo(attributedPart.GetType()));
             if (mappedType.Assembly.ReflectionOnly)
             {
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Argument_ReflectionContextReturnsReflectionOnlyType, nameof(reflectionContext)), nameof(reflectionContext));
+                throw new ArgumentException(SR.Format(SR.Argument_ReflectionContextReturnsReflectionOnlyType, nameof(reflectionContext)), nameof(reflectionContext));
             }
 
             ReflectionComposablePartDefinition definition = AttributedModelDiscovery.CreatePartDefinition(mappedType, PartCreationPolicyAttribute.Shared, true, (ICompositionElement)null);
index 91b4a3c..ed24e45 100644 (file)
@@ -57,7 +57,7 @@ namespace System.ComponentModel.Composition
         {
             get
             {
-                return string.Format(CultureInfo.CurrentCulture, 
+                return SR.Format(
                     SR.CompositionException_ChangesRejected,
                     base.Message);
             }
index 7a8042b..611b8cb 100644 (file)
@@ -129,7 +129,7 @@ namespace System.ComponentModel
                 throw new ArgumentNullException(nameof(partDefinitionType));
             }
 
-            return new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidPartDefinition, partDefinitionType), parameterName);
+            return new ArgumentException(SR.Format(SR.ReflectionModel_InvalidPartDefinition, partDefinitionType), parameterName);
         }
 
         public static ArgumentException ExportFactory_TooManyGenericParameters(string typeName)
index 8bcc93f..6e79d0c 100644 (file)
@@ -155,7 +155,7 @@ namespace System.ComponentModel.Composition
             bool succeeded = ContractServices.TryCast(typeof(T), exportedValue, out typedExportedValue);
             if (!succeeded)
             {
-                throw new CompositionContractMismatchException(string.Format(CultureInfo.CurrentCulture,
+                throw new CompositionContractMismatchException(SR.Format(
                     SR.ContractMismatch_ExportedValueCannotBeCastToT,
                     element.DisplayName,
                     typeof(T)));
index 588a968..ebbbf74 100644 (file)
@@ -392,7 +392,7 @@ namespace System.ComponentModel.Composition.Hosting
         {
             if (assembly.ReflectionOnly)
             {
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Argument_AssemblyReflectionOnly, nameof(assembly)), nameof(assembly));
+                throw new ArgumentException(SR.Format(SR.Argument_AssemblyReflectionOnly, nameof(assembly)), nameof(assembly));
             }
             _assembly = assembly;
         }
index 4fb21a2..a4f9fb9 100644 (file)
@@ -909,7 +909,7 @@ namespace System.ComponentModel.Composition.Hosting
         {
             if ((_sourceProvider == null) || (_importEngine == null))
             {
-                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.ObjectMustBeInitialized, "SourceProvider")); // NOLOC
+                throw new InvalidOperationException(SR.Format(SR.ObjectMustBeInitialized, "SourceProvider")); // NOLOC
             }
         }
 
@@ -940,7 +940,7 @@ namespace System.ComponentModel.Composition.Hosting
         {
             if ((_isRunning) || (currentValue != null))
             {
-                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.ObjectAlreadyInitialized));
+                throw new InvalidOperationException(SR.ObjectAlreadyInitialized);
             }
         }
 
index 5ae073b..e37d990 100644 (file)
@@ -418,7 +418,7 @@ namespace System.ComponentModel.Composition.Hosting
         {
             if (_sourceProvider == null)
             {
-                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.ObjectMustBeInitialized, "SourceProvider")); // NOLOC
+                throw new InvalidOperationException(SR.Format(SR.ObjectMustBeInitialized, "SourceProvider")); // NOLOC
             }
         }
 
@@ -444,7 +444,7 @@ namespace System.ComponentModel.Composition.Hosting
         {
             if ((_isRunning) || (currentValue != null))
             {
-                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.ObjectAlreadyInitialized));
+                throw new InvalidOperationException(SR.ObjectAlreadyInitialized);
             }
         }
     }
index 47ff7dd..69f2cdf 100644 (file)
@@ -793,7 +793,7 @@ namespace System.ComponentModel.Composition.Hosting
 
             if (!MetadataViewProvider.IsViewTypeValid(metadataViewType))
             {
-                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.InvalidMetadataView, metadataViewType.Name));
+                throw new InvalidOperationException(SR.Format(SR.InvalidMetadataView, metadataViewType.Name));
             }
 
             ImportDefinition importDefinition = BuildImportDefinition(type, metadataViewType, contractName, cardinality);
index 0ee867b..c85374f 100644 (file)
@@ -106,13 +106,13 @@ namespace System.ComponentModel.Composition.Hosting
                 case ExportCardinalityCheckResult.Match:
                     return exports;
                 case ExportCardinalityCheckResult.NoExports:
-                    throw new ImportCardinalityMismatchException(string.Format(CultureInfo.CurrentCulture, SR.CardinalityMismatch_NoExports, definition.ToString()));
+                    throw new ImportCardinalityMismatchException(SR.Format(SR.CardinalityMismatch_NoExports, definition));
                 default:
                     if (result != ExportCardinalityCheckResult.TooManyExports)
                     {
                         throw new Exception(SR.Diagnostic_InternalExceptionMessage);
                     }
-                    throw new ImportCardinalityMismatchException(string.Format(CultureInfo.CurrentCulture, SR.CardinalityMismatch_TooManyExports_Constraint, definition.ToString()));
+                    throw new ImportCardinalityMismatchException(SR.Format(SR.CardinalityMismatch_TooManyExports_Constraint, definition));
             }
         }
 
index fe3c2cc..382d646 100644 (file)
@@ -183,7 +183,7 @@ namespace System.ComponentModel.Composition.Hosting
                 }
                 if (type.Assembly.ReflectionOnly)
                 {
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Argument_ElementReflectionOnlyType, nameof(types)), nameof(types));
+                    throw new ArgumentException(SR.Format(SR.Argument_ElementReflectionOnlyType, nameof(types)), nameof(types));
                 }
                 var typeInfo = type.GetTypeInfo();
                 var lclType = (reflectionContext != null) ? reflectionContext.MapType(typeInfo) : typeInfo;
@@ -194,7 +194,7 @@ namespace System.ComponentModel.Composition.Hosting
                     // The final mapped type may be activated so we check to see if it is in a reflect only assembly
                     if (lclType.Assembly.ReflectionOnly)
                     {
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Argument_ReflectionContextReturnsReflectionOnlyType, nameof(reflectionContext)), nameof(reflectionContext));
+                        throw new ArgumentException(SR.Format(SR.Argument_ReflectionContextReturnsReflectionOnlyType, nameof(reflectionContext)), nameof(reflectionContext));
                     }
                     typesList.Add(lclType);
                 }
@@ -212,7 +212,7 @@ namespace System.ComponentModel.Composition.Hosting
                 }
                 else if (type.Assembly.ReflectionOnly)
                 {
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Argument_ElementReflectionOnlyType, nameof(types)), nameof(types));
+                    throw new ArgumentException(SR.Format(SR.Argument_ElementReflectionOnlyType, nameof(types)), nameof(types));
                 }
             }
             _types = types.ToArray();
@@ -360,7 +360,7 @@ namespace System.ComponentModel.Composition.Hosting
 
         private string GetDisplayName()
         {
-            return string.Format(CultureInfo.CurrentCulture,
+            return SR.Format(
                                 SR.TypeCatalog_DisplayNameFormat,
                                 GetType().Name,
                                 GetTypesDisplay());
index f19f6e4..020b145 100644 (file)
@@ -218,7 +218,7 @@ namespace System.ComponentModel.Composition
                 string fieldName = string.Format(CultureInfo.InvariantCulture, "_{0}_{1}", propertyInfo.Name, Guid.NewGuid());
 
                 // Cache names and type for exception
-                string propertyName = string.Format(CultureInfo.InvariantCulture, "{0}", propertyInfo.Name);
+                string propertyName = propertyInfo.Name;
 
                 Type[] propertyTypeArguments = new Type[] { propertyInfo.PropertyType };
                 Type[] optionalModifiers = null;
@@ -312,7 +312,7 @@ namespace System.ComponentModel.Composition
                 if (propertyInfo.CanWrite)
                 {
                     // The MetadataView '{0}' is invalid because property '{1}' has a property set method.
-                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture,
+                    throw new NotSupportedException(SR.Format(
                         SR.InvalidSetterOnMetadataField,
                         viewType,
                         propertyName));
@@ -321,7 +321,7 @@ namespace System.ComponentModel.Composition
                 {
                     // Generate "get" method implementation.
                     MethodBuilder getMethodBuilder = proxyTypeBuilder.DefineMethod(
-                        string.Format(CultureInfo.InvariantCulture, "get_{0}", propertyName),
+                        "get_" + propertyName,
                         MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.NewSlot | MethodAttributes.Virtual | MethodAttributes.Final,
                         CallingConventions.HasThis,
                         propertyInfo.PropertyType,
index a98277b..c052ed9 100644 (file)
@@ -42,7 +42,7 @@ namespace System.ComponentModel.Composition
                         }
                         catch (TypeLoadException ex)
                         {
-                            throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, SR.NotSupportedInterfaceMetadataView, metadataViewType.FullName), ex);
+                            throw new NotSupportedException(SR.Format(SR.NotSupportedInterfaceMetadataView, metadataViewType.FullName), ex);
                         }
                     }
                     else
@@ -51,7 +51,7 @@ namespace System.ComponentModel.Composition
                         proxyType = implementationAttribute.ImplementationType;
                         if(proxyType == null)
                         {
-                            throw new CompositionContractMismatchException(string.Format(CultureInfo.CurrentCulture, 
+                            throw new CompositionContractMismatchException(SR.Format(
                                 SR.ContractMismatch_MetadataViewImplementationCanNotBeNull,
                                 metadataViewType.FullName,
                                 proxyType.FullName));
@@ -60,7 +60,7 @@ namespace System.ComponentModel.Composition
                         {
                             if(!metadataViewType.IsAssignableFrom(proxyType))
                             {
-                                throw new CompositionContractMismatchException(string.Format(CultureInfo.CurrentCulture, 
+                                throw new CompositionContractMismatchException(SR.Format(
                                     SR.ContractMismatch_MetadataViewImplementationDoesNotImplementViewInterface,
                                     metadataViewType.FullName,
                                     proxyType.FullName));
@@ -92,7 +92,7 @@ namespace System.ComponentModel.Composition
                 catch (MissingMethodException ex)
                 {
                     // Unable to create an Instance of the Metadata view '{0}' because a constructor could not be selected.  Ensure that the type implements a constructor which takes an argument of type IDictionary<string, object>.
-                    throw new CompositionContractMismatchException(string.Format(CultureInfo.CurrentCulture,
+                    throw new CompositionContractMismatchException(SR.Format(
                         SR.CompositionException_MetadataViewInvalidConstructor,
                         proxyType.AssemblyQualifiedName), ex);
                 }
@@ -104,7 +104,7 @@ namespace System.ComponentModel.Composition
                         if(ex.InnerException.GetType() == typeof(InvalidCastException))
                         {
                             // Unable to create an Instance of the Metadata view {0} because the exporter exported the metadata for the item {1} with the value {2} as type {3} but the view imports it as type {4}.
-                            throw new CompositionContractMismatchException(string.Format(CultureInfo.CurrentCulture, 
+                            throw new CompositionContractMismatchException(SR.Format(
                                 SR.ContractMismatch_InvalidCastOnMetadataField,
                                 ex.InnerException.Data[MetadataViewGenerator.MetadataViewType],
                                 ex.InnerException.Data[MetadataViewGenerator.MetadataItemKey],
@@ -115,7 +115,7 @@ namespace System.ComponentModel.Composition
                         else if (ex.InnerException.GetType() == typeof(NullReferenceException))
                         {
                             // Unable to create an Instance of the Metadata view {0} because the exporter exported the metadata for the item {1} with a null value and null is not a valid value for type {2}.
-                            throw new CompositionContractMismatchException(string.Format(CultureInfo.CurrentCulture,
+                            throw new CompositionContractMismatchException(SR.Format(
                                 SR.ContractMismatch_NullReferenceOnMetadataField,
                                 ex.InnerException.Data[MetadataViewGenerator.MetadataViewType],
                                 ex.InnerException.Data[MetadataViewGenerator.MetadataItemKey],
index 587629c..78f1884 100644 (file)
@@ -230,7 +230,7 @@ namespace System.ComponentModel.Composition.Primitives
                     if ((metadataItem.Key == null) || (metadataItem.Value == null))
                     {
                         throw new InvalidOperationException(
-                            string.Format(CultureInfo.CurrentCulture, SR.Argument_NullElement, "requiredMetadata"));
+                            SR.Format(SR.Argument_NullElement, "requiredMetadata"));
                     }
                 }
                 _isRequiredMetadataValidated = true;
@@ -385,7 +385,7 @@ namespace System.ComponentModel.Composition.Primitives
 
             if(_requiredMetadata.Count() > 0)
             {
-                sb.Append(string.Format("\n\tRequiredMetadata"));
+                sb.Append("\n\tRequiredMetadata");
                 foreach (KeyValuePair<string, Type> metadataItem in _requiredMetadata)
                 {
                     sb.Append(string.Format("\n\t\t{0}\t({1})", metadataItem.Key, metadataItem.Value));
index b4d25e8..63d1bc9 100644 (file)
@@ -105,7 +105,7 @@ namespace System.ComponentModel.Composition.Primitives
                 (cardinality != ImportCardinality.ZeroOrOne)
                 )
             {
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_InvalidEnum, nameof(cardinality), cardinality, typeof(ImportCardinality).Name), nameof(cardinality));
+                throw new ArgumentException(SR.Format(SR.ArgumentOutOfRange_InvalidEnum, nameof(cardinality), cardinality, typeof(ImportCardinality).Name), nameof(cardinality));
             }
 
             _contractName = contractName ?? EmptyContractName;
index fec4f25..bb20799 100644 (file)
@@ -59,7 +59,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     // we'll add some context and rethrow.
 
                     throw new ComposablePartException(
-                        string.Format(CultureInfo.CurrentCulture,
+                        SR.Format(
                             SR.ReflectionModel_ExportThrewException,
                             _member.GetDisplayName()),
                         Definition.ToElement(),
@@ -71,7 +71,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     // this is not supported in MEF currently.  Ideally we would validate against it, however, we already shipped
                     // so we will turn it into a ComposablePartException instead, that they should already be prepared for
                     throw new ComposablePartException(
-                        string.Format(CultureInfo.CurrentCulture,
+                        SR.Format(
                         SR.ExportNotValidOnIndexers,
                         _member.GetDisplayName()),
                         Definition.ToElement(),
@@ -99,7 +99,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             {   // Property does not have a getter
 
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture, 
+                    SR.Format(
                         SR.ReflectionModel_ExportNotReadable,
                         _member.GetDisplayName()),
                     Definition.ToElement());
index 4f85335..f8a5dc7 100644 (file)
@@ -107,7 +107,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (!ContractServices.TryCast(type, value, out result))
             {
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ReflectionModel_ImportNotAssignableFromExport,
                         export.ToElement().DisplayName,
                         type.FullName),
index d7a5d68..ccbf278 100644 (file)
@@ -72,7 +72,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                 // leak out as a 'raw' unhandled exception, instead,
                 // we'll add some context and rethrow.
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ReflectionModel_ImportThrewException,
                         _member.GetDisplayName()),
                     Definition.ToElement(),
@@ -84,7 +84,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                 // this is not supported in MEF currently.  Ideally we would validate against it, however, we already shipped
                 // so we will turn it into a ComposablePartException instead, that they should already be prepared for
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ImportNotValidOnIndexers,
                         _member.GetDisplayName()),
                     Definition.ToElement(),
@@ -99,7 +99,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                 // field is marked as read-only.
 
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ReflectionModel_ImportNotWritable,
                         _member.GetDisplayName()),
                         Definition.ToElement());
@@ -142,7 +142,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                 catch (TargetInvocationException exception)
                 {
                     throw new ComposablePartException(
-                        string.Format(CultureInfo.CurrentCulture,
+                        SR.Format(
                             SR.ReflectionModel_ImportCollectionGetThrewException,
                             _member.GetDisplayName()),
                         Definition.ToElement(),
@@ -164,7 +164,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     catch (TargetInvocationException exception)
                     {
                         throw new ComposablePartException(
-                            string.Format(CultureInfo.CurrentCulture,
+                            SR.Format(
                                 SR.ReflectionModel_ImportCollectionConstructionThrewException,
                                 _member.GetDisplayName(),
                                 ImportType.ActualType.FullName),
@@ -179,7 +179,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (collectionObject == null)
             {
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ReflectionModel_ImportCollectionNull,
                         _member.GetDisplayName()),
                     Definition.ToElement());
@@ -203,7 +203,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             catch (Exception exception)
             {
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ReflectionModel_ImportCollectionIsReadOnlyThrewException,
                         _member.GetDisplayName(),
                         collection.GetType().FullName),
@@ -214,7 +214,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (isReadOnly)
             {
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ReflectionModel_ImportCollectionNotWritable,
                         _member.GetDisplayName()),
                     Definition.ToElement());
@@ -241,7 +241,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             catch (Exception exception)
             {
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ReflectionModel_ImportCollectionClearThrewException,
                         _member.GetDisplayName(),
                         collection.GetType().FullName),
@@ -258,7 +258,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                 catch (Exception exception)
                 {
                     throw new ComposablePartException(
-                        string.Format(CultureInfo.CurrentCulture,
+                        SR.Format(
                             SR.ReflectionModel_ImportCollectionAddThrewException,
                             _member.GetDisplayName(),
                             collection.GetType().FullName),
index 4ffdc8e..d97bdc7 100644 (file)
@@ -199,7 +199,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                         (accessors.Length != 1) ||
                         ((accessors.Length == 1) && (accessors[0].MemberType != memberType)))
                     {
-                        errorMessage = string.Format(CultureInfo.CurrentCulture, SR.LazyMemberInfo_InvalidAccessorOnSimpleMember, memberType);
+                        errorMessage = SR.Format(SR.LazyMemberInfo_InvalidAccessorOnSimpleMember, memberType);
                         return false;
                     }
                    
index d35e2f4..a66f880 100644 (file)
@@ -48,11 +48,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public override string ToString()
         {
-            StringBuilder sb = new StringBuilder();
-            
-            sb.Append(string.Format("\n\tExportFactory of: {0}", ProductImportDefinition.ToString()));
-            
-            return sb.ToString();
+            return "\n\tExportFactory of: " + ProductImportDefinition.ToString();
         }
     }
 }
index 8a27db6..e7b94be 100644 (file)
@@ -48,11 +48,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
         public override string ToString()
         {
-            StringBuilder sb = new StringBuilder();
-            
-            sb.Append(string.Format("\n\tExportFactory of: {0}", ProductImportDefinition.ToString()));
-            
-            return sb.ToString();
+            return "\n\tExportFactory of: " + ProductImportDefinition.ToString();
         }
 
     }
index a6c6079..5518b98 100644 (file)
@@ -273,7 +273,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     if (constructor == null)
                     {
                         throw new ComposablePartException(
-                            string.Format(CultureInfo.CurrentCulture,
+                            SR.Format(
                                 SR.ReflectionModel_PartConstructorMissing,
                                 Definition.GetPartType().FullName),
                             Definition.ToElement());
@@ -321,7 +321,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     if (definition.Cardinality == ImportCardinality.ZeroOrMore && !import.ImportType.IsAssignableCollectionType)
                     {
                         throw new ComposablePartException(
-                            string.Format(CultureInfo.CurrentCulture,
+                            SR.Format(
                                 SR.ReflectionModel_ImportManyOnParameterCanOnlyBeAssigned,
                                 Definition.GetPartType().FullName,
                                 definition.ImportingLazyParameter.Value.Name),
@@ -370,7 +370,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             {
                 if (_importValues == null || !ImportValues.ContainsKey(definition))
                 {
-                    throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
+                    throw new InvalidOperationException(SR.Format(
                                                             SR.InvalidOperation_GetExportedValueBeforePrereqImportSet,
                                                             definition.ToElement().DisplayName));
                 }
@@ -432,7 +432,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (exception != null)
             {
                 throw new ComposablePartException(
-                    string.Format(CultureInfo.CurrentCulture,
+                    SR.Format(
                         SR.ReflectionModel_PartConstructorThrewException,
                         Definition.GetPartType().FullName),
                     Definition.ToElement(),
@@ -547,7 +547,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
                     catch (Exception exception)
                     {
                         throw new ComposablePartException(
-                            string.Format(CultureInfo.CurrentCulture,
+                            SR.Format(
                                 SR.ReflectionModel_PartOnImportsSatisfiedThrewException,
                                 Definition.GetPartType().FullName),
                             Definition.ToElement(),
index 45c5dc5..a99406b 100644 (file)
@@ -50,7 +50,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (reflectionExportDefinition == null)
             {
                 throw new ArgumentException(
-                    string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidExportDefinition, exportDefinition.GetType()),
+                    SR.Format(SR.ReflectionModel_InvalidExportDefinition, exportDefinition.GetType()),
                     nameof(exportDefinition));
             }
 
@@ -65,7 +65,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (reflectionMemberImportDefinition == null)
             {
                 throw new ArgumentException(
-                    string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidMemberImportDefinition, importDefinition.GetType()),
+                    SR.Format(SR.ReflectionModel_InvalidMemberImportDefinition, importDefinition.GetType()),
                     nameof(importDefinition));
             }
 
@@ -81,7 +81,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (reflectionParameterImportDefinition == null)
             {
                 throw new ArgumentException(
-                    string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidParameterImportDefinition, importDefinition.GetType()),
+                    SR.Format(SR.ReflectionModel_InvalidParameterImportDefinition, importDefinition.GetType()),
                     nameof(importDefinition));
             }
 
@@ -96,7 +96,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (reflectionImportDefinition == null)
             {
                 throw new ArgumentException(
-                    string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidImportDefinition, importDefinition.GetType()),
+                    SR.Format(SR.ReflectionModel_InvalidImportDefinition, importDefinition.GetType()),
                     nameof(importDefinition));
             }
 
@@ -119,7 +119,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
             if (partCreatorImportDefinition == null)
             {
                 throw new ArgumentException(
-                    string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidImportDefinition, importDefinition.GetType()),
+                    SR.Format(SR.ReflectionModel_InvalidImportDefinition, importDefinition.GetType()),
                     nameof(importDefinition));
             }
 
@@ -434,7 +434,7 @@ internal class ReflectionPartCreationInfo : IReflectionPartCreationInfo
                 if (reflectionExport == null)
                 {
                     throw new InvalidOperationException(
-                        string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidExportDefinition, export.GetType()));
+                        SR.Format(SR.ReflectionModel_InvalidExportDefinition, export.GetType()));
                 }
                 yield return reflectionExport;
             }
@@ -460,7 +460,7 @@ internal class ReflectionPartCreationInfo : IReflectionPartCreationInfo
                 if (reflectionImport == null)
                 {
                     throw new InvalidOperationException(
-                        string.Format(CultureInfo.CurrentCulture, SR.ReflectionModel_InvalidMemberImportDefinition, import.GetType()));
+                        SR.Format(SR.ReflectionModel_InvalidMemberImportDefinition, import.GetType()));
                 }
                 yield return reflectionImport;
             }
index c71ebdb..b4eb2ed 100644 (file)
@@ -48,7 +48,7 @@ namespace System.ComponentModel.Design
 
             if (name.Length == 0)
             {
-                throw new ArgumentException(SR.Format(SR.InvalidArgumentValue, name.Length.ToString(CultureInfo.CurrentCulture), (0).ToString(CultureInfo.CurrentCulture)), "name.Length");
+                throw new ArgumentException(SR.Format(SR.InvalidArgumentValue, name.Length.ToString(), "0"), "name.Length");
             }
 
             return new DesignerOptionCollection(this, parent, name, value);
index 48216c9..a7b19a4 100644 (file)
@@ -54,7 +54,7 @@ namespace System.ComponentModel
             _tabClasses = new Type[] { tabClass };
             if (tabScope < PropertyTabScope.Document)
             {
-                throw new ArgumentException(SR.Format(SR.PropertyTabAttributeBadPropertyTabScope), nameof(tabScope));
+                throw new ArgumentException(SR.PropertyTabAttributeBadPropertyTabScope, nameof(tabScope));
             }
             TabScopes = new PropertyTabScope[] { tabScope };
         }
@@ -68,7 +68,7 @@ namespace System.ComponentModel
             _tabClassNames = new string[] { tabClassName };
             if (tabScope < PropertyTabScope.Document)
             {
-                throw new ArgumentException(SR.Format(SR.PropertyTabAttributeBadPropertyTabScope), nameof(tabScope));
+                throw new ArgumentException(SR.PropertyTabAttributeBadPropertyTabScope, nameof(tabScope));
             }
             TabScopes = new PropertyTabScope[] { tabScope };
         }
index 2ea119b..1f8fe3e 100644 (file)
@@ -129,7 +129,7 @@ namespace System.ComponentModel
                 // the enum isn't a flags style.
                 if (!EnumType.IsDefined(typeof(FlagsAttribute), false) && !Enum.IsDefined(EnumType, value))
                 {
-                    throw new ArgumentException(SR.Format(SR.EnumConverterInvalidValue, value.ToString(), EnumType.Name));
+                    throw new ArgumentException(SR.Format(SR.EnumConverterInvalidValue, value, EnumType.Name));
                 }
 
                 return Enum.Format(EnumType, value, "G");
index 196a87a..fa1ef2d 100644 (file)
@@ -100,7 +100,7 @@ namespace System.ComponentModel
                     string providerName = site?.Name;
                     if (providerName != null && providerName.Length > 0)
                     {
-                        name = string.Format(SR.MetaExtenderName, name, providerName);
+                        name = SR.Format(SR.MetaExtenderName, name, providerName);
                     }
                 }
                 return name;
index 407e1e9..6583455 100644 (file)
@@ -35,7 +35,7 @@ namespace System.ComponentModel
         protected virtual string GetKey(Type type)
         {
             // This string should not be localized.
-            return string.Format(CultureInfo.InvariantCulture, "{0} is a licensed component.", type.FullName);
+            return type.FullName + " is a licensed component.";
         }
 
         /// <summary>
index 529ec39..053afa0 100644 (file)
@@ -228,7 +228,7 @@ namespace System.ComponentModel
         {
             if (string.IsNullOrEmpty(mask))
             {
-                throw new ArgumentException(SR.Format(SR.MaskedTextProviderMaskNullOrEmpty), nameof(mask));
+                throw new ArgumentException(SR.MaskedTextProviderMaskNullOrEmpty, nameof(mask));
             }
 
             foreach (char c in mask)
index 8daaede..60236d5 100644 (file)
@@ -147,7 +147,7 @@ namespace System.ComponentModel
                         string childName = _name;
                         if (ownerName != null)
                         {
-                            childName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", ownerName, childName);
+                            childName = ownerName + "." + childName;
                         }
 
                         return childName;
index 31eaf9e..ec06ef4 100644 (file)
@@ -88,12 +88,12 @@ namespace System.ComponentModel
                 if (type == null)
                 {
                     Debug.WriteLine($"type == null, name == {name}");
-                    throw new ArgumentException(string.Format(SR.ErrorInvalidPropertyType, name));
+                    throw new ArgumentException(SR.Format(SR.ErrorInvalidPropertyType, name));
                 }
                 if (componentClass == null)
                 {
                     Debug.WriteLine($"componentClass == null, name == {name}");
-                    throw new ArgumentException(string.Format(SR.InvalidNullArgument, nameof(componentClass)));
+                    throw new ArgumentException(SR.Format(SR.InvalidNullArgument, nameof(componentClass)));
                 }
                 _type = type;
                 _componentClass = componentClass;
@@ -143,7 +143,7 @@ namespace System.ComponentModel
 
             if (componentClass == null)
             {
-                throw new ArgumentException(string.Format(SR.InvalidNullArgument, nameof(componentClass)));
+                throw new ArgumentException(SR.Format(SR.InvalidNullArgument, nameof(componentClass)));
             }
 
             // If the classes are the same, we can potentially optimize the method fetch because
@@ -224,7 +224,7 @@ namespace System.ComponentModel
             {
                 if (!_state[s_bitChangedQueried])
                 {
-                    _realChangedEvent = TypeDescriptor.GetEvents(ComponentType)[string.Format(CultureInfo.InvariantCulture, "{0}Changed", Name)];
+                    _realChangedEvent = TypeDescriptor.GetEvents(ComponentType)[Name + "Changed"];
                     _state[s_bitChangedQueried] = true;
                 }
 
@@ -317,7 +317,7 @@ namespace System.ComponentModel
                         }
                         if (_getMethod == null)
                         {
-                            throw new InvalidOperationException(string.Format(SR.ErrorMissingPropertyAccessors, _componentClass.FullName + "." + Name));
+                            throw new InvalidOperationException(SR.Format(SR.ErrorMissingPropertyAccessors, _componentClass.FullName + "." + Name));
                         }
                     }
                     else
@@ -325,7 +325,7 @@ namespace System.ComponentModel
                         _getMethod = FindMethod(_componentClass, "Get" + Name, new Type[] { _receiverType }, _type);
                         if (_getMethod == null)
                         {
-                            throw new ArgumentException(string.Format(SR.ErrorMissingPropertyAccessors, Name));
+                            throw new ArgumentException(SR.Format(SR.ErrorMissingPropertyAccessors, Name));
                         }
                     }
                     _state[s_bitGetQueried] = true;
@@ -925,7 +925,7 @@ namespace System.ComponentModel
 
                     string message = t.Message ?? t.GetType().Name;
 
-                    throw new TargetInvocationException(string.Format(SR.ErrorPropertyAccessorException, Name, name, message), t);
+                    throw new TargetInvocationException(SR.Format(SR.ErrorPropertyAccessorException, Name, name, message), t);
                 }
             }
             Debug.WriteLine("[" + Name + "]:   ---> returning: null");
index 254d9c3..6e9d2dd 100644 (file)
@@ -1159,7 +1159,7 @@ namespace System.ComponentModel
                     name = ci.ToString(CultureInfo.InvariantCulture);
                 }
 
-                suffix = string.Format(CultureInfo.InvariantCulture, "_{0}", name);
+                suffix = "_" + name;
             }
 
             return suffix;
index 57f088c..0cc593a 100644 (file)
@@ -117,7 +117,7 @@ namespace System.Drawing
 
             if (x == null || y == null || !(x is int) || !(y is int))
             {
-                throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry));
+                throw new ArgumentException(SR.PropertyValueInvalidEntry);
             }
 
             return new Point((int)x, (int)y);
index ab6eabb..97b8970 100644 (file)
@@ -123,7 +123,7 @@ namespace System.Drawing
             if (x == null || y == null || width == null || height == null ||
                 !(x is int) || !(y is int) || !(width is int) || !(height is int))
             {
-                throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry));
+                throw new ArgumentException(SR.PropertyValueInvalidEntry);
             }
 
             return new Rectangle((int)x, (int)y, (int)width, (int)height);
index ffb5cde..6d4f3ae 100644 (file)
@@ -115,7 +115,7 @@ namespace System.Drawing
 
             if (width == null || height == null || !(width is int) || !(height is int))
             {
-                throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry));
+                throw new ArgumentException(SR.PropertyValueInvalidEntry);
             }
 
             return new Size((int)width, (int)height);
index 1f7390e..d2c3efc 100644 (file)
@@ -112,7 +112,7 @@ namespace System.Drawing
 
             if (width == null || height == null || !(width is float) || !(height is float))
             {
-                throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry));
+                throw new ArgumentException(SR.PropertyValueInvalidEntry);
             }
 
             return new SizeF((float)width, (float)height);
index 233e263..3db0db0 100644 (file)
@@ -48,7 +48,7 @@ namespace System.Composition.Hosting.Core
             // cardinality violations in advance of this in all but a few very rare scenarios.
             if (allForExport.Length != 1)
             {
-                var ex = new CompositionFailedException(SR.Format(SR.CardinalityMismatch_TooManyExports, exportKey.ToString()));
+                var ex = new CompositionFailedException(SR.Format(SR.CardinalityMismatch_TooManyExports, exportKey));
                 Debug.WriteLine(SR.Diagnostic_ThrowingException, ex.ToString());
                 throw ex;
             }
index 3294cc9..5b8c44d 100644 (file)
@@ -230,7 +230,7 @@ namespace System.Composition.TypedParts.Discovery
             }
             else if (!contractType.IsAssignableFrom(partType))
             {
-                string message = string.Format(SR.TypeInspector_ContractNotAssignable, contractType.Name, partType.Name);
+                string message = SR.Format(SR.TypeInspector_ContractNotAssignable, contractType.Name, partType.Name);
                 throw new CompositionFailedException(message);
             }
         }
index e717a90..5dc0a72 100644 (file)
@@ -37,7 +37,7 @@ namespace System.Configuration
 
             string val = _map[key];
 
-            if (val == null) throw new InvalidOperationException(string.Format(SR.AppSettingsReaderNoKey, key));
+            if (val == null) throw new InvalidOperationException(SR.Format(SR.AppSettingsReaderNoKey, key));
 
             if (type == s_stringType)
             {
@@ -71,7 +71,7 @@ namespace System.Configuration
                 catch (Exception)
                 {
                     string displayString = (val.Length == 0) ? SR.AppSettingsReaderEmptyString : val;
-                    throw new InvalidOperationException(string.Format(SR.AppSettingsReaderCantParse, displayString, key, type.ToString()));
+                    throw new InvalidOperationException(SR.Format(SR.AppSettingsReaderCantParse, displayString, key, type));
                 }
             }
         }
index 09fac32..b142a94 100644 (file)
@@ -111,7 +111,7 @@ namespace System.Configuration
             {
                 if (xmlUtil.Reader.Name != elementName)
                     throw new ConfigurationErrorsException(
-                        string.Format(SR.Config_name_value_file_section_file_invalid_root, elementName),
+                        SR.Format(SR.Config_name_value_file_section_file_invalid_root, elementName),
                         xmlUtil);
 
                 lineOffset = xmlUtil.Reader.LineNumber;
@@ -133,7 +133,7 @@ namespace System.Configuration
 
             if (internalReader.MoveToNextAttribute())
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Config_base_unrecognized_attribute, internalReader.Name),
+                    SR.Format(SR.Config_base_unrecognized_attribute, internalReader.Name),
                     (XmlReader)internalReader);
 
             internalReader.MoveToElement();
@@ -141,4 +141,4 @@ namespace System.Configuration
             base.DeserializeElement(internalReader, serializeCollectionKey);
         }
     }
-}
\ No newline at end of file
+}
index 10ae363..d4533b2 100644 (file)
@@ -483,14 +483,14 @@ namespace System.Configuration
                     Type providerType = Type.GetType(providerTypeName);
                     if (providerType == null)
                     {
-                        throw new ConfigurationErrorsException(string.Format(SR.ProviderTypeLoadFailed, providerTypeName));
+                        throw new ConfigurationErrorsException(SR.Format(SR.ProviderTypeLoadFailed, providerTypeName));
                     }
 
                     SettingsProvider settingsProvider = TypeUtil.CreateInstance(providerType) as SettingsProvider;
 
                     if (settingsProvider == null)
                     {
-                        throw new ConfigurationErrorsException(string.Format(SR.ProviderInstantiationFailed, providerTypeName));
+                        throw new ConfigurationErrorsException(SR.Format(SR.ProviderInstantiationFailed, providerTypeName));
                     }
 
                     settingsProvider.Initialize(null, null);
@@ -649,12 +649,12 @@ namespace System.Configuration
                                         }
                                         else
                                         {
-                                            throw new ConfigurationErrorsException(string.Format(SR.ProviderInstantiationFailed, providerTypeName));
+                                            throw new ConfigurationErrorsException(SR.Format(SR.ProviderInstantiationFailed, providerTypeName));
                                         }
                                     }
                                     else
                                     {
-                                        throw new ConfigurationErrorsException(string.Format(SR.ProviderTypeLoadFailed, providerTypeName));
+                                        throw new ConfigurationErrorsException(SR.Format(SR.ProviderTypeLoadFailed, providerTypeName));
                                     }
                                 }
                                 else if (attr is SettingsSerializeAsAttribute)
index 0d41f9f..9e772e6 100644 (file)
@@ -1353,7 +1353,7 @@ namespace System.Configuration
             catch (Exception e)
             {
                 throw ExceptionUtil.WrapAsConfigException(
-                    string.Format(SR.Config_exception_creating_section, factoryRecord.ConfigKey),
+                    SR.Format(SR.Config_exception_creating_section, factoryRecord.ConfigKey),
                     e, input.SectionXmlInfo);
             }
 
@@ -1496,7 +1496,7 @@ namespace System.Configuration
                 if (stream == null)
                 {
                     throw new ConfigurationErrorsException(
-                        string.Format(SR.Config_cannot_open_config_source, sectionXmlInfo.ConfigSource),
+                        SR.Format(SR.Config_cannot_open_config_source, sectionXmlInfo.ConfigSource),
                         sectionXmlInfo);
                 }
 
@@ -1598,7 +1598,7 @@ namespace System.Configuration
 
             if (!throwIfNotFound) return null;
 
-            throw new ConfigurationErrorsException(string.Format(SR.ProtectedConfigurationProvider_not_found,
+            throw new ConfigurationErrorsException(SR.Format(SR.ProtectedConfigurationProvider_not_found,
                 providerName));
         }
 
@@ -1635,7 +1635,7 @@ namespace System.Configuration
             catch (Exception e)
             {
                 throw ExceptionUtil.WrapAsConfigException(
-                    string.Format(SR.Config_exception_creating_section_handler, factoryRecord.ConfigKey), e, filename,
+                    SR.Format(SR.Config_exception_creating_section_handler, factoryRecord.ConfigKey), e, filename,
                     line);
             }
 
@@ -1738,7 +1738,7 @@ namespace System.Configuration
                 catch (Exception e)
                 {
                     throw ExceptionUtil.WrapAsConfigException(
-                        string.Format(SR.Config_exception_creating_section_handler, factoryRecord.ConfigKey), e,
+                        SR.Format(SR.Config_exception_creating_section_handler, factoryRecord.ConfigKey), e,
                         factoryRecord);
                 }
             }
@@ -1760,7 +1760,7 @@ namespace System.Configuration
             // Check for a root <configuration>
             if ((xmlUtil.Reader.NodeType != XmlNodeType.Element) || (xmlUtil.Reader.Name != ConfigurationTag))
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Config_file_doesnt_have_root_configuration, xmlUtil.Filename), xmlUtil);
+                    SR.Format(SR.Config_file_doesnt_have_root_configuration, xmlUtil.Filename), xmlUtil);
 
             // Look at the configuration attributes
             while (xmlUtil.Reader.MoveToNextAttribute())
@@ -1777,7 +1777,7 @@ namespace System.Configuration
                         {
                             // A configuration namespace was defined that we don't understand
                             ConfigurationErrorsException ce = new ConfigurationErrorsException(
-                                string.Format(SR.Config_namespace_invalid, xmlUtil.Reader.Value, ConfigurationNamespace),
+                                SR.Format(SR.Config_namespace_invalid, xmlUtil.Reader.Value, ConfigurationNamespace),
                                 xmlUtil);
                             xmlUtil.SchemaErrors.AddError(ce, ExceptionAction.Global);
                         }
@@ -1867,7 +1867,7 @@ namespace System.Configuration
                                 {
                                     // Error: duplicate <sectionGroup> declaration
                                     xmlUtil.SchemaErrors.AddError(
-                                        new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined_at_this_level, tagName), xmlUtil),
+                                        new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined_at_this_level, tagName), xmlUtil),
                                         ExceptionAction.Local);
                                 }
                                 else
@@ -1883,7 +1883,7 @@ namespace System.Configuration
                                             (!parentFactoryRecord.IsGroup || !parentFactoryRecord.IsEquivalentSectionGroupFactory(Host, typeName)))
                                         {
                                             xmlUtil.SchemaErrors.AddError(
-                                                new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined, tagName), xmlUtil),
+                                                new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined, tagName), xmlUtil),
                                                 ExceptionAction.Local);
                                             parentFactoryRecord = null;
                                         }
@@ -2004,7 +2004,7 @@ namespace System.Configuration
                                     // Error: duplicate section declaration
                                     xmlUtil.SchemaErrors.AddError(
                                         new ConfigurationErrorsException(
-                                            string.Format(SR.Config_tag_name_already_defined_at_this_level, tagName),
+                                            SR.Format(SR.Config_tag_name_already_defined_at_this_level, tagName),
                                             xmlUtil),
                                         ExceptionAction.Local);
                                 }
@@ -2022,7 +2022,7 @@ namespace System.Configuration
                                             // Already a <sectionGroup> with this name
                                             xmlUtil.SchemaErrors.AddError(
                                                 new ConfigurationErrorsException(
-                                                    string.Format(SR.Config_tag_name_already_defined, tagName), xmlUtil),
+                                                    SR.Format(SR.Config_tag_name_already_defined, tagName), xmlUtil),
                                                 ExceptionAction.Local);
                                             parentFactoryRecord = null;
                                         }
@@ -2031,7 +2031,7 @@ namespace System.Configuration
                                         {
                                             // Already a <section> with the same name
                                             xmlUtil.SchemaErrors.AddError(
-                                                new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined, tagName), xmlUtil),
+                                                new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined, tagName), xmlUtil),
                                                 ExceptionAction.Local);
                                             parentFactoryRecord = null;
                                         }
@@ -2373,7 +2373,7 @@ namespace System.Configuration
                     case ConfigSectionsTag: // <configSections>
                         // Either a duplicate or not the first tag under <configuration>
                         xmlUtil.SchemaErrors.AddError(
-                            new ConfigurationErrorsException(string.Format(SR.Config_client_config_too_many_configsections_elements, tagName), xmlUtil),
+                            new ConfigurationErrorsException(SR.Format(SR.Config_client_config_too_many_configsections_elements, tagName), xmlUtil),
                             ExceptionAction.NonSpecific);
                         xmlUtil.StrictSkipToNextElement(ExceptionAction.NonSpecific);
                         continue;
@@ -2415,7 +2415,7 @@ namespace System.Configuration
                     {
                         xmlUtil.SchemaErrors.AddError(
                             new ConfigurationErrorsException(
-                                string.Format(SR.Config_unrecognized_configuration_section, configKey), xmlUtil),
+                                SR.Format(SR.Config_unrecognized_configuration_section, configKey), xmlUtil),
                             ExceptionAction.Local);
                     }
 
@@ -3072,7 +3072,7 @@ namespace System.Configuration
                 }
 
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Cannot_declare_or_remove_implicit_section, name), errorInfo);
+                    SR.Format(SR.Cannot_declare_or_remove_implicit_section, name), errorInfo);
             }
 
             if (StringUtil.StartsWithOrdinal(name, "config"))
@@ -3238,7 +3238,7 @@ namespace System.Configuration
                 {
                     if (streamInfo.SectionName != configKey)
                     {
-                        throw new ConfigurationErrorsException(string.Format(SR.Config_source_cannot_be_shared,
+                        throw new ConfigurationErrorsException(SR.Format(SR.Config_source_cannot_be_shared,
                             streamname));
                     }
 
@@ -3328,7 +3328,7 @@ namespace System.Configuration
                     if ((streamInfo != null) && (streamInfo.SectionName != configKey))
                     {
                         throw new ConfigurationErrorsException(
-                            string.Format(SR.Config_source_cannot_be_shared, configSourceArg),
+                            SR.Format(SR.Config_source_cannot_be_shared, configSourceArg),
                             errorInfo);
                     }
                 }
@@ -3354,7 +3354,7 @@ namespace System.Configuration
                         if (streamInfo != null)
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_source_parent_conflict, configSourceArg),
+                                SR.Format(SR.Config_source_parent_conflict, configSourceArg),
                                 errorInfo);
                         }
                     }
@@ -3629,7 +3629,7 @@ namespace System.Configuration
             catch (Exception e)
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Decryption_failed, protectionProvider.Name, e.Message), e, filename, lineNumber);
+                    SR.Format(SR.Decryption_failed, protectionProvider.Name, e.Message), e, filename, lineNumber);
             }
 
             // Detect if there is any XML left over after <EncryptedData>
@@ -3808,8 +3808,7 @@ namespace System.Configuration
                     return -1;
                 }
 
-                Debug.Assert(false,
-                    "It's not possible for two location input to come from the same config file and point to the same target");
+                Debug.Fail("It's not possible for two location input to come from the same config file and point to the same target");
                 return 0;
             }
         }
index 624ee39..2d3f5e0 100644 (file)
@@ -37,7 +37,7 @@ namespace System.Configuration
                 }
 
                 if (_callbackMethod == null)
-                    throw new ArgumentException(string.Format(SR.Validator_method_not_found, _callbackMethodName));
+                    throw new ArgumentException(SR.Format(SR.Validator_method_not_found, _callbackMethodName));
 
                 return new CallbackValidator(_callbackMethod);
             }
@@ -63,4 +63,4 @@ namespace System.Configuration
             }
         }
     }
-}
\ No newline at end of file
+}
index 90cfc95..a9a2668 100644 (file)
@@ -206,7 +206,7 @@ namespace System.Configuration
                 catch (ConfigurationErrorsException ex)
                 {
                     // We wrap this in an exception with our error message and throw again.
-                    throw new ConfigurationErrorsException(string.Format(SR.SettingsSaveFailed, ex.Message), ex);
+                    throw new ConfigurationErrorsException(SR.Format(SR.SettingsSaveFailed, ex.Message), ex);
                 }
             }
             else
index 251517b..7895df7 100644 (file)
@@ -21,7 +21,7 @@ namespace System.Configuration
         internal void ValidateType(object value, Type expected)
         {
             if ((value != null) && (value.GetType() != expected))
-                throw new ArgumentException(string.Format(SR.Converter_unsupported_value_type, expected.Name));
+                throw new ArgumentException(SR.Format(SR.Converter_unsupported_value_type, expected.Name));
         }
     }
-}
\ No newline at end of file
+}
index 0a3f463..102f903 100644 (file)
@@ -111,7 +111,7 @@ namespace System.Configuration
                 }
                 else
                 {
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_base_attribute_locked, LockItemKey));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_base_attribute_locked, LockItemKey));
                 }
             }
         }
@@ -409,7 +409,7 @@ namespace System.Configuration
                         {
                             // Don't allow the override
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_attribute_locked, propInfo.Name));
+                                SR.Format(SR.Config_base_attribute_locked, propInfo.Name));
                         }
 
                         // They did not override so we need to make sure the value comes from the locked one
@@ -535,7 +535,7 @@ namespace System.Configuration
                     ((_itemLockedFlag & ConfigurationValueFlags.Inherited) != 0)
                     )
                 {
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_base_element_locked, elementName),
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_base_element_locked, elementName),
                         reader);
                 }
             }
@@ -816,7 +816,7 @@ namespace System.Configuration
             if (!validator.CanValidate(type))
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Validator_does_not_support_elem_type, type.Name));
+                    SR.Format(SR.Validator_does_not_support_elem_type, type.Name));
             }
 
             s_perTypeValidators.Add(type, validator);
@@ -852,7 +852,7 @@ namespace System.Configuration
                 (_lockedAttributesList.DefinedInParent(prop.Name) || _lockedAttributesList.DefinedInParent(LockAll))) ||
                 (((_itemLockedFlag & ConfigurationValueFlags.Locked) != 0) &&
                 ((_itemLockedFlag & ConfigurationValueFlags.Inherited) != 0))))
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_attribute_locked, prop.Name));
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_attribute_locked, prop.Name));
 
             _modified = true;
 
@@ -1095,7 +1095,7 @@ namespace System.Configuration
                     {
                         if (prop.IsRequired)
                         {
-                            throw new ConfigurationErrorsException(string.Format(
+                            throw new ConfigurationErrorsException(SR.Format(
                                 SR.Config_base_required_attribute_locked, prop.Name));
                         }
                         value = s_nullPropertyValue;
@@ -1185,7 +1185,7 @@ namespace System.Configuration
                         else
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_element_cannot_have_multiple_child_elements, prop.Name));
+                                SR.Format(SR.Config_base_element_cannot_have_multiple_child_elements, prop.Name));
                         }
                     }
                 }
@@ -1280,12 +1280,12 @@ namespace System.Configuration
             if (value != null)
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(CultureInfo.CurrentCulture, format, attribToLockTrim, sb.ToString()),
+                    SR.Format(format, attribToLockTrim, sb),
                     value.SourceInfo.FileName, value.SourceInfo.LineNumber);
             }
 
-            throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, format,
-                attribToLockTrim, sb.ToString()));
+            throw new ConfigurationErrorsException(SR.Format(format,
+                attribToLockTrim, sb));
         }
 
         private ConfigurationLockCollection ParseLockedAttributes(ConfigurationValue value,
@@ -1300,18 +1300,18 @@ namespace System.Configuration
                 switch (lockType)
                 {
                     case ConfigurationLockCollectionType.LockedAttributes:
-                        throw new ConfigurationErrorsException(string.Format(SR.Empty_attribute, LockAttributesKey),
+                        throw new ConfigurationErrorsException(SR.Format(SR.Empty_attribute, LockAttributesKey),
                             value.SourceInfo.FileName, value.SourceInfo.LineNumber);
                     case ConfigurationLockCollectionType.LockedElements:
-                        throw new ConfigurationErrorsException(string.Format(SR.Empty_attribute, LockElementsKey),
+                        throw new ConfigurationErrorsException(SR.Format(SR.Empty_attribute, LockElementsKey),
                             value.SourceInfo.FileName, value.SourceInfo.LineNumber);
                     case ConfigurationLockCollectionType.LockedExceptionList:
                         throw new ConfigurationErrorsException(
-                            string.Format(SR.Config_empty_lock_attributes_except, LockAllAttributesExceptKey,
+                            SR.Format(SR.Config_empty_lock_attributes_except, LockAllAttributesExceptKey,
                                 LockAttributesKey), value.SourceInfo.FileName, value.SourceInfo.LineNumber);
                     case ConfigurationLockCollectionType.LockedElementsExceptionList:
                         throw new ConfigurationErrorsException(
-                            string.Format(SR.Config_empty_lock_element_except, LockAllElementsExceptKey, LockElementsKey),
+                            SR.Format(SR.Config_empty_lock_element_except, LockAllElementsExceptKey, LockElementsKey),
                             value.SourceInfo.FileName, value.SourceInfo.LineNumber);
                 }
             }
@@ -1367,7 +1367,7 @@ namespace System.Configuration
                         if ((propToLock != null) && propToLock.IsRequired)
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_required_attribute_lock_attempt, propToLock.Name));
+                                SR.Format(SR.Config_base_required_attribute_lock_attempt, propToLock.Name));
                         }
                     }
 
@@ -1427,7 +1427,7 @@ namespace System.Configuration
                 (((_itemLockedFlag & ConfigurationValueFlags.Locked) != 0) &&
                 ((_itemLockedFlag & ConfigurationValueFlags.Inherited) != 0))
                 )
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_element_locked, reader.Name), reader);
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_element_locked, reader.Name), reader);
 
 
             if (reader.AttributeCount > 0)
@@ -1444,7 +1444,7 @@ namespace System.Configuration
                         if ((propertyName != LockAttributesKey) && (propertyName != LockAllAttributesExceptKey))
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_attribute_locked, propertyName), reader);
+                                SR.Format(SR.Config_base_attribute_locked, propertyName), reader);
                         }
                     }
 
@@ -1454,7 +1454,7 @@ namespace System.Configuration
                         if (serializeCollectionKey && !prop.IsKey)
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_unrecognized_attribute, propertyName), reader);
+                                SR.Format(SR.Config_base_unrecognized_attribute, propertyName), reader);
                         }
 
                         Values.SetValue(propertyName,
@@ -1475,7 +1475,7 @@ namespace System.Configuration
                                 catch
                                 {
                                     throw new ConfigurationErrorsException(
-                                        string.Format(SR.Config_invalid_boolean_attribute, propertyName), reader);
+                                        SR.Format(SR.Config_invalid_boolean_attribute, propertyName), reader);
                                 }
                                 break;
                             case LockAttributesKey:
@@ -1499,7 +1499,7 @@ namespace System.Configuration
                                     !OnDeserializeUnrecognizedAttribute(propertyName, reader.Value))
                                 {
                                     throw new ConfigurationErrorsException(
-                                        string.Format(SR.Config_base_unrecognized_attribute, propertyName),
+                                        SR.Format(SR.Config_base_unrecognized_attribute, propertyName),
                                         reader);
                                 }
                                 break;
@@ -1532,7 +1532,7 @@ namespace System.Configuration
                                     if (nodeFound.Contains(propertyName))
                                     {
                                         throw new ConfigurationErrorsException(
-                                            string.Format(SR.Config_base_element_cannot_have_multiple_child_elements,
+                                            SR.Format(SR.Config_base_element_cannot_have_multiple_child_elements,
                                                 propertyName), reader);
                                     }
 
@@ -1547,7 +1547,7 @@ namespace System.Configuration
                                 else
                                 {
                                     throw new ConfigurationErrorsException(
-                                        string.Format(SR.Config_base_property_is_not_a_configuration_element,
+                                        SR.Format(SR.Config_base_property_is_not_a_configuration_element,
                                             propertyName), reader);
                                 }
                             }
@@ -1560,7 +1560,7 @@ namespace System.Configuration
                                         !defaultCollection.OnDeserializeUnrecognizedElement(propertyName, reader))
                                     {
                                         throw new ConfigurationErrorsException(
-                                            string.Format(SR.Config_base_unrecognized_element_name, propertyName), reader);
+                                            SR.Format(SR.Config_base_unrecognized_element_name, propertyName), reader);
                                     }
                                 }
                             }
@@ -1785,7 +1785,7 @@ namespace System.Configuration
                 // the validator supports the type of elem every time
                 if ((validator != null) && !validator.CanValidate(elem.GetType()))
                 {
-                    throw new ConfigurationErrorsException(string.Format(SR.Validator_does_not_support_elem_type,
+                    throw new ConfigurationErrorsException(SR.Format(SR.Validator_does_not_support_elem_type,
                         elem.GetType().Name));
                 }
             }
@@ -1801,7 +1801,7 @@ namespace System.Configuration
             }
             catch (Exception ex)
             {
-                throw new ConfigurationErrorsException(string.Format(SR.Validator_element_not_valid, elem.ElementTagName,
+                throw new ConfigurationErrorsException(SR.Format(SR.Validator_element_not_valid, elem.ElementTagName,
                     ex.Message));
             }
 
@@ -1854,7 +1854,7 @@ namespace System.Configuration
             // Derivied classes can override this to return a value for a required property that is missing
             // Here we treat this as an error though
 
-            throw new ConfigurationErrorsException(string.Format(SR.Config_base_required_attribute_missing, name),
+            throw new ConfigurationErrorsException(SR.Format(SR.Config_base_required_attribute_missing, name),
                 PropertyFileName(name),
                 PropertyLineNumber(name));
         }
index 7f89704..4d6e060 100644 (file)
@@ -46,7 +46,7 @@ namespace System.Configuration
             {
                 _addElement = value;
                 if (BaseConfigurationRecord.IsReservedAttributeName(value))
-                    throw new ArgumentException(string.Format(SR.Item_name_reserved, DefaultAddItemName, value));
+                    throw new ArgumentException(SR.Format(SR.Item_name_reserved, DefaultAddItemName, value));
             }
         }
 
@@ -56,7 +56,7 @@ namespace System.Configuration
             set
             {
                 if (BaseConfigurationRecord.IsReservedAttributeName(value))
-                    throw new ArgumentException(string.Format(SR.Item_name_reserved, DefaultRemoveItemName, value));
+                    throw new ArgumentException(SR.Format(SR.Item_name_reserved, DefaultRemoveItemName, value));
                 _removeElement = value;
             }
         }
@@ -67,7 +67,7 @@ namespace System.Configuration
             set
             {
                 if (BaseConfigurationRecord.IsReservedAttributeName(value))
-                    throw new ArgumentException(string.Format(SR.Item_name_reserved, DefaultClearItemsName, value));
+                    throw new ArgumentException(SR.Format(SR.Item_name_reserved, DefaultClearItemsName, value));
                 _clearElement = value;
             }
         }
@@ -505,7 +505,7 @@ namespace System.Configuration
             if (IsReadOnly()) throw new ConfigurationErrorsException(SR.Config_base_read_only);
 
             if (LockItem && (ignoreLocks == false))
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_element_locked, _addElement));
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_element_locked, _addElement));
 
             object key = GetElementKeyInternal(element);
             int iFoundItem = -1;
@@ -522,7 +522,7 @@ namespace System.Configuration
                     if (!element.Equals(entry.Value))
                     {
                         throw new ConfigurationErrorsException(
-                            string.Format(SR.Config_base_collection_entry_already_exists, key),
+                            SR.Format(SR.Config_base_collection_entry_already_exists, key),
                             element.PropertyFileName(""), element.PropertyLineNumber(""));
                     }
 
@@ -623,7 +623,7 @@ namespace System.Configuration
                     (CollectionType == ConfigurationElementCollectionType.BasicMapAlternate))
                 {
                     if (BaseConfigurationRecord.IsReservedAttributeName(ElementName))
-                        throw new ArgumentException(string.Format(SR.Basicmap_item_name_reserved, ElementName));
+                        throw new ArgumentException(SR.Format(SR.Basicmap_item_name_reserved, ElementName));
                     CheckLockedElement(ElementName, null);
                 }
 
@@ -659,7 +659,7 @@ namespace System.Configuration
             if (index >= 0)
             {
                 if (index > Items.Count)
-                    throw new ConfigurationErrorsException(string.Format(SR.IndexOutOfRange, index));
+                    throw new ConfigurationErrorsException(SR.Format(SR.IndexOutOfRange, index));
                 Items.Insert(index, new Entry(entryType, key, element));
             }
             else
@@ -678,7 +678,7 @@ namespace System.Configuration
         private void BaseAdd(int index, ConfigurationElement element, bool ignoreLocks)
         {
             if (IsReadOnly()) throw new ConfigurationErrorsException(SR.Config_base_read_only);
-            if (index < -1) throw new ConfigurationErrorsException(string.Format(SR.IndexOutOfRange, index));
+            if (index < -1) throw new ConfigurationErrorsException(SR.Format(SR.IndexOutOfRange, index));
 
             if ((index != -1) &&
                 ((CollectionType == ConfigurationElementCollectionType.AddRemoveClearMap) ||
@@ -709,7 +709,7 @@ namespace System.Configuration
                     if (!element.Equals(entry.Value))
                     {
                         throw new ConfigurationErrorsException(
-                            string.Format(SR.Config_base_collection_entry_already_exists, key),
+                            SR.Format(SR.Config_base_collection_entry_already_exists, key),
                             element.PropertyFileName(""), element.PropertyLineNumber(""));
                     }
 
@@ -740,13 +740,13 @@ namespace System.Configuration
                         if (throwIfMissing)
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_collection_entry_not_found, key));
+                                SR.Format(SR.Config_base_collection_entry_not_found, key));
                         }
                         return;
                     }
 
                     if (entry.Value.LockItem)
-                        throw new ConfigurationErrorsException(string.Format(SR.Config_base_attribute_locked, key));
+                        throw new ConfigurationErrorsException(SR.Format(SR.Config_base_attribute_locked, key));
 
                     if (entry.Value.ElementPresent == false)
                         CheckLockedElement(_removeElement, null); // has remove been locked?
@@ -811,7 +811,7 @@ namespace System.Configuration
             //  remove the item at the parent level.
 
             if (throwIfMissing)
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_collection_entry_not_found, key));
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_collection_entry_not_found, key));
 
             if ((CollectionType != ConfigurationElementCollectionType.AddRemoveClearMap) &&
                 (CollectionType != ConfigurationElementCollectionType.AddRemoveClearMapAlternate))
@@ -846,7 +846,7 @@ namespace System.Configuration
 
         protected internal ConfigurationElement BaseGet(int index)
         {
-            if (index < 0) throw new ConfigurationErrorsException(string.Format(SR.IndexOutOfRange, index));
+            if (index < 0) throw new ConfigurationErrorsException(SR.Format(SR.IndexOutOfRange, index));
 
             int virtualIndex = 0;
             Entry entry = null;
@@ -864,7 +864,7 @@ namespace System.Configuration
             if (entry != null)
                 return entry.Value;
 
-            throw new ConfigurationErrorsException(string.Format(SR.IndexOutOfRange, index));
+            throw new ConfigurationErrorsException(SR.Format(SR.IndexOutOfRange, index));
         }
 
         protected internal object[] BaseGetAllKeys()
@@ -884,7 +884,7 @@ namespace System.Configuration
         {
             int virtualIndex = 0;
             Entry entry = null;
-            if (index < 0) throw new ConfigurationErrorsException(string.Format(SR.IndexOutOfRange, index));
+            if (index < 0) throw new ConfigurationErrorsException(SR.Format(SR.IndexOutOfRange, index));
 
             foreach (Entry entryfound in Items)
             {
@@ -898,7 +898,7 @@ namespace System.Configuration
             }
 
             // Entry entry = (Entry)_items[index];
-            if (entry == null) throw new ConfigurationErrorsException(string.Format(SR.IndexOutOfRange, index));
+            if (entry == null) throw new ConfigurationErrorsException(SR.Format(SR.IndexOutOfRange, index));
 
             return entry.GetKey(this);
         }
@@ -973,10 +973,10 @@ namespace System.Configuration
                 if (entryfound.EntryType != EntryType.Removed) virtualIndex++;
             }
 
-            if (entry == null) throw new ConfigurationErrorsException(string.Format(SR.IndexOutOfRange, index));
+            if (entry == null) throw new ConfigurationErrorsException(SR.Format(SR.IndexOutOfRange, index));
             if (entry.Value.LockItem)
             {
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_attribute_locked,
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_attribute_locked,
                     entry.GetKey(this)));
             }
 
@@ -1059,7 +1059,7 @@ namespace System.Configuration
                             {
                                 if (BaseConfigurationRecord.IsReservedAttributeName(ElementName))
                                 {
-                                    throw new ArgumentException(string.Format(SR.Basicmap_item_name_reserved,
+                                    throw new ArgumentException(SR.Format(SR.Basicmap_item_name_reserved,
                                         ElementName));
                                 }
 
@@ -1120,7 +1120,7 @@ namespace System.Configuration
                             {
                                 string propertyName = reader.Name;
                                 throw new ConfigurationErrorsException(
-                                    string.Format(SR.Config_base_unrecognized_attribute, propertyName), reader);
+                                    SR.Format(SR.Config_base_unrecognized_attribute, propertyName), reader);
                             }
                         }
 
@@ -1136,7 +1136,7 @@ namespace System.Configuration
                 if (elementName == ElementName)
                 {
                     if (BaseConfigurationRecord.IsReservedAttributeName(elementName))
-                        throw new ArgumentException(string.Format(SR.Basicmap_item_name_reserved, elementName));
+                        throw new ArgumentException(SR.Format(SR.Basicmap_item_name_reserved, elementName));
                     ConfigurationElement elem = CallCreateNewElement();
                     elem.ResetLockLists(this);
                     elem.DeserializeElement(reader, false);
@@ -1148,7 +1148,7 @@ namespace System.Configuration
 
                     // this section handle the collection like the allow deny senario which
                     if (BaseConfigurationRecord.IsReservedAttributeName(elementName))
-                        throw new ArgumentException(string.Format(SR.Basicmap_item_name_reserved, elementName));
+                        throw new ArgumentException(SR.Format(SR.Basicmap_item_name_reserved, elementName));
 
                     // have multiple tags for the collection
                     ConfigurationElement elem = CallCreateNewElement(elementName);
index 65ac59b..bcaf86b 100644 (file)
@@ -29,7 +29,7 @@ namespace System.Configuration
                 throw new ArgumentNullException(nameof(machineConfigFilename));
 
             if (!File.Exists(machineConfigFilename))
-                throw new ArgumentException(string.Format(SR.Machine_config_file_not_found, machineConfigFilename),
+                throw new ArgumentException(SR.Format(SR.Machine_config_file_not_found, machineConfigFilename),
                     nameof(machineConfigFilename));
 
             MachineConfigFilename = machineConfigFilename;
@@ -59,4 +59,4 @@ namespace System.Configuration
 
         internal bool IsMachinePathDefault => _getFilenameThunk == GetFilenameFromMachineConfigFilePath;
     }
-}
\ No newline at end of file
+}
index c71e0ac..f07c299 100644 (file)
@@ -127,7 +127,7 @@ namespace System.Configuration
         {
             if (((_thisElement.ItemLocked & ConfigurationValueFlags.Locked) != 0) &&
                 ((_thisElement.ItemLocked & ConfigurationValueFlags.Inherited) != 0))
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_attribute_locked, name));
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_attribute_locked, name));
 
             ConfigurationValueFlags flags = ConfigurationValueFlags.Modified;
 
@@ -160,7 +160,7 @@ namespace System.Configuration
                 // the lock is in the property bag but is it the correct type?
                 if ((propToLock != null) && propToLock.IsRequired)
                 {
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_base_required_attribute_lock_attempt,
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_base_required_attribute_lock_attempt,
                         propToLock.Name));
                 }
 
@@ -247,7 +247,7 @@ namespace System.Configuration
         public void Remove(string name)
         {
             if (!_internalDictionary.Contains(name))
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_collection_entry_not_found, name));
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_collection_entry_not_found, name));
 
             // in a locked list you cannot remove items that were locked in the parent
             // in an exception list this is legal because it makes the list more restrictive
@@ -255,7 +255,7 @@ namespace System.Configuration
                 (((ConfigurationValueFlags)_internalDictionary[name] & ConfigurationValueFlags.Inherited) != 0))
             {
                 if (((ConfigurationValueFlags)_internalDictionary[name] & ConfigurationValueFlags.Modified) == 0)
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_base_attribute_locked, name));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_base_attribute_locked, name));
 
                 // allow the local one to be "removed" so it won't write out but throw if they try and remove
                 // one that is only inherited
@@ -318,7 +318,7 @@ namespace System.Configuration
         public bool IsReadOnly(string name)
         {
             if (!_internalDictionary.Contains(name))
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_collection_entry_not_found, name));
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_collection_entry_not_found, name));
             return
                 ((ConfigurationValueFlags)_internalDictionary[name] & ConfigurationValueFlags.Inherited) != 0;
         }
@@ -334,4 +334,4 @@ namespace System.Configuration
             }
         }
     }
-}
\ No newline at end of file
+}
index 84f228e..42e3c04 100644 (file)
@@ -101,7 +101,7 @@ namespace System.Configuration
                         // list of validators and executes them all
 
                         throw new ConfigurationErrorsException(
-                            string.Format(SR.Validator_multiple_validator_attributes, info.Name));
+                            SR.Format(SR.Validator_multiple_validator_attributes, info.Name));
                     }
 
                     ConfigurationValidatorAttribute validatorAttribute = (ConfigurationValidatorAttribute)attribute;
@@ -221,7 +221,7 @@ namespace System.Configuration
             if (typeof(ConfigurationSection).IsAssignableFrom(type))
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Config_properties_may_not_be_derived_from_configuration_section, name));
+                    SR.Format(SR.Config_properties_may_not_be_derived_from_configuration_section, name));
             }
 
             // save the provided name so we can check for default collection names
@@ -251,7 +251,7 @@ namespace System.Configuration
             {
                 // Make sure the supplied validator supports the type of this property
                 if (!Validator.CanValidate(Type))
-                    throw new ConfigurationErrorsException(string.Format(SR.Validator_does_not_support_prop_type, Name));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Validator_does_not_support_prop_type, Name));
             }
         }
 
@@ -261,7 +261,7 @@ namespace System.Configuration
                 throw new ArgumentException(SR.String_null_or_empty, nameof(name));
 
             if (BaseConfigurationRecord.IsReservedAttributeName(name))
-                throw new ArgumentException(string.Format(SR.Property_name_reserved, name));
+                throw new ArgumentException(SR.Format(SR.Property_name_reserved, name));
         }
 
         private void SetDefaultValue(object value)
@@ -273,7 +273,7 @@ namespace System.Configuration
             if (!Type.IsInstanceOfType(value))
             {
                 if (!Converter.CanConvertFrom(value.GetType()))
-                    throw new ConfigurationErrorsException(string.Format(SR.Default_value_wrong_type, Name));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Default_value_wrong_type, Name));
 
                 value = Converter.ConvertFrom(value);
             }
@@ -301,7 +301,7 @@ namespace System.Configuration
                 }
                 catch (Exception ex)
                 {
-                    throw new ConfigurationErrorsException(string.Format(SR.Default_value_conversion_error_from_string,
+                    throw new ConfigurationErrorsException(SR.Format(SR.Default_value_conversion_error_from_string,
                         Name, ex.Message));
                 }
             }
@@ -332,7 +332,7 @@ namespace System.Configuration
             }
             catch (Exception ex)
             {
-                throw new ConfigurationErrorsException(string.Format(SR.Top_level_conversion_error_from_string, Name,
+                throw new ConfigurationErrorsException(SR.Format(SR.Top_level_conversion_error_from_string, Name,
                     ex.Message));
             }
 
@@ -356,7 +356,7 @@ namespace System.Configuration
             catch (Exception ex)
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Top_level_conversion_error_to_string, Name, ex.Message));
+                    SR.Format(SR.Top_level_conversion_error_to_string, Name, ex.Message));
             }
         }
 
@@ -369,7 +369,7 @@ namespace System.Configuration
             catch (Exception ex)
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Top_level_validation_error, Name, ex.Message), ex);
+                    SR.Format(SR.Top_level_validation_error, Name, ex.Message), ex);
             }
         }
 
@@ -397,7 +397,7 @@ namespace System.Configuration
                     !_converter.CanConvertTo(typeof(string)))
                 {
                     // Need to be able to convert to/from string
-                    throw new ConfigurationErrorsException(string.Format(SR.No_converter, Name, Type.Name));
+                    throw new ConfigurationErrorsException(SR.Format(SR.No_converter, Name, Type.Name));
                 }
             }
         }
index 7b904e2..d130c00 100644 (file)
@@ -53,7 +53,7 @@ namespace System.Configuration
                         FactoryRecord factoryRecord = FindParentFactoryRecord(false);
                         if ((factoryRecord != null) && !factoryRecord.IsEquivalentType(_configRecord.Host, typeName))
                         {
-                            throw new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined,
+                            throw new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined,
                                 SectionGroupName));
                         }
                     }
@@ -168,4 +168,4 @@ namespace System.Configuration
             return true;
         }
     }
-}
\ No newline at end of file
+}
index 04bd235..99c8445 100644 (file)
@@ -19,7 +19,7 @@ namespace System.Configuration
 
             if (!typeof(ConfigurationValidatorBase).IsAssignableFrom(validator))
             {
-                throw new ArgumentException(string.Format(SR.Validator_Attribute_param_not_validator,
+                throw new ArgumentException(SR.Format(SR.Validator_Attribute_param_not_validator,
                     "ConfigurationValidatorBase"));
             }
 
@@ -57,4 +57,4 @@ namespace System.Configuration
             }
         }
     }
-}
\ No newline at end of file
+}
index 80abfb4..e500c0f 100644 (file)
@@ -98,7 +98,7 @@ namespace System.Configuration
             _keyEntropy = configurationValues["keyEntropy"];
             configurationValues.Remove("keyEntropy");
             if (configurationValues.Count > 0)
-                throw new ConfigurationErrorsException(string.Format(SR.Unrecognized_initialization_value, configurationValues.GetKey(0)));
+                throw new ConfigurationErrorsException(SR.Format(SR.Unrecognized_initialization_value, configurationValues.GetKey(0)));
         }
 
         private static XmlNode TraverseToChild(XmlNode node, string name, bool onlyChild)
@@ -131,7 +131,7 @@ namespace System.Configuration
                 return true;
             if (s == "false")
                 return false;
-            throw new ConfigurationErrorsException(string.Format(SR.Config_invalid_boolean_attribute, valueName));
+            throw new ConfigurationErrorsException(SR.Format(SR.Config_invalid_boolean_attribute, valueName));
         }
     }
 }
index 50506ac..d890541 100644 (file)
@@ -13,27 +13,27 @@ namespace System.Configuration
 
         internal static ArgumentException ParameterInvalid(string parameter)
         {
-            return new ArgumentException(string.Format(SR.Parameter_Invalid, parameter), parameter);
+            return new ArgumentException(SR.Format(SR.Parameter_Invalid, parameter), parameter);
         }
 
         internal static ArgumentException ParameterNullOrEmpty(string parameter)
         {
-            return new ArgumentException(string.Format(SR.Parameter_NullOrEmpty, parameter), parameter);
+            return new ArgumentException(SR.Format(SR.Parameter_NullOrEmpty, parameter), parameter);
         }
 
         internal static ArgumentException PropertyInvalid(string property)
         {
-            return new ArgumentException(string.Format(SR.Property_Invalid, property), property);
+            return new ArgumentException(SR.Format(SR.Property_Invalid, property), property);
         }
 
         internal static ArgumentException PropertyNullOrEmpty(string property)
         {
-            return new ArgumentException(string.Format(SR.Property_NullOrEmpty, property), property);
+            return new ArgumentException(SR.Format(SR.Property_NullOrEmpty, property), property);
         }
 
         internal static InvalidOperationException UnexpectedError(string methodName)
         {
-            return new InvalidOperationException(string.Format(SR.Unexpected_Error, methodName));
+            return new InvalidOperationException(SR.Format(SR.Unexpected_Error, methodName));
         }
 
         internal static ConfigurationErrorsException WrapAsConfigException(string outerMessage, Exception e,
@@ -73,7 +73,7 @@ namespace System.Configuration
             if (e != null)
             {
                 return new ConfigurationErrorsException(
-                    string.Format(SR.Wrapped_exception_message, outerMessage, e.Message),
+                    SR.Format(SR.Wrapped_exception_message, outerMessage, e.Message),
                     e,
                     filename,
                     line);
@@ -81,9 +81,9 @@ namespace System.Configuration
 
             // If there is no exception, create a new exception with no further information.
             return new ConfigurationErrorsException(
-                string.Format(SR.Wrapped_exception_message, outerMessage, NoExceptionInformation),
+                SR.Format(SR.Wrapped_exception_message, outerMessage, NoExceptionInformation),
                 filename,
                 line);
         }
     }
-}
\ No newline at end of file
+}
index 5319cbb..28c682f 100644 (file)
@@ -59,7 +59,7 @@ namespace System.Configuration
                 }
                 names.Append(name);
             }
-            return new ArgumentException(string.Format(SR.Invalid_enum_value, names.ToString()));
+            return new ArgumentException(SR.Format(SR.Invalid_enum_value, names));
         }
     }
 }
index 9694e0a..f3027fe 100644 (file)
@@ -21,7 +21,7 @@ namespace System.Configuration
             if (fRequired && a == null)
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Config_missing_required_attribute, attrib, node.Name),
+                    SR.Format(SR.Config_missing_required_attribute, attrib, node.Name),
                     node);
             }
 
@@ -55,7 +55,7 @@ namespace System.Configuration
                 catch (Exception e)
                 {
                     throw new ConfigurationErrorsException(
-                            string.Format(SR.Config_invalid_boolean_attribute, a.Name),
+                            SR.Format(SR.Config_invalid_boolean_attribute, a.Name),
                             e, a);
                 }
             }
@@ -77,7 +77,7 @@ namespace System.Configuration
                 if (a.Value.Trim() != a.Value)
                 {
                     throw new ConfigurationErrorsException(
-                        string.Format(SR.Config_invalid_integer_attribute, a.Name), a);
+                        SR.Format(SR.Config_invalid_integer_attribute, a.Name), a);
                 }
 
                 try
@@ -87,7 +87,7 @@ namespace System.Configuration
                 catch (Exception e)
                 {
                     throw new ConfigurationErrorsException(
-                        string.Format(SR.Config_invalid_integer_attribute, a.Name),
+                        SR.Format(SR.Config_invalid_integer_attribute, a.Name),
                         e, a);
                 }
             }
@@ -105,7 +105,7 @@ namespace System.Configuration
             if (node.Attributes.Count != 0)
             {
                 throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_unrecognized_attribute, node.Attributes[0].Name),
+                                SR.Format(SR.Config_base_unrecognized_attribute, node.Attributes[0].Name),
                                 node);
             }
         }
@@ -137,14 +137,14 @@ namespace System.Configuration
             if (attribute == null)
             {
                 throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_required_attribute_missing, name),
+                                SR.Format(SR.Config_base_required_attribute_missing, name),
                                 node);
             }
 
             if (string.IsNullOrEmpty(attribute.Value) && allowEmpty == false)
             {
                 throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_base_required_attribute_empty, name),
+                                SR.Format(SR.Config_base_required_attribute_empty, name),
                                 node);
             }
 
index d8cff7f..7b944a9 100644 (file)
@@ -205,7 +205,7 @@ namespace System.Configuration.Internal
             // ensure the result is in or under the directory of the original source
             string dirResult = UrlPath.GetDirectoryOrRootName(result);
             if (!UrlPath.IsEqualOrSubdirectory(dirStream, dirResult))
-                throw new ArgumentException(string.Format(SR.Config_source_not_under_config_dir, configSource));
+                throw new ArgumentException(SR.Format(SR.Config_source_not_under_config_dir, configSource));
 
             return result;
         }
@@ -257,7 +257,7 @@ namespace System.Configuration.Internal
                     FileAttributes attrs = fi.Attributes;
                     if ((attrs & InvalidAttributesForWrite) != 0)
                     {
-                        throw new IOException(string.Format(SR.Config_invalid_attributes_for_write, streamName));
+                        throw new IOException(SR.Format(SR.Config_invalid_attributes_for_write, streamName));
                     }
                 }
 
@@ -270,7 +270,7 @@ namespace System.Configuration.Internal
                     // Wrap all exceptions so that we provide a meaningful filename - otherwise the end user
                     // will just see the temporary file name, which is meaningless.
 
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_write_failed, streamName), e);
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_write_failed, streamName), e);
                 }
             }
             catch
index f251038..cdf6457 100644 (file)
@@ -177,7 +177,7 @@ namespace System.Configuration.Internal
 
             if (!writeSucceeded)
             {
-                throw new ConfigurationErrorsException(string.Format(SR.Config_write_failed, target));
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_write_failed, target));
             }
         }
 
@@ -233,4 +233,4 @@ namespace System.Configuration.Internal
             }
         }
     }
-}
\ No newline at end of file
+}
index 3d31e4e..4624afd 100644 (file)
@@ -384,7 +384,7 @@ namespace System.Configuration
 
             if (!string.IsNullOrEmpty(key))
             {
-                sectionName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", sectionName, key);
+                sectionName = sectionName + "." + key;
             }
 
             return XmlConvert.EncodeLocalName(sectionName);
@@ -446,11 +446,11 @@ namespace System.Configuration
 
             if (isUser && isApp)
             {
-                throw new ConfigurationErrorsException(string.Format(SR.BothScopeAttributes, setting.Name));
+                throw new ConfigurationErrorsException(SR.Format(SR.BothScopeAttributes, setting.Name));
             }
             else if (!(isUser || isApp))
             {
-                throw new ConfigurationErrorsException(string.Format(SR.NoScopeAttributes, setting.Name));
+                throw new ConfigurationErrorsException(SR.Format(SR.NoScopeAttributes, setting.Name));
             }
 
             return isUser;
index 79f0e87..5e9043a 100644 (file)
@@ -197,7 +197,7 @@ namespace System.Configuration
             FactoryRecord factoryRecord = FindFactoryRecord(configKey, false);
             if (factoryRecord == null)
             {
-                throw new ConfigurationErrorsException(string.Format(SR.Config_unrecognized_configuration_section,
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_unrecognized_configuration_section,
                     configKey));
             }
 
@@ -270,7 +270,7 @@ namespace System.Configuration
                 catch (Exception e)
                 {
                     throw new ConfigurationErrorsException(
-                        string.Format(SR.Config_exception_creating_section_handler, factoryRecord.ConfigKey),
+                        SR.Format(SR.Config_exception_creating_section_handler, factoryRecord.ConfigKey),
                         e, factoryRecord);
                 }
             }
@@ -416,7 +416,7 @@ namespace System.Configuration
             catch (Exception e)
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Config_exception_in_config_section_handler,
+                    SR.Format(SR.Config_exception_in_config_section_handler,
                         configSection.SectionInformation.SectionName),
                     e, ConfigStreamInfo.StreamName, 0);
             }
@@ -487,7 +487,7 @@ namespace System.Configuration
             catch (Exception e)
             {
                 throw new ConfigurationErrorsException(
-                    string.Format(SR.Config_exception_in_config_section_handler,
+                    SR.Format(SR.Config_exception_in_config_section_handler,
                         configSection.SectionInformation.SectionName),
                     e, null, 0);
             }
@@ -569,7 +569,7 @@ namespace System.Configuration
                     if (streamInfo.SectionName != sectionInformation.ConfigKey)
                     {
                         throw new ConfigurationErrorsException(
-                            string.Format(SR.Config_source_cannot_be_shared, newConfigSource));
+                            SR.Format(SR.Config_source_cannot_be_shared, newConfigSource));
                     }
                 }
                 else
@@ -606,13 +606,13 @@ namespace System.Configuration
                 // Verify that the it is an element
                 reader.Read();
                 if (reader.NodeType != XmlNodeType.Element)
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_unexpected_node_type, reader.NodeType));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_unexpected_node_type, reader.NodeType));
 
                 // Verify the name of the element is a section
                 string group, name;
                 SplitConfigKey(configKey, out group, out name);
                 if (reader.Name != name)
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_unexpected_element_name, reader.Name));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_unexpected_element_name, reader.Name));
 
                 for (;;)
                 {
@@ -621,7 +621,7 @@ namespace System.Configuration
                         // ensure there is a matching end element
                         if (reader.Depth != 0)
                         {
-                            throw new ConfigurationErrorsException(string.Format(SR.Config_unexpected_element_end),
+                            throw new ConfigurationErrorsException(SR.Config_unexpected_element_end,
                                 reader);
                         }
 
@@ -972,7 +972,7 @@ namespace System.Configuration
                 // are actually fullpaths on the remote machine.  In this case there is no way to
                 // detect if we have a conflict or not.
                 if (!Host.IsRemote && _streamInfoUpdates.Contains(filename))
-                    throw new ArgumentException(string.Format(SR.Filename_in_SaveAs_is_used_already, filename));
+                    throw new ArgumentException(SR.Format(SR.Filename_in_SaveAs_is_used_already, filename));
 
                 // If there was no config file for this config record,
                 // record the new stream name and version.
@@ -1587,7 +1587,7 @@ namespace System.Configuration
                             (!overrideMode.IsDefaultForLocationTag || !inheritInChildApplications))
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_inconsistent_location_attributes, configKey));
+                                SR.Format(SR.Config_inconsistent_location_attributes, configKey));
                         }
 
                         addToConfigSourceUpdates = requireUpdates &&
@@ -1687,7 +1687,7 @@ namespace System.Configuration
                                         catch (Exception e)
                                         {
                                             throw new ConfigurationErrorsException(
-                                                string.Format(SR.Encryption_failed,
+                                                SR.Format(SR.Encryption_failed,
                                                     configSection.SectionInformation.SectionName,
                                                     configSection.SectionInformation.ProtectionProvider.Name, e.Message),
                                                 e);
@@ -1707,7 +1707,7 @@ namespace System.Configuration
                         catch (Exception e)
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_exception_in_config_section_handler,
+                                SR.Format(SR.Config_exception_in_config_section_handler,
                                     configSection.SectionInformation.SectionName), e);
                         }
                     }
@@ -1907,7 +1907,7 @@ namespace System.Configuration
                         catch (Exception e)
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_exception_in_config_section_handler, sectionRecord.ConfigKey), e,
+                                SR.Format(SR.Config_exception_in_config_section_handler, sectionRecord.ConfigKey), e,
                                 ConfigStreamInfo.StreamName, 0);
                         }
                     }
index ead1b43..726e57c 100644 (file)
@@ -57,7 +57,7 @@ namespace System.Configuration
                     if (section.Name != doc.DocumentElement.Name)
                     {
                         throw new ConfigurationErrorsException(
-                            string.Format(SR.Config_name_value_file_section_file_invalid_root, section.Name),
+                            SR.Format(SR.Config_name_value_file_section_file_invalid_root, section.Name),
                             doc.DocumentElement);
                     }
 
index 2e28350..985c783 100644 (file)
@@ -313,7 +313,7 @@ namespace System.Configuration
                         result = false;
                         break;
                     default:
-                        Debug.Assert(false, "Unrecognized OverrideMode");
+                        Debug.Fail("Unrecognized OverrideMode");
                         break;
                 }
 
index 23cb626..b9b8e07 100644 (file)
@@ -18,11 +18,11 @@ namespace System.Configuration
             if (!(provider is ProtectedConfigurationProvider))
             {
                 throw new ArgumentException(
-                    string.Format(SR.Config_provider_must_implement_type,
+                    SR.Format(SR.Config_provider_must_implement_type,
                         typeof(ProtectedConfigurationProvider).ToString()), nameof(provider));
             }
 
             base.Add(provider);
         }
     }
-}
\ No newline at end of file
+}
index 2d86713..df02774 100644 (file)
@@ -55,7 +55,7 @@ namespace System.Configuration
             ProviderSettings ps = Providers[providerName];
 
             if (ps == null)
-                throw new ArgumentException(string.Format(SR.ProtectedConfigurationProvider_not_found, providerName), nameof(providerName));
+                throw new ArgumentException(SR.Format(SR.ProtectedConfigurationProvider_not_found, providerName), nameof(providerName));
 
             return InstantiateProvider(ps);
         }
index 212bdbf..039286f 100644 (file)
@@ -32,7 +32,7 @@ namespace System.Configuration
 
             Match match = _regex.Match((string)value);
 
-            if (!match.Success) throw new ArgumentException(string.Format(SR.Regex_validator_error, _expression));
+            if (!match.Success) throw new ArgumentException(SR.Format(SR.Regex_validator_error, _expression));
         }
     }
-}
\ No newline at end of file
+}
index d4435d1..6e42304 100644 (file)
@@ -192,7 +192,7 @@ namespace System.Configuration
             _useOAEP = GetBooleanValue(configurationValues, "useOAEP", false);
             _useFIPS = GetBooleanValue(configurationValues, "useFIPS", false);
             if (configurationValues.Count > 0)
-                throw new ConfigurationErrorsException(string.Format(SR.Unrecognized_initialization_value, configurationValues.GetKey(0)));
+                throw new ConfigurationErrorsException(SR.Format(SR.Unrecognized_initialization_value, configurationValues.GetKey(0)));
         }
 
         public RSAParameters RsaPublicKey { get { return GetCryptoServiceProvider(false, false).ExportParameters(false); } }
@@ -244,7 +244,7 @@ namespace System.Configuration
                 return true;
             if (s == "false")
                 return false;
-            throw new ConfigurationErrorsException(string.Format(SR.Config_invalid_boolean_attribute, valueName));
+            throw new ConfigurationErrorsException(SR.Format(SR.Config_invalid_boolean_attribute, valueName));
         }
 
         private SymmetricAlgorithm GetSymAlgorithmProvider()
index a19a971..52e0b94 100644 (file)
@@ -72,7 +72,7 @@ namespace System.Configuration
                 catch (Exception e)
                 {
                     throw new ConfigurationErrorsException(
-                        string.Format(SR.Config_exception_in_config_section_handler,
+                        SR.Format(SR.Config_exception_in_config_section_handler,
                             section.SectionInformation.SectionName), e);
                 }
             }
@@ -128,7 +128,7 @@ namespace System.Configuration
                         if (ConfigurationElement.IsLockAttributeName(attribute.Name))
                         {
                             throw new ConfigurationErrorsException(
-                                string.Format(SR.Config_element_locking_not_supported, sectionName), attribute);
+                                SR.Format(SR.Config_element_locking_not_supported, sectionName), attribute);
                         }
                 }
 
@@ -188,4 +188,4 @@ namespace System.Configuration
             }
         }
     }
-}
\ No newline at end of file
+}
index a19fa80..3bf3301 100644 (file)
@@ -94,7 +94,7 @@ namespace System.Configuration
                 // so long as it doesn't conflict with a type already defined
                 FactoryRecord factoryRecord = FindParentFactoryRecord(false);
                 if ((factoryRecord != null) && (factoryRecord.AllowDefinition != value))
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined, ConfigKey));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined, ConfigKey));
 
                 _allowDefinition = value;
                 _modifiedFlags[FlagAllowDefinitionModified] = true;
@@ -115,7 +115,7 @@ namespace System.Configuration
                 // so long as it doesn't conflict with a type already defined
                 FactoryRecord factoryRecord = FindParentFactoryRecord(false);
                 if ((factoryRecord != null) && (factoryRecord.AllowExeDefinition != value))
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined, ConfigKey));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined, ConfigKey));
 
                 _allowExeDefinition = value;
                 _modifiedFlags[FlagAllowExeDefinitionModified] = true;
@@ -136,7 +136,7 @@ namespace System.Configuration
                 // so long as it doesn't conflict with a type already defined
                 FactoryRecord factoryRecord = FindParentFactoryRecord(false);
                 if ((factoryRecord != null) && (factoryRecord.OverrideModeDefault.OverrideMode != value))
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined, ConfigKey));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined, ConfigKey));
 
                 // Threat "Inherit" as "Allow" as "Inherit" does not make sense as a default
                 if (value == OverrideMode.Inherit) value = OverrideMode.Allow;
@@ -162,7 +162,7 @@ namespace System.Configuration
                 // so long as it doesn't conflict with a type already defined
                 FactoryRecord factoryRecord = FindParentFactoryRecord(false);
                 if ((factoryRecord != null) && (factoryRecord.AllowLocation != value))
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined, ConfigKey));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined, ConfigKey));
 
                 _flags[FlagAllowLocation] = value;
                 _modifiedFlags[FlagAllowLocation] = true;
@@ -208,7 +208,7 @@ namespace System.Configuration
                         _flags[FlagChildrenLocked] = true;
                         break;
                     default:
-                        Debug.Assert(false, "Unexpected value for OverrideMode");
+                        Debug.Fail("Unexpected value for OverrideMode");
                         break;
                 }
             }
@@ -326,7 +326,7 @@ namespace System.Configuration
                 // so long as it doesn't conflict with a type already defined
                 FactoryRecord factoryRecord = FindParentFactoryRecord(false);
                 if ((factoryRecord != null) && (factoryRecord.RestartOnExternalChanges != value))
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined, ConfigKey));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined, ConfigKey));
 
                 _flags[FlagRestartOnExternalChanges] = value;
                 _modifiedFlags[FlagRestartOnExternalChanges] = true;
@@ -347,7 +347,7 @@ namespace System.Configuration
                 // so long as it doesn't conflict with a type already defined
                 FactoryRecord factoryRecord = FindParentFactoryRecord(false);
                 if ((factoryRecord != null) && (factoryRecord.RequirePermission != value))
-                    throw new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined, ConfigKey));
+                    throw new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined, ConfigKey));
 
                 _flags[FlagRequirePermission] = value;
                 _modifiedFlags[FlagRequirePermission] = true;
@@ -377,7 +377,7 @@ namespace System.Configuration
 
                     if (!factoryRecord.IsEquivalentType(host, value))
                     {
-                        throw new ConfigurationErrorsException(string.Format(SR.Config_tag_name_already_defined,
+                        throw new ConfigurationErrorsException(SR.Format(SR.Config_tag_name_already_defined,
                             ConfigKey));
                     }
                 }
index 0a04123..096589f 100644 (file)
@@ -54,17 +54,17 @@ namespace System.Configuration
         private object GetPropertyValueByName(string propertyName)
         {
             if (Properties == null || _propertyValues == null || Properties.Count == 0)
-                throw new SettingsPropertyNotFoundException(string.Format(SR.SettingsPropertyNotFound, propertyName));
+                throw new SettingsPropertyNotFoundException(SR.Format(SR.SettingsPropertyNotFound, propertyName));
             SettingsProperty pp = Properties[propertyName];
             if (pp == null)
-                throw new SettingsPropertyNotFoundException(string.Format(SR.SettingsPropertyNotFound, propertyName));
+                throw new SettingsPropertyNotFoundException(SR.Format(SR.SettingsPropertyNotFound, propertyName));
             SettingsPropertyValue p = _propertyValues[propertyName];
             if (p == null)
             {
                 GetPropertiesFromProvider(pp.Provider);
                 p = _propertyValues[propertyName];
                 if (p == null)
-                    throw new SettingsPropertyNotFoundException(string.Format(SR.SettingsPropertyNotFound, propertyName));
+                    throw new SettingsPropertyNotFoundException(SR.Format(SR.SettingsPropertyNotFound, propertyName));
             }
             return p.PropertyValue;
         }
@@ -72,17 +72,17 @@ namespace System.Configuration
         private void SetPropertyValueByName(string propertyName, object propertyValue)
         {
             if (Properties == null || _propertyValues == null || Properties.Count == 0)
-                throw new SettingsPropertyNotFoundException(string.Format(SR.SettingsPropertyNotFound, propertyName));
+                throw new SettingsPropertyNotFoundException(SR.Format(SR.SettingsPropertyNotFound, propertyName));
 
             SettingsProperty pp = Properties[propertyName];
             if (pp == null)
-                throw new SettingsPropertyNotFoundException(string.Format(SR.SettingsPropertyNotFound, propertyName));
+                throw new SettingsPropertyNotFoundException(SR.Format(SR.SettingsPropertyNotFound, propertyName));
 
             if (pp.IsReadOnly)
-                throw new SettingsPropertyIsReadOnlyException(string.Format(SR.SettingsPropertyReadOnly, propertyName));
+                throw new SettingsPropertyIsReadOnlyException(SR.Format(SR.SettingsPropertyReadOnly, propertyName));
 
             if (propertyValue != null && !pp.PropertyType.IsInstanceOfType(propertyValue))
-                throw new SettingsPropertyWrongTypeException(string.Format(SR.SettingsPropertyWrongType, propertyName));
+                throw new SettingsPropertyWrongTypeException(SR.Format(SR.SettingsPropertyWrongType, propertyName));
 
             SettingsPropertyValue p = _propertyValues[propertyName];
             if (p == null)
@@ -90,7 +90,7 @@ namespace System.Configuration
                 GetPropertiesFromProvider(pp.Provider);
                 p = _propertyValues[propertyName];
                 if (p == null)
-                    throw new SettingsPropertyNotFoundException(string.Format(SR.SettingsPropertyNotFound, propertyName));
+                    throw new SettingsPropertyNotFoundException(SR.Format(SR.SettingsPropertyNotFound, propertyName));
             }
 
             p.PropertyValue = propertyValue;
index 962fa99..8dee53d 100644 (file)
@@ -151,12 +151,12 @@ namespace System.Configuration
                     }
                     catch (Exception e)
                     {
-                        throw new ArgumentException(string.Format(SR.Could_not_create_from_default_value, Property.Name, e.Message));
+                        throw new ArgumentException(SR.Format(SR.Could_not_create_from_default_value, Property.Name, e.Message));
                     }
                 }
 
                 if (value != null && !Property.PropertyType.IsAssignableFrom(value.GetType())) // is it the correct type
-                    throw new ArgumentException(string.Format(SR.Could_not_create_from_default_value_2, Property.Name));
+                    throw new ArgumentException(SR.Format(SR.Could_not_create_from_default_value_2, Property.Name));
             }
 
             // Attempt 3: Create via the parameterless constructor
@@ -206,7 +206,7 @@ namespace System.Configuration
                     TypeConverter converter = TypeDescriptor.GetConverter(type);
                     if (converter != null && converter.CanConvertTo(typeof(string)) && converter.CanConvertFrom(typeof(string)))
                         return converter.ConvertFromInvariantString(serializedValue);
-                    throw new ArgumentException(string.Format(SR.Unable_to_convert_type_from_string, type.ToString()), nameof(type));
+                    throw new ArgumentException(SR.Format(SR.Unable_to_convert_type_from_string, type), nameof(type));
                 default:
                     return null;
             }
@@ -246,7 +246,7 @@ namespace System.Configuration
                         TypeConverter converter = TypeDescriptor.GetConverter(type);
                         if (converter != null && converter.CanConvertTo(typeof(string)) && converter.CanConvertFrom(typeof(string)))
                             return converter.ConvertToInvariantString(propertyValue);
-                        throw new ArgumentException(string.Format(SR.Unable_to_convert_type_to_string, type.ToString()), nameof(type));
+                        throw new ArgumentException(SR.Format(SR.Unable_to_convert_type_to_string, type), nameof(type));
                     case SettingsSerializeAs.Xml:
                         XmlSerializer xs = new XmlSerializer(type);
                         StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
index d06798d..1ace349 100644 (file)
@@ -17,7 +17,7 @@ namespace System.Configuration
 
             if (!(provider is SettingsProvider))
             {
-                throw new ArgumentException(string.Format(SR.Config_provider_must_implement_type, typeof(SettingsProvider).ToString()), nameof(provider));
+                throw new ArgumentException(SR.Format(SR.Config_provider_must_implement_type, typeof(SettingsProvider)), nameof(provider));
             }
 
             base.Add(provider);
index 294ff4c..3401e83 100644 (file)
@@ -79,7 +79,7 @@ namespace System.Configuration
         private static void ThrowIfContainsDelimiter(string value)
         {
             if (value.Contains(",")) // string.Contains(char) is .NetCore2.1+ specific
-                throw new ConfigurationErrorsException(string.Format(SR.Config_base_value_cannot_contain, ","));
+                throw new ConfigurationErrorsException(SR.Format(SR.Config_base_value_cannot_contain, ","));
         }
 
         public void SetReadOnly()
index 05b0506..bbf3d2a 100644 (file)
@@ -38,9 +38,9 @@ namespace System.Configuration
             int len = data?.Length ?? 0;
 
             if (len < _minLength)
-                throw new ArgumentException(string.Format(SR.Validator_string_min_length, _minLength));
+                throw new ArgumentException(SR.Format(SR.Validator_string_min_length, _minLength));
             if (len > _maxLength)
-                throw new ArgumentException(string.Format(SR.Validator_string_max_length, _maxLength));
+                throw new ArgumentException(SR.Format(SR.Validator_string_max_length, _maxLength));
 
             // Check if the string contains any invalid characters
             if ((len > 0) && !string.IsNullOrEmpty(_invalidChars))
@@ -50,8 +50,8 @@ namespace System.Configuration
                 _invalidChars.CopyTo(0, array, 0, _invalidChars.Length);
 
                 if (data.IndexOfAny(array) != -1)
-                    throw new ArgumentException(string.Format(SR.Validator_string_invalid_chars, _invalidChars));
+                    throw new ArgumentException(SR.Format(SR.Validator_string_invalid_chars, _invalidChars));
             }
         }
     }
-}
\ No newline at end of file
+}
index f1e907c..1ccc195 100644 (file)
@@ -31,9 +31,9 @@ namespace System.Configuration
 
             if (!_base.IsAssignableFrom((Type)value))
             {
-                throw new ArgumentException(string.Format(SR.Subclass_validator_error, ((Type)value).FullName,
+                throw new ArgumentException(SR.Format(SR.Subclass_validator_error, ((Type)value).FullName,
                     _base.FullName));
             }
         }
     }
-}
\ No newline at end of file
+}
index 42dc47b..b043b76 100644 (file)
@@ -25,9 +25,9 @@ namespace System.Configuration
         {
             Type result = TypeUtil.GetType((string)data, false);
 
-            if (result == null) throw new ArgumentException(string.Format(SR.Type_cannot_be_resolved, (string)data));
+            if (result == null) throw new ArgumentException(SR.Format(SR.Type_cannot_be_resolved, (string)data));
 
             return result;
         }
     }
-}
\ No newline at end of file
+}
index e1f04f0..1be007d 100644 (file)
@@ -158,7 +158,7 @@ namespace System.Configuration
             ConstructorInfo ctor = type.GetConstructor(BindingFlags, null, CallingConventions.HasThis, Type.EmptyTypes,
                 null);
             if ((ctor == null) && throwOnError)
-                throw new TypeLoadException(string.Format(SR.TypeNotPublic, type.AssemblyQualifiedName));
+                throw new TypeLoadException(SR.Format(SR.TypeNotPublic, type.AssemblyQualifiedName));
 
             return ctor;
         }
@@ -171,7 +171,7 @@ namespace System.Configuration
             if (throwOnError)
             {
                 throw new TypeLoadException(
-                    string.Format(SR.Config_type_doesnt_inherit_from_type, type.FullName, baseType.FullName));
+                    SR.Format(SR.Config_type_doesnt_inherit_from_type, type.FullName, baseType.FullName));
             }
 
             return null;
index 3ebccbb..240ec40 100644 (file)
@@ -59,7 +59,7 @@ namespace System.Configuration
                     : SR.Validation_scalar_range_violation_not_in_range;
             }
 
-            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
+            throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
                 error,
                 min.ToString(),
                 max.ToString()));
@@ -70,7 +70,7 @@ namespace System.Configuration
             Debug.Assert(resolution > 0, "resolution > 0");
 
             if (value % resolution != 0)
-                throw new ArgumentException(string.Format(SR.Validator_scalar_resolution_violation, resolutionAsString));
+                throw new ArgumentException(SR.Format(SR.Validator_scalar_resolution_violation, resolutionAsString));
         }
 
         public static void ValidateScalar(TimeSpan value, TimeSpan min, TimeSpan max, long resolutionInSeconds,
@@ -86,4 +86,4 @@ namespace System.Configuration
             }
         }
     }
-}
\ No newline at end of file
+}
index 1ffa3b5..600118d 100644 (file)
@@ -271,7 +271,7 @@ namespace System.Configuration
         internal void AddErrorUnrecognizedAttribute(ExceptionAction action)
         {
             ConfigurationErrorsException ex = new ConfigurationErrorsException(
-                string.Format(SR.Config_base_unrecognized_attribute, Reader.Name),
+                SR.Format(SR.Config_base_unrecognized_attribute, Reader.Name),
                 this);
 
             SchemaErrors.AddError(ex, action);
@@ -280,7 +280,7 @@ namespace System.Configuration
         internal void AddErrorRequiredAttribute(string attrib, ExceptionAction action)
         {
             ConfigurationErrorsException ex = new ConfigurationErrorsException(
-                string.Format(SR.Config_missing_required_attribute, attrib, Reader.Name),
+                SR.Format(SR.Config_missing_required_attribute, attrib, Reader.Name),
                 this);
 
             SchemaErrors.AddError(ex, action);
@@ -289,7 +289,7 @@ namespace System.Configuration
         internal void AddErrorReservedAttribute(ExceptionAction action)
         {
             ConfigurationErrorsException ex = new ConfigurationErrorsException(
-                string.Format(SR.Config_reserved_attribute, Reader.Name),
+                SR.Format(SR.Config_reserved_attribute, Reader.Name),
                 this);
 
             SchemaErrors.AddError(ex, action);
@@ -312,7 +312,7 @@ namespace System.Configuration
                 newValue = null;
 
                 ConfigurationException ex = new ConfigurationErrorsException(
-                    string.Format(SR.Empty_attribute, Reader.Name),
+                    SR.Format(SR.Empty_attribute, Reader.Name),
                     this);
 
                 SchemaErrors.AddError(ex, action);
@@ -337,7 +337,7 @@ namespace System.Configuration
                 default:
                     newValue = defaultValue;
                     SchemaErrors.AddError(
-                        new ConfigurationErrorsException(string.Format(SR.Config_invalid_boolean_attribute, Reader.Name), this),
+                        new ConfigurationErrorsException(SR.Format(SR.Config_invalid_boolean_attribute, Reader.Name), this),
                         action);
                     break;
             }
index bcabe01..2521d11 100644 (file)
@@ -136,7 +136,7 @@ namespace System
 
                 default:
                     // This can never happen.
-                    Debug.Assert(false, "Unexpected handleType value (" + handleType + ")");
+                    Debug.Fail("Unexpected handleType value (" + handleType + ")");
                     return true;
             }
         }
index 075fb74..d538b6e 100644 (file)
@@ -71,7 +71,7 @@ namespace System.Data.Common
             {
                 case AcceptRejectRule.None:
                 case AcceptRejectRule.Cascade:
-                    Debug.Assert(false, "valid AcceptRejectRule " + value.ToString());
+                    Debug.Fail("valid AcceptRejectRule " + value.ToString());
                     break;
             }
 #endif
@@ -86,7 +86,7 @@ namespace System.Data.Common
             {
                 case CatalogLocation.Start:
                 case CatalogLocation.End:
-                    Debug.Assert(false, "valid CatalogLocation " + value.ToString());
+                    Debug.Fail("valid CatalogLocation " + value.ToString());
                     break;
             }
 #endif
@@ -101,7 +101,7 @@ namespace System.Data.Common
                 case ConflictOption.CompareAllSearchableValues:
                 case ConflictOption.CompareRowVersion:
                 case ConflictOption.OverwriteChanges:
-                    Debug.Assert(false, "valid ConflictOption " + value.ToString());
+                    Debug.Fail("valid ConflictOption " + value.ToString());
                     break;
             }
 #endif
@@ -119,7 +119,7 @@ namespace System.Data.Common
                 case DataRowState.Added:
                 case DataRowState.Deleted:
                 case DataRowState.Modified:
-                    Debug.Assert(false, "valid DataRowState " + value.ToString());
+                    Debug.Fail("valid DataRowState " + value.ToString());
                     break;
             }
 #endif
@@ -134,7 +134,7 @@ namespace System.Data.Common
             {
                 case KeyRestrictionBehavior.PreventUsage:
                 case KeyRestrictionBehavior.AllowOnly:
-                    Debug.Assert(false, "valid KeyRestrictionBehavior " + value.ToString());
+                    Debug.Fail("valid KeyRestrictionBehavior " + value.ToString());
                     break;
             }
 #endif
@@ -150,7 +150,7 @@ namespace System.Data.Common
                 case LoadOption.OverwriteChanges:
                 case LoadOption.PreserveChanges:
                 case LoadOption.Upsert:
-                    Debug.Assert(false, "valid LoadOption " + value.ToString());
+                    Debug.Fail("valid LoadOption " + value.ToString());
                     break;
             }
 #endif
@@ -166,7 +166,7 @@ namespace System.Data.Common
                 case MissingMappingAction.Passthrough:
                 case MissingMappingAction.Ignore:
                 case MissingMappingAction.Error:
-                    Debug.Assert(false, "valid MissingMappingAction " + value.ToString());
+                    Debug.Fail("valid MissingMappingAction " + value.ToString());
                     break;
             }
 #endif
@@ -183,7 +183,7 @@ namespace System.Data.Common
                 case MissingSchemaAction.Ignore:
                 case MissingSchemaAction.Error:
                 case MissingSchemaAction.AddWithKey:
-                    Debug.Assert(false, "valid MissingSchemaAction " + value.ToString());
+                    Debug.Fail("valid MissingSchemaAction " + value.ToString());
                     break;
             }
 #endif
@@ -199,7 +199,7 @@ namespace System.Data.Common
                 case Rule.Cascade:
                 case Rule.SetNull:
                 case Rule.SetDefault:
-                    Debug.Assert(false, "valid Rule " + value.ToString());
+                    Debug.Fail("valid Rule " + value.ToString());
                     break;
             }
 #endif
@@ -214,7 +214,7 @@ namespace System.Data.Common
             {
                 case SchemaType.Source:
                 case SchemaType.Mapped:
-                    Debug.Assert(false, "valid SchemaType " + value.ToString());
+                    Debug.Fail("valid SchemaType " + value.ToString());
                     break;
             }
 #endif
@@ -232,7 +232,7 @@ namespace System.Data.Common
                 case StatementType.Update:
                 case StatementType.Delete:
                 case StatementType.Batch:
-                    Debug.Assert(false, "valid StatementType " + value.ToString());
+                    Debug.Fail("valid StatementType " + value.ToString());
                     break;
             }
 #endif
@@ -249,7 +249,7 @@ namespace System.Data.Common
                 case UpdateStatus.ErrorsOccurred:
                 case UpdateStatus.SkipAllRemainingRows:
                 case UpdateStatus.SkipCurrentRow:
-                    Debug.Assert(false, "valid UpdateStatus " + value.ToString());
+                    Debug.Fail("valid UpdateStatus " + value.ToString());
                     break;
             }
 #endif
@@ -278,7 +278,7 @@ namespace System.Data.Common
         //
         internal static Exception WrongType(Type got, Type expected)
         {
-            return Argument(SR.Format(SR.SQL_WrongType, got.ToString(), expected.ToString()));
+            return Argument(SR.Format(SR.SQL_WrongType, got, expected));
         }
 
         //
@@ -458,7 +458,7 @@ namespace System.Data.Common
                         goto default;
 #if DEBUG
                     case StatementType.Select:
-                        Debug.Assert(false, "shouldn't be here");
+                        Debug.Fail("shouldn't be here");
                         goto default;
 #endif
                     default:
@@ -493,10 +493,10 @@ namespace System.Data.Common
                         break;
 #if DEBUG
                     case StatementType.Select:
-                        Debug.Assert(false, "shouldn't be here");
+                        Debug.Fail("shouldn't be here");
                         goto default;
                     case StatementType.Batch:
-                        Debug.Assert(false, "isRowUpdatingCommand should have been true");
+                        Debug.Fail("isRowUpdatingCommand should have been true");
                         goto default;
 #endif
                     default:
@@ -590,7 +590,7 @@ namespace System.Data.Common
 #if DEBUG
                 case StatementType.Select:
                 case StatementType.Insert:
-                    Debug.Assert(false, "should be here");
+                    Debug.Fail("should be here");
                     goto default;
 #endif
                 default:
@@ -626,7 +626,7 @@ namespace System.Data.Common
                         break;
 #if DEBUG
                     case StatementType.Batch:
-                        Debug.Assert(false, "isRowUpdatingCommand should have been true");
+                        Debug.Fail("isRowUpdatingCommand should have been true");
                         goto default;
 #endif
                     default:
@@ -840,4 +840,4 @@ namespace System.Data.Common
 
         internal static int SrcCompare(string strA, string strB) => strA == strB ? 0 : 1;
     }
-}
\ No newline at end of file
+}
index 1b77af4..617bed7 100644 (file)
@@ -197,7 +197,7 @@ namespace System.Data.Common
                                 // found duplicate name
                                 // the name unchanged name wins
                                 int iMutatedName = _isMutatedName[j] ? j : i;
-                                Debug.Assert(_isMutatedName[iMutatedName], string.Format(CultureInfo.InvariantCulture, "{0} expected to be a mutated name", _baseParameterNames[iMutatedName]));
+                                Debug.Assert(_isMutatedName[iMutatedName], $"{_baseParameterNames[iMutatedName]} expected to be a mutated name");
                                 _baseParameterNames[iMutatedName] = null;   // null out the culprit
                             }
                         }
@@ -601,7 +601,7 @@ namespace System.Data.Common
                     }
                     else
                     {
-                        Debug.Assert(false, "Rowcount expected to be 1");
+                        Debug.Fail("Rowcount expected to be 1");
                         useColumnsForParameterNames = false;
                     }
                 }
@@ -1539,7 +1539,7 @@ namespace System.Data.Common
                         switch (stmtType)
                         {
                             case StatementType.Select:
-                                Debug.Assert(false, "how did we get here?");
+                                Debug.Fail("how did we get here?");
                                 return; // don't mess with it
                             case StatementType.Insert:
                                 command = InsertCommand;
@@ -1604,7 +1604,7 @@ namespace System.Data.Common
                     break;
 #if DEBUG
                 case StatementType.Select:
-                    Debug.Assert(false, "how did we get here?");
+                    Debug.Fail("how did we get here?");
                     goto default;
 #endif
                 default:
index bc574a3..34b262b 100644 (file)
@@ -234,7 +234,7 @@ namespace System.Data.Common
 
         public virtual int GetStringLength(int record)
         {
-            Debug.Assert(false, "not a String or SqlString column");
+            Debug.Fail("not a String or SqlString column");
             return int.MaxValue;
         }
 
@@ -342,7 +342,7 @@ namespace System.Data.Common
                 case StorageType.SqlString: return new SqlStringStorage(column);
 
                 default:
-                    Debug.Assert(false, "shouldn't be here");
+                    Debug.Fail("shouldn't be here");
                     goto case StorageType.Object;
             }
         }
index 5def410..aa315f4 100644 (file)
@@ -1027,7 +1027,7 @@ namespace System.Data.Common
                                     dataCommand = _IDbDataAdapter.UpdateCommand;
                                     break;
                                 default:
-                                    Debug.Assert(false, "InvalidDataRowState");
+                                    Debug.Fail("InvalidDataRowState");
                                     throw ADP.InvalidDataRowState(dataRow.RowState); // out of Update without completing batch
                             }
 
@@ -1540,7 +1540,7 @@ namespace System.Data.Common
             else
             {
                 // StatementType.Select, StatementType.Batch
-                Debug.Assert(false, "unexpected StatementType");
+                Debug.Fail("unexpected StatementType");
             }
 
             // map the parameter results to the dataSet
index 69b51f3..258df6a 100644 (file)
@@ -643,7 +643,7 @@ namespace System.Data
         //
         // Storage
         //
-        public static Exception AggregateException(AggregateType aggregateType, Type type) => _Data(SR.Format(SR.DataStorage_AggregateException, aggregateType.ToString(), type.Name));
+        public static Exception AggregateException(AggregateType aggregateType, Type type) => _Data(SR.Format(SR.DataStorage_AggregateException, aggregateType, type.Name));
         public static Exception InvalidStorageType(TypeCode typecode) => _Data(SR.Format(SR.DataStorage_InvalidStorageType, typecode.ToString()));
         public static Exception RangeArgument(int min, int max) => _Argument(SR.Format(SR.Range_Argument, (min).ToString(CultureInfo.InvariantCulture), (max).ToString(CultureInfo.InvariantCulture)));
         public static Exception NullRange() => _Data(SR.Range_NullRange);
index f8587f2..ddaf339 100644 (file)
@@ -145,13 +145,13 @@ namespace System.Data
 
         public override int GetHashCode()
         {
-            Debug.Assert(false, "don't put DataKey into a Hashtable");
+            Debug.Fail("don't put DataKey into a Hashtable");
             return base.GetHashCode();
         }
         
         public override bool Equals(object value)
         {
-            Debug.Assert(false, "need to directly call Equals(DataKey)");
+            Debug.Fail("need to directly call Equals(DataKey)");
             return Equals((DataKey)value);
         }
 
index c241db1..fbae328 100644 (file)
@@ -5150,7 +5150,7 @@ namespace System.Data
                             }
                             break;
                         case DataRowState.Deleted:
-                            Debug.Assert(false, "LoadOption.Upsert with deleted row, should not be here");
+                            Debug.Fail("LoadOption.Upsert with deleted row, should not be here");
                             break;
                         default:
                             action = DataRowAction.Change;
index b4a0da3..bbe3b9d 100644 (file)
@@ -1282,7 +1282,7 @@ namespace System.Data
                     }
                     else
                     {
-                        Debug.Assert(false, "ItemAdded DataRow already in view");
+                        Debug.Fail("ItemAdded DataRow already in view");
                     }
                     break;
                 case ListChangedType.ItemDeleted:
@@ -1299,12 +1299,12 @@ namespace System.Data
                         }
                         else
                         {
-                            Debug.Assert(false, "ItemDeleted DataRow not in view tracking");
+                            Debug.Fail("ItemDeleted DataRow not in view tracking");
                         }
                     }
                     if (!_rowViewCache.Remove(row))
                     {
-                        Debug.Assert(false, "ItemDeleted DataRow not in view");
+                        Debug.Fail("ItemDeleted DataRow not in view");
                     }
                     break;
                 case ListChangedType.Reset:
@@ -1317,7 +1317,7 @@ namespace System.Data
                 case ListChangedType.PropertyDescriptorAdded:
                 case ListChangedType.PropertyDescriptorChanged:
                 case ListChangedType.PropertyDescriptorDeleted:
-                    Debug.Assert(false, "unexpected");
+                    Debug.Fail("unexpected");
                     break;
             }
         }
index 7c2876f..69916d8 100644 (file)
@@ -1251,7 +1251,7 @@ namespace System.Data
                 case DataTypePrecedence.SqlBinary: return StorageType.SqlBinary;
                 case DataTypePrecedence.SqlMoney: return StorageType.SqlMoney;
                 default:
-                    Debug.Assert(false, "Invalid (unmapped) precedence " + code.ToString());
+                    Debug.Fail("Invalid (unmapped) precedence " + code.ToString());
                     goto case DataTypePrecedence.Error;
             }
         }
@@ -1579,7 +1579,7 @@ namespace System.Data
                     string s2 = substring.TrimEnd(trimChars);
                     return table.IsSuffix(s1, s2);
                 default:
-                    Debug.Assert(false, "Unexpected LIKE kind");
+                    Debug.Fail("Unexpected LIKE kind");
                     return DBNull.Value;
             }
         }
index cfed574..1c13175 100644 (file)
@@ -59,7 +59,7 @@ namespace System.Data
                     break;
 
                 default:
-                    Debug.Assert(false, "NYI");
+                    Debug.Fail("NYI");
                     goto case ValueType.Object;
             }
         }
index e3fcfb3..d15a423 100644 (file)
@@ -307,7 +307,7 @@ namespace System.Data
                                 node = new ConstNode(_table, ValueType.Date, str);
                                 break;
                             default:
-                                Debug.Assert(false, "unhandled token");
+                                Debug.Fail("unhandled token");
                                 break;
                         }
 
@@ -762,7 +762,7 @@ namespace System.Data
                         break;
 
                     default:
-                        Debug.Assert(false, "Unhandled operator type");
+                        Debug.Fail("Unhandled operator type");
                         goto end_loop;
                 }
                 Debug.Assert(expr != null, "Failed to create expression");
index a898364..22704be 100644 (file)
@@ -217,7 +217,7 @@ namespace System.Data
 
         public static Exception ArgumentType(string function, int arg, Type type)
         {
-            return _Eval(SR.Format(SR.Expr_ArgumentType, function, arg.ToString(CultureInfo.InvariantCulture), type.ToString()));
+            return _Eval(SR.Format(SR.Expr_ArgumentType, function, arg.ToString(CultureInfo.InvariantCulture), type));
         }
 
         public static Exception ArgumentTypeInteger(string function, int arg)
@@ -227,12 +227,12 @@ namespace System.Data
 
         public static Exception TypeMismatchInBinop(int op, Type type1, Type type2)
         {
-            return _Eval(SR.Format(SR.Expr_TypeMismatchInBinop, Operators.ToString(op), type1.ToString(), type2.ToString()));
+            return _Eval(SR.Format(SR.Expr_TypeMismatchInBinop, Operators.ToString(op), type1, type2));
         }
 
         public static Exception AmbiguousBinop(int op, Type type1, Type type2)
         {
-            return _Eval(SR.Format(SR.Expr_AmbiguousBinop, Operators.ToString(op), type1.ToString(), type2.ToString()));
+            return _Eval(SR.Format(SR.Expr_AmbiguousBinop, Operators.ToString(op), type1, type2));
         }
 
         public static Exception UnsupportedOperator(int op)
index 413ce89..675a89a 100644 (file)
@@ -112,7 +112,7 @@ namespace System.Data
                                 value = -(SqlInt16)vl;
                                 break;
                             default:
-                                Debug.Assert(false, "Missing a type conversion");
+                                Debug.Fail("Missing a type conversion");
                                 value = DBNull.Value;
                                 break;
                         }
index c4b9235..bd58132 100644 (file)
@@ -345,7 +345,7 @@ namespace System.Data
                     }
                 default:
                     {
-                        Debug.Assert(false, "Unknown Rule value");
+                        Debug.Fail("Unknown Rule value");
                         break;
                     }
             }
@@ -479,7 +479,7 @@ namespace System.Data
                     }
                 default:
                     {
-                        Debug.Assert(false, "Unknown Rule value");
+                        Debug.Fail("Unknown Rule value");
                         break;
                     }
             }
@@ -542,7 +542,7 @@ namespace System.Data
                 }
                 else
                 {
-                    Debug.Assert(false, "attempt to cascade unknown action: " + action.ToString());
+                    Debug.Fail("attempt to cascade unknown action: " + action.ToString());
                 }
             }
             finally
index 4c13980..9ecb62a 100644 (file)
@@ -422,7 +422,7 @@ namespace System.Data.ProviderBase
                         dataRow = _dataTable.LoadDataRow(mapped, false);
                         break;
                     default:
-                        Debug.Assert(false, "unexpected LoadOption");
+                        Debug.Fail("unexpected LoadOption");
                         throw ADP.InvalidLoadOption(_loadOption);
                 }
                 if ((null != _chapterMap) && (null != _dataSet))
index 62db1e2..9b8e08b 100644 (file)
@@ -413,7 +413,7 @@ namespace System.Data.SqlTypes
             byte bActualPrecision = BActualPrec();
             _bPrec = bPrec;  // restore current value
 
-            Debug.Assert(precision == bActualPrecision, string.Format(null, "CalculatePrecision={0}, BActualPrec={1}. Results must be equal!", precision, bActualPrecision));
+            Debug.Assert(precision == bActualPrecision, $"CalculatePrecision={precision}, BActualPrec={bActualPrecision}. Results must be equal!");
 #endif
             return precision;
         }
index ca1b75c..ab8bd50 100644 (file)
@@ -434,7 +434,7 @@ namespace System.Data.SqlTypes
                     break;
 
                 default:
-                    Debug.Assert(false, "Invalid ecExpectedResult");
+                    Debug.Fail("Invalid ecExpectedResult");
                     return SqlBoolean.Null;
             }
 
index 05386f5..7cc41ce 100644 (file)
@@ -121,7 +121,7 @@ namespace System.Xml
             {
                 if (CurrentNode != _rowElement)
                 {
-                    Debug.Assert(false);
+                    Debug.Fail("Reading the initial text value for sub-regions.");
                 }
             }
 #endif
index 6887fc7..9344c2e 100644 (file)
@@ -1226,8 +1226,7 @@ namespace System.Xml
                 parent2 = curNode2.ParentNode;
             }
 
-            //logically, we shouldn't reach here
-            Debug.Assert(false);
+            Debug.Fail("Logically, we shouldn't reach here.");
             return XmlNodeOrder.Unknown;
         }
 
index 8498332..cd679f4 100644 (file)
@@ -81,7 +81,7 @@ namespace System.Xml
 #if DEBUG
             object val = _pointers[pointer];
             if (val != (object)pointer)
-                Debug.Assert(false);
+                Debug.Fail("Pointer not present");
 #endif
         }
         // This function attaches the DataSet to XmlDataDocument
@@ -1092,7 +1092,7 @@ namespace System.Xml
                     return true;
 
                 case XmlNodeType.EntityReference:
-                    Debug.Assert(false);
+                    Debug.Fail("Found entity reference");
                     return false;
 
                 default:
@@ -1250,12 +1250,10 @@ namespace System.Xml
                                 // Nothing to do (the row already has an associated element as a fragment
                                 break;
                             case DataRowState.Detached:
-                                // We should not get rows in this state
-                                Debug.Assert(false);
+                                Debug.Fail("We should not get rows in this state");
                                 break;
                             default:
-                                // Unknown row state
-                                Debug.Assert(false);
+                                Debug.Fail("Unknown row state");
                                 break;
                         }
                     }
@@ -2068,11 +2066,11 @@ namespace System.Xml
                             break;
 
                         case DataRowAction.Delete:
-                            // DataRow is beeing deleted
+                            // DataRow is being deleted
                             //    - state transition from New (AKA PendingInsert) to Detached (AKA Created)
                             //    - state transition from Unchanged to Deleted (AKA PendingDelete)
                             //    - state transition from Modified (AKA PendingChange) to Delete (AKA PendingDelete)
-                            Debug.Assert(false);  // This should have been handled above, irrespective of ignoreDataSetEvents value (true or false)
+                            Debug.Fail("This should have been handled above, irrespective of ignoreDataSetEvents value (true or false)");
                             break;
 
                         case DataRowAction.Rollback:
@@ -2420,8 +2418,7 @@ namespace System.Xml
             }
             catch
             {
-                // We should not get any exceptions because we always handle data-type conversion
-                Debug.Assert(false);
+                Debug.Fail("We should not get any exceptions because we always handle data-type conversion");
                 throw;
             }
 #endif
@@ -2434,8 +2431,7 @@ namespace System.Xml
             }
             catch
             {
-                // We should not get any exceptions because DataSet.EnforceConstraints should be always off
-                Debug.Assert(false);
+                Debug.Fail("We should not get any exceptions because DataSet.EnforceConstraints should be always off");
                 throw;
             }
 #endif
@@ -2732,8 +2728,7 @@ namespace System.Xml
                     }
                     catch
                     {
-                        // We should not get any exceptions here
-                        Debug.Assert(false);
+                        Debug.Fail("We should not get any exceptions here");
                         throw;
                     }
 #endif
@@ -2761,15 +2756,13 @@ namespace System.Xml
                     }
                     catch
                     {
-                        // We should not get any exceptions here
-                        Debug.Assert(false);
+                        Debug.Fail("We should not get any exceptions here");
                         throw;
                     }
 #endif
                     break;
                 default:
-                    // Handle your case above
-                    Debug.Assert(false);
+                    Debug.Fail("Handle your case above");
                     break;
             }
             Debug.Assert(IsRowLive(rowElem.Row));
@@ -2796,8 +2789,7 @@ namespace System.Xml
                     }
                     catch
                     {
-                        // We should not get any exceptions here
-                        Debug.Assert(false);
+                        Debug.Fail("We should not get any exceptions here");
                         throw;
                     }
 #endif
@@ -2820,8 +2812,7 @@ namespace System.Xml
                     break;
 
                 default:
-                    // Handle your case above
-                    Debug.Assert(false);
+                    Debug.Fail("Handle your case above");
                     break;
             }
 
index c2fc2bb..a84613a 100644 (file)
@@ -162,7 +162,7 @@ namespace System.Data
             {
                 if (DBNull.Value == value)
                 {
-                    throw DataSetUtil.InvalidCast(string.Format(SR.DataSetLinq_NonNullableCast, typeof(T).ToString()));
+                    throw DataSetUtil.InvalidCast(SR.Format(SR.DataSetLinq_NonNullableCast, typeof(T)));
                 }
                 return (T)value;
             }
index c06e089..fb781d3 100644 (file)
@@ -59,7 +59,7 @@ internal static class DataSetUtil
 
     static internal ArgumentOutOfRangeException InvalidEnumerationValue(Type type, int value)
     {
-        return ArgumentOutOfRange(string.Format(SR.DataSetLinq_InvalidEnumerationValue, type.Name, value.ToString(System.Globalization.CultureInfo.InvariantCulture)), type.Name);
+        return ArgumentOutOfRange(SR.Format(SR.DataSetLinq_InvalidEnumerationValue, type.Name, value.ToString(System.Globalization.CultureInfo.InvariantCulture)), type.Name);
     }
 
     static internal ArgumentOutOfRangeException InvalidDataRowState(DataRowState value)
@@ -72,7 +72,7 @@ internal static class DataSetUtil
             case DataRowState.Added:
             case DataRowState.Deleted:
             case DataRowState.Modified:
-                Debug.Assert(false, "valid DataRowState " + value.ToString());
+                Debug.Fail("valid DataRowState " + value.ToString());
                 break;
         }
 #endif
@@ -87,7 +87,7 @@ internal static class DataSetUtil
             case LoadOption.OverwriteChanges:
             case LoadOption.PreserveChanges:
             case LoadOption.Upsert:
-                Debug.Assert(false, "valid LoadOption " + value.ToString());
+                Debug.Fail("valid LoadOption " + value.ToString());
                 break;
         }
 #endif
@@ -114,4 +114,4 @@ internal static class DataSetUtil
                  (type != s_accessViolationType) &&
                  !s_securityType.IsAssignableFrom(type));
     }
-}
\ No newline at end of file
+}
index 929a9df..fc4917e 100644 (file)
@@ -94,7 +94,7 @@ namespace System.Data.Common
                 case CommandType.Text:
                 case CommandType.StoredProcedure:
                 case CommandType.TableDirect:
-                    Debug.Assert(false, "valid CommandType " + value.ToString());
+                    Debug.Fail("valid CommandType " + value.ToString());
                     break;
             }
 #endif
@@ -111,7 +111,7 @@ namespace System.Data.Common
                 case DataRowVersion.Current:
                 case DataRowVersion.Original:
                 case DataRowVersion.Proposed:
-                    Debug.Assert(false, "valid DataRowVersion " + value.ToString());
+                    Debug.Fail("valid DataRowVersion " + value.ToString());
                     break;
             }
 #endif
@@ -131,7 +131,7 @@ namespace System.Data.Common
                 case IsolationLevel.RepeatableRead:
                 case IsolationLevel.Serializable:
                 case IsolationLevel.Snapshot:
-                    Debug.Assert(false, "valid IsolationLevel " + value.ToString());
+                    Debug.Fail("valid IsolationLevel " + value.ToString());
                     break;
             }
 #endif
@@ -146,7 +146,7 @@ namespace System.Data.Common
             {
                 case KeyRestrictionBehavior.PreventUsage:
                 case KeyRestrictionBehavior.AllowOnly:
-                    Debug.Assert(false, "valid KeyRestrictionBehavior " + value.ToString());
+                    Debug.Fail("valid KeyRestrictionBehavior " + value.ToString());
                     break;
             }
 #endif
@@ -163,7 +163,7 @@ namespace System.Data.Common
                 case ParameterDirection.Output:
                 case ParameterDirection.InputOutput:
                 case ParameterDirection.ReturnValue:
-                    Debug.Assert(false, "valid ParameterDirection " + value.ToString());
+                    Debug.Fail("valid ParameterDirection " + value.ToString());
                     break;
             }
 #endif
@@ -180,7 +180,7 @@ namespace System.Data.Common
                 case UpdateRowSource.OutputParameters:
                 case UpdateRowSource.FirstReturnedRecord:
                 case UpdateRowSource.Both:
-                    Debug.Assert(false, "valid UpdateRowSource " + value.ToString());
+                    Debug.Fail("valid UpdateRowSource " + value.ToString());
                     break;
             }
 #endif
index 8ab02b7..ee134b0 100644 (file)
@@ -172,7 +172,7 @@ namespace System.Data.Common
 #if DEBUG
                             else
                             {
-                                Debug.Assert(false, "empty restriction");
+                                Debug.Fail("empty restriction");
                             }
 #endif
                         }
@@ -314,7 +314,7 @@ namespace System.Data.Common
                     }
                     else
                     {
-                        Debug.Assert(false, string.Format("Unknown behavior for combined set: {0}", combinedSet._behavior));
+                        Debug.Fail($"Unknown behavior for combined set: {combinedSet._behavior}");
                     }
                 }
                 else if (componentSet._behavior == KeyRestrictionBehavior.PreventUsage)
@@ -335,12 +335,12 @@ namespace System.Data.Common
                     }
                     else
                     {
-                        Debug.Assert(false, string.Format("Unknown behavior for combined set: {0}", combinedSet._behavior));
+                        Debug.Fail($"Unknown behavior for combined set: {combinedSet._behavior}");
                     }
                 }
                 else
                 {
-                    Debug.Assert(false, string.Format("Unknown behavior for component set: {0}", componentSet._behavior));
+                    Debug.Fail($"Unknown behavior for component set: {componentSet._behavior}");
                 }
             }
         }
@@ -383,7 +383,7 @@ namespace System.Data.Common
                     }
                     break;
                 default:
-                    Debug.Assert(false, "invalid KeyRestrictionBehavior");
+                    Debug.Fail("invalid KeyRestrictionBehavior");
                     throw ADP.InvalidKeyRestrictionBehavior(_behavior);
             }
             return true;
@@ -540,4 +540,4 @@ namespace System.Data.Common
             }
         }
     }
-}
\ No newline at end of file
+}
index b71de57..9cf9745 100644 (file)
@@ -44,12 +44,12 @@ namespace System.Data.Odbc
             {
                 case CommandType.Text:
                 case CommandType.StoredProcedure:
-                    Debug.Assert(false, "valid CommandType " + value.ToString());
+                    Debug.Fail("valid CommandType " + value.ToString());
                     break;
                 case CommandType.TableDirect:
                     break;
                 default:
-                    Debug.Assert(false, "invalid CommandType " + value.ToString());
+                    Debug.Fail("invalid CommandType " + value.ToString());
                     break;
             }
 #endif
@@ -66,12 +66,12 @@ namespace System.Data.Odbc
                 case IsolationLevel.RepeatableRead:
                 case IsolationLevel.Serializable:
                 case IsolationLevel.Snapshot:
-                    Debug.Assert(false, "valid IsolationLevel " + value.ToString());
+                    Debug.Fail("valid IsolationLevel " + value.ToString());
                     break;
                 case IsolationLevel.Chaos:
                     break;
                 default:
-                    Debug.Assert(false, "invalid IsolationLevel " + value.ToString());
+                    Debug.Fail("invalid IsolationLevel " + value.ToString());
                     break;
             }
 #endif
@@ -167,7 +167,7 @@ namespace System.Data.Odbc
                 case RetCode.INVALID_HANDLE: return "INVALID_HANDLE";
                 case RetCode.NO_DATA: return "NO_DATA";
                 default:
-                    Debug.Assert(false, "Unknown enumerator passed to RetcodeToString method");
+                    Debug.Fail("Unknown enumerator passed to RetcodeToString method");
                     goto case RetCode.ERROR;
             }
         }
index b20cef2..a172a1b 100644 (file)
@@ -796,7 +796,7 @@ namespace System.Data.Odbc
 
                             default:
                                 // this should NEVER happen
-                                Debug.Assert(false, "ExecuteReaderObjectcalled with unsupported ODBC API method.");
+                                Debug.Fail("ExecuteReaderObjectcalled with unsupported ODBC API method.");
                                 throw ADP.InvalidOperation(method.ToString());
                         }
 
index c96c97a..0025de6 100644 (file)
@@ -227,7 +227,7 @@ namespace System.Data.Odbc
                             parameter.Direction = ParameterDirection.ReturnValue;
                             break;
                         default:
-                            Debug.Assert(false, "Unexpected Parametertype while DeriveParamters");
+                            Debug.Fail("Unexpected Parametertype while DeriveParamters");
                             break;
                     }
                     parameter.OdbcType = TypeMap.FromSqlType((ODBC32.SQL_TYPE)reader.GetInt16(ODBC32.DATA_TYPE - 1))._odbcType;
index 8c2e06d..223e729 100644 (file)
@@ -723,7 +723,7 @@ namespace System.Data.Odbc
                     ProviderInfo.NoConnectionDead = true;
                     break;
                 default:
-                    Debug.Assert(false, "Can't flag unknown Attribute");
+                    Debug.Fail("Can't flag unknown Attribute");
                     break;
             }
         }
@@ -742,7 +742,7 @@ namespace System.Data.Odbc
                     ProviderInfo.NoSqlSoptSSHiddenColumns = true;
                     break;
                 default:
-                    Debug.Assert(false, "Can't flag unknown Attribute");
+                    Debug.Fail("Can't flag unknown Attribute");
                     break;
             }
         }
@@ -759,7 +759,7 @@ namespace System.Data.Odbc
                         break;
                     // SSS_WARNINGS_ON
                     default:
-                        Debug.Assert(false, "Can't flag unknown Attribute");
+                        Debug.Fail("Can't flag unknown Attribute");
                         break;
                 }
             }
@@ -768,7 +768,7 @@ namespace System.Data.Odbc
                 switch (v2FieldId)
                 {
                     default:
-                        Debug.Assert(false, "Can't flag unknown Attribute");
+                        Debug.Fail("Can't flag unknown Attribute");
                         break;
                 }
             }
@@ -787,7 +787,7 @@ namespace System.Data.Odbc
             }
             else
             {
-                Debug.Assert(false, "GetFunctions called and ConnectionHandle is null (connection is disposed?)");
+                Debug.Fail("GetFunctions called and ConnectionHandle is null (connection is disposed?)");
                 throw ODBC.ConnectionClosed();
             }
 
@@ -838,7 +838,7 @@ namespace System.Data.Odbc
                         break;
                     }
                 default:
-                    Debug.Assert(false, "Testing that sqltype is currently not supported");
+                    Debug.Fail("Testing that sqltype is currently not supported");
                     return false;
             }
             // now we can check if we have already tested that type
@@ -875,7 +875,7 @@ namespace System.Data.Odbc
                         break;
                     }
                 default:
-                    Debug.Assert(false, "Testing that sqltype is currently not supported");
+                    Debug.Fail("Testing that sqltype is currently not supported");
                     return false;
             }
             return (0 != (ProviderInfo.RestrictedSQLBindTypes & (int)sqlcvt));
index 8bee497..304ded8 100644 (file)
@@ -238,7 +238,7 @@ namespace System.Data.Odbc
             }
             else
             {
-                Debug.Assert(false, "unexpected state switch");
+                Debug.Fail("unexpected state switch");
                 if (originalState != currentState)
                 {
                     OnStateChange(new StateChangeEventArgs(originalState, currentState));
index d954980..9724ca0 100644 (file)
@@ -88,7 +88,7 @@ namespace System.Data.Odbc
                             case Keywords.Dsn: Dsn = ConvertToString(value); break;
                             //                      case Keywords.NamedConnection: NamedConnection = ConvertToString(value); break;
                             default:
-                                Debug.Assert(false, "unexpected keyword");
+                                Debug.Fail("unexpected keyword");
                                 throw ADP.KeywordNotSupported(keyword);
                         }
                     }
@@ -226,7 +226,7 @@ namespace System.Data.Odbc
                 case Keywords.Dsn: return Dsn;
                 //          case Keywords.NamedConnection: return NamedConnection;
                 default:
-                    Debug.Assert(false, "unexpected keyword");
+                    Debug.Fail("unexpected keyword");
                     throw ADP.KeywordNotSupported(s_validKeywords[(int)index]);
             }
         }
@@ -303,7 +303,7 @@ namespace System.Data.Odbc
                 //               _namedConnection = DbConnectionStringDefaults.NamedConnection;
                 //                break;
                 default:
-                    Debug.Assert(false, "unexpected keyword");
+                    Debug.Fail("unexpected keyword");
                     throw ADP.KeywordNotSupported(s_validKeywords[(int)index]);
             }
         }
index e36852a..09dcfce 100644 (file)
@@ -73,7 +73,7 @@ namespace System.Data.Odbc
                 CNativeBuffer value = _cmdWrapper._dataReaderBuf;
                 if (null == value)
                 {
-                    Debug.Assert(false, "object is disposed");
+                    Debug.Fail("object is disposed");
                     throw new ObjectDisposedException(GetType().Name);
                 }
                 return value;
@@ -1666,7 +1666,7 @@ namespace System.Data.Odbc
             // APP_PARAM_DESC is a (ODBCVER >= 0x0300) attribute
             if (!Connection.IsV3Driver)
             {
-                Debug.Assert(false, "Non-V3 driver. Must not call GetDescFieldStr");
+                Debug.Fail("Non-V3 driver. Must not call GetDescFieldStr");
                 return null;
             }
 
index b149052..d642517 100644 (file)
@@ -43,7 +43,7 @@ namespace System.Data.Odbc
                         break;
                     //              case ODBC32.SQL_HANDLE.DESC:
                     default:
-                        Debug.Assert(false, "unexpected handleType");
+                        Debug.Fail("unexpected handleType");
                         break;
                 }
             }
index 15f00c2..ec888aa 100644 (file)
@@ -396,7 +396,7 @@ namespace System.Data.Odbc
                             }
                         }
 #if DEBUG
-                        else { Debug.Assert(false, "not expecting this"); }
+                        else { Debug.Fail("not expecting this"); }
 #endif
                         // Note: ColumnSize should never be 0,
                         // this represents the size of the column on the backend.
@@ -407,7 +407,7 @@ namespace System.Data.Odbc
                     }
                 }
             }
-            Debug.Assert((0 <= cch) && (cch < 0x3fffffff), string.Format((IFormatProvider)null, "GetColumnSize: cch = {0} out of range, _internalShouldSerializeSize = {1}, _internalSize = {2}", cch, _internalShouldSerializeSize, _internalSize));
+            Debug.Assert((0 <= cch) && (cch < 0x3fffffff), $"GetColumnSize: cch = {cch} out of range, _internalShouldSerializeSize = {_internalShouldSerializeSize}, _internalSize = {_internalSize}");
             return cch;
         }
 
@@ -452,7 +452,7 @@ namespace System.Data.Odbc
                     cch *= 2;
                 }
             }
-            Debug.Assert((0 <= cch) && (cch < 0x3fffffff), string.Format((IFormatProvider)null, "GetValueSize: cch = {0} out of range, _internalShouldSerializeSize = {1}, _internalSize = {2}", cch, _internalShouldSerializeSize, _internalSize));
+            Debug.Assert((0 <= cch) && (cch < 0x3fffffff), $"GetValueSize: cch = {cch} out of range, _internalShouldSerializeSize = {_internalShouldSerializeSize}, _internalSize = {_internalSize}");
             return cch;
         }
 
@@ -501,7 +501,7 @@ namespace System.Data.Odbc
                             ccb = ((byte[])value).Length - offset;
                         }
 #if DEBUG
-                        else { Debug.Assert(false, "not expecting this"); }
+                        else { Debug.Fail("not expecting this"); }
 #endif
                         if ((0 != (ParameterDirection.Output & _internalDirection)) && (0x3fffffff <= _internalSize))
                         {
@@ -1101,7 +1101,7 @@ namespace System.Data.Odbc
                 case ParameterDirection.InputOutput:
                     return ODBC32.SQL_PARAM.INPUT_OUTPUT;
                 default:
-                    Debug.Assert(false, "Unexpected Direction Property on Parameter");
+                    Debug.Fail("Unexpected Direction Property on Parameter");
                     return ODBC32.SQL_PARAM.INPUT;
             }
         }
index fd14e8c..62f6866 100644 (file)
@@ -30,7 +30,7 @@ namespace System.Data.Odbc
                     }
                     else
                     {
-                        Debug.Assert(false, "shouldn't be here");
+                        Debug.Fail("shouldn't be here");
                     }
                     break;
                 case Closing:
@@ -40,11 +40,11 @@ namespace System.Data.Odbc
                     }
                     else
                     {
-                        Debug.Assert(false, "shouldn't be here");
+                        Debug.Fail("shouldn't be here");
                     }
                     break;
                 default:
-                    Debug.Assert(false, "shouldn't be here");
+                    Debug.Fail("shouldn't be here");
                     break;
             }
         }
index 8b0b56d..2ca26f0 100644 (file)
@@ -141,7 +141,7 @@ namespace System.Data.Odbc
                     break;
 
                 default:
-                    Debug.Assert(false, "UnknownSQLCType");
+                    Debug.Fail("UnknownSQLCType");
                     value = null;
                     break;
             };
@@ -313,7 +313,7 @@ namespace System.Data.Odbc
                     }
 
                 default:
-                    Debug.Assert(false, "UnknownSQLCType");
+                    Debug.Fail("UnknownSQLCType");
                     break;
             }
         }
index dc38087..580c202 100644 (file)
@@ -330,7 +330,7 @@ namespace Microsoft.SqlServer.Server
                     // For SqlParameter, both userDefinedType and udtAssemblyQualifiedName can be NULL,
                     // so we are checking only maxLength if it will be used (i.e. userDefinedType is NULL)
                     Debug.Assert((null != userDefinedType) || (0 <= maxLength || UnlimitedMaxLengthIndicator == maxLength),
-                            string.Format(null, "SmiMetaData.ctor: Udt name={0}, maxLength={1}", udtAssemblyQualifiedName, maxLength));
+                            $"SmiMetaData.ctor: Udt name={udtAssemblyQualifiedName}, maxLength={maxLength}");
                     // Type not validated until matched to a server.  Could be null if extended metadata supplies three-part name!
                     _clrType = userDefinedType;
                     if (null != userDefinedType)
@@ -367,7 +367,7 @@ namespace Microsoft.SqlServer.Server
                     _maxLength = 10 - s_maxVarTimeLenOffsetFromScale[scale];
                     break;
                 default:
-                    Debug.Assert(false, "How in the world did we get here? :" + dbType);
+                    Debug.Fail("How in the world did we get here? :" + dbType);
                     break;
             }
 
@@ -1280,4 +1280,4 @@ namespace Microsoft.SqlServer.Server
 
         internal SqlBoolean IsHidden => _isHidden;
     }
-}
\ No newline at end of file
+}
index 6ce6112..9eb5fcc 100644 (file)
@@ -1551,7 +1551,7 @@ namespace Microsoft.SqlServer.Server
                 case ExtendedClrTypeCode.TextReader: SetTextReader_Unchecked(sink, setters, ordinal, metaData, (TextDataFeed)value); break;
                 case ExtendedClrTypeCode.XmlReader: SetXmlReader_Unchecked(sink, setters, ordinal, ((XmlDataFeed)value)._source); break;
                 default:
-                    Debug.Assert(false, "Unvalidated extendedtypecode: " + typeCode);
+                    Debug.Fail("Unvalidated extendedtypecode: " + typeCode);
                     break;
             }
         }
@@ -1807,7 +1807,7 @@ namespace Microsoft.SqlServer.Server
                             // invalid instance of SqlDbType, or one would have to add 
                             // new member to SqlDbType without adding a case in this 
                             // switch, hence the assert.
-                            Debug.Assert(false, "unsupported DbType:" + metaData[i].SqlDbType.ToString());
+                            Debug.Fail("unsupported DbType:" + metaData[i].SqlDbType.ToString());
                             throw ADP.NotSupported();
                     }
                 }
@@ -2015,7 +2015,7 @@ namespace Microsoft.SqlServer.Server
                             // invalid instance of SqlDbType, or one would have to add 
                             // new member to SqlDbType without adding a case in this 
                             // switch, hence the assert.
-                            Debug.Assert(false, "unsupported DbType:" + metaData[i].SqlDbType.ToString());
+                            Debug.Fail("unsupported DbType:" + metaData[i].SqlDbType.ToString());
                             throw ADP.NotSupported();
                     }
                 }
@@ -2177,7 +2177,7 @@ namespace Microsoft.SqlServer.Server
                             break;
 
                         default:
-                            Debug.Assert(false, "unsupported DbType:" + metaData[i].SqlDbType.ToString());
+                            Debug.Fail("unsupported DbType:" + metaData[i].SqlDbType.ToString());
                             throw ADP.NotSupported();
                     }
                 }
@@ -3047,12 +3047,12 @@ namespace Microsoft.SqlServer.Server
         internal static int GetBytes_Unchecked(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
         {
             Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
-            Debug.Assert(ordinal >= 0, string.Format("Invalid ordinal: {0}", ordinal));
+            Debug.Assert(ordinal >= 0, $"Invalid ordinal: {ordinal}");
             Debug.Assert(sink != null, "Null SmiEventSink");
             Debug.Assert(getters != null, "Null getters");
-            Debug.Assert(fieldOffset >= 0, string.Format("Invalid field offset: {0}", fieldOffset));
+            Debug.Assert(fieldOffset >= 0, $"Invalid field offset: {fieldOffset}");
             Debug.Assert(buffer != null, "Null buffer");
-            Debug.Assert(bufferOffset >= 0 && length >= 0 && bufferOffset + length <= buffer.Length, string.Format("Bad offset or length. bufferOffset: {0}, length: {1}, buffer.Length{2}", bufferOffset, length, buffer.Length));
+            Debug.Assert(bufferOffset >= 0 && length >= 0 && bufferOffset + length <= buffer.Length, $"Bad offset or length. bufferOffset: {bufferOffset}, length: {length}, buffer.Length{buffer.Length}");
 
             int result = getters.GetBytes(sink, ordinal, fieldOffset, buffer, bufferOffset, length);
             sink.ProcessMessagesAndThrow();
@@ -3086,12 +3086,12 @@ namespace Microsoft.SqlServer.Server
         internal static int GetChars_Unchecked(SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length)
         {
             Debug.Assert(!IsDBNull_Unchecked(sink, getters, ordinal));
-            Debug.Assert(ordinal >= 0, string.Format("Invalid ordinal: {0}", ordinal));
+            Debug.Assert(ordinal >= 0, $"Invalid ordinal: {ordinal}");
             Debug.Assert(sink != null, "Null SmiEventSink");
             Debug.Assert(getters != null, "Null getters");
-            Debug.Assert(fieldOffset >= 0, string.Format("Invalid field offset: {0}", fieldOffset));
+            Debug.Assert(fieldOffset >= 0, $"Invalid field offset: {fieldOffset}");
             Debug.Assert(buffer != null, "Null buffer");
-            Debug.Assert(bufferOffset >= 0 && length >= 0 && bufferOffset + length <= buffer.Length, string.Format("Bad offset or length. bufferOffset: {0}, length: {1}, buffer.Length{2}", bufferOffset, length, buffer.Length));
+            Debug.Assert(bufferOffset >= 0 && length >= 0 && bufferOffset + length <= buffer.Length, $"Bad offset or length. bufferOffset: {bufferOffset}, length: {length}, buffer.Length{buffer.Length}");
 
             int result = getters.GetChars(sink, ordinal, fieldOffset, buffer, bufferOffset, length);
             sink.ProcessMessagesAndThrow();
index d2f51ae..e37e22c 100644 (file)
@@ -116,7 +116,7 @@ namespace System.Data.Common
                 case CommandType.Text:
                 case CommandType.StoredProcedure:
                 case CommandType.TableDirect:
-                    Debug.Assert(false, "valid CommandType " + value.ToString());
+                    Debug.Fail("valid CommandType " + value.ToString());
                     break;
             }
 #endif
@@ -154,7 +154,7 @@ namespace System.Data.Common
                 case ParameterDirection.Output:
                 case ParameterDirection.InputOutput:
                 case ParameterDirection.ReturnValue:
-                    Debug.Assert(false, "valid ParameterDirection " + value.ToString());
+                    Debug.Fail("valid ParameterDirection " + value.ToString());
                     break;
             }
 #endif
@@ -177,7 +177,7 @@ namespace System.Data.Common
                 case UpdateRowSource.OutputParameters:
                 case UpdateRowSource.FirstReturnedRecord:
                 case UpdateRowSource.Both:
-                    Debug.Assert(false, "valid UpdateRowSource " + value.ToString());
+                    Debug.Fail("valid UpdateRowSource " + value.ToString());
                     break;
             }
 #endif
index c98ef72..0a84175 100644 (file)
@@ -102,7 +102,7 @@ namespace System.Data
             if (sniError != 0)
             {
                 string sniErrorMessage = SQL.GetSNIErrorMessage(sniError);
-                errorMessage = string.Format((IFormatProvider)null, "{0} (error: {1} - {2})",
+                errorMessage = string.Format("{0} (error: {1} - {2})",
                          errorMessage, sniError, sniErrorMessage);
             }
 
index ceaa311..48a850a 100644 (file)
@@ -455,7 +455,7 @@ namespace System.Data.SqlClient
             string CatalogName = parts[MultipartIdentifier.CatalogIndex];
             if (isTempTable && string.IsNullOrEmpty(CatalogName))
             {
-                TDSCommand += string.Format((IFormatProvider)null, "exec tempdb..{0} N'{1}.{2}'",
+                TDSCommand += string.Format("exec tempdb..{0} N'{1}.{2}'",
                     TableCollationsStoredProc,
                     SchemaName,
                     TableName
@@ -468,7 +468,7 @@ namespace System.Data.SqlClient
                 {
                     CatalogName = SqlServerEscapeHelper.EscapeIdentifier(CatalogName);
                 }
-                TDSCommand += string.Format((IFormatProvider)null, "exec {0}..{1} N'{2}.{3}'",
+                TDSCommand += string.Format("exec {0}..{1} N'{2}.{3}'",
                     CatalogName,
                     TableCollationsStoredProc,
                     SchemaName,
@@ -869,7 +869,7 @@ namespace System.Data.SqlClient
                                     Debug.Assert(_SqlDataReaderRowSource != null, "Should not be reading row as an XmlReader if bulk copy source is not a SqlDataReader");
                                     return new XmlDataFeed(_SqlDataReaderRowSource.GetXmlReader(sourceOrdinal));
                                 default:
-                                    Debug.Fail(string.Format("Current column is marked as being a DataFeed, but no DataFeed compatible method was provided. Method: {0}", _currentRowMetadata[destRowIndex].Method));
+                                    Debug.Fail($"Current column is marked as being a DataFeed, but no DataFeed compatible method was provided. Method: {_currentRowMetadata[destRowIndex].Method}");
                                     isDataFeed = false;
                                     object columnValue = _DbDataReaderRowSource.GetValue(sourceOrdinal);
                                     ADP.IsNullOrSqlType(columnValue, out isNull, out isSqlType);
@@ -897,7 +897,7 @@ namespace System.Data.SqlClient
                                     value = new SqlDecimal(_SqlDataReaderRowSource.GetSqlSingle(sourceOrdinal).Value);
                                     break;
                                 default:
-                                    Debug.Fail(string.Format("Current column is marked as being a SqlType, but no SqlType compatible method was provided. Method: {0}", _currentRowMetadata[destRowIndex].Method));
+                                    Debug.Fail($"Current column is marked as being a SqlType, but no SqlType compatible method was provided. Method: {_currentRowMetadata[destRowIndex].Method}");
                                     value = (INullable)_SqlDataReaderRowSource.GetSqlValue(sourceOrdinal);
                                     break;
                             }
@@ -1009,7 +1009,7 @@ namespace System.Data.SqlClient
                                     }
                                 default:
                                     {
-                                        Debug.Fail(string.Format("Current column is marked as being a SqlType, but no SqlType compatible method was provided. Method: {0}", _currentRowMetadata[destRowIndex].Method));
+                                        Debug.Fail($"Current column is marked as being a SqlType, but no SqlType compatible method was provided. Method: {_currentRowMetadata[destRowIndex].Method}");
                                         break;
                                     }
                             }
@@ -1125,7 +1125,7 @@ namespace System.Data.SqlClient
                         break;
                     default:
                         t = null;
-                        Debug.Fail(string.Format("Unknown value source: {0}", _rowSourceType));
+                        Debug.Fail($"Unknown value source: {_rowSourceType}");
                         break;
                 }
 
index 7f4feee..6c63de6 100644 (file)
@@ -3061,7 +3061,7 @@ namespace System.Data.SqlClient
                 }
                 else
                 {
-                    Debug.Assert(false, "OnReturnStatus: SqlCommand got too many DONEPROC events");
+                    Debug.Fail("OnReturnStatus: SqlCommand got too many DONEPROC events");
                     parameters = null;
                 }
             }
@@ -3202,7 +3202,7 @@ namespace System.Data.SqlClient
                 }
                 else
                 {
-                    Debug.Assert(false, "OnReturnValue: SqlCommand got too many DONEPROC events");
+                    Debug.Fail("OnReturnValue: SqlCommand got too many DONEPROC events");
                     return null;
                 }
             }
@@ -3393,7 +3393,7 @@ namespace System.Data.SqlClient
                     // InputOutput/Output parameters are aways sent
                     return true;
                 default:
-                    Debug.Assert(false, "Invalid ParameterDirection!");
+                    Debug.Fail("Invalid ParameterDirection!");
                     return false;
             }
         }
index 85bde43..2e686c4 100644 (file)
@@ -848,7 +848,7 @@ namespace System.Data.SqlClient
                 _recoverySessionData = null;
                 _suppressStateChangeForReconnection = false;
             }
-            Debug.Assert(false, "Should not reach this point");
+            Debug.Fail("Should not reach this point");
         }
 
         internal Task ValidateAndReconnect(Action beforeDisconnect, int timeout)
index 2e318bf..f47d53d 100644 (file)
@@ -237,7 +237,7 @@ namespace System.Data.SqlClient
             }
             else
             {
-                Debug.Assert(false, "unexpected state switch");
+                Debug.Fail("unexpected state switch");
                 if (originalState != currentState)
                 {
                     OnStateChange(new StateChangeEventArgs(originalState, currentState));
index 4e2f509..49cf106 100644 (file)
@@ -264,7 +264,7 @@ namespace System.Data.SqlClient
                         case Keywords.ConnectRetryInterval: ConnectRetryInterval = ConvertToInt32(value); break;
 
                         default:
-                            Debug.Assert(false, "unexpected keyword");
+                            Debug.Fail("unexpected keyword");
                             throw UnsupportedKeyword(keyword);
                     }
                 }
@@ -714,7 +714,7 @@ namespace System.Data.SqlClient
                 case Keywords.ConnectRetryInterval: return ConnectRetryInterval;
 
                 default:
-                    Debug.Assert(false, "unexpected keyword");
+                    Debug.Fail("unexpected keyword");
                     throw UnsupportedKeyword(s_validKeywords[(int)index]);
             }
         }
@@ -846,7 +846,7 @@ namespace System.Data.SqlClient
                     _workstationID = DbConnectionStringDefaults.WorkstationID;
                     break;
                 default:
-                    Debug.Assert(false, "unexpected keyword");
+                    Debug.Fail("unexpected keyword");
                     throw UnsupportedKeyword(s_validKeywords[(int)index]);
             }
         }
index 3d553a2..37601b2 100644 (file)
@@ -754,7 +754,7 @@ namespace System.Data.SqlClient
                     return false;
                 }
 
-                Debug.Assert(TdsParser.IsValidTdsToken(token), string.Format("Invalid token after performing CleanPartialRead: {0,-2:X2}", token));
+                Debug.Assert(TdsParser.IsValidTdsToken(token), $"Invalid token after performing CleanPartialRead: {token,-2:X2}");
             }
 #endif            
             _sharedState._dataReady = false;
@@ -886,7 +886,7 @@ namespace System.Data.SqlClient
                         // if user called read but didn't fetch any values, skip the row
                         // same applies after NextResult on ALTROW because NextResult starts rowconsumption in that case ...
 
-                        Debug.Assert(SniContext.Snix_Read == stateObj.SniContext, string.Format((IFormatProvider)null, "The SniContext should be Snix_Read but it actually is {0}", stateObj.SniContext));
+                        Debug.Assert(SniContext.Snix_Read == stateObj.SniContext, $"The SniContext should be Snix_Read but it actually is {stateObj.SniContext}");
 
                         if (_altRowStatus == ALTROWSTATUS.AltRow)
                         {
@@ -914,7 +914,7 @@ namespace System.Data.SqlClient
                                 return false;
                             }
 
-                            Debug.Assert(TdsParser.IsValidTdsToken(token), string.Format("DataReady is false, but next token is invalid: {0,-2:X2}", token));
+                            Debug.Assert(TdsParser.IsValidTdsToken(token), $"DataReady is false, but next token is invalid: {token,-2:X2}");
                         }
 #endif
 
@@ -3268,7 +3268,7 @@ namespace System.Data.SqlClient
                         return false;
                     }
 
-                    Debug.Assert(TdsParser.IsValidTdsToken(token), string.Format("DataReady is false, but next token is invalid: {0,-2:X2}", token));
+                    Debug.Assert(TdsParser.IsValidTdsToken(token), $"DataReady is false, but next token is invalid: {token,-2:X2}");
                 }
 #endif
 
index 8a38e1b..69f3ac4 100644 (file)
@@ -560,7 +560,7 @@ namespace System.Data.SqlClient
         {
             get
             {
-                return (string.Format((IFormatProvider)null, "{0:00}.{1:00}.{2:0000}", _loginAck.majorVersion,
+                return (string.Format("{0:00}.{1:00}.{2:0000}", _loginAck.majorVersion,
                        (short)_loginAck.minorVersion, _loginAck.buildNum));
             }
         }
@@ -931,7 +931,7 @@ namespace System.Data.SqlClient
                         requestType = TdsEnums.TransactionManagerRequestType.Save;
                         break;
                     default:
-                        Debug.Assert(false, "Unknown transaction type");
+                        Debug.Fail("Unknown transaction type");
                         break;
                 }
 
@@ -1065,7 +1065,7 @@ namespace System.Data.SqlClient
                 _recoverySessionData = null;
             }
 
-            Debug.Assert(SniContext.Snix_Login == Parser._physicalStateObj.SniContext, string.Format((IFormatProvider)null, "SniContext should be Snix_Login; actual Value: {0}", Parser._physicalStateObj.SniContext));
+            Debug.Assert(SniContext.Snix_Login == Parser._physicalStateObj.SniContext, $"SniContext should be Snix_Login; actual Value: {Parser._physicalStateObj.SniContext}");
             _parser._physicalStateObj.SniContext = SniContext.Snix_EnableMars;
             _parser.EnableMars();
 
@@ -1329,7 +1329,7 @@ namespace System.Data.SqlClient
                     _parser.Disconnect();
 
                 _parser = new TdsParser(ConnectionOptions.MARS, ConnectionOptions.Asynchronous);
-                Debug.Assert(SniContext.Undefined == Parser._physicalStateObj.SniContext, string.Format((IFormatProvider)null, "SniContext should be Undefined; actual Value: {0}", Parser._physicalStateObj.SniContext));
+                Debug.Assert(SniContext.Undefined == Parser._physicalStateObj.SniContext, $"SniContext should be Undefined; actual Value: {Parser._physicalStateObj.SniContext}");
 
                 try
                 {
@@ -1520,7 +1520,7 @@ namespace System.Data.SqlClient
                     _parser.Disconnect();
 
                 _parser = new TdsParser(ConnectionOptions.MARS, ConnectionOptions.Asynchronous);
-                Debug.Assert(SniContext.Undefined == Parser._physicalStateObj.SniContext, string.Format((IFormatProvider)null, "SniContext should be Undefined; actual Value: {0}", Parser._physicalStateObj.SniContext));
+                Debug.Assert(SniContext.Undefined == Parser._physicalStateObj.SniContext, $"SniContext should be Undefined; actual Value: {Parser._physicalStateObj.SniContext}");
 
                 ServerInfo currentServerInfo;
                 if (useFailoverHost)
@@ -1843,7 +1843,7 @@ namespace System.Data.SqlClient
                     break;
 
                 default:
-                    Debug.Assert(false, "Missed token in EnvChange!");
+                    Debug.Fail("Missed token in EnvChange!");
                     break;
             }
         }
@@ -1952,7 +1952,7 @@ namespace System.Data.SqlClient
                                 break;
 
                             default:
-                                Debug.Assert(false, "Unknown _fedAuthLibrary type");
+                                Debug.Fail("Unknown _fedAuthLibrary type");
                                 throw SQL.ParsingErrorLibraryType(ParsingErrorState.FedAuthFeatureAckUnknownLibraryType, (int)_fedAuthFeatureExtensionData.Value.libraryType);
                         }
                         _federatedAuthenticationAcknowledged = true;
index fc1f28d..7ae5f3d 100644 (file)
@@ -152,7 +152,7 @@ namespace System.Data.SqlClient
                 {
                     // No parent, so we better be LocalFromTSQL.  Should we even return in this case -
                     // since it could be argued this is invalid?
-                    Debug.Assert(false, "Why are we calling IsOrphaned with no parent?");
+                    Debug.Fail("Why are we calling IsOrphaned with no parent?");
                     Debug.Assert(_transactionType == TransactionType.LocalFromTSQL, "invalid state");
                     result = false;
                 }
index 48d1b5b..b7346c0 100644 (file)
@@ -150,7 +150,7 @@ namespace System.Data.SqlClient
                             byte[] byteArrayValue = (byte[])values[publicKeyIndex];
                             foreach (byte b in byteArrayValue)
                             {
-                                resultString.Append(string.Format((IFormatProvider)null, "{0,-2:x2}", b));
+                                resultString.Append(string.Format("{0,-2:x2}", b));
                             }
                             nameString.Append(resultString.ToString());
                         }
@@ -286,4 +286,4 @@ namespace System.Data.SqlClient
 
 
     }
-}
\ No newline at end of file
+}
index 33a2c8f..51c01ab 100644 (file)
@@ -895,7 +895,7 @@ namespace System.Data.SqlClient
                             _actualSize = 5 + (isSqlVariant ? 5 : MetaType.GetTimeSizeFromScale(GetActualScale()));
                             break;
                         default:
-                            Debug.Assert(false, "Unknown variable length type!");
+                            Debug.Fail("Unknown variable length type!");
                             break;
                     }
 
@@ -2039,4 +2039,4 @@ namespace System.Data.SqlClient
             }
         }
     }
-}
\ No newline at end of file
+}
index 5325fb7..ee6bbf1 100644 (file)
@@ -58,7 +58,7 @@ namespace System.Data.SqlClient
                 _peekedChar = Read();
             }
 
-            Debug.Assert(_peekedChar == -1 || ((_peekedChar >= char.MinValue) && (_peekedChar <= char.MaxValue)), string.Format("Bad peeked character: {0}", _peekedChar));
+            Debug.Assert(_peekedChar == -1 || ((_peekedChar >= char.MinValue) && (_peekedChar <= char.MaxValue)), $"Bad peeked character: {_peekedChar}");
             return _peekedChar;
         }
 
@@ -92,7 +92,7 @@ namespace System.Data.SqlClient
                 }
             }
 
-            Debug.Assert(readChar == -1 || ((readChar >= char.MinValue) && (readChar <= char.MaxValue)), string.Format("Bad read character: {0}", readChar));
+            Debug.Assert(readChar == -1 || ((readChar >= char.MinValue) && (readChar <= char.MaxValue)), $"Bad read character: {readChar}");
             return readChar;
         }
 
@@ -114,7 +114,7 @@ namespace System.Data.SqlClient
             // Load in peeked char
             if ((charsNeeded > 0) && (HasPeekedChar))
             {
-                Debug.Assert((_peekedChar >= char.MinValue) && (_peekedChar <= char.MaxValue), string.Format("Bad peeked character: {0}", _peekedChar));
+                Debug.Assert((_peekedChar >= char.MinValue) && (_peekedChar <= char.MaxValue), $"Bad peeked character: {_peekedChar}");
                 buffer[index + charsRead] = (char)_peekedChar;
                 charsRead++;
                 charsNeeded--;
@@ -159,7 +159,7 @@ namespace System.Data.SqlClient
                             int peekedChar = _peekedChar;
                             if (peekedChar >= char.MinValue)
                             {
-                                Debug.Assert((_peekedChar >= char.MinValue) && (_peekedChar <= char.MaxValue), string.Format("Bad peeked character: {0}", _peekedChar));
+                                Debug.Assert((_peekedChar >= char.MinValue) && (_peekedChar <= char.MaxValue), $"Bad peeked character: {_peekedChar}");
                                 buffer[adjustedIndex] = (char)peekedChar;
                                 adjustedIndex++;
                                 charsRead++;
@@ -312,7 +312,7 @@ namespace System.Data.SqlClient
         private int InternalRead(char[] buffer, int index, int count)
         {
             Debug.Assert(buffer != null, "Null output buffer");
-            Debug.Assert((index >= 0) && (count >= 0) && (index + count <= buffer.Length), string.Format("Bad count: {0} or index: {1}", count, index));
+            Debug.Assert((index >= 0) && (count >= 0) && (index + count <= buffer.Length), $"Bad count: {count} or index: {index}");
             Debug.Assert(!IsClosed, "Can't read while textreader is closed");
 
             try
@@ -397,9 +397,9 @@ namespace System.Data.SqlClient
         private int DecodeBytesToChars(byte[] inBuffer, int inBufferCount, char[] outBuffer, int outBufferOffset, int outBufferCount)
         {
             Debug.Assert(inBuffer != null, "Null input buffer");
-            Debug.Assert((inBufferCount > 0) && (inBufferCount <= inBuffer.Length), string.Format("Bad inBufferCount: {0}", inBufferCount));
+            Debug.Assert((inBufferCount > 0) && (inBufferCount <= inBuffer.Length), $"Bad inBufferCount: {inBufferCount}");
             Debug.Assert(outBuffer != null, "Null output buffer");
-            Debug.Assert((outBufferOffset >= 0) && (outBufferCount > 0) && (outBufferOffset + outBufferCount <= outBuffer.Length), string.Format("Bad outBufferCount: {0} or outBufferOffset: {1}", outBufferCount, outBufferOffset));
+            Debug.Assert((outBufferOffset >= 0) && (outBufferCount > 0) && (outBufferOffset + outBufferCount <= outBuffer.Length), $"Bad outBufferCount: {outBufferCount} or outBufferOffset: {outBufferOffset}");
 
             int charsRead;
             int bytesUsed;
index 461e5c0..d972511 100644 (file)
@@ -352,12 +352,12 @@ namespace System.Data.SqlClient
             {
                 case CommandType.Text:
                 case CommandType.StoredProcedure:
-                    Debug.Assert(false, "valid CommandType " + value.ToString());
+                    Debug.Fail("valid CommandType " + value.ToString());
                     break;
                 case CommandType.TableDirect:
                     break;
                 default:
-                    Debug.Assert(false, "invalid CommandType " + value.ToString());
+                    Debug.Fail("invalid CommandType " + value.ToString());
                     break;
             }
 #endif
@@ -374,12 +374,12 @@ namespace System.Data.SqlClient
                 case IsolationLevel.RepeatableRead:
                 case IsolationLevel.Serializable:
                 case IsolationLevel.Snapshot:
-                    Debug.Assert(false, "valid IsolationLevel " + value.ToString());
+                    Debug.Fail("valid IsolationLevel " + value.ToString());
                     break;
                 case IsolationLevel.Chaos:
                     break;
                 default:
-                    Debug.Assert(false, "invalid IsolationLevel " + value.ToString());
+                    Debug.Fail("invalid IsolationLevel " + value.ToString());
                     break;
             }
 #endif
@@ -1020,7 +1020,7 @@ namespace System.Data.SqlClient
         {
             Debug.Assert(sniError > 0 && sniError <= (int)SNINativeMethodWrapper.SniSpecialErrors.MaxErrorValue, "SNI error is out of range");
 
-            string errorMessageId = string.Format((IFormatProvider)null, "SNI_ERROR_{0}", sniError);
+            string errorMessageId = string.Format("SNI_ERROR_{0}", sniError);
             return SR.GetResourceString(errorMessageId, errorMessageId);
         }
 
index 8d65ba2..ea5094a 100644 (file)
@@ -288,7 +288,7 @@ namespace System.Data.SqlClient
         {
             if (_state != TdsParserState.Closed)
             {
-                Debug.Assert(false, "TdsParser.Connect called on non-closed connection!");
+                Debug.Fail("TdsParser.Connect called on non-closed connection!");
                 return;
             }
 
@@ -302,7 +302,7 @@ namespace System.Data.SqlClient
                 _physicalStateObj.AddError(ProcessSNIError(_physicalStateObj));
                 _physicalStateObj.Dispose();
                 ThrowExceptionAndWarning(_physicalStateObj);
-                Debug.Assert(false, "SNI returned status != success, but no error thrown?");
+                Debug.Fail("SNI returned status != success, but no error thrown?");
             }
 
             _sniSpnBuffer = null;
@@ -333,7 +333,7 @@ namespace System.Data.SqlClient
                 // a bad error could be returned (as it was when it was freed to early for me).
                 _physicalStateObj.Dispose();
                 ThrowExceptionAndWarning(_physicalStateObj);
-                Debug.Assert(false, "SNI returned status != success, but no error thrown?");
+                Debug.Fail("SNI returned status != success, but no error thrown?");
             }
 
             _server = serverInfo.ResolvedServerName;
@@ -638,7 +638,7 @@ namespace System.Data.SqlClient
                         break;
 
                     default:
-                        Debug.Assert(false, "UNKNOWN option in SendPreLoginHandshake");
+                        Debug.Fail("UNKNOWN option in SendPreLoginHandshake");
                         break;
                 }
 
@@ -773,7 +773,7 @@ namespace System.Data.SqlClient
                                 break;
 
                             default:
-                                Debug.Assert(false, "Invalid client encryption option detected");
+                                Debug.Fail("Invalid client encryption option detected");
                                 break;
                         }
 
@@ -865,7 +865,7 @@ namespace System.Data.SqlClient
                         break;
 
                     default:
-                        Debug.Assert(false, "UNKNOWN option in ConsumePreLoginHandshake, option:" + option);
+                        Debug.Fail("UNKNOWN option in ConsumePreLoginHandshake, option:" + option);
 
                         // DO NOTHING FOR THESE UNKNOWN OPTIONS
                         offset += 4;
@@ -1202,9 +1202,9 @@ namespace System.Data.SqlClient
             string sniContextEnumName = TdsEnums.GetSniContextEnumName(stateObj.SniContext);
 
             string sqlContextInfo = SR.GetResourceString(sniContextEnumName, sniContextEnumName);
-            string providerRid = string.Format((IFormatProvider)null, "SNI_PN{0}", details.provider);
+            string providerRid = string.Format("SNI_PN{0}", details.provider);
             string providerName = SR.GetResourceString(providerRid, providerRid);
-            Debug.Assert(!string.IsNullOrEmpty(providerName), string.Format((IFormatProvider)null, "invalid providerResourceId '{0}'", providerRid));
+            Debug.Assert(!string.IsNullOrEmpty(providerName), $"invalid providerResourceId '{providerRid}'");
             uint win32ErrorCode = details.nativeError;
 
             if (details.sniErrorNumber == 0)
@@ -1261,7 +1261,7 @@ namespace System.Data.SqlClient
                     }
                 }
             }
-            errorMessage = string.Format((IFormatProvider)null, "{0} (provider: {1}, error: {2} - {3})",
+            errorMessage = string.Format("{0} (provider: {1}, error: {2} - {3})",
                 sqlContextInfo, providerName, (int)details.sniErrorNumber, errorMessage);
 
             return new SqlError((int)details.nativeError, 0x00, TdsEnums.FATAL_ERROR_CLASS,
@@ -1575,7 +1575,7 @@ namespace System.Data.SqlClient
         {
             Debug.Assert((SniContext.Undefined != stateObj.SniContext) &&       // SniContext must not be Undefined
                 ((stateObj._attentionSent) || ((SniContext.Snix_Execute != stateObj.SniContext) && (SniContext.Snix_SendRows != stateObj.SniContext))),  // SniContext should not be Execute or SendRows unless attention was sent (and, therefore, we are looking for an ACK)
-                        string.Format("Unexpected SniContext on call to TryRun; SniContext={0}", stateObj.SniContext));
+                        $"Unexpected SniContext on call to TryRun; SniContext={stateObj.SniContext}");
 
             if (TdsParserState.Broken == State || TdsParserState.Closed == State)
             {
@@ -1628,7 +1628,7 @@ namespace System.Data.SqlClient
 
                 if (!IsValidTdsToken(token))
                 {
-                    Debug.Assert(false, string.Format((IFormatProvider)null, "unexpected token; token = {0,-2:X2}", token));
+                    Debug.Fail($"unexpected token; token = {token,-2:X2}");
                     _state = TdsParserState.Broken;
                     _connHandler.BreakConnection();
                     throw SQL.ParsingError();
@@ -2126,7 +2126,7 @@ namespace System.Data.SqlClient
                 {
                     return false;
                 }
-                Debug.Assert(IsValidTdsToken(token), string.Format("DataReady is false, but next token is not valid: {0,-2:X2}", token));
+                Debug.Assert(IsValidTdsToken(token), $"DataReady is false, but next token is not valid: {token,-2:X2}");
             }
 #endif
 
@@ -2468,7 +2468,7 @@ namespace System.Data.SqlClient
                         break;
 
                     default:
-                        Debug.Assert(false, "Unknown environment change token: " + env.type);
+                        Debug.Fail("Unknown environment change token: " + env.type);
                         break;
                 }
                 processedLength += env.length;
@@ -3442,7 +3442,7 @@ namespace System.Data.SqlClient
                         ThrowUnsupportedCollationEncountered(stateObj);
                     }
 
-                    Debug.Assert(codePage >= 0, string.Format("Invalid code page. codePage: {0}. cultureId: {1}", codePage, cultureId));
+                    Debug.Assert(codePage >= 0, $"Invalid code page. codePage: {codePage}. cultureId: {cultureId}");
                 }
             }
 
@@ -3784,7 +3784,7 @@ namespace System.Data.SqlClient
                         break;
 
                     default:
-                        Debug.Assert(false, "Unknown VariableTime type!");
+                        Debug.Fail("Unknown VariableTime type!");
                         break;
                 }
             }
@@ -4305,7 +4305,7 @@ namespace System.Data.SqlClient
                     break;
 
                 default:
-                    Debug.Assert(false, "unknown null sqlType!" + md.type.ToString());
+                    Debug.Fail("unknown null sqlType!" + md.type.ToString());
                     break;
             }
 
@@ -4479,7 +4479,7 @@ namespace System.Data.SqlClient
                     }
 
                 default:
-                    Debug.Assert(false, "Unknown tds type for SqlString!" + type.ToString(CultureInfo.InvariantCulture));
+                    Debug.Fail("Unknown tds type for SqlString!" + type.ToString(CultureInfo.InvariantCulture));
                     break;
             }
 
@@ -4620,7 +4620,7 @@ namespace System.Data.SqlClient
                     break;
 
                 default:
-                    Debug.Assert(false, "ReadSqlDateTime is called with the wrong tdsType");
+                    Debug.Fail("ReadSqlDateTime is called with the wrong tdsType");
                     break;
             }
 
@@ -4844,7 +4844,7 @@ namespace System.Data.SqlClient
                     break;
 
                 default:
-                    Debug.Assert(false, "Unknown SqlType!" + tdsType.ToString(CultureInfo.InvariantCulture));
+                    Debug.Fail("Unknown SqlType!" + tdsType.ToString(CultureInfo.InvariantCulture));
                     break;
             } // switch
 
@@ -5035,7 +5035,7 @@ namespace System.Data.SqlClient
                     }
 
                 default:
-                    Debug.Assert(false, "Unknown tds type in SqlVariant!" + type.ToString(CultureInfo.InvariantCulture));
+                    Debug.Fail("Unknown tds type in SqlVariant!" + type.ToString(CultureInfo.InvariantCulture));
                     break;
             } // switch
 
@@ -5195,7 +5195,7 @@ namespace System.Data.SqlClient
                     break;
 
                 default:
-                    Debug.Assert(false, "unknown tds type for sqlvariant!");
+                    Debug.Fail("unknown tds type for sqlvariant!");
                     break;
             } // switch
             // return point for accumulated writes, note: non-accumulated writes returned from their case statements
@@ -5363,7 +5363,7 @@ namespace System.Data.SqlClient
                     break;
 
                 default:
-                    Debug.Assert(false, "unknown tds type for sqlvariant!");
+                    Debug.Fail("unknown tds type for sqlvariant!");
                     break;
             } // switch
             // return point for accumulated writes, note: non-accumulated writes returned from their case statements
@@ -5879,7 +5879,7 @@ namespace System.Data.SqlClient
                         return true;
                     }
                 default:
-                    Debug.Assert(false, "Unknown token length!");
+                    Debug.Fail("Unknown token length!");
                     tokenLength = 0;
                     return true;
             }
@@ -6059,7 +6059,7 @@ namespace System.Data.SqlClient
                     dataLen = 1 + sizeof(int) + fedAuthFeatureData.accessToken.Length; // length of feature data = 1 byte for library and echo, security token length and sizeof(int) for token lengh itself
                     break;
                 default:
-                    Debug.Assert(false, "Unrecognized library type for fedauth feature extension request");
+                    Debug.Fail("Unrecognized library type for fedauth feature extension request");
                     break;
             }
 
@@ -6081,7 +6081,7 @@ namespace System.Data.SqlClient
                         options |= TdsEnums.FEDAUTHLIB_SECURITYTOKEN << 1;
                         break;
                     default:
-                        Debug.Assert(false, "Unrecognized FedAuthLibrary type for feature extension request");
+                        Debug.Fail("Unrecognized FedAuthLibrary type for feature extension request");
                         break;
                 }
 
@@ -6242,7 +6242,7 @@ namespace System.Data.SqlClient
                     // Call helper function for SSPI data and actual length.
                     // Since we don't have SSPI data from the server, send null for the
                     // byte[] buffer and 0 for the int length.
-                    Debug.Assert(SniContext.Snix_Login == _physicalStateObj.SniContext, string.Format((IFormatProvider)null, "Unexpected SniContext. Expecting Snix_Login, actual value is '{0}'", _physicalStateObj.SniContext));
+                    Debug.Assert(SniContext.Snix_Login == _physicalStateObj.SniContext, $"Unexpected SniContext. Expecting Snix_Login, actual value is '{_physicalStateObj.SniContext}'");
                     _physicalStateObj.SniContext = SniContext.Snix_LoginSspi;
 
                     SSPIData(null, 0, ref outSSPIBuff, ref outSSPILength);
@@ -6649,7 +6649,7 @@ namespace System.Data.SqlClient
                                                         timeout, null, stateObj, true))
             {
 
-                Debug.Assert(SniContext.Snix_Read == stateObj.SniContext, string.Format((IFormatProvider)null, "The SniContext should be Snix_Read but it actually is {0}", stateObj.SniContext));
+                Debug.Assert(SniContext.Snix_Read == stateObj.SniContext, $"The SniContext should be Snix_Read but it actually is {stateObj.SniContext}");
                 if (null != dtcReader && dtcReader.Read())
                 {
                     Debug.Assert(dtcReader.GetName(0) == "TM Address", "TdsParser: GetDTCAddress did not return 'TM Address'");
@@ -6670,7 +6670,7 @@ namespace System.Data.SqlClient
 #if DEBUG
                     else
                     {
-                        Debug.Assert(false, "unexpected length (> Int32.MaxValue) returned from dtcReader.GetBytes");
+                        Debug.Fail("unexpected length (> Int32.MaxValue) returned from dtcReader.GetBytes");
                         // if we hit this case we'll just return a null address so that the user
                         // will get a transcaction enlistment error in the upper layers
                     }
@@ -6838,7 +6838,7 @@ namespace System.Data.SqlClient
                         WriteString(transactionName, stateObj);
                         break;
                     default:
-                        Debug.Assert(false, "Unexpected TransactionManagerRequest");
+                        Debug.Fail("Unexpected TransactionManagerRequest");
                         break;
                 }
 
@@ -7983,7 +7983,7 @@ namespace System.Data.SqlClient
                     }
                     else
                     {
-                        Debug.Assert(false, "SUDTs not yet supported.");
+                        Debug.Fail("SUDTs not yet supported.");
                     }
                     break;
                 case SqlDbType.Date:
@@ -8002,7 +8002,7 @@ namespace System.Data.SqlClient
                     stateObj.WriteByte(metaData.Scale);
                     break;
                 default:
-                    Debug.Assert(false, "Unknown SqlDbType should have been caught earlier!");
+                    Debug.Fail("Unknown SqlDbType should have been caught earlier!");
                     break;
             }
         }
@@ -8627,7 +8627,7 @@ namespace System.Data.SqlClient
                         break;
 
                     default:
-                        Debug.Assert(false, "Unknown token length!");
+                        Debug.Fail("Unknown token length!");
                         break;
                 }
 
@@ -8890,7 +8890,7 @@ namespace System.Data.SqlClient
                     throw SQL.UDTUnexpectedResult(value.GetType().AssemblyQualifiedName);
 
                 default:
-                    Debug.Assert(false, "Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
+                    Debug.Fail("Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
                     break;
             } // switch
             // return point for accumulated writes, note: non-accumulated writes returned from their case statements
@@ -9089,7 +9089,7 @@ namespace System.Data.SqlClient
                     _next.Write(value);
                     _written++;
                 }
-                Debug.Assert(_size < 0 || _written <= _size, string.Format("Length of data written exceeds specified length.  Written: {0}, specified: {1}", _written, _size));
+                Debug.Assert(_size < 0 || _written <= _size, $"Length of data written exceeds specified length.  Written: {_written}, specified: {_size}");
             }
 
             public override void Write(char[] buffer, int index, int count)
@@ -9571,7 +9571,7 @@ namespace System.Data.SqlClient
                     break;
 
                 default:
-                    Debug.Assert(false, "Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
+                    Debug.Fail("Unknown TdsType!" + type.NullableType.ToString("x2", (IFormatProvider)null));
                     break;
             } // switch
             // return point for accumulated writes, note: non-accumulated writes returned from their case statements
@@ -9660,7 +9660,7 @@ namespace System.Data.SqlClient
                         "Out of sync plp read request");
             if (stateObj._longlenleft == 0)
             {
-                Debug.Assert(false, "Out of sync read request");
+                Debug.Fail("Out of sync read request");
                 charsRead = 0;
                 return true;
             }
index 1a85774..c62443b 100644 (file)
@@ -528,7 +528,7 @@ namespace System.Data.SqlClient
                     return altMetaDataSet;
                 }
             }
-            Debug.Assert(false, "Can't match up altMetaDataSet with given id");
+            Debug.Fail("Can't match up altMetaDataSet with given id");
             return null;
         }
 
index 6e527a8..8b6431c 100644 (file)
@@ -855,7 +855,7 @@ namespace System.Data.SqlClient
 
             // NOTE: TdsParserSessionPool may call DecrementPendingCallbacks on a TdsParserStateObject which is already disposed
             // This is not dangerous (since the stateObj is no longer in use), but we need to add a workaround in the assert for it
-            Debug.Assert((remaining == -1 && SessionHandle.IsNull) || (0 <= remaining && remaining < 3), string.Format("_pendingCallbacks values is invalid after decrementing: {0}", remaining));
+            Debug.Assert((remaining == -1 && SessionHandle.IsNull) || (0 <= remaining && remaining < 3), $"_pendingCallbacks values is invalid after decrementing: {remaining}");
             return remaining;
         }
 
@@ -904,7 +904,7 @@ namespace System.Data.SqlClient
         internal int IncrementPendingCallbacks()
         {
             int remaining = Interlocked.Increment(ref _pendingCallbacks);
-            Debug.Assert(0 < remaining && remaining <= 3, string.Format("_pendingCallbacks values is invalid after incrementing: {0}", remaining));
+            Debug.Assert(0 < remaining && remaining <= 3, $"_pendingCallbacks values is invalid after incrementing: {remaining}");
             return remaining;
         }
 
@@ -1104,7 +1104,7 @@ namespace System.Data.SqlClient
                 }
                 else
                 {
-                    Debug.Assert(false, "entered negative _inBytesPacket loop");
+                    Debug.Fail("entered negative _inBytesPacket loop");
                 }
                 AssertValidState();
             }
@@ -3158,7 +3158,7 @@ namespace System.Data.SqlClient
             else
             {
                 status = TdsEnums.ST_EOM;
-                Debug.Assert(false, string.Format((IFormatProvider)null, "Unexpected argument {0,-2:x2} to WritePacket", flushMode));
+                Debug.Fail($"Unexpected argument {flushMode,-2:x2} to WritePacket");
             }
 
             _outBuff[0] = _outputMessageType;         // Message Type
@@ -3509,26 +3509,13 @@ namespace System.Data.SqlClient
 
         private void AssertValidState()
         {
-            string assertMessage = null;
-
             if (_inBytesUsed < 0 || _inBytesRead < 0)
             {
-                assertMessage = string.Format(
-                    CultureInfo.InvariantCulture,
-                    "either _inBytesUsed or _inBytesRead is negative: {0}, {1}",
-                    _inBytesUsed, _inBytesRead);
+                Debug.Fail($"Invalid TDS Parser State: either _inBytesUsed or _inBytesRead is negative: {_inBytesUsed}, {_inBytesRead}");
             }
             else if (_inBytesUsed > _inBytesRead)
             {
-                assertMessage = string.Format(
-                    CultureInfo.InvariantCulture,
-                    "_inBytesUsed > _inBytesRead: {0} > {1}",
-                    _inBytesUsed, _inBytesRead);
-            }
-
-            if (assertMessage != null)
-            {
-                Debug.Assert(false, "Invalid TDS Parser State: " + assertMessage);
+                Debug.Fail($"Invalid TDS Parser State: _inBytesUsed > _inBytesRead: {_inBytesUsed} > {_inBytesRead}");
             }
 
             Debug.Assert(_inBytesPacket >= 0, "Packet must not be negative");
@@ -3743,7 +3730,7 @@ namespace System.Data.SqlClient
                 Debug.Assert(_asyncWriteCount == 0, "StateObj still has outstanding async writes");
                 Debug.Assert(_delayedWriteAsyncCallbackException == null, "StateObj has an unobserved exceptions from an async write");
                 // Attention\Cancellation\Timeouts
-                Debug.Assert(!_attentionReceived && !_attentionSent && !_attentionSending, string.Format("StateObj is still dealing with attention: Sent: {0}, Received: {1}, Sending: {2}", _attentionSent, _attentionReceived, _attentionSending));
+                Debug.Assert(!_attentionReceived && !_attentionSent && !_attentionSending, $"StateObj is still dealing with attention: Sent: {_attentionSent}, Received: {_attentionReceived}, Sending: {_attentionSending}");
                 Debug.Assert(!_cancelled, "StateObj still has cancellation set");
                 Debug.Assert(!_internalTimeout, "StateObj still has internal timeout set");
                 // Errors and Warnings
index 5c43bdb..d790a0e 100644 (file)
@@ -129,7 +129,7 @@ namespace System.Data.SqlClient
 #if DEBUG
                 else
                 {
-                    Debug.Assert(false, "Removing a packet from the pending list that was never added to it");
+                    Debug.Fail("Removing a packet from the pending list that was never added to it");
                 }
 #endif
             }
index 1ce488c..50960b3 100644 (file)
@@ -99,16 +99,16 @@ namespace System.Data.SqlClient
                         break;
                     case SqlDbType.Udt:
                     case SqlDbType.Xml:
-                        Debug.Assert(false, "PLP-only types shouldn't get to this point. Type: " + _metaData.SqlDbType);
+                        Debug.Fail("PLP-only types shouldn't get to this point. Type: " + _metaData.SqlDbType);
                         break;
                     case SqlDbType.Variant:
                         _stateObj.Parser.WriteInt(TdsEnums.FIXEDNULL, _stateObj);
                         break;
                     case SqlDbType.Structured:
-                        Debug.Assert(false, "Not yet implemented.  Not needed until Structured UDTs");
+                        Debug.Fail("Not yet implemented.  Not needed until Structured UDTs");
                         break;
                     default:
-                        Debug.Assert(false, "Unexpected SqlDbType: " + _metaData.SqlDbType);
+                        Debug.Fail("Unexpected SqlDbType: " + _metaData.SqlDbType);
                         break;
                 }
             }
index fec277d..9cb049e 100644 (file)
@@ -611,7 +611,7 @@ namespace System.Diagnostics
                     }
 
                     if (inaccessibleLogs != null)
-                        throw new SecurityException(SR.Format(wantToCreate ? SR.SomeLogsInaccessibleToCreate : SR.SomeLogsInaccessible, inaccessibleLogs.ToString()));
+                        throw new SecurityException(SR.Format(wantToCreate ? SR.SomeLogsInaccessibleToCreate : SR.SomeLogsInaccessible, inaccessibleLogs));
 
                 }
                 finally
index 6c329e0..47acfb7 100644 (file)
@@ -873,7 +873,7 @@ namespace System.Diagnostics
         {
             EventLogEntry entry = GetEntryAtNoThrow(index);
             if (entry == null)
-                throw new ArgumentException(SR.Format(SR.IndexOutOfBounds, index.ToString(CultureInfo.CurrentCulture)));
+                throw new ArgumentException(SR.Format(SR.IndexOutOfBounds, index.ToString()));
             return entry;
         }
 
@@ -952,7 +952,7 @@ namespace System.Diagnostics
 
                 if (!success)
                 {
-                    throw new InvalidOperationException(SR.Format(SR.CantReadLogEntryAt, index.ToString(CultureInfo.CurrentCulture)), new Win32Exception());
+                    throw new InvalidOperationException(SR.Format(SR.CantReadLogEntryAt, index.ToString()), new Win32Exception());
                 }
             }
 
@@ -1108,7 +1108,7 @@ namespace System.Diagnostics
                 {
                     e = new Win32Exception();
                 }
-                throw new InvalidOperationException(SR.Format(SR.CantOpenLog, logname.ToString(), currentMachineName, e?.Message ?? ""));
+                throw new InvalidOperationException(SR.Format(SR.CantOpenLog, logname, currentMachineName, e?.Message ?? ""));
             }
 
             readHandle = handle;
@@ -1311,7 +1311,7 @@ namespace System.Diagnostics
                         string rightLogName = EventLog.LogNameFromSourceName(sourceName, currentMachineName);
                         string currentLogName = GetLogName(currentMachineName);
                         if (rightLogName != null && currentLogName != null && !string.Equals(rightLogName, currentLogName, StringComparison.OrdinalIgnoreCase))
-                            throw new ArgumentException(SR.Format(SR.LogSourceMismatch, Source.ToString(), currentLogName, rightLogName));
+                            throw new ArgumentException(SR.Format(SR.LogSourceMismatch, Source, currentLogName, rightLogName));
                     }
                 }
                 finally
@@ -1328,7 +1328,7 @@ namespace System.Diagnostics
                 string rightLogName = EventLog._InternalLogNameFromSourceName(sourceName, currentMachineName);
                 string currentLogName = GetLogName(currentMachineName);
                 if (rightLogName != null && currentLogName != null && !string.Equals(rightLogName, currentLogName, StringComparison.OrdinalIgnoreCase))
-                    throw new ArgumentException(SR.Format(SR.LogSourceMismatch, Source.ToString(), currentLogName, rightLogName));
+                    throw new ArgumentException(SR.Format(SR.LogSourceMismatch, Source, currentLogName, rightLogName));
             }
             boolFlags[Flag_sourceVerified] = true;
         }
index 89ab073..c715a45 100644 (file)
@@ -96,7 +96,7 @@ namespace System.Diagnostics
                 throw new ArgumentNullException(nameof(value));
 
             if (!(value is CounterCreationData))
-                throw new ArgumentException(SR.Format(SR.MustAddCounterCreationData));
+                throw new ArgumentException(SR.MustAddCounterCreationData);
         }
 
     }
index dd7b705..03346bd 100644 (file)
@@ -79,7 +79,7 @@ namespace System.Diagnostics
             }
             else if (oldSample.CounterType != newSample.CounterType)
             {
-                throw new InvalidOperationException(SR.Format(SR.MismatchedCounterTypes));
+                throw new InvalidOperationException(SR.MismatchedCounterTypes);
             }
 
             if (newCounterType == Interop.Kernel32.PerformanceCounterOptions.PERF_ELAPSED_TIME)
index 8346e83..92edf20 100644 (file)
@@ -231,7 +231,7 @@ namespace System.Diagnostics
                     throw new ArgumentOutOfRangeException(nameof(value));
 
                 if (_initialized)
-                    throw new InvalidOperationException(SR.Format(SR.CantSetLifetimeAfterInitialized));
+                    throw new InvalidOperationException(SR.CantSetLifetimeAfterInitialized);
 
                 _instanceLifetime = value;
             }
@@ -435,14 +435,14 @@ namespace System.Diagnostics
 
         private void ThrowReadOnly()
         {
-            throw new InvalidOperationException(SR.Format(SR.ReadOnlyCounter));
+            throw new InvalidOperationException(SR.ReadOnlyCounter);
         }
 
         private static void VerifyWriteableCounterAllowed()
         {
             if (EnvironmentHelpers.IsAppContainerProcess)
             {
-                throw new NotSupportedException(SR.Format(SR.PCNotSupportedUnderAppContainer));
+                throw new NotSupportedException(SR.PCNotSupportedUnderAppContainer);
             }
         }
 
@@ -471,9 +471,9 @@ namespace System.Diagnostics
                     string currentMachineName = _machineName;
 
                     if (currentCategoryName == string.Empty)
-                        throw new InvalidOperationException(SR.Format(SR.CategoryNameMissing));
+                        throw new InvalidOperationException(SR.CategoryNameMissing);
                     if (_counterName == string.Empty)
-                        throw new InvalidOperationException(SR.Format(SR.CounterNameMissing));
+                        throw new InvalidOperationException(SR.CounterNameMissing);
 
                     if (ReadOnly)
                     {
@@ -493,17 +493,17 @@ namespace System.Diagnostics
                         }
 
                         if (_instanceLifetime != PerformanceCounterInstanceLifetime.Global)
-                            throw new InvalidOperationException(SR.Format(SR.InstanceLifetimeProcessonReadOnly));
+                            throw new InvalidOperationException(SR.InstanceLifetimeProcessonReadOnly);
 
                         _initialized = true;
                     }
                     else
                     {
                         if (currentMachineName != "." && !string.Equals(currentMachineName, PerformanceCounterLib.ComputerName, StringComparison.OrdinalIgnoreCase))
-                            throw new InvalidOperationException(SR.Format(SR.RemoteWriting));
+                            throw new InvalidOperationException(SR.RemoteWriting);
 
                         if (!PerformanceCounterLib.IsCustomCategory(currentMachineName, currentCategoryName))
-                            throw new InvalidOperationException(SR.Format(SR.NotCustomCounter));
+                            throw new InvalidOperationException(SR.NotCustomCounter);
 
                         // check category type
                         PerformanceCounterCategoryType categoryType = PerformanceCounterLib.GetCategoryType(currentMachineName, currentCategoryName);
@@ -519,7 +519,7 @@ namespace System.Diagnostics
                         }
 
                         if (string.IsNullOrEmpty(_instanceName) && InstanceLifetime == PerformanceCounterInstanceLifetime.Process)
-                            throw new InvalidOperationException(SR.Format(SR.InstanceLifetimeProcessforSingleInstance));
+                            throw new InvalidOperationException(SR.InstanceLifetimeProcessforSingleInstance);
 
                         _sharedCounter = new SharedPerformanceCounter(currentCategoryName.ToLower(CultureInfo.InvariantCulture), _counterName.ToLower(CultureInfo.InvariantCulture), _instanceName.ToLower(CultureInfo.InvariantCulture), _instanceLifetime);
                         _initialized = true;
@@ -560,7 +560,7 @@ namespace System.Diagnostics
                 else
                 {
                     if (_instanceName == null || _instanceName.Length == 0)
-                        throw new InvalidOperationException(SR.Format(SR.InstanceNameRequired));
+                        throw new InvalidOperationException(SR.InstanceNameRequired);
 
                     return counterSample.GetInstanceValue(_instanceName);
                 }
@@ -590,7 +590,7 @@ namespace System.Diagnostics
         public void RemoveInstance()
         {
             if (_isReadOnly)
-                throw new InvalidOperationException(SR.Format(SR.ReadOnlyRemoveInstance));
+                throw new InvalidOperationException(SR.ReadOnlyRemoveInstance);
 
             Initialize();
             _sharedCounter.RemoveInstance(_instanceName.ToLower(CultureInfo.InvariantCulture), _instanceLifetime);
index 41e871d..7fe04dc 100644 (file)
@@ -92,7 +92,7 @@ namespace System.Diagnostics
             get
             {
                 if (_categoryName == null)
-                    throw new InvalidOperationException(SR.Format(SR.CategoryNameNotSet));
+                    throw new InvalidOperationException(SR.CategoryNameNotSet);
 
                 if (_categoryHelp == null)
                     _categoryHelp = PerformanceCounterLib.GetCategoryHelp(_machineName, _categoryName);
@@ -157,7 +157,7 @@ namespace System.Diagnostics
                 throw new ArgumentNullException(nameof(counterName));
 
             if (_categoryName == null)
-                throw new InvalidOperationException(SR.Format(SR.CategoryNameNotSet));
+                throw new InvalidOperationException(SR.CategoryNameNotSet);
 
             return PerformanceCounterLib.CounterExists(_machineName, _categoryName, counterName);
         }
@@ -263,7 +263,7 @@ namespace System.Diagnostics
             // 1026 chars is the size of the buffer used in perfcounter.dll to get this name.  
             // If the categoryname plus prefix is too long, we won't be able to read the category properly. 
             if (categoryName.Length > (1024 - SharedPerformanceCounter.DefaultFileMappingName.Length))
-                throw new ArgumentException(SR.Format(SR.CategoryNameTooLong));
+                throw new ArgumentException(SR.CategoryNameTooLong);
         }
 
         internal static void CheckValidCounter(string counterName)
@@ -314,7 +314,7 @@ namespace System.Diagnostics
             {
                 if (counterData[i].CounterName == null || counterData[i].CounterName.Length == 0)
                 {
-                    throw new ArgumentException(SR.Format(SR.InvalidCounterName));
+                    throw new ArgumentException(SR.InvalidCounterName);
                 }
 
                 int currentSampleType = (int)counterData[i].CounterType;
@@ -328,20 +328,20 @@ namespace System.Diagnostics
                         (currentSampleType == Interop.Kernel32.PerformanceCounterOptions.PERF_AVERAGE_TIMER))
                 {
                     if (counterData.Count <= (i + 1))
-                        throw new InvalidOperationException(SR.Format(SR.CounterLayout));
+                        throw new InvalidOperationException(SR.CounterLayout);
                     else
                     {
                         currentSampleType = (int)counterData[i + 1].CounterType;
 
 
                         if (!PerformanceCounterLib.IsBaseCounter(currentSampleType))
-                            throw new InvalidOperationException(SR.Format(SR.CounterLayout));
+                            throw new InvalidOperationException(SR.CounterLayout);
                     }
                 }
                 else if (PerformanceCounterLib.IsBaseCounter(currentSampleType))
                 {
                     if (i == 0)
-                        throw new InvalidOperationException(SR.Format(SR.CounterLayout));
+                        throw new InvalidOperationException(SR.CounterLayout);
                     else
                     {
                         currentSampleType = (int)counterData[i - 1].CounterType;
@@ -355,7 +355,7 @@ namespace System.Diagnostics
                         (currentSampleType != Interop.Kernel32.PerformanceCounterOptions.PERF_RAW_FRACTION) &&
                         (currentSampleType != Interop.Kernel32.PerformanceCounterOptions.PERF_SAMPLE_FRACTION) &&
                         (currentSampleType != Interop.Kernel32.PerformanceCounterOptions.PERF_AVERAGE_TIMER))
-                            throw new InvalidOperationException(SR.Format(SR.CounterLayout));
+                            throw new InvalidOperationException(SR.CounterLayout);
                     }
                 }
 
@@ -391,7 +391,7 @@ namespace System.Diagnostics
             {
                 NetFrameworkUtils.EnterMutex(PerfMutexName, ref mutex);
                 if (!PerformanceCounterLib.IsCustomCategory(machineName, categoryName))
-                    throw new InvalidOperationException(SR.Format(SR.CantDeleteCategory));
+                    throw new InvalidOperationException(SR.CantDeleteCategory);
 
                 SharedPerformanceCounter.RemoveAllInstances(categoryName);
 
@@ -462,7 +462,7 @@ namespace System.Diagnostics
         public PerformanceCounter[] GetCounters()
         {
             if (GetInstanceNames().Length != 0)
-                throw new ArgumentException(SR.Format(SR.InstanceNameRequired));
+                throw new ArgumentException(SR.InstanceNameRequired);
             return GetCounters("");
         }
 
@@ -475,7 +475,7 @@ namespace System.Diagnostics
                 throw new ArgumentNullException(nameof(instanceName));
 
             if (_categoryName == null)
-                throw new InvalidOperationException(SR.Format(SR.CategoryNameNotSet));
+                throw new InvalidOperationException(SR.CategoryNameNotSet);
 
             if (instanceName.Length != 0 && !InstanceExists(instanceName))
                 throw new InvalidOperationException(SR.Format(SR.MissingInstance, instanceName, _categoryName));
@@ -519,7 +519,7 @@ namespace System.Diagnostics
         public string[] GetInstanceNames()
         {
             if (_categoryName == null)
-                throw new InvalidOperationException(SR.Format(SR.CategoryNameNotSet));
+                throw new InvalidOperationException(SR.CategoryNameNotSet);
 
             return GetCounterInstances(_categoryName, _machineName);
         }
@@ -533,7 +533,7 @@ namespace System.Diagnostics
                 throw new ArgumentNullException(nameof(instanceName));
 
             if (_categoryName == null)
-                throw new InvalidOperationException(SR.Format(SR.CategoryNameNotSet));
+                throw new InvalidOperationException(SR.CategoryNameNotSet);
 
             using (CategorySample categorySample = PerformanceCounterLib.GetCategorySample(_machineName, _categoryName))
             {
@@ -577,7 +577,7 @@ namespace System.Diagnostics
         public InstanceDataCollectionCollection ReadCategory()
         {
             if (_categoryName == null)
-                throw new InvalidOperationException(SR.Format(SR.CategoryNameNotSet));
+                throw new InvalidOperationException(SR.CategoryNameNotSet);
 
             using (CategorySample categorySample = PerformanceCounterLib.GetCategorySample(_machineName, _categoryName))
             {
index 791e9ee..ed96bef 100644 (file)
@@ -372,7 +372,7 @@ namespace System.Diagnostics
             if (!categoryExists)
             {
                 // Consider adding diagnostic logic here, may be we can dump the nameTable...
-                throw new InvalidOperationException(SR.Format(SR.MissingCategory));
+                throw new InvalidOperationException(SR.MissingCategory);
             }
 
             return counterExists;
@@ -457,7 +457,7 @@ namespace System.Diagnostics
                         iniWriter.Write(HelpSufix);
                         iniWriter.Write("=");
                         if (categoryHelp == null || categoryHelp == string.Empty)
-                            iniWriter.WriteLine(SR.Format(SR.HelpNotAvailable));
+                            iniWriter.WriteLine(SR.HelpNotAvailable);
                         else
                             iniWriter.WriteLine(categoryHelp);
 
@@ -793,7 +793,7 @@ namespace System.Diagnostics
             help = library.GetCategoryHelp(category);
 
             if (help == null)
-                throw new InvalidOperationException(SR.Format(SR.MissingCategory));
+                throw new InvalidOperationException(SR.MissingCategory);
 
             return help;
         }
@@ -824,7 +824,7 @@ namespace System.Diagnostics
                 }
             }
             if (sample == null)
-                throw new InvalidOperationException(SR.Format(SR.MissingCategory));
+                throw new InvalidOperationException(SR.MissingCategory);
 
             return sample;
         }
@@ -865,7 +865,7 @@ namespace System.Diagnostics
             }
 
             if (!categoryExists)
-                throw new InvalidOperationException(SR.Format(SR.MissingCategory));
+                throw new InvalidOperationException(SR.MissingCategory);
 
             return counters;
         }
@@ -1449,7 +1449,7 @@ namespace System.Diagnostics
             }
 
             if (!foundCategory)
-                throw new InvalidOperationException(SR.Format(SR.CantReadCategoryIndex, categoryIndex.ToString(CultureInfo.CurrentCulture)));
+                throw new InvalidOperationException(SR.Format(SR.CantReadCategoryIndex, categoryIndex.ToString()));
 
             ref readonly PERF_OBJECT_TYPE perfObject = ref MemoryMarshal.AsRef<PERF_OBJECT_TYPE>(data.Slice(pos));
 
@@ -1622,7 +1622,7 @@ namespace System.Diagnostics
                                     return multiSample._baseCounterDefinitionSample;
                             }
 
-                            throw new InvalidOperationException(SR.Format(SR.CounterLayout));
+                            throw new InvalidOperationException(SR.CounterLayout);
                         }
                         return sample;
                     }
index 60a3941..847dde5 100644 (file)
@@ -181,7 +181,7 @@ namespace System.Diagnostics.PerformanceData
             }
             if (instanceName.Length == 0)
             {
-                throw new ArgumentException(SR.Format(SR.Perflib_Argument_EmptyInstanceName), nameof(instanceName));
+                throw new ArgumentException(SR.Perflib_Argument_EmptyInstanceName, nameof(instanceName));
             }
             if (_provider == null)
             {
index dc069d8..b8ad492 100644 (file)
@@ -101,18 +101,18 @@ namespace System.Diagnostics
             if (_categoryData.UseUniqueSharedMemory)
             {
                 if (instanceName != null && instanceName.Length > InstanceNameMaxLength)
-                    throw new InvalidOperationException(SR.Format(SR.InstanceNameTooLong));
+                    throw new InvalidOperationException(SR.InstanceNameTooLong);
             }
             else
             {
                 if (lifetime != PerformanceCounterInstanceLifetime.Global)
-                    throw new InvalidOperationException(SR.Format(SR.ProcessLifetimeNotValidInGlobal));
+                    throw new InvalidOperationException(SR.ProcessLifetimeNotValidInGlobal);
             }
 
             if (counterName != null && instanceName != null)
             {
                 if (!_categoryData.CounterNames.Contains(counterName))
-                    Debug.Assert(false, "Counter " + counterName + " does not exist in category " + catName);
+                    Debug.Fail("Counter " + counterName + " does not exist in category " + catName);
                 else
                     _counterEntryPointer = GetCounter(counterName, instanceName, _categoryData.EnableReuse, lifetime);
             }
@@ -179,7 +179,7 @@ namespace System.Diagnostics
 
             if (newOffset > FileView._fileMappingSize || newOffset < 0)
             {
-                throw new InvalidOperationException(SR.Format(SR.CountersOOM));
+                throw new InvalidOperationException(SR.CountersOOM);
             }
 
             return newOffset;
@@ -593,7 +593,7 @@ namespace System.Diagnostics
                 currentChar++;
             }
 
-            throw new InvalidOperationException(SR.Format(SR.MappingCorrupted));
+            throw new InvalidOperationException(SR.MappingCorrupted);
         }
 
         // Compare a managed string to a string located at a given offset.  If we walk past the end of the 
@@ -607,7 +607,7 @@ namespace System.Diagnostics
             for (i = 0; i < stringA.Length; i++)
             {
                 if ((ulong)(currentChar + i) > (endAddress - 2))
-                    throw new InvalidOperationException(SR.Format(SR.MappingCorrupted));
+                    throw new InvalidOperationException(SR.MappingCorrupted);
 
                 if (stringA[i] != currentChar[i])
                     return false;
@@ -615,7 +615,7 @@ namespace System.Diagnostics
 
             // now check for the null termination. 
             if ((ulong)(currentChar + i) > (endAddress - 2))
-                throw new InvalidOperationException(SR.Format(SR.MappingCorrupted));
+                throw new InvalidOperationException(SR.MappingCorrupted);
 
             return (currentChar[i] == 0);
         }
@@ -1038,7 +1038,7 @@ namespace System.Diagnostics
                                 if (lifetimeEntry != null && lifetimeEntry->ProcessId != 0)
                                 {
                                     if (lifetime != PerformanceCounterInstanceLifetime.Process)
-                                        throw new InvalidOperationException(SR.Format(SR.CantConvertProcessToGlobal));
+                                        throw new InvalidOperationException(SR.CantConvertProcessToGlobal);
 
                                     // make sure only one process is using this instance. 
                                     if (ProcessData.ProcessId != lifetimeEntry->ProcessId)
@@ -1054,7 +1054,7 @@ namespace System.Diagnostics
                                 else
                                 {
                                     if (lifetime == PerformanceCounterInstanceLifetime.Process)
-                                        throw new InvalidOperationException(SR.Format(SR.CantConvertGlobalToProcess));
+                                        throw new InvalidOperationException(SR.CantConvertGlobalToProcess);
                                 }
                                 return true;
                             }
@@ -1627,7 +1627,7 @@ namespace System.Diagnostics
             //It is very important to check the integrity of the shared memory
             //everytime a new address is resolved.
             if (offset > (FileView._fileMappingSize - sizeToRead) || offset < 0)
-                throw new InvalidOperationException(SR.Format(SR.MappingCorrupted));
+                throw new InvalidOperationException(SR.MappingCorrupted);
 
             long address = _baseAddress + offset;
 
@@ -1641,7 +1641,7 @@ namespace System.Diagnostics
             //It is very important to check the integrity of the shared memory
             //everytime a new address is resolved.
             if (offset > (FileView._fileMappingSize - sizeToRead) || offset < 0)
-                throw new InvalidOperationException(SR.Format(SR.MappingCorrupted));
+                throw new InvalidOperationException(SR.MappingCorrupted);
 
             return offset;
         }
@@ -1664,7 +1664,7 @@ namespace System.Diagnostics
                 get
                 {
                     if (_fileViewAddress.IsInvalid)
-                        throw new InvalidOperationException(SR.Format(SR.SharedMemoryGhosted));
+                        throw new InvalidOperationException(SR.SharedMemoryGhosted);
 
                     return _fileViewAddress.DangerousGetHandle();
                 }
@@ -1688,7 +1688,7 @@ namespace System.Diagnostics
 
                     if (!Interop.Advapi32.ConvertStringSecurityDescriptorToSecurityDescriptor(sddlString, Interop.Kernel32.PerformanceCounterOptions.SDDL_REVISION_1,
                                                                                                     out securityDescriptorPointer, IntPtr.Zero))
-                        throw new InvalidOperationException(SR.Format(SR.SetSecurityDescriptorFailed));
+                        throw new InvalidOperationException(SR.SetSecurityDescriptorFailed);
 
                     Interop.Kernel32.SECURITY_ATTRIBUTES securityAttributes = new Interop.Kernel32.SECURITY_ATTRIBUTES();
                     securityAttributes.bInheritHandle = Interop.BOOL.FALSE;
@@ -1744,17 +1744,17 @@ namespace System.Diagnostics
                     }
                     if (_fileMappingHandle.IsInvalid)
                     {
-                        throw new InvalidOperationException(SR.Format(SR.CantCreateFileMapping));
+                        throw new InvalidOperationException(SR.CantCreateFileMapping);
                     }
 
                     _fileViewAddress = Interop.Kernel32.MapViewOfFile(_fileMappingHandle, Interop.Kernel32.FileMapOptions.FILE_MAP_WRITE, 0, 0, UIntPtr.Zero);
                     if (_fileViewAddress.IsInvalid)
-                        throw new InvalidOperationException(SR.Format(SR.CantMapFileView));
+                        throw new InvalidOperationException(SR.CantMapFileView);
 
                     // figure out what size the share memory really is.
                     Interop.Kernel32.MEMORY_BASIC_INFORMATION meminfo = new Interop.Kernel32.MEMORY_BASIC_INFORMATION();
                     if (Interop.Kernel32.VirtualQuery(_fileViewAddress, ref meminfo, (UIntPtr)sizeof(Interop.Kernel32.MEMORY_BASIC_INFORMATION)) == UIntPtr.Zero)
-                        throw new InvalidOperationException(SR.Format(SR.CantGetMappingSize));
+                        throw new InvalidOperationException(SR.CantGetMappingSize);
 
                     _fileMappingSize = (int)meminfo.RegionSize;
                 }
index aa769a5..dc6bfbe 100644 (file)
@@ -683,7 +683,7 @@ namespace System.Diagnostics
             {
                 if (handle.IsInvalid)
                 {
-                    throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, _processId.ToString(CultureInfo.CurrentCulture)));
+                    throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, _processId.ToString()));
                 }
 
                 ProcessThreadTimes processTimes = new ProcessThreadTimes();
@@ -762,7 +762,7 @@ namespace System.Diagnostics
                         if (waitHandle.WaitOne(0))
                         {
                             if (_haveProcessId)
-                                throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, _processId.ToString(CultureInfo.CurrentCulture)));
+                                throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, _processId.ToString()));
                             else
                                 throw new InvalidOperationException(SR.ProcessHasExitedNoId);
                         }
@@ -783,7 +783,7 @@ namespace System.Diagnostics
                 {
                     if (Interop.Kernel32.GetExitCodeProcess(handle, out _exitCode) && _exitCode != Interop.Kernel32.HandleOptions.STILL_ACTIVE)
                     {
-                        throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, _processId.ToString(CultureInfo.CurrentCulture)));
+                        throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, _processId.ToString()));
                     }
                 }
                 return handle;
index 5a59327..a7b8a24 100644 (file)
@@ -999,7 +999,7 @@ namespace System.Diagnostics
         {
             if (!ProcessManager.IsProcessRunning(processId, machineName))
             {
-                throw new ArgumentException(SR.Format(SR.MissingProccess, processId.ToString(CultureInfo.CurrentCulture)));
+                throw new ArgumentException(SR.Format(SR.MissingProccess, processId.ToString()));
             }
 
             return new Process(machineName, ProcessManager.IsRemoteMachine(machineName), processId, null);
index 328347c..bc84718 100644 (file)
@@ -198,7 +198,7 @@ namespace System.Diagnostics
             {
                 if (throwIfExited)
                 {
-                    throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, processId.ToString(CultureInfo.CurrentCulture)));
+                    throw new InvalidOperationException(SR.Format(SR.ProcessHasExited, processId.ToString()));
                 }
                 else
                 {
@@ -215,7 +215,7 @@ namespace System.Diagnostics
             if (threadHandle.IsInvalid)
             {
                 if (result == Interop.Errors.ERROR_INVALID_PARAMETER)
-                    throw new InvalidOperationException(SR.Format(SR.ThreadExited, threadId.ToString(CultureInfo.CurrentCulture)));
+                    throw new InvalidOperationException(SR.Format(SR.ThreadExited, threadId.ToString()));
                 throw new Win32Exception(result);
             }
             return threadHandle;
index 7ac716c..409a61f 100644 (file)
@@ -172,7 +172,7 @@ namespace System.Diagnostics
             }
             catch (Exception e)
             {
-                WriteLine(string.Format(SR.ExceptionOccurred, LogFileName, e.ToString()), useLogFile: false);
+                WriteLine(SR.Format(SR.ExceptionOccurred, LogFileName, e), useLogFile: false);
             }
         }
     }
index 52e6639..b390358 100644 (file)
@@ -2145,9 +2145,7 @@ namespace System.DirectoryServices.AccountManagement
                                                 serverName);
 
                         throw new PrincipalOperationException(
-                                string.Format(CultureInfo.CurrentCulture,
-                                                  SR.ADStoreCtxCantResolveSidForCrossStore,
-                                                  err));
+                                SR.Format(SR.ADStoreCtxCantResolveSidForCrossStore, err));
                     }
 
                     GlobalDebug.WriteLineIf(GlobalDebug.Info,
index 975863a..edbe177 100644 (file)
@@ -1183,7 +1183,7 @@ namespace System.DirectoryServices.AccountManagement
             if ((value == null) || (value.Length > 0))
                 de.Properties[suggestedAdProperty].Value = value;
             else
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.InvalidStringValueForStore, propertyName));
+                throw new ArgumentException(SR.Format(SR.InvalidStringValueForStore, propertyName));
         }
 
         protected static void BinaryToLdapConverter(Principal p, string propertyName, DirectoryEntry de, string suggestedAdProperty)
@@ -1532,7 +1532,7 @@ namespace System.DirectoryServices.AccountManagement
                         (!memberType.IsSubclassOf(typeof(AuthenticablePrincipal))))
                     {
                         throw new InvalidOperationException(
-                                        string.Format(CultureInfo.CurrentCulture, SR.StoreCtxUnsupportedPrincipalTypeForGroupInsert, memberType.ToString()));
+                                        SR.Format(SR.StoreCtxUnsupportedPrincipalTypeForGroupInsert, memberType));
                     }
                     // Can't inserted unpersisted principal
                     if (member.unpersisted)
index 7834d41..d94221f 100644 (file)
@@ -161,8 +161,7 @@ namespace System.DirectoryServices.AccountManagement
                     {
                         // Must be a property we don't support
                         throw new InvalidOperationException(
-                                    string.Format(
-                                        CultureInfo.CurrentCulture,
+                                    SR.Format(
                                         SR.StoreCtxUnsupportedPropertyForQuery,
                                         PropertyNamesExternal.GetExternalForm(filter.PropertyName)));
                     }
@@ -206,9 +205,8 @@ namespace System.DirectoryServices.AccountManagement
                 string objClass = ExtensionHelper.ReadStructuralObjectClass(principalType);
                 if (null == objClass)
                 {
-                    Debug.Fail("ADStoreCtx.GetObjectClassPortion: fell off end looking for " + principalType.ToString());
-                    throw new InvalidOperationException(
-                                    string.Format(CultureInfo.CurrentCulture, SR.StoreCtxUnsupportedPrincipalTypeForQuery, principalType.ToString()));
+                    Debug.Fail($"ADStoreCtx.GetObjectClassPortion: fell off end looking for {principalType}");
+                    throw new InvalidOperationException(SR.Format(SR.StoreCtxUnsupportedPrincipalTypeForQuery, principalType));
                 }
                 StringBuilder SB = new StringBuilder();
                 SB.Append("(&(objectClass=");
@@ -734,8 +732,7 @@ namespace System.DirectoryServices.AccountManagement
                     // This bit doesn't work correctly in AD (AD models the "user can't change password"
                     // setting as special ACEs in the ntSecurityDescriptor).
                     throw new InvalidOperationException(
-                                            string.Format(
-                                                    CultureInfo.CurrentCulture,
+                                            SR.Format(
                                                     SR.StoreCtxUnsupportedPropertyForQuery,
                                                     PropertyNamesExternal.GetExternalForm(filter.PropertyName)));
 
index cb48898..e587b40 100644 (file)
@@ -220,8 +220,7 @@ namespace System.DirectoryServices.AccountManagement
                 // It's not a type of Principal that we support
                 GlobalDebug.WriteLineIf(GlobalDebug.Warn, "SDSUtils", "InsertPrincipal: Bad principal type:" + p.GetType().ToString());
 
-                throw new InvalidOperationException(
-                                string.Format(CultureInfo.CurrentCulture, SR.StoreCtxUnsupportedPrincipalTypeForSave, p.GetType().ToString()));
+                throw new InvalidOperationException(SR.Format(SR.StoreCtxUnsupportedPrincipalTypeForSave, p.GetType()));
             }
 
             // Commit the properties
index 7e43ec7..9530b30 100644 (file)
@@ -150,7 +150,7 @@ namespace System.DirectoryServices.AccountManagement
                 {
                     GlobalDebug.WriteLineIf(GlobalDebug.Warn, "AuthZSet", "SidList: couldn't get policy handle, err={0}", err);
 
-                    throw new PrincipalOperationException(string.Format(CultureInfo.CurrentCulture,
+                    throw new PrincipalOperationException(SR.Format(
                                                                SR.AuthZErrorEnumeratingGroups,
                                                                SafeNativeMethods.LsaNtStatusToWinError(err)));
                 }
@@ -176,7 +176,7 @@ namespace System.DirectoryServices.AccountManagement
                 {
                     GlobalDebug.WriteLineIf(GlobalDebug.Warn, "AuthZSet", "SidList: LsaLookupSids failed, err={0}", err);
 
-                    throw new PrincipalOperationException(string.Format(CultureInfo.CurrentCulture,
+                    throw new PrincipalOperationException(SR.Format(
                                                                SR.AuthZErrorEnumeratingGroups,
                                                                SafeNativeMethods.LsaNtStatusToWinError(err)));
                 }
index 5bf4d68..8b4c2b0 100644 (file)
@@ -355,7 +355,7 @@ namespace System.DirectoryServices.AccountManagement
                     break;
 
                 default:
-                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "AccountInfo.LoadValueIntoProperty: fell off end looking for {0}", propertyName));
+                    Debug.Fail($"AccountInfo.LoadValueIntoProperty: fell off end looking for {propertyName}");
                     break;
             }
         }
@@ -403,7 +403,7 @@ namespace System.DirectoryServices.AccountManagement
                     return _scriptPathChanged == LoadState.Changed;
 
                 default:
-                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "AccountInfo.GetChangeStatusForProperty: fell off end looking for {0}", propertyName));
+                    Debug.Fail($"AccountInfo.GetChangeStatusForProperty: fell off end looking for {propertyName}");
                     return false;
             }
         }
@@ -440,7 +440,7 @@ namespace System.DirectoryServices.AccountManagement
                     return _scriptPath;
 
                 default:
-                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "AccountInfo.GetValueForProperty: fell off end looking for {0}", propertyName));
+                    Debug.Fail($"AccountInfo.GetValueForProperty: fell off end looking for {propertyName}");
                     return null;
             }
         }
index 8f88ab6..005faea 100644 (file)
@@ -167,8 +167,7 @@ namespace System.DirectoryServices.AccountManagement
                         else
                         {
                             lastError = Marshal.GetLastWin32Error();
-                            // With a zero-length buffer, this should have never succeeded
-                            Debug.Assert(false);
+                            Debug.Fail("With a zero-length buffer, this should have never succeeded");
                         }
                     }
                     else
@@ -186,8 +185,7 @@ namespace System.DirectoryServices.AccountManagement
                     GlobalDebug.WriteLineIf(GlobalDebug.Warn, "AuthZSet", "Failed to retrieve group list, {0}", lastError);
 
                     throw new PrincipalOperationException(
-                                    string.Format(
-                                            CultureInfo.CurrentCulture,
+                                    SR.Format(
                                             SR.AuthZFailedToRetrieveGroupList,
                                             lastError));
                 }
@@ -647,7 +645,7 @@ namespace System.DirectoryServices.AccountManagement
                             {
                                 GlobalDebug.WriteLineIf(GlobalDebug.Warn, "AuthZSet", "SidList: couldn't get policy handle, err={0}", err);                                                                
 
-                                throw new PrincipalOperationException(String.Format(CultureInfo.CurrentCulture,
+                                throw new PrincipalOperationException(SR.Format(
                                                                            SR.AuthZErrorEnumeratingGroups,
                                                                            SafeNativeMethods.LsaNtStatusToWinError(err)));
                             }
@@ -669,7 +667,7 @@ namespace System.DirectoryServices.AccountManagement
                             {
                                 GlobalDebug.WriteLineIf(GlobalDebug.Warn, "AuthZSet", "SidList: LsaLookupSids failed, err={0}", err);                                                                
 
-                                throw new PrincipalOperationException(String.Format(CultureInfo.CurrentCulture,
+                                throw new PrincipalOperationException(SR.Format(
                                                                            SR.AuthZErrorEnumeratingGroups,
                                                                            SafeNativeMethods.LsaNtStatusToWinError(err)));
                             }
index 45ab446..a6f4d09 100644 (file)
@@ -689,7 +689,7 @@ namespace System.DirectoryServices.AccountManagement
 
                 if (_serverProperties.contextType != _contextType)
                 {
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.PassedContextTypeDoesNotMatchDetectedType, _serverProperties.contextType.ToString()));
+                    throw new ArgumentException(SR.Format(SR.PassedContextTypeDoesNotMatchDetectedType, _serverProperties.contextType.ToString()));
                 }
             }
         }
index e5c3e8b..d855818 100644 (file)
@@ -35,7 +35,7 @@ namespace System.DirectoryServices.AccountManagement
 
                 //
                 Debug.WriteLine(
-                            String.Format(
+                            string.Format(
                                 System.Globalization.CultureInfo.InvariantCulture,
                                 "Principal API Debug Log - AppDomain {0} with ID {1} - {2} (UTC)",
                                 System.Threading.Thread.GetDomain().FriendlyName,
index d695ad0..7378376 100644 (file)
@@ -279,7 +279,7 @@ namespace System.DirectoryServices.AccountManagement
                     break;
 
                 default:
-                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "PasswordInfo.LoadValueIntoProperty: fell off end looking for {0}", propertyName));
+                    Debug.Fail($"PasswordInfo.LoadValueIntoProperty: fell off end looking for {propertyName}");
                     break;
             }
         }
@@ -314,7 +314,7 @@ namespace System.DirectoryServices.AccountManagement
                     return (_expirePasswordImmediately != false);
 
                 default:
-                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "PasswordInfo.GetChangeStatusForProperty: fell off end looking for {0}", propertyName));
+                    Debug.Fail($"PasswordInfo.GetChangeStatusForProperty: fell off end looking for {propertyName}");
                     return false;
             }
         }
@@ -345,7 +345,7 @@ namespace System.DirectoryServices.AccountManagement
                     return _expirePasswordImmediately;
 
                 default:
-                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "PasswordInfo.GetValueForProperty: fell off end looking for {0}", propertyName));
+                    Debug.Fail($"PasswordInfo.GetValueForProperty: fell off end looking for {propertyName}");
                     return null;
             }
         }
index da74ea4..595cedf 100644 (file)
@@ -1249,7 +1249,7 @@ namespace System.DirectoryServices.AccountManagement
                     return _extensionCache;
 
                 default:
-                    Debug.Fail(string.Format(CultureInfo.CurrentCulture, "Principal.GetValueForProperty: Ran off end of list looking for {0}", propertyName));
+                    Debug.Fail($"Principal.GetValueForProperty: Ran off end of list looking for {propertyName}");
                     return null;
             }
         }
index 3da9c85..1d44d8b 100644 (file)
@@ -200,7 +200,7 @@ namespace System.DirectoryServices.AccountManagement
                 }
             }
 
-            Debug.Fail(string.Format(CultureInfo.CurrentCulture, "PrincipalCollectionEnumerator.MoveNext: fell off end of function, mode = {0}", _currentMode.ToString()));
+            Debug.Fail($"PrincipalCollectionEnumerator.MoveNext: fell off end of function, mode = {_currentMode}");
             return false;
         }
 
index 782d5f0..f1e517c 100644 (file)
@@ -429,9 +429,7 @@ namespace System.DirectoryServices.AccountManagement
                                         err);
 
                 throw new PrincipalOperationException(
-                            string.Format(CultureInfo.CurrentCulture,
-                                          SR.SAMStoreCtxErrorEnumeratingGroup,
-                                          err));
+                            SR.Format(SR.SAMStoreCtxErrorEnumeratingGroup, err));
             }
 
             if (string.Equals(_storeCtx.MachineFlatName, domainName, StringComparison.OrdinalIgnoreCase))
index 64db290..72f71f3 100644 (file)
@@ -264,8 +264,7 @@ namespace System.DirectoryServices.AccountManagement
                 {
                     // Must be a property we don't support
                     throw new NotSupportedException(
-                                string.Format(
-                                        CultureInfo.CurrentCulture,
+                                SR.Format(
                                         SR.StoreCtxUnsupportedPropertyForQuery,
                                         PropertyNamesExternal.GetExternalForm(filter.PropertyName)));
                 }
index 6bf73ca..ba53e6c 100644 (file)
@@ -845,9 +845,7 @@ namespace System.DirectoryServices.AccountManagement
                                         this.MachineUserSuppliedName);
 
                 throw new PrincipalOperationException(
-                            string.Format(CultureInfo.CurrentCulture,
-                                          SR.SAMStoreCtxCantResolveSidForCrossStore,
-                                          err));
+                            SR.Format(SR.SAMStoreCtxCantResolveSidForCrossStore, err));
             }
 
             GlobalDebug.WriteLineIf(GlobalDebug.Info,
@@ -1081,8 +1079,7 @@ namespace System.DirectoryServices.AccountManagement
                 else
                 {
                     throw new PrincipalOperationException(
-                                    string.Format(
-                                        CultureInfo.CurrentCulture,
+                                    SR.Format(
                                         SR.SAMStoreCtxUnableToRetrieveFlatMachineName,
                                         err));
                 }
@@ -1104,7 +1101,7 @@ namespace System.DirectoryServices.AccountManagement
             }
             else
             {
-                Debug.Assert(false);
+                Debug.Fail("Property not found");
                 return false;
             }
         }
index cda57dc..30cedd1 100644 (file)
@@ -52,7 +52,7 @@ namespace System.DirectoryServices.AccountManagement
                     else
                     {
                         throw new InvalidOperationException(
-                                        string.Format(CultureInfo.CurrentCulture, SR.StoreCtxUnsupportedPrincipalTypeForSave, principalType.ToString()));
+                                        SR.Format(SR.StoreCtxUnsupportedPrincipalTypeForSave, principalType));
                     }
 
                     // Determine the SAM account name for the entry we'll be creating.  Use the name from the NT4 IdentityClaim.
@@ -904,10 +904,9 @@ namespace System.DirectoryServices.AccountManagement
         private static void ExceptionToWinNTConverter(Principal p, string propertyName, DirectoryEntry de, string suggestedWinNTProperty, bool isLSAM)
         {
             throw new InvalidOperationException(
-                            string.Format(CultureInfo.CurrentCulture,
-                                          SR.PrincipalUnsupportPropertyForType,
-                                          p.GetType().ToString(),
-                                          PropertyNamesExternal.GetExternalForm(propertyName)));
+                            SR.Format(SR.PrincipalUnsupportPropertyForType,
+                                      p.GetType(),
+                                      PropertyNamesExternal.GetExternalForm(propertyName)));
         }
 
         private static void StringToWinNTConverter(Principal p, string propertyName, DirectoryEntry de, string suggestedWinNTProperty, bool isLSAM)
@@ -957,9 +956,7 @@ namespace System.DirectoryServices.AccountManagement
         {
             if (!isLSAM)
                 throw new InvalidOperationException(
-                    string.Format(CultureInfo.CurrentCulture,
-                                  SR.PrincipalUnsupportPropertyForPlatform,
-                                  PropertyNamesExternal.GetExternalForm(propertyName)));
+                    SR.Format(SR.PrincipalUnsupportPropertyForPlatform, PropertyNamesExternal.GetExternalForm(propertyName)));
         }
 
         private static void GroupTypeToWinNTConverter(Principal p, string propertyName, DirectoryEntry de, string suggestedWinNTProperty, bool isLSAM)
@@ -968,9 +965,7 @@ namespace System.DirectoryServices.AccountManagement
             {
                 if (!isLSAM)
                     throw new InvalidOperationException(
-                        string.Format(CultureInfo.CurrentCulture,
-                                      SR.PrincipalUnsupportPropertyForPlatform,
-                                      PropertyNamesExternal.GetExternalForm(propertyName)));
+                        SR.Format(SR.PrincipalUnsupportPropertyForPlatform, PropertyNamesExternal.GetExternalForm(propertyName)));
             }
             else
             {
@@ -988,9 +983,7 @@ namespace System.DirectoryServices.AccountManagement
         {
             if (!isLSAM)
                 throw new InvalidOperationException(
-                    string.Format(CultureInfo.CurrentCulture,
-                                  SR.PrincipalUnsupportPropertyForPlatform,
-                                  PropertyNamesExternal.GetExternalForm(propertyName)));
+                    SR.Format(SR.PrincipalUnsupportPropertyForPlatform, PropertyNamesExternal.GetExternalForm(propertyName)));
         }
 
         private static void AcctExpirDateToNTConverter(Principal p, string propertyName, DirectoryEntry de, string suggestedWinNTProperty, bool isLSAM)
@@ -1063,8 +1056,7 @@ namespace System.DirectoryServices.AccountManagement
                         GlobalDebug.WriteLineIf(GlobalDebug.Warn, "SAMStoreCtx", "UpdateGroupMembership: error while clearing, hr={0}", hr);
 
                         throw new PrincipalOperationException(
-                                        string.Format(
-                                                CultureInfo.CurrentCulture,
+                                        SR.Format(
                                                 SR.SAMStoreCtxFailedToClearGroup,
                                                 hr.ToString(CultureInfo.InvariantCulture)));
                     }
@@ -1085,7 +1077,7 @@ namespace System.DirectoryServices.AccountManagement
                          (memberType != typeof(GroupPrincipal)) && (!memberType.IsSubclassOf(typeof(GroupPrincipal))))
                     {
                         throw new InvalidOperationException(
-                                        string.Format(CultureInfo.CurrentCulture, SR.StoreCtxUnsupportedPrincipalTypeForGroupInsert, memberType.ToString()));
+                                        SR.Format(SR.StoreCtxUnsupportedPrincipalTypeForGroupInsert, memberType));
                     }
 
                     // Can't inserted unpersisted principal
index 5c42ca6..ef41b7c 100644 (file)
@@ -138,9 +138,9 @@ namespace System.DirectoryServices.AccountManagement
             }
             else
             {
-                Debug.Fail("SAMStoreCtx.GetSchemaFilter: fell off end looking for " + principalType.ToString());
+                Debug.Fail($"SAMStoreCtx.GetSchemaFilter: fell off end looking for {principalType}");
                 throw new InvalidOperationException(
-                                string.Format(CultureInfo.CurrentCulture, SR.StoreCtxUnsupportedPrincipalTypeForQuery, principalType.ToString()));
+                                SR.Format(SR.StoreCtxUnsupportedPrincipalTypeForQuery, principalType));
             }
 
             return schemaTypes;
index d2b0394..9216101 100644 (file)
@@ -74,32 +74,18 @@ namespace System.DirectoryServices.AccountManagement
                 // Sanity check: there are no negetive OS versions, nor is there a version "0".
                 if (versionMajor <= 0 || versionMinor < 0)
                 {
-                    Debug.Fail(string.Format(
-                                    CultureInfo.CurrentCulture,
-                                    "SAMUtils.GetOSVersion: {0} claims to have negetive OS version, {1}",
-                                    computerDE.Path,
-                                    version));
-
+                    Debug.Fail("SAMUtils.GetOSVersion: {computerDE.Path} claims to have negetive OS version, {version}");
                     return false;
                 }
             }
             catch (FormatException)
             {
-                Debug.Fail(string.Format(
-                                CultureInfo.CurrentCulture,
-                                "SAMUtils.GetOSVersion: FormatException on {0} for {1}",
-                                version,
-                                computerDE.Path));
-
+                Debug.Fail($"SAMUtils.GetOSVersion: FormatException on {version} for {computerDE.Path}");
                 return false;
             }
             catch (OverflowException)
             {
-                Debug.Fail(string.Format(
-                                CultureInfo.CurrentCulture,
-                                "SAMUtils.GetOSVersion: OverflowException on {0} for {1}",
-                                version,
-                                computerDE.Path));
+                Debug.Fail($"SAMUtils.GetOSVersion: OverflowException on {version} for {computerDE.Path}");
                 return false;
             }
 
@@ -123,11 +109,7 @@ namespace System.DirectoryServices.AccountManagement
             }
             else
             {
-                Debug.Fail(string.Format(
-                                CultureInfo.CurrentCulture,
-                                "SAMUtils.DirectoryEntryAsPrincipal: fell off end, Path={0}, SchemaClassName={1}",
-                                de.Path,
-                                de.SchemaClassName));
+                Debug.Fail($"SAMUtils.DirectoryEntryAsPrincipal: fell off end, Path={de.Path}, SchemaClassName={de.SchemaClassName}");
                 return null;
             }
         }
index a359656..65a54f8 100644 (file)
@@ -337,8 +337,7 @@ namespace System.DirectoryServices.AccountManagement
                         p.GetChangeStatusForProperty(PropertyNames.AcctInfoExpiredAccount))
                 {
                     throw new InvalidOperationException(
-                                       string.Format(
-                                           CultureInfo.CurrentCulture,
+                                       SR.Format(
                                            SR.StoreCtxMultipleFiltersForPropertyUnsupported,
                                            PropertyNamesExternal.GetExternalForm(ExpirationDateFilter.PropertyNameStatic)));
                 }
@@ -439,12 +438,7 @@ namespace System.DirectoryServices.AccountManagement
                         else
                         {
                             // Internal error.  Didn't match either the known multivalued or scalar cases.
-                            Debug.Fail(string.Format(
-                                                CultureInfo.CurrentCulture,
-                                                "StoreCtx.BuildFilterSet: fell off end looking for {0} of type {1}",
-                                                propertyName,
-                                                value.GetType().ToString()
-                                                ));
+                            Debug.Fail($"StoreCtx.BuildFilterSet: fell off end looking for {propertyName} of type {value.GetType()}");
                         }
 
                         qbeFilterDescription.FiltersToApply.Add(filter);
index bf66ae0..f1fdb10 100644 (file)
@@ -383,20 +383,14 @@ namespace System.DirectoryServices.AccountManagement
                             int lastError = Marshal.GetLastWin32Error();
                             GlobalDebug.WriteLineIf(GlobalDebug.Error, "Utils", "GetCurrentUserSid: OpenProcessToken failed, gle=" + lastError);
 
-                            throw new PrincipalOperationException(
-                                            string.Format(CultureInfo.CurrentCulture,
-                                                          SR.UnableToOpenToken,
-                                                          lastError));
+                            throw new PrincipalOperationException(SR.Format(SR.UnableToOpenToken, lastError));
                         }
                     }
                     else
                     {
                         GlobalDebug.WriteLineIf(GlobalDebug.Error, "Utils", "GetCurrentUserSid: OpenThreadToken failed, gle=" + error);
 
-                        throw new PrincipalOperationException(
-                                        string.Format(CultureInfo.CurrentCulture,
-                                                      SR.UnableToOpenToken,
-                                                      error));
+                        throw new PrincipalOperationException(SR.Format(SR.UnableToOpenToken, error));
                     }
                 }
 
@@ -419,7 +413,7 @@ namespace System.DirectoryServices.AccountManagement
                     GlobalDebug.WriteLineIf(GlobalDebug.Error, "Utils", "GetCurrentUserSid: GetTokenInformation (1st try) failed, gle=" + getTokenInfoError);
 
                     throw new PrincipalOperationException(
-                                    string.Format(CultureInfo.CurrentCulture, SR.UnableToRetrieveTokenInfo, getTokenInfoError));
+                                    SR.Format(SR.UnableToRetrieveTokenInfo, getTokenInfoError));
                 }
 
                 // Allocate the necessary buffer.
@@ -442,7 +436,7 @@ namespace System.DirectoryServices.AccountManagement
                                       "GetCurrentUserSid: GetTokenInformation (2nd try) failed, neededBufferSize=" + neededBufferSize + ", gle=" + lastError);
 
                     throw new PrincipalOperationException(
-                                    string.Format(CultureInfo.CurrentCulture, SR.UnableToRetrieveTokenInfo, lastError));
+                                    SR.Format(SR.UnableToRetrieveTokenInfo, lastError));
                 }
 
                 // Retrieve the user's SID from the user info
@@ -463,7 +457,7 @@ namespace System.DirectoryServices.AccountManagement
                                       "GetCurrentUserSid: CopySid failed, errorcode=" + lastError);
 
                     throw new PrincipalOperationException(
-                                    string.Format(CultureInfo.CurrentCulture, SR.UnableToRetrieveTokenInfo, lastError));
+                                    SR.Format(SR.UnableToRetrieveTokenInfo, lastError));
                 }
 
                 return pCopyOfUserSid;
@@ -501,7 +495,7 @@ namespace System.DirectoryServices.AccountManagement
                 {
                     GlobalDebug.WriteLineIf(GlobalDebug.Error, "Utils", "GetMachineDomainSid: LsaOpenPolicy failed, gle=" + SafeNativeMethods.LsaNtStatusToWinError(err));
 
-                    throw new PrincipalOperationException(string.Format(CultureInfo.CurrentCulture,
+                    throw new PrincipalOperationException(SR.Format(
                                                                SR.UnableToRetrievePolicy,
                                                                SafeNativeMethods.LsaNtStatusToWinError(err)));
                 }
@@ -516,7 +510,7 @@ namespace System.DirectoryServices.AccountManagement
                 {
                     GlobalDebug.WriteLineIf(GlobalDebug.Error, "Utils", "GetMachineDomainSid: LsaQueryInformationPolicy failed, gle=" + SafeNativeMethods.LsaNtStatusToWinError(err));
 
-                    throw new PrincipalOperationException(string.Format(CultureInfo.CurrentCulture,
+                    throw new PrincipalOperationException(SR.Format(
                                                                SR.UnableToRetrievePolicy,
                                                                SafeNativeMethods.LsaNtStatusToWinError(err)));
                 }
@@ -539,7 +533,7 @@ namespace System.DirectoryServices.AccountManagement
                                       "GetMachineDomainSid: CopySid failed, errorcode=" + lastError);
 
                     throw new PrincipalOperationException(
-                                    string.Format(CultureInfo.CurrentCulture, SR.UnableToRetrievePolicy, lastError));
+                                    SR.Format(SR.UnableToRetrievePolicy, lastError));
                 }
 
                 return pCopyOfSid;
@@ -593,8 +587,7 @@ namespace System.DirectoryServices.AccountManagement
                 {
                     GlobalDebug.WriteLineIf(GlobalDebug.Error, "Utils", "GetDcName: DsGetDcName failed, err=" + err);
                     throw new PrincipalOperationException(
-                                    string.Format(
-                                            CultureInfo.CurrentCulture,
+                                    SR.Format(
                                             SR.UnableToRetrieveDomainInfo,
                                             err));
                 }
@@ -785,9 +778,7 @@ namespace System.DirectoryServices.AccountManagement
                 GlobalDebug.WriteLineIf(GlobalDebug.Error, "Utils", "BeginImpersonation: LogonUser failed, gle=" + lastError);
 
                 throw new PrincipalOperationException(
-                    string.Format(CultureInfo.CurrentCulture,
-                                  SR.UnableToImpersonateCredentials,
-                                  lastError));
+                    SR.Format(SR.UnableToImpersonateCredentials, lastError));
             }
 
             result = UnsafeNativeMethods.ImpersonateLoggedOnUser(hToken);
@@ -800,9 +791,7 @@ namespace System.DirectoryServices.AccountManagement
                 UnsafeNativeMethods.CloseHandle(hToken);
 
                 throw new PrincipalOperationException(
-                    string.Format(CultureInfo.CurrentCulture,
-                                  SR.UnableToImpersonateCredentials,
-                                  lastError));
+                    SR.Format(SR.UnableToImpersonateCredentials, lastError));
             }
 
             hUserToken = hToken;
@@ -833,8 +822,7 @@ namespace System.DirectoryServices.AccountManagement
                 {
                     GlobalDebug.WriteLineIf(GlobalDebug.Error, "Utils", "IsMachineDC: DsRoleGetPrimaryDomainInformation failed, err=" + err);
                     throw new PrincipalOperationException(
-                                    string.Format(
-                                            CultureInfo.CurrentCulture,
+                                    SR.Format(
                                             SR.UnableToRetrieveDomainInfo,
                                             err));
                 }
index de8e8c5..e850364 100644 (file)
@@ -45,14 +45,14 @@ namespace System.DirectoryServices.Protocols
                     {
                         // we don't have enough argument for the format string
                         Debug.WriteLine("value argument is not valid, valueCount >= value.Length\n");
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     if (!(value[valueCount] is int))
                     {
                         // argument is wrong                                                                        
                         Debug.WriteLine("type should be int\n");
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     // one int argument
@@ -67,14 +67,14 @@ namespace System.DirectoryServices.Protocols
                     {
                         // we don't have enough argument for the format string
                         Debug.WriteLine("value argument is not valid, valueCount >= value.Length\n");
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     if (!(value[valueCount] is bool))
                     {
                         // argument is wrong
                         Debug.WriteLine("type should be boolean\n");
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     // one int argument                    
@@ -89,7 +89,7 @@ namespace System.DirectoryServices.Protocols
                     {
                         // we don't have enough argument for the format string
                         Debug.WriteLine("value argument is not valid, valueCount >= value.Length\n");
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     if (value[valueCount] != null && !(value[valueCount] is string))
@@ -97,7 +97,7 @@ namespace System.DirectoryServices.Protocols
                         // argument is wrong
                         Debug.WriteLine("type should be string, but receiving value has type of ");
                         Debug.WriteLine(value[valueCount].GetType());
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     // one string argument       
@@ -118,7 +118,7 @@ namespace System.DirectoryServices.Protocols
                     {
                         // we don't have enough argument for the format string
                         Debug.WriteLine("value argument is not valid, valueCount >= value.Length\n");
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     if (value[valueCount] != null && !(value[valueCount] is byte[]))
@@ -126,7 +126,7 @@ namespace System.DirectoryServices.Protocols
                         // argument is wrong
                         Debug.WriteLine("type should be byte[], but receiving value has type of ");
                         Debug.WriteLine(value[valueCount].GetType());
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     byte[] tempValue = (byte[])value[valueCount];
@@ -141,7 +141,7 @@ namespace System.DirectoryServices.Protocols
                     {
                         // we don't have enough argument for the format string
                         Debug.WriteLine("value argument is not valid, valueCount >= value.Length\n");
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     if (value[valueCount] != null && !(value[valueCount] is string[]))
@@ -149,7 +149,7 @@ namespace System.DirectoryServices.Protocols
                         // argument is wrong
                         Debug.WriteLine("type should be string[], but receiving value has type of ");
                         Debug.WriteLine(value[valueCount].GetType());
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     string[] stringValues = (string[])value[valueCount];
@@ -180,7 +180,7 @@ namespace System.DirectoryServices.Protocols
                     {
                         // we don't have enough argument for the format string
                         Debug.WriteLine("value argument is not valid, valueCount >= value.Length\n");
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     if (value[valueCount] != null && !(value[valueCount] is byte[][]))
@@ -188,7 +188,7 @@ namespace System.DirectoryServices.Protocols
                         // argument is wrong
                         Debug.WriteLine("type should be byte[][], but receiving value has type of ");
                         Debug.WriteLine(value[valueCount].GetType());
-                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterNotMatch));
+                        throw new ArgumentException(SR.BerConverterNotMatch);
                     }
 
                     byte[][] tempValue = (byte[][])value[valueCount];
@@ -201,7 +201,7 @@ namespace System.DirectoryServices.Protocols
                 {
                     Debug.WriteLine("Format string contains undefined character: ");
                     Debug.WriteLine(new string(fmt, 1));
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterUndefineChar));
+                    throw new ArgumentException(SR.BerConverterUndefineChar);
                 }
 
                 // process the return value
@@ -424,7 +424,7 @@ namespace System.DirectoryServices.Protocols
                 else
                 {
                     Debug.WriteLine("Format string contains undefined character\n");
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.BerConverterUndefineChar));
+                    throw new ArgumentException(SR.BerConverterUndefineChar);
                 }
 
                 if (error != 0)
index a33909b..7409fc8 100644 (file)
@@ -28,7 +28,7 @@ namespace System.DirectoryServices.Protocols
             {
                 if (value < TimeSpan.Zero)
                 {
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.NoNegativeTimeLimit), nameof(value));
+                    throw new ArgumentException(SR.NoNegativeTimeLimit, nameof(value));
                 }
 
                 _connectionTimeOut = value;
index 19b430a..1951498 100644 (file)
@@ -89,7 +89,7 @@ namespace System.DirectoryServices.ActiveDirectory
                         throw new NotSupportedException(SR.NotSupportTransportSMTP);
                     }
 
-                    throw new ActiveDirectoryObjectNotFoundException(SR.Format(SR.TransportNotFound , transport.ToString()), typeof(ActiveDirectoryInterSiteTransport), transport.ToString());
+                    throw new ActiveDirectoryObjectNotFoundException(SR.Format(SR.TransportNotFound, transport.ToString()), typeof(ActiveDirectoryInterSiteTransport), transport.ToString());
                 }
                 else
                     throw ExceptionHelper.GetExceptionFromCOMException(context, e);
index a8bf27b..2ada257 100644 (file)
@@ -632,7 +632,7 @@ namespace System.DirectoryServices.ActiveDirectory
 
                     default:
                         // should not happen since we are calling this only internally
-                        Debug.Assert(false, "ConfigurationSet.GetRoleOwner: Invalid role type.");
+                        Debug.Fail("ConfigurationSet.GetRoleOwner: Invalid role type.");
                         break;
                 }
                 entry.RefreshCache();
index 588945f..326ea36 100644 (file)
@@ -1097,7 +1097,7 @@ namespace System.DirectoryServices.ActiveDirectory
                         }
                     default:
                         // should not happen since we are calling this only internally
-                        Debug.Assert(false, "Domain.GetRoleOwner: Invalid role type.");
+                        Debug.Fail("Domain.GetRoleOwner: Invalid role type.");
                         break;
                 }
 
index 8bfdeae..571d0f5 100644 (file)
@@ -848,7 +848,7 @@ namespace System.DirectoryServices.ActiveDirectory
 
                     default:
                         // should not happen since we are calling this only internally
-                        Debug.Assert(false, "Forest.GetRoleOwner: Invalid role type.");
+                        Debug.Fail("Forest.GetRoleOwner: Invalid role type.");
                         break;
                 }
 
index bfb9b10..e823ba9 100644 (file)
@@ -1732,7 +1732,7 @@ namespace System.DirectoryServices.ActiveDirectory
 
                 if (hostName == null)
                 {
-                    Debug.Fail(string.Format(CultureInfo.InvariantCulture, "ConfigurationSet::GetReplicaList - no dnsHostName information for replica {0}", ntdsaName));
+                    Debug.Fail($"ConfigurationSet::GetReplicaList - no dnsHostName information for replica {ntdsaName}");
                     if (isADAM)
                     {
                         throw new ActiveDirectoryOperationException(SR.Format(SR.NoHostNameOrPortNumber , ntdsaName));
@@ -1747,7 +1747,7 @@ namespace System.DirectoryServices.ActiveDirectory
                 {
                     if (serverPorts[ntdsaName] == null)
                     {
-                        Debug.Fail(string.Format(CultureInfo.InvariantCulture, "ConfigurationSet::GetReplicaList - no port number  information for replica {0}", ntdsaName));
+                        Debug.Fail($"ConfigurationSet::GetReplicaList - no port number  information for replica {ntdsaName}");
                         throw new ActiveDirectoryOperationException(SR.Format(SR.NoHostNameOrPortNumber , ntdsaName));
                     }
                 }
@@ -2246,8 +2246,7 @@ namespace System.DirectoryServices.ActiveDirectory
                 if (err != 0)
                 {
                     throw new InvalidOperationException(
-                                    string.Format(
-                                            CultureInfo.CurrentCulture,
+                                    SR.Format(
                                             SR.UnableToRetrieveDomainInfo,
                                             err));
                 }
index 7b6f697..520e625 100644 (file)
@@ -146,7 +146,7 @@ namespace System.Drawing
                                                              ColorTranslator.ToWin32(background));
             if (status == 2 /* invalid parameter*/ && (Width >= short.MaxValue || Height >= short.MaxValue))
             {
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidSize));
+                throw new ArgumentException(SR.GdiplusInvalidSize);
             }
 
             Gdip.CheckStatus(status);
@@ -209,7 +209,7 @@ namespace System.Drawing
         {
             if (RawFormat.Guid == ImageFormat.Icon.Guid)
             {
-                throw new InvalidOperationException(SR.Format(SR.CantMakeIconTransparent));
+                throw new InvalidOperationException(SR.CantMakeIconTransparent);
             }
 
             Size size = Size;
@@ -267,12 +267,12 @@ namespace System.Drawing
         {
             if (x < 0 || x >= Width)
             {
-                throw new ArgumentOutOfRangeException(nameof(x), SR.Format(SR.ValidRangeX));
+                throw new ArgumentOutOfRangeException(nameof(x), SR.ValidRangeX);
             }
 
             if (y < 0 || y >= Height)
             {
-                throw new ArgumentOutOfRangeException(nameof(y), SR.Format(SR.ValidRangeY));
+                throw new ArgumentOutOfRangeException(nameof(y), SR.ValidRangeY);
             }
 
             int color = 0;
@@ -286,17 +286,17 @@ namespace System.Drawing
         {
             if ((PixelFormat & PixelFormat.Indexed) != 0)
             {
-                throw new InvalidOperationException(SR.Format(SR.GdiplusCannotSetPixelFromIndexedPixelFormat));
+                throw new InvalidOperationException(SR.GdiplusCannotSetPixelFromIndexedPixelFormat);
             }
 
             if (x < 0 || x >= Width)
             {
-                throw new ArgumentOutOfRangeException(nameof(x), SR.Format(SR.ValidRangeX));
+                throw new ArgumentOutOfRangeException(nameof(x), SR.ValidRangeX);
             }
 
             if (y < 0 || y >= Height)
             {
-                throw new ArgumentOutOfRangeException(nameof(y), SR.Format(SR.ValidRangeY));
+                throw new ArgumentOutOfRangeException(nameof(y), SR.ValidRangeY);
             }
 
             int status = Gdip.GdipBitmapSetPixel(new HandleRef(this, nativeImage), x, y, color.ToArgb());
index 2f501f6..e5cfb5f 100644 (file)
@@ -100,7 +100,7 @@ namespace System.Drawing
 
                 if (hbm == IntPtr.Zero)
                 {
-                    throw new OutOfMemoryException(SR.Format(SR.GraphicsBufferQueryFail));
+                    throw new OutOfMemoryException(SR.GraphicsBufferQueryFail);
                 }
 
                 pbmi.bmiHeader_biSize = Marshal.SizeOf(typeof(NativeMethods.BITMAPINFOHEADER));
@@ -272,7 +272,7 @@ namespace System.Drawing
                 case NativeMethods.OBJ_ENHMETADC:
                     break;
                 default:
-                    throw new ArgumentException(SR.Format(SR.DCTypeInvalid));
+                    throw new ArgumentException(SR.DCTypeInvalid);
             }
 
             if (FillBitmapInfo(hdc, hpal, ref pbmi))
@@ -363,7 +363,7 @@ namespace System.Drawing
             {
                 if (oldBusy == BufferBusyPainting)
                 {
-                    throw new InvalidOperationException(SR.Format(SR.GraphicsBufferCurrentlyBusy));
+                    throw new InvalidOperationException(SR.GraphicsBufferCurrentlyBusy);
                 }
 
                 if (_compatGraphics != null)
index 432c349..d3cba10 100644 (file)
@@ -284,9 +284,9 @@ namespace System.Drawing.Drawing2D
         public void SetSigmaBellShape(float focus, float scale)
         {
             if (focus < 0 || focus > 1)
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter), nameof(focus));
+                throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(focus));
             if (scale < 0 || scale > 1)
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter), nameof(scale));
+                throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(scale));
 
             Gdip.CheckStatus(Gdip.GdipSetLineSigmaBlend(new HandleRef(this, NativeBrush), focus, scale));
         }
@@ -296,9 +296,9 @@ namespace System.Drawing.Drawing2D
         public void SetBlendTriangularShape(float focus, float scale)
         {
             if (focus < 0 || focus > 1)
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter), nameof(focus));
+                throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(focus));
             if (scale < 0 || scale > 1)
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter), nameof(scale));
+                throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(scale));
 
             Gdip.CheckStatus(Gdip.GdipSetLineLinearBlend(new HandleRef(this, NativeBrush), focus, scale));
 
@@ -316,7 +316,7 @@ namespace System.Drawing.Drawing2D
             {
                 if (!_interpolationColorsWasSet)
                     throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
-                                                SR.Format(SR.InterpolationColorsColorBlendNotSet), string.Empty));
+                                                SR.InterpolationColorsColorBlendNotSet, string.Empty));
 
                 // Figure out the size of blend factor array.
                 Gdip.CheckStatus(Gdip.GdipGetLinePresetBlendCount(new HandleRef(this, NativeBrush), out int retval));
@@ -372,31 +372,31 @@ namespace System.Drawing.Drawing2D
                 if (value == null)
                 {
                     throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
-                                                SR.Format(SR.InterpolationColorsInvalidColorBlendObject), string.Empty));
+                                                SR.InterpolationColorsInvalidColorBlendObject, string.Empty));
                 }
                 else if (value.Colors.Length < 2)
                 {
                     throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
-                                                SR.Format(SR.InterpolationColorsInvalidColorBlendObject),
-                                                SR.Format(SR.InterpolationColorsLength)));
+                                                SR.InterpolationColorsInvalidColorBlendObject,
+                                                SR.InterpolationColorsLength));
                 }
                 else if (value.Colors.Length != value.Positions.Length)
                 {
                     throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
-                                                SR.Format(SR.InterpolationColorsInvalidColorBlendObject),
-                                                SR.Format(SR.InterpolationColorsLengthsDiffer)));
+                                                SR.InterpolationColorsInvalidColorBlendObject,
+                                                SR.InterpolationColorsLengthsDiffer));
                 }
                 else if (value.Positions[0] != 0.0f)
                 {
                     throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
-                                                SR.Format(SR.InterpolationColorsInvalidColorBlendObject),
-                                                SR.Format(SR.InterpolationColorsInvalidStartPosition)));
+                                                SR.InterpolationColorsInvalidColorBlendObject,
+                                                SR.InterpolationColorsInvalidStartPosition));
                 }
                 else if (value.Positions[value.Positions.Length - 1] != 1.0f)
                 {
                     throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
-                                                SR.Format(SR.InterpolationColorsInvalidColorBlendObject),
-                                                SR.Format(SR.InterpolationColorsInvalidEndPosition)));
+                                                SR.InterpolationColorsInvalidColorBlendObject,
+                                                SR.InterpolationColorsInvalidEndPosition));
                 }
 
 
index c0622bd..4b18403 100644 (file)
@@ -239,9 +239,9 @@ namespace System.Drawing.Drawing2D
         public void SetSigmaBellShape(float focus, float scale)
         {
             if (focus < 0 || focus > 1)
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter), nameof(focus));
+                throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(focus));
             if (scale < 0 || scale > 1)
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter), nameof(scale));
+                throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(scale));
 
             Gdip.CheckStatus(Gdip.GdipSetPathGradientSigmaBlend(new HandleRef(this, NativeBrush), focus, scale));
         }
@@ -251,9 +251,9 @@ namespace System.Drawing.Drawing2D
         public void SetBlendTriangularShape(float focus, float scale)
         {
             if (focus < 0 || focus > 1)
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter), nameof(focus));
+                throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(focus));
             if (scale < 0 || scale > 1)
-                throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter), nameof(scale));
+                throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(scale));
 
             Gdip.CheckStatus(Gdip.GdipSetPathGradientLinearBlend(new HandleRef(this, NativeBrush), focus, scale));
         }
index 14d984b..c60cdb4 100644 (file)
@@ -277,7 +277,7 @@ namespace System.Drawing
             // Special case this incredibly common error message to give more information
             if (status == Gdip.NotTrueTypeFont)
             {
-                throw new ArgumentException(SR.Format(SR.GdiplusNotTrueTypeFont_NoName));
+                throw new ArgumentException(SR.GdiplusNotTrueTypeFont_NoName);
             }
             else if (status != Gdip.Ok)
             {
@@ -307,7 +307,7 @@ namespace System.Drawing
             // Special case this incredibly common error message to give more information
             if (status == Gdip.NotTrueTypeFont)
             {
-                throw new ArgumentException(SR.Format(SR.GdiplusNotTrueTypeFont_NoName));
+                throw new ArgumentException(SR.GdiplusNotTrueTypeFont_NoName);
             }
             else if (status != Gdip.Ok)
             {
index 0348d15..2777f86 100644 (file)
@@ -136,7 +136,7 @@ namespace System.Drawing
             if (image == null)
                 throw new ArgumentNullException(nameof(image));
             if ((image.PixelFormat & PixelFormat.Indexed) != 0)
-                throw new ArgumentException(SR.Format(SR.GdiplusCannotCreateGraphicsFromIndexedPixelFormat), nameof(image));
+                throw new ArgumentException(SR.GdiplusCannotCreateGraphicsFromIndexedPixelFormat, nameof(image));
 
             Gdip.CheckStatus(Gdip.GdipGetImageGraphicsContext(
                 new HandleRef(image, image.nativeImage),
@@ -1704,7 +1704,7 @@ namespace System.Drawing
 
             int count = destPoints.Length;
             if (count != 3 && count != 4)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidLength));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
 
             fixed (PointF* p = destPoints)
             {
@@ -1728,7 +1728,7 @@ namespace System.Drawing
 
             int count = destPoints.Length;
             if (count != 3 && count != 4)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidLength));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
 
             fixed (Point* p = destPoints)
             {
@@ -1826,7 +1826,7 @@ namespace System.Drawing
 
             int count = destPoints.Length;
             if (count != 3 && count != 4)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidLength));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
 
             fixed (PointF* p = destPoints)
             {
@@ -1880,7 +1880,7 @@ namespace System.Drawing
 
             int count = destPoints.Length;
             if (count != 3 && count != 4)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidLength));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
 
             fixed (PointF* p = destPoints)
             {
@@ -1945,7 +1945,7 @@ namespace System.Drawing
 
             int count = destPoints.Length;
             if (count != 3 && count != 4)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidLength));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
 
             fixed (Point* p = destPoints)
             {
@@ -2257,7 +2257,7 @@ namespace System.Drawing
             if (destPoints == null)
                 throw new ArgumentNullException(nameof(destPoints));
             if (destPoints.Length != 3)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidParallelogram));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidParallelogram);
 
             fixed (PointF* p = destPoints)
             {
@@ -2295,7 +2295,7 @@ namespace System.Drawing
             if (destPoints == null)
                 throw new ArgumentNullException(nameof(destPoints));
             if (destPoints.Length != 3)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidParallelogram));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidParallelogram);
 
             fixed (Point* p = destPoints)
             {
@@ -2526,7 +2526,7 @@ namespace System.Drawing
             if (destPoints == null)
                 throw new ArgumentNullException(nameof(destPoints));
             if (destPoints.Length != 3)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidParallelogram));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidParallelogram);
 
             fixed (PointF* p = destPoints)
             {
@@ -2579,7 +2579,7 @@ namespace System.Drawing
             if (destPoints == null)
                 throw new ArgumentNullException(nameof(destPoints));
             if (destPoints.Length != 3)
-                throw new ArgumentException(SR.Format(SR.GdiplusDestPointsInvalidParallelogram));
+                throw new ArgumentException(SR.GdiplusDestPointsInvalidParallelogram);
 
             fixed (Point* p = destPoints)
             {
index 7de66c4..1829495 100644 (file)
@@ -155,7 +155,7 @@ namespace System.Drawing
                     image = Metafile.FromGDIplus(nativeImage);
                     break;
                 default:
-                    throw new ArgumentException(SR.Format(SR.InvalidImage));
+                    throw new ArgumentException(SR.InvalidImage);
             }
 
             return image;
index b9449f4..9b6fe05 100644 (file)
@@ -340,7 +340,7 @@ namespace System.Drawing
         internal void SetNativeImage(IntPtr handle)
         {
             if (handle == IntPtr.Zero)
-                throw new ArgumentException(SR.Format(SR.NativeHandle0), nameof(handle));
+                throw new ArgumentException(SR.NativeHandle0, nameof(handle));
 
             nativeImage = handle;
         }
index 7d399de..ab50b66 100644 (file)
@@ -91,7 +91,7 @@ namespace System.Drawing
                     {
                         if (value < 0 || value >= FrameCount)
                         {
-                            throw new ArgumentException(SR.Format(SR.InvalidFrame), nameof(value));
+                            throw new ArgumentException(SR.InvalidFrame, nameof(value));
                         }
 
                         if (Animated)
index d4fb995..03ac8b4 100644 (file)
@@ -27,7 +27,7 @@ namespace System.Drawing
                 Gdip.CheckStatus(status);
                 if (lineCap == IntPtr.Zero)
                 {
-                    throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter));
+                    throw new ArgumentException(SR.GdiplusInvalidParameter);
                 }
 
                 return CustomLineCap.CreateCustomLineCapObject(lineCap);
@@ -55,7 +55,7 @@ namespace System.Drawing
                 // If the CustomEndCap has never been set, this accessor should throw.
                 if (_cachedEndCap == null)
                 {
-                    throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter));
+                    throw new ArgumentException(SR.GdiplusInvalidParameter);
                 }
 
                 return _cachedEndCap;
index 7ce30c5..b8e7250 100644 (file)
@@ -794,14 +794,14 @@ namespace System.Drawing
 
                 if (value == null || value.Length == 0)
                 {
-                    throw new ArgumentException(SR.Format(SR.InvalidDashPattern));
+                    throw new ArgumentException(SR.InvalidDashPattern);
                 }
 
                 foreach (float val in value)
                 {
                     if (val <= 0)
                     {
-                        throw new ArgumentException(SR.Format(SR.InvalidDashPattern));
+                        throw new ArgumentException(SR.InvalidDashPattern);
                     }
                 }
 
@@ -848,14 +848,14 @@ namespace System.Drawing
 
                 if (value.Length <= 1)
                 {
-                    throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter));
+                    throw new ArgumentException(SR.GdiplusInvalidParameter);
                 }
 
                 foreach (float val in value)
                 {
                     if (val < 0 || val > 1)
                     {
-                        throw new ArgumentException(SR.Format(SR.GdiplusInvalidParameter));
+                        throw new ArgumentException(SR.GdiplusInvalidParameter);
                     }
                 }
 
index 734fe00..a11d9d9 100644 (file)
@@ -156,7 +156,7 @@ namespace System.Drawing {
 
             if(x == null || y == null || 
                 !(x is int) || !(y is int)) {
-                throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry));
+                throw new ArgumentException(SR.PropertyValueInvalidEntry);
             }
     
             
index db6f96e..cd3c9c9 100644 (file)
@@ -27,7 +27,7 @@ namespace System.Drawing.Printing
         {
             if (settings.IsDefaultPrinter)
             {
-                return SR.Format(SR.InvalidPrinterException_NoDefaultPrinter);
+                return SR.InvalidPrinterException_NoDefaultPrinter;
             }
             else
             {
@@ -37,7 +37,7 @@ namespace System.Drawing.Printing
                 }
                 catch (SecurityException)
                 {
-                    return SR.Format(SR.InvalidPrinterException_InvalidPrinter, SR.Format(SR.CantTellPrinterName));
+                    return SR.Format(SR.InvalidPrinterException_InvalidPrinter, SR.CantTellPrinterName);
                 }
             }
         }
index aa73af0..7959fd7 100644 (file)
@@ -256,15 +256,7 @@ namespace System.Drawing.Printing
 
         public override string ToString()
         {
-            string ret = "[PageSettings: Color={0}";
-            ret += ", Landscape={1}";
-            ret += ", Margins={2}";
-            ret += ", PaperSize={3}";
-            ret += ", PaperSource={4}";
-            ret += ", PrinterResolution={5}";
-            ret += "]";
-
-            return string.Format(ret, this.color, this.landscape, this.margins, this.paperSize, this.paperSource, this.printerResolution);
+            return $"[{nameof(PageSettings)}: {nameof(Color)}={color}, {nameof(Landscape)}={landscape}, {nameof(Margins)}={margins}, {nameof(PaperSize)}={paperSize}, {nameof(PaperSource)}={paperSource}, {nameof(PrinterResolution)}={printerResolution}]";
         }
     }
 }
index f762020..0dd0e31 100644 (file)
@@ -61,7 +61,7 @@ namespace System.Drawing.Printing
             set
             {
                 if (_kind != PaperKind.Custom && !_createdByDefaultConstructor)
-                    throw new ArgumentException(SR.Format(SR.PSizeNotCustom));
+                    throw new ArgumentException(SR.PSizeNotCustom);
                 _height = value;
             }
         }
@@ -91,7 +91,7 @@ namespace System.Drawing.Printing
             set
             {
                 if (_kind != PaperKind.Custom && !_createdByDefaultConstructor)
-                    throw new ArgumentException(SR.Format(SR.PSizeNotCustom));
+                    throw new ArgumentException(SR.PSizeNotCustom);
                 _name = value;
             }
         }
@@ -118,7 +118,7 @@ namespace System.Drawing.Printing
             set
             {
                 if (_kind != PaperKind.Custom && !_createdByDefaultConstructor)
-                    throw new ArgumentException(SR.Format(SR.PSizeNotCustom));
+                    throw new ArgumentException(SR.PSizeNotCustom);
                 _width = value;
             }
         }
index 28b817f..e3fe35f 100644 (file)
@@ -732,7 +732,7 @@ namespace System.Drawing.Printing
                 bool status = SafeNativeMethods.PrintDlg(data);
 
                 if (!status)
-                    return SR.Format(SR.NoDefaultPrinter);
+                    return SR.NoDefaultPrinter;
 
                 IntPtr handle = data.hDevNames;
                 IntPtr names = SafeNativeMethods.GlobalLock(new HandleRef(data, handle));
@@ -756,7 +756,7 @@ namespace System.Drawing.Printing
                 bool status = SafeNativeMethods.PrintDlg(data);
 
                 if (!status)
-                    return SR.Format(SR.NoDefaultPrinter);
+                    return SR.NoDefaultPrinter;
 
                 IntPtr handle = data.hDevNames;
                 IntPtr names = SafeNativeMethods.GlobalLock(new HandleRef(data, handle));
@@ -785,7 +785,7 @@ namespace System.Drawing.Printing
                 data.Flags = SafeNativeMethods.PD_RETURNDEFAULT;
                 bool status = SafeNativeMethods.PrintDlg(data);
                 if (!status)
-                    return SR.Format(SR.NoDefaultPrinter);
+                    return SR.NoDefaultPrinter;
 
                 IntPtr handle = data.hDevNames;
                 IntPtr names = SafeNativeMethods.GlobalLock(new HandleRef(data, handle));
@@ -810,7 +810,7 @@ namespace System.Drawing.Printing
                 bool status = SafeNativeMethods.PrintDlg(data);
 
                 if (!status)
-                    return SR.Format(SR.NoDefaultPrinter);
+                    return SR.NoDefaultPrinter;
 
                 IntPtr handle = data.hDevNames;
                 IntPtr names = SafeNativeMethods.GlobalLock(new HandleRef(data, handle));
index 78cabdf..677c64f 100644 (file)
@@ -825,21 +825,23 @@ namespace System.Drawing.Printing
             int width = size.Width * 72 / 100;
             int height = size.Height * 72 / 100;
 
-            StringBuilder sb = new StringBuilder();
-            sb.Append(
-                "copies=" + printer_settings.Copies + " " +
-                "Collate=" + printer_settings.Collate + " " +
-                "ColorModel=" + (page_settings.Color ? "Color" : "Black") + " " +
-                "PageSize=" + string.Format("Custom.{0}x{1}", width, height) + " " +
-                "landscape=" + page_settings.Landscape
-            );
+            var sb = new StringBuilder();
+            sb.Append("copies=").Append(printer_settings.Copies).Append(' ')
+                .Append("Collate=").Append(printer_settings.Collate).Append(' ')
+                .Append("ColorModel=").Append(page_settings.Color ? "Color" : "Black").Append(' ')
+                .Append("PageSize=Custom.").Append(width).Append('x').Append(height).Append(' ')
+                .Append("landscape=").Append(page_settings.Landscape);
 
             if (printer_settings.CanDuplex)
             {
                 if (printer_settings.Duplex == Duplex.Simplex)
+                {
                     sb.Append(" Duplex=None");
+                }
                 else
+                {
                     sb.Append(" Duplex=DuplexNoTumble");
+                }
             }
 
             return LibcupsNative.cupsParseOptions(sb.ToString(), 0, ref options);
index f16ba8f..ec3dd6a 100644 (file)
@@ -66,7 +66,7 @@ namespace System.Drawing.Printing
         public static explicit operator bool (TriState value)
         {
             if (value.IsDefault)
-                throw new InvalidCastException(SR.Format(SR.TriStateCompareError));
+                throw new InvalidCastException(SR.TriStateCompareError);
             else
                 return (value == TriState.True);
         }
index baf32b3..fffa552 100644 (file)
@@ -163,7 +163,7 @@ namespace System.Drawing {
 
             if(x == null || y == null || width == null || height == null ||
                 !(x is int) || !(y is int) || !(width is int) || !(height is int) ) {
-                    throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry));
+                    throw new ArgumentException(SR.PropertyValueInvalidEntry);
             }
             return new Rectangle((int)x,
                                      (int)y,
index 32952a4..2fc9ebc 100644 (file)
@@ -157,7 +157,7 @@ namespace System.Drawing {
 
             if(width == null || height == null || 
                 !(width is int) || !(height is int)) {
-                throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry));
+                throw new ArgumentException(SR.PropertyValueInvalidEntry);
             }
             return new Size((int)width,
                              (int)height);
index 8dbb1ca..521a26b 100644 (file)
@@ -107,7 +107,7 @@ namespace System.Drawing.Internal
 #if GDI_FINALIZATION_WATCH
                     else
                     {
-                        try { Debug.WriteLine(string.Format("Allocation stack:\r\n{0}\r\nDeallocation stack:\r\n{1}", AllocationSite, DeAllocationSite)); } catch  {}
+                        try { Debug.WriteLine($"Allocation stack:\r\n{AllocationSite}\r\nDeallocation stack:\r\n{DeAllocationSite}"); } catch  {}
                     }
 #endif
                 }
@@ -144,7 +144,7 @@ namespace System.Drawing.Internal
             // the hDc will be created on demand.
 
 #if TRACK_HDC
-            Debug.WriteLine( DbgUtil.StackTraceToStr(String.Format( "DeviceContext( hWnd=0x{0:x8} )", unchecked((int) hWnd))));
+            Debug.WriteLine( DbgUtil.StackTraceToStr(string.Format( "DeviceContext( hWnd=0x{0:x8} )", unchecked((int) hWnd))));
 #endif
         }
 
@@ -164,7 +164,7 @@ namespace System.Drawing.Internal
                 _hWnd = IntUnsafeNativeMethods.WindowFromDC(new HandleRef(this, _hDC));
             }
 #if TRACK_HDC
-            Debug.WriteLine( DbgUtil.StackTraceToStr( String.Format("DeviceContext( hDC=0x{0:X8}, Type={1} )", unchecked((int) hDC), dcType) ));
+            Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("DeviceContext( hDC=0x{0:X8}, Type={1} )", unchecked((int) hDC), dcType) ));
 #endif
         }
 
@@ -254,7 +254,7 @@ namespace System.Drawing.Internal
                     // CreateDC and CreateIC add an HDC handle to the HandleCollector; to remove it properly we need 
                     // to call DeleteHDC.
 #if TRACK_HDC
-                    Debug.WriteLine( DbgUtil.StackTraceToStr( String.Format("DC.DeleteHDC(hdc=0x{0:x8})", unchecked((int) _hDC))));
+                    Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("DC.DeleteHDC(hdc=0x{0:x8})", unchecked((int) _hDC))));
 #endif
 
                     IntUnsafeNativeMethods.DeleteHDC(new HandleRef(this, _hDC));
@@ -267,7 +267,7 @@ namespace System.Drawing.Internal
                     // CreatCompatibleDC adds a GDI handle to HandleCollector, to remove it properly we need to call 
                     // DeleteDC.
 #if TRACK_HDC
-                    Debug.WriteLine( DbgUtil.StackTraceToStr( String.Format("DC.DeleteDC(hdc=0x{0:x8})", unchecked((int) _hDC))));
+                    Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("DC.DeleteDC(hdc=0x{0:x8})", unchecked((int) _hDC))));
 #endif
                     IntUnsafeNativeMethods.DeleteDC(new HandleRef(this, _hDC));
 
@@ -300,7 +300,7 @@ namespace System.Drawing.Internal
                 // For example, the default font is System.
                 _hDC = IntUnsafeNativeMethods.GetDC(new HandleRef(this, _hWnd));
 #if TRACK_HDC
-                Debug.WriteLine( DbgUtil.StackTraceToStr( String.Format("hdc[0x{0:x8}]=DC.GetHdc(hWnd=0x{1:x8})", unchecked((int) _hDC), unchecked((int) _hWnd))));
+                Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("hdc[0x{0:x8}]=DC.GetHdc(hWnd=0x{1:x8})", unchecked((int) _hDC), unchecked((int) _hWnd))));
 #endif            
             }
 
@@ -321,7 +321,7 @@ namespace System.Drawing.Internal
                 IntUnsafeNativeMethods.ReleaseDC(new HandleRef(this, _hWnd), new HandleRef(this, _hDC));
                 // Note: retVal == 0 means it was not released but doesn't necessarily means an error; class or private DCs are never released.
 #if TRACK_HDC
-                Debug.WriteLine( DbgUtil.StackTraceToStr( String.Format("[ret={0}]=DC.ReleaseDC(hDc=0x{1:x8}, hWnd=0x{2:x8})", retVal, unchecked((int) _hDC), unchecked((int) _hWnd))));
+                Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("[ret={0}]=DC.ReleaseDC(hDc=0x{1:x8}, hWnd=0x{2:x8})", retVal, unchecked((int) _hDC), unchecked((int) _hWnd))));
 #endif                 
                 _hDC = IntPtr.Zero;
             }
@@ -347,7 +347,7 @@ namespace System.Drawing.Internal
             IntUnsafeNativeMethods.RestoreDC(new HandleRef(this, _hDC), -1);
 #if TRACK_HDC
             // Note: Winforms may call this method during app exit at which point the DC may have been finalized already causing this assert to popup.
-            Debug.WriteLine( DbgUtil.StackTraceToStr( String.Format("ret[0]=DC.RestoreHdc(hDc=0x{1:x8}, state={2})", result, unchecked((int) _hDC), restoreState) ));
+            Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("ret[0]=DC.RestoreHdc(hDc=0x{1:x8}, state={2})", result, unchecked((int) _hDC), restoreState) ));
 #endif 
             Debug.Assert(_contextStack != null, "Someone is calling RestoreHdc() before SaveHdc()");
 
@@ -396,7 +396,7 @@ namespace System.Drawing.Internal
             _contextStack.Push(g);
 
 #if TRACK_HDC
-            Debug.WriteLine( DbgUtil.StackTraceToStr( String.Format("state[0]=DC.SaveHdc(hDc=0x{1:x8})", state, unchecked((int) _hDC)) ));
+            Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("state[0]=DC.SaveHdc(hDc=0x{1:x8})", state, unchecked((int) _hDC)) ));
 #endif
 
             return state;
index c1b5b1c..968035f 100644 (file)
@@ -56,7 +56,7 @@ namespace System.IO.IsolatedStorage
         {
             get
             {
-                throw new InvalidOperationException(string.Format(SR.IsolatedStorage_CurrentSizeUndefined, nameof(CurrentSize)));
+                throw new InvalidOperationException(SR.Format(SR.IsolatedStorage_CurrentSizeUndefined, nameof(CurrentSize)));
             }
         }
 
@@ -64,7 +64,7 @@ namespace System.IO.IsolatedStorage
         {
             get
             {
-                throw new InvalidOperationException(string.Format(SR.IsolatedStorage_QuotaIsUndefined, nameof(UsedSize)));
+                throw new InvalidOperationException(SR.Format(SR.IsolatedStorage_QuotaIsUndefined, nameof(UsedSize)));
             }
         }
 
@@ -72,7 +72,7 @@ namespace System.IO.IsolatedStorage
         {
             get
             {
-                throw new InvalidOperationException(string.Format(SR.IsolatedStorage_QuotaIsUndefined, nameof(AvailableFreeSpace)));
+                throw new InvalidOperationException(SR.Format(SR.IsolatedStorage_QuotaIsUndefined, nameof(AvailableFreeSpace)));
             }
         }
 
@@ -85,7 +85,7 @@ namespace System.IO.IsolatedStorage
                 if (_validQuota)
                     return _quota;
 
-                throw new InvalidOperationException(string.Format(SR.IsolatedStorage_QuotaIsUndefined, nameof(MaximumSize)));
+                throw new InvalidOperationException(SR.Format(SR.IsolatedStorage_QuotaIsUndefined, nameof(MaximumSize)));
             }
         }
 
@@ -96,7 +96,7 @@ namespace System.IO.IsolatedStorage
                 if (_validQuota)
                     return (long)_quota;
 
-                throw new InvalidOperationException(string.Format(SR.IsolatedStorage_QuotaIsUndefined, nameof(Quota)));
+                throw new InvalidOperationException(SR.Format(SR.IsolatedStorage_QuotaIsUndefined, nameof(Quota)));
             }
 
             internal set
index 79974e4..b975754 100644 (file)
@@ -373,7 +373,7 @@ namespace System.IO.IsolatedStorage
             }
             catch (FileNotFoundException)
             {
-                throw new FileNotFoundException(string.Format(SR.PathNotFound_Path, sourceFileName));
+                throw new FileNotFoundException(SR.Format(SR.PathNotFound_Path, sourceFileName));
             }
             catch (PathTooLongException)
             {
@@ -414,7 +414,7 @@ namespace System.IO.IsolatedStorage
             }
             catch (FileNotFoundException)
             {
-                throw new FileNotFoundException(string.Format(SR.PathNotFound_Path, sourceFileName));
+                throw new FileNotFoundException(SR.Format(SR.PathNotFound_Path, sourceFileName));
             }
             catch (PathTooLongException)
             {
@@ -455,7 +455,7 @@ namespace System.IO.IsolatedStorage
             }
             catch (DirectoryNotFoundException)
             {
-                throw new DirectoryNotFoundException(string.Format(SR.PathNotFound_Path, sourceDirectoryName));
+                throw new DirectoryNotFoundException(SR.Format(SR.PathNotFound_Path, sourceDirectoryName));
             }
             catch (PathTooLongException)
             {
index 8273185..49e777a 100644 (file)
@@ -177,9 +177,7 @@ namespace System.IO.Packaging
             }
             catch (XmlException exception)
             {
-                var r = SR.NotAValidXmlIdString;
-                var s = SR.Format(r, id);
-                throw new XmlException(s, exception);
+                throw new XmlException(SR.Format(SR.NotAValidXmlIdString, id), exception);
             }
         }
 
index ce1ae30..c2e0c53 100644 (file)
@@ -157,7 +157,7 @@ namespace System.IO.Packaging
                 default:
                     //Debug.Assert is fine here since the parameters have already been validated. And all the properties are 
                     //readonly
-                    Debug.Assert(false, "This option should never be called");
+                    Debug.Fail("This option should never be called");
                     break;
             }
 
index 99f58b8..92535eb 100644 (file)
@@ -587,7 +587,7 @@ namespace System.IO.Packaging
                     }
                     else  // An unexpected element is an error.
                     {
-                        Debug.Assert(false, "Unknown value type for properties");
+                        Debug.Fail("Unknown value type for properties");
                     }
                 }
             }
index 6c70b1d..05ba78f 100644 (file)
@@ -424,7 +424,7 @@ namespace System.IO.Packaging
                 // fall-through is not allowed
                 default:
                     {
-                        Debug.Assert(false, "Encountered an invalid CompressionOption enum value");
+                        Debug.Fail("Encountered an invalid CompressionOption enum value");
                         goto case CompressionOption.NotCompressed;
                     }
             }
index c4d755a..4ea5fd4 100644 (file)
@@ -100,7 +100,7 @@ namespace System.IO.Pipes
                     
                     if (serverEUID != peerID)
                     {
-                        throw new UnauthorizedAccessException(string.Format(SR.UnauthorizedAccess_ClientIsNotCurrentUser, peerID, serverEUID));
+                        throw new UnauthorizedAccessException(SR.Format(SR.UnauthorizedAccess_ClientIsNotCurrentUser, peerID, serverEUID));
                     }
                 }
 
index dfdac02..db9d881 100644 (file)
@@ -38,9 +38,7 @@ namespace System.IO.Ports
             Interop.Sys.Shutdown(handle, SocketShutdown.Both);
             int result = Interop.Serial.SerialPortClose(handle);
 
-            Debug.Assert(result == 0, string.Format(
-                             "Close failed with result {0} and error {1}",
-                             result, Interop.Sys.GetLastErrorInfo()));
+            Debug.Assert(result == 0, $"Close failed with result {result} and error {Interop.Sys.GetLastErrorInfo()}");
 
             return result == 0;
         }
index 1252bf0..7fbf155 100644 (file)
@@ -210,7 +210,7 @@ namespace System.IO.Ports
             set
             {
                 if (value < MinDataBits || value > MaxDataBits)
-                    throw new ArgumentOutOfRangeException(nameof(DataBits), string.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, MinDataBits, MaxDataBits));
+                    throw new ArgumentOutOfRangeException(nameof(DataBits), SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, MinDataBits, MaxDataBits));
 
                 if (IsOpen)
                     _internalSerialStream.DataBits = value;
@@ -278,7 +278,7 @@ namespace System.IO.Ports
                 if (!(value is ASCIIEncoding || value is UTF8Encoding || value is UnicodeEncoding || value is UTF32Encoding ||
                       value.CodePage < 50000 || value.CodePage == 54936))
                 {
-                    throw new ArgumentException(string.Format(SR.NotSupportedEncoding, value.WebName), nameof(Encoding));
+                    throw new ArgumentException(SR.Format(SR.NotSupportedEncoding, value.WebName), nameof(Encoding));
                 }
 
                 _encoding = value;
@@ -321,7 +321,7 @@ namespace System.IO.Ports
                 if (value == null)
                     throw new ArgumentNullException(nameof(NewLine));
                 if (value.Length == 0)
-                    throw new ArgumentException(string.Format(SR.InvalidNullEmptyArgument, nameof(NewLine)), nameof(NewLine));
+                    throw new ArgumentException(SR.Format(SR.InvalidNullEmptyArgument, nameof(NewLine)), nameof(NewLine));
 
                 _newLine = value;
             }
@@ -371,7 +371,7 @@ namespace System.IO.Ports
                     throw new ArgumentException(SR.PortNameEmpty_String, nameof(PortName));
 
                 if (IsOpen)
-                    throw new InvalidOperationException(string.Format(SR.Cant_be_set_when_open, nameof(PortName)));
+                    throw new InvalidOperationException(SR.Format(SR.Cant_be_set_when_open, nameof(PortName)));
                 _portName = value;
             }
         }
@@ -388,7 +388,7 @@ namespace System.IO.Ports
                     throw new ArgumentOutOfRangeException(nameof(ReadBufferSize));
 
                 if (IsOpen)
-                    throw new InvalidOperationException(string.Format(SR.Cant_be_set_when_open, nameof(ReadBufferSize)));
+                    throw new InvalidOperationException(SR.Format(SR.Cant_be_set_when_open, nameof(ReadBufferSize)));
 
                 _readBufferSize = value;
             }
@@ -486,7 +486,7 @@ namespace System.IO.Ports
                     throw new ArgumentOutOfRangeException(nameof(WriteBufferSize));
 
                 if (IsOpen)
-                    throw new InvalidOperationException(string.Format(SR.Cant_be_set_when_open, nameof(WriteBufferSize)));
+                    throw new InvalidOperationException(SR.Format(SR.Cant_be_set_when_open, nameof(WriteBufferSize)));
 
                 _writeBufferSize = value;
             }
@@ -1012,7 +1012,7 @@ namespace System.IO.Ports
             if (value == null)
                 throw new ArgumentNullException(nameof(value));
             if (value.Length == 0)
-                throw new ArgumentException(string.Format(SR.InvalidNullEmptyArgument, nameof(value)), nameof(value));
+                throw new ArgumentException(SR.Format(SR.InvalidNullEmptyArgument, nameof(value)), nameof(value));
 
             int startTicks = Environment.TickCount;
             int numCharsRead;
index 735ec37..eaf6515 100644 (file)
@@ -441,8 +441,7 @@ namespace System.IO.Ports
         {
             if (!pollReadEvents && !pollWriteEvents)
             {
-                // This should not happen
-                Debug.Assert(false);
+                Debug.Fail("This should not happen");
                 throw new Exception();
             }
 
index 4bd5e21..4b22ced 100644 (file)
@@ -79,7 +79,7 @@ namespace System.IO.Ports
                     else
                     {
                         // otherwise, we can present the bounds on the baud rate for this driver
-                        throw new ArgumentOutOfRangeException(nameof(BaudRate), string.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, 0, _commProp.dwMaxBaud));
+                        throw new ArgumentOutOfRangeException(nameof(BaudRate), SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, 0, _commProp.dwMaxBaud));
                     }
                 }
                 // Set only if it's different.  Rollback to previous values if setting fails.
@@ -608,7 +608,7 @@ namespace System.IO.Ports
                 }
 
                 if (_commProp.dwMaxBaud != 0 && baudRate > _commProp.dwMaxBaud)
-                    throw new ArgumentOutOfRangeException(nameof(baudRate), string.Format(SR.Max_Baud, _commProp.dwMaxBaud));
+                    throw new ArgumentOutOfRangeException(nameof(baudRate), SR.Format(SR.Max_Baud, _commProp.dwMaxBaud));
 
                 _comStat = new Interop.Kernel32.COMSTAT();
                 // create internal DCB structure, initialize according to Platform SDK
@@ -719,7 +719,7 @@ namespace System.IO.Ports
                         else
                         {
                             // should not happen
-                            Debug.Fail(string.Format("Unexpected error code from EscapeCommFunction in SerialPort.Dispose(bool)  Error code: 0x{0:x}", (uint)hr));
+                            Debug.Fail($"Unexpected error code from EscapeCommFunction in SerialPort.Dispose(bool)  Error code: 0x{(uint)hr:x}");
 
                             // Do not throw an exception from the finalizer here.
                             if (disposing)
@@ -1165,7 +1165,7 @@ namespace System.IO.Ports
                     _dcb.StopBits = NativeMethods.TWOSTOPBITS;
                     break;
                 default:
-                    Debug.Assert(false, "Invalid value for stopBits");
+                    Debug.Fail("Invalid value for stopBits");
                     break;
             }
 
@@ -1636,14 +1636,14 @@ namespace System.IO.Ports
                                     // Ignore ERROR_IO_INCOMPLETE and ERROR_INVALID_PARAMETER, because there's a chance we'll get
                                     // one of those while shutting down
                                     if (!((error == Interop.Errors.ERROR_IO_INCOMPLETE || error == Interop.Errors.ERROR_INVALID_PARAMETER) && ShutdownLoop))
-                                        Debug.Assert(false, "GetOverlappedResult returned error, we might leak intOverlapped memory" + error.ToString(CultureInfo.InvariantCulture));
+                                        Debug.Fail("GetOverlappedResult returned error, we might leak intOverlapped memory" + error.ToString(CultureInfo.InvariantCulture));
                                 }
                             }
                             else if (hr != Interop.Errors.ERROR_INVALID_PARAMETER)
                             {
                                 // ignore ERROR_INVALID_PARAMETER errors.  WaitCommError seems to return this
                                 // when SetCommMask is changed while it's blocking (like we do in Dispose())
-                                Debug.Assert(false, "WaitCommEvent returned error " + hr);
+                                Debug.Fail("WaitCommEvent returned error " + hr);
                             }
                         }
                     }
index 29bacd8..d1d3aa0 100644 (file)
@@ -20,7 +20,7 @@ namespace System.Dynamic.Utils
         {
             get
             {
-                Debug.Assert(false, "Unreachable");
+                Debug.Fail("Unreachable");
                 return new InvalidOperationException("Code supposed to be unreachable");
             }
         }
index 86b29b5..2077dd4 100644 (file)
@@ -1251,7 +1251,7 @@ namespace System.Linq.Expressions
 
         private static string QuoteName(string name)
         {
-            return string.Format(CultureInfo.CurrentCulture, "'{0}'", name);
+            return "'" + name + "'";
         }
 
         private static string GetDisplayName(string name)
index 6235ccc..bd00a0d 100644 (file)
@@ -315,7 +315,7 @@ namespace System.Management
             if (hModule == IntPtr.Zero)
             {
                 // This is unlikely, so having the TypeInitializationException wrapping it is fine.
-                throw new Win32Exception(Marshal.GetLastWin32Error(), string.Format(SR.LoadLibraryFailed, wminet_utilsPath));
+                throw new Win32Exception(Marshal.GetLastWin32Error(), SR.Format(SR.LoadLibraryFailed, wminet_utilsPath));
             }
 
             if (LoadDelegate(ref ResetSecurity_f, hModule, "ResetSecurity") &&
@@ -375,7 +375,7 @@ namespace System.Management
             }
             else
             {
-                LoadPlatformNotSupportedDelegates(string.Format(SR.PlatformNotSupported_FrameworkUpdatedRequired, wminet_utilsPath));
+                LoadPlatformNotSupportedDelegates(SR.Format(SR.PlatformNotSupported_FrameworkUpdatedRequired, wminet_utilsPath));
             }
         }
         static bool LoadDelegate<TDelegate>(ref TDelegate delegate_f, IntPtr hModule, string procName) where TDelegate : class
index c9580d5..3caf42a 100644 (file)
@@ -4919,7 +4919,7 @@ namespace System.Management
             }
             catch
             {
-                throw new ArgumentOutOfRangeException(string.Format(SR.UnableToCreateCodeGeneratorException , strProvider ));
+                throw new ArgumentOutOfRangeException(SR.Format(SR.UnableToCreateCodeGeneratorException , strProvider ));
             }
 
             if(bSucceeded == true)
@@ -4928,7 +4928,7 @@ namespace System.Management
             }
             else
             {
-                throw new ArgumentOutOfRangeException(string.Format(SR.UnableToCreateCodeGeneratorException , strProvider));
+                throw new ArgumentOutOfRangeException(SR.Format(SR.UnableToCreateCodeGeneratorException , strProvider));
             }
             return true;
         }
index 0a07349..5862fd2 100644 (file)
@@ -161,7 +161,7 @@ namespace System.Net.Http
                 && state.ExpectedBytesToRead.HasValue
                 && state.CurrentBytesRead < state.ExpectedBytesToRead.Value)
             {
-                state.LifecycleAwaitable.SetException(new IOException(string.Format(
+                state.LifecycleAwaitable.SetException(new IOException(SR.Format(
                     SR.net_http_io_read_incomplete,
                     state.ExpectedBytesToRead.Value,
                     state.CurrentBytesRead)));
index de711e9..b2f2aab 100644 (file)
@@ -301,7 +301,7 @@ namespace System.Net.Http.Headers
             int dispositionTypeLength = GetDispositionTypeExpressionLength(dispositionType, 0, out tempDispositionType);
             if ((dispositionTypeLength == 0) || (tempDispositionType.Length != dispositionType.Length))
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture,
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture,
                     SR.net_http_headers_invalid_value, dispositionType));
             }
         }
@@ -438,7 +438,7 @@ namespace System.Net.Http.Headers
 
             if (result.IndexOf("\"", 0, StringComparison.Ordinal) >= 0) // Only bounding quotes are allowed.
             {
-                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
+                throw new ArgumentException(SR.Format(CultureInfo.InvariantCulture,
                     SR.net_http_headers_invalid_value, input));
             }
             else if (RequiresEncoding(result))
index 75d77e1..9abfac6 100644 (file)
@@ -154,7 +154,7 @@ namespace System.Net.Http.Headers
 
             if (HttpRuleParser.GetTokenLength(value, 0) != value.Length)
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, value));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, value));
             }
         }
 
@@ -169,7 +169,7 @@ namespace System.Net.Http.Headers
             if ((HttpRuleParser.GetCommentLength(value, 0, out length) != HttpParseResult.Parsed) ||
                 (length != value.Length)) // no trailing spaces allowed
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, value));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, value));
             }
         }
 
@@ -184,7 +184,7 @@ namespace System.Net.Http.Headers
             if ((HttpRuleParser.GetQuotedStringLength(value, 0, out length) != HttpParseResult.Parsed) ||
                 (length != value.Length)) // no trailing spaces allowed
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, value));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, value));
             }
         }
 
index ca9c27e..b948800 100644 (file)
@@ -71,7 +71,7 @@ namespace System.Net.Http.Headers
             object result = null;
             if (!TryParseValue(value, storeValue, ref index, out result))
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value,
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value,
                     value == null ? "<null>" : value.Substring(index)));
             }
             return result;
index 9bedfc8..4fb3566 100644 (file)
@@ -989,7 +989,7 @@ namespace System.Net.Http.Headers
                     break;
 
                 default:
-                    Debug.Assert(false, "Unknown StoreLocation value: " + location.ToString());
+                    Debug.Fail("Unknown StoreLocation value: " + location.ToString());
                     break;
             }
         }
@@ -1062,7 +1062,7 @@ namespace System.Net.Http.Headers
             // value already set.
             if (!info.CanAddValue(descriptor.Parser))
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_single_value_header, descriptor.Name));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_single_value_header, descriptor.Name));
             }
 
             int index = 0;
index 4791537..e433ded 100644 (file)
@@ -263,7 +263,7 @@ namespace System.Net.Http.Headers
             int mediaTypeLength = GetMediaTypeExpressionLength(mediaType, 0, out tempMediaType);
             if ((mediaTypeLength == 0) || (tempMediaType.Length != mediaType.Length))
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, mediaType));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, mediaType));
             }
         }
 
index a29b3fc..8b15463 100644 (file)
@@ -357,7 +357,7 @@ namespace System.Net.Http.Headers
             // Either value is null/empty or a valid token/quoted string
             if (!(string.IsNullOrEmpty(value) || (GetValueLength(value, 0) == value.Length)))
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, value));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, value));
             }
         }
 
index c2c7423..aa4b302 100644 (file)
@@ -99,7 +99,7 @@ namespace System.Net.Http.Headers
             {
                 // There is some invalid leftover data. Normally BaseHeaderParser.TryParseValue would 
                 // handle this, but ProductInfoHeaderValue does not derive from BaseHeaderParser.
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, input.Substring(index)));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, input.Substring(index)));
             }
             return (ProductInfoHeaderValue)result;
         }
index af4dc87..08418bc 100644 (file)
@@ -298,7 +298,7 @@ namespace System.Net.Http.Headers
             string host = null;
             if (HttpRuleParser.GetHostLength(receivedBy, 0, true, out host) != receivedBy.Length)
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, receivedBy));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, receivedBy));
             }
         }
     }
index 821915d..bf18913 100644 (file)
@@ -247,7 +247,7 @@ namespace System.Net.Http.Headers
 
             if (!HeaderUtilities.TryParseInt32(input, current, codeLength, out code))
             {
-                Debug.Assert(false, "Unable to parse value even though it was parsed as <=3 digits string. Input: '" +
+                Debug.Fail("Unable to parse value even though it was parsed as <=3 digits string. Input: '" +
                     input + "', Current: " + current + ", CodeLength: " + codeLength);
                 return false;
             }
@@ -340,7 +340,7 @@ namespace System.Net.Http.Headers
             string host = null;
             if (HttpRuleParser.GetHostLength(agent, 0, true, out host) != agent.Length)
             {
-                throw new FormatException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, agent));
+                throw new FormatException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, agent));
             }
         }
     }
index d3b172e..5682663 100644 (file)
@@ -85,7 +85,7 @@ namespace System.Net.Http
                 if (value > HttpContent.MaxBufferSize)
                 {
                     throw new ArgumentOutOfRangeException(nameof(value), value,
-                        string.Format(System.Globalization.CultureInfo.InvariantCulture,
+                        SR.Format(System.Globalization.CultureInfo.InvariantCulture,
                         SR.net_http_content_buffersize_limit, HttpContent.MaxBufferSize));
                 }
                 CheckDisposedOrStarted();
index 9c1bb25..79dd984 100644 (file)
@@ -36,7 +36,7 @@ namespace System.Net.Http
                 if (value > HttpContent.MaxBufferSize)
                 {
                     throw new ArgumentOutOfRangeException(nameof(value), value,
-                        string.Format(CultureInfo.InvariantCulture, SR.net_http_content_buffersize_limit,
+                        SR.Format(CultureInfo.InvariantCulture, SR.net_http_content_buffersize_limit,
                         HttpContent.MaxBufferSize));
                 }                
 
index 3106bc0..2c15aa5 100644 (file)
@@ -391,7 +391,7 @@ namespace System.Net.Http
                 // This should only be hit when called directly; HttpClient/HttpClientHandler
                 // will not exceed this limit.
                 throw new ArgumentOutOfRangeException(nameof(maxBufferSize), maxBufferSize,
-                    string.Format(System.Globalization.CultureInfo.InvariantCulture,
+                    SR.Format(System.Globalization.CultureInfo.InvariantCulture,
                     SR.net_http_content_buffersize_limit, HttpContent.MaxBufferSize));
             }
 
@@ -510,7 +510,7 @@ namespace System.Net.Http
 
                 if (contentLength > maxBufferSize)
                 {
-                    error = new HttpRequestException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_content_buffersize_exceeded, maxBufferSize));
+                    error = new HttpRequestException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_content_buffersize_exceeded, maxBufferSize));
                     return null;
                 }
 
index 6fae4e3..860822c 100644 (file)
@@ -155,7 +155,7 @@ namespace System.Net.Http
         {
             if (!IsSuccessStatusCode)
             {
-                throw new HttpRequestException(string.Format(
+                throw new HttpRequestException(SR.Format(
                     System.Globalization.CultureInfo.InvariantCulture,
                     SR.net_http_message_not_success_statuscode,
                     (int)_statusCode,
index 2570797..5a4ce7c 100644 (file)
@@ -413,7 +413,7 @@ namespace System.Net.Http
                                 break;
 
                             case HttpParseResult.NotParsed:
-                                Debug.Assert(false, "'NotParsed' is unexpected: We started nested expression " +
+                                Debug.Fail("'NotParsed' is unexpected: We started nested expression " +
                                     "parsing, because we found the open-char. So either it's a valid nested " +
                                     "expression or it has invalid format.");
                                 break;
@@ -423,7 +423,7 @@ namespace System.Net.Http
                                 return HttpParseResult.InvalidFormat;
 
                             default:
-                                Debug.Assert(false, "Unknown enum result: " + nestedResult);
+                                Debug.Fail("Unknown enum result: " + nestedResult);
                                 break;
                         }
                     }
index dd9fdda..1c468c3 100644 (file)
@@ -83,12 +83,12 @@ namespace System.Net.Http
             if (boundary.Length > 70)
             {
                 throw new ArgumentOutOfRangeException(nameof(boundary), boundary,
-                    string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_content_field_too_long, 70));
+                    SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_content_field_too_long, 70));
             }
             // Cannot end with space.
             if (boundary.EndsWith(" ", StringComparison.Ordinal))
             {
-                throw new ArgumentException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, boundary), nameof(boundary));
+                throw new ArgumentException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, boundary), nameof(boundary));
             }
             Contract.EndContractBlock();
 
@@ -105,7 +105,7 @@ namespace System.Net.Http
                 }
                 else
                 {
-                    throw new ArgumentException(string.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, boundary), nameof(boundary));
+                    throw new ArgumentException(SR.Format(System.Globalization.CultureInfo.InvariantCulture, SR.net_http_headers_invalid_value, boundary), nameof(boundary));
                 }
             }
         }
index a215ad9..ad7555a 100644 (file)
@@ -106,7 +106,7 @@ namespace System.Net.Http
                 }
                 if (!UseCookies)
                 {
-                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
+                    throw new InvalidOperationException(SR.Format(CultureInfo.InvariantCulture,
                         SR.net_http_invalid_enable_first, nameof(UseCookies), "true"));
                 }
                 CheckDisposedOrStarted();
@@ -200,7 +200,7 @@ namespace System.Net.Http
                 CheckDisposedOrStarted();
                 if (value != null && value != CredentialCache.DefaultCredentials && !(value is NetworkCredential))
                 {
-                    throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
+                    throw new PlatformNotSupportedException(SR.Format(CultureInfo.InvariantCulture,
                         SR.net_http_value_not_supported, value, nameof(Credentials)));
                 }
                 
@@ -219,7 +219,7 @@ namespace System.Net.Http
                 CheckDisposedOrStarted();
                 if (value != null && value != CredentialCache.DefaultCredentials && !(value is NetworkCredential))
                 {
-                    throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
+                    throw new PlatformNotSupportedException(SR.Format(CultureInfo.InvariantCulture,
                         SR.net_http_value_not_supported, value, nameof(DefaultProxyCredentials)));
                 }
                 
@@ -306,7 +306,7 @@ namespace System.Net.Http
                 {
                     if (!RTServerCustomValidationRequestedSupported)
                     {
-                        throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
+                        throw new PlatformNotSupportedException(SR.Format(CultureInfo.InvariantCulture,
                             SR.net_http_feature_requires_Windows10Version1607));
                     }
                 }
@@ -477,7 +477,7 @@ namespace System.Net.Http
                     RTCertificate rtClientCert = await CertificateHelper.ConvertDotNetClientCertToWinRtClientCertAsync(clientCert).ConfigureAwait(false);
                     if (rtClientCert == null)
                     {
-                        throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
+                        throw new PlatformNotSupportedException(SR.Format(CultureInfo.InvariantCulture,
                             SR.net_http_feature_UWPClientCertSupportRequiresCertInPersonalCertificateStore));
                     }
 
@@ -594,7 +594,7 @@ namespace System.Net.Http
                 if (string.Equals(request.Method.Method, HttpMethod.Trace.Method, StringComparison.OrdinalIgnoreCase))
                 {
                     // https://github.com/dotnet/corefx/issues/22161
-                    throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
+                    throw new PlatformNotSupportedException(SR.Format(CultureInfo.InvariantCulture,
                         SR.net_http_httpmethod_notsupported_error, request.Method.Method));
                 }
 
index 31673dc..ad45b3c 100644 (file)
@@ -1130,11 +1130,7 @@ namespace System.Net.WebSockets
             bool endOfMessage)
         {
             Debug.Assert(messageType == WebSocketMessageType.Binary || messageType == WebSocketMessageType.Text,
-                string.Format(CultureInfo.InvariantCulture,
-                    "The value of 'messageType' ({0}) is invalid. Valid message types: '{1}, {2}'",
-                    messageType,
-                    WebSocketMessageType.Binary,
-                    WebSocketMessageType.Text));
+                $"The value of 'messageType' ({messageType}) is invalid. Valid message types: '{WebSocketMessageType.Binary}, {WebSocketMessageType.Text}'");
 
             if (messageType == WebSocketMessageType.Text)
             {
@@ -1172,8 +1168,7 @@ namespace System.Net.WebSockets
                     // This indicates a contract violation of the websocket protocol component,
                     // because we currently don't support any WebSocket extensions and would
                     // not accept a Websocket handshake requesting extensions
-                    Debug.Assert(false,
-                    string.Format(CultureInfo.InvariantCulture,
+                    Debug.Fail(string.Format(CultureInfo.InvariantCulture,
                         "The value of 'bufferType' ({0}) is invalid. Valid buffer types: {1}, {2}, {3}, {4}, {5}.",
                         bufferType,
                         WebSocketProtocolComponent.BufferType.Close,
@@ -1414,11 +1409,7 @@ namespace System.Net.WebSockets
             int receiveState;
             if ((receiveState = Interlocked.Exchange(ref _receiveState, newReceiveState)) != expectedReceiveState)
             {
-                Debug.Assert(false,
-                    string.Format(CultureInfo.InvariantCulture,
-                        "'_receiveState' had an invalid value '{0}'. The expected value was '{1}'.",
-                        receiveState,
-                        expectedReceiveState));
+                Debug.Fail($"'_receiveState' had an invalid value '{receiveState}'. The expected value was '{expectedReceiveState}'.");
             }
         }
 
@@ -1791,10 +1782,7 @@ namespace System.Net.WebSockets
 
                                     break;
                                 default:
-                                    string assertMessage = string.Format(CultureInfo.InvariantCulture,
-                                        "Invalid action '{0}' returned from WebSocketGetAction.",
-                                        action);
-                                    Debug.Assert(false, assertMessage);
+                                    Debug.Fail($"Invalid action '{action}' returned from WebSocketGetAction.");
                                     throw new InvalidOperationException();
                             }
                         }
@@ -1864,7 +1852,7 @@ namespace System.Net.WebSockets
                             _receiveState = ReceiveState.Application;
                             break;
                         case ReceiveState.Application:
-                            Debug.Assert(false, "'originalReceiveState' MUST NEVER be ReceiveState.Application at this point.");
+                            Debug.Fail("'originalReceiveState' MUST NEVER be ReceiveState.Application at this point.");
                             break;
                         case ReceiveState.PayloadAvailable:
                             WebSocketReceiveResult receiveResult;
@@ -1876,8 +1864,7 @@ namespace System.Net.WebSockets
                             _receiveCompleted = true;
                             break;
                         default:
-                            Debug.Assert(false,
-                                string.Format(CultureInfo.InvariantCulture, "Invalid ReceiveState '{0}'.", originalReceiveState));
+                            Debug.Fail($"Invalid ReceiveState '{originalReceiveState}'.");
                             break;
                     }
                 }
index f96532d..332566f 100644 (file)
@@ -179,7 +179,7 @@ namespace System.Net.WebSockets
 
             if (previousState != SendBufferState.None)
             {
-                Debug.Assert(false, "'m_SendBufferState' MUST BE 'None' at this point.");
+                Debug.Fail("'m_SendBufferState' MUST BE 'None' at this point.");
                 // Indicates a violation in the API contract that could indicate 
                 // memory corruption because the pinned sendbuffer is shared between managed and native code
                 throw new AccessViolationException();
@@ -379,7 +379,7 @@ namespace System.Net.WebSockets
                     (int)bufferLength);
             }
 
-            Debug.Assert(false, "'buffer' MUST reference a memory segment within the pinned InternalBuffer.");
+            Debug.Fail("'buffer' MUST reference a memory segment within the pinned InternalBuffer.");
             // Indicates a violation in the contract with native Websocket.dll and could indicate 
             // memory corruption because the internal buffer is shared between managed and native code
             throw new AccessViolationException();
@@ -412,7 +412,7 @@ namespace System.Net.WebSockets
                 }
                 else
                 {
-                    Debug.Assert(false, "'buffer' MUST reference a memory segment within the pinned InternalBuffer.");
+                    Debug.Fail("'buffer' MUST reference a memory segment within the pinned InternalBuffer.");
                     // Indicates a violation in the contract with native Websocket.dll and could indicate 
                     // memory corruption because the internal buffer is shared between managed and native code
                     throw new AccessViolationException();
@@ -437,7 +437,7 @@ namespace System.Net.WebSockets
             ThrowIfDisposed();
             if (dataBufferCount > dataBuffers.Length)
             {
-                Debug.Assert(false, "'dataBufferCount' MUST NOT be bigger than 'dataBuffers.Length'.");
+                Debug.Fail("'dataBufferCount' MUST NOT be bigger than 'dataBuffers.Length'.");
                 // Indicates a violation in the contract with native Websocket.dll and could indicate 
                 // memory corruption because the internal buffer is shared between managed and native code
                 throw new AccessViolationException();
@@ -474,8 +474,7 @@ namespace System.Net.WebSockets
                 {
                     if (!isSendActivity || !isPinnedSendPayloadBuffer)
                     {
-                        Debug.Assert(false,
-                        "'dataBuffer.BufferLength' MUST NOT be bigger than 'm_ReceiveBufferSize' and 'm_SendBufferSize'.");
+                        Debug.Fail("'dataBuffer.BufferLength' MUST NOT be bigger than 'm_ReceiveBufferSize' and 'm_SendBufferSize'.");
                         // Indicates a violation in the contract with native Websocket.dll and could indicate 
                         // memory corruption because the internal buffer is shared between managed and native code
                         throw new AccessViolationException();
@@ -484,8 +483,7 @@ namespace System.Net.WebSockets
 
                 if (!isPinnedSendPayloadBuffer && !IsNativeBuffer(bufferData, bufferLength))
                 {
-                    Debug.Assert(false,
-                        "WebSocketGetAction MUST return a pointer within the pinned internal buffer.");
+                    Debug.Fail("WebSocketGetAction MUST return a pointer within the pinned internal buffer.");
                     // Indicates a violation in the contract with native Websocket.dll and could indicate 
                     // memory corruption because the internal buffer is shared between managed and native code
                     throw new AccessViolationException();
@@ -497,7 +495,7 @@ namespace System.Net.WebSockets
                 action != WebSocketProtocolComponent.Action.IndicateReceiveComplete &&
                 action != WebSocketProtocolComponent.Action.IndicateSendComplete)
             {
-                Debug.Assert(false, "At least one 'dataBuffer.Buffer' MUST NOT be NULL.");
+                Debug.Fail("At least one 'dataBuffer.Buffer' MUST NOT be NULL.");
             }
         }
 
@@ -531,10 +529,7 @@ namespace System.Net.WebSockets
                     bufferLength = buffer.Data.BufferLength;
                     break;
                 default:
-                    Debug.Assert(false,
-                        string.Format(CultureInfo.InvariantCulture,
-                            "BufferType '{0}' is invalid/unknown.",
-                            bufferType));
+                    Debug.Fail($"BufferType '{bufferType}' is invalid/unknown.");
                     break;
             }
         }
index f028ea5..21d624e 100644 (file)
@@ -1052,7 +1052,7 @@ namespace System.Net.WebSockets
                         throw new ObjectDisposedException(GetType().FullName);
                     }
 
-                    Debug.Assert(false, "Only one outstanding async operation is allowed per HttpListenerAsyncEventArgs instance.");
+                    Debug.Fail("Only one outstanding async operation is allowed per HttpListenerAsyncEventArgs instance.");
                     // Only one at a time.
                     throw new InvalidOperationException();
                 }
index 2abaecf..d5b015b 100644 (file)
@@ -471,7 +471,7 @@ namespace System.Net.WebSockets
             if ((httpHeader.Name == null && length != 0) ||
                 (httpHeader.Name != null && length != httpHeader.Name.Length))
             {
-                Debug.Assert(false, "The length of 'httpHeader.Name' MUST MATCH 'length'.");
+                Debug.Fail("The length of 'httpHeader.Name' MUST MATCH 'length'.");
                 throw new AccessViolationException();
             }
 
@@ -494,7 +494,7 @@ namespace System.Net.WebSockets
             if ((httpHeader.Value == null && length != 0) ||
                 (httpHeader.Value != null && length != httpHeader.Value.Length))
             {
-                Debug.Assert(false, "The length of 'httpHeader.Value' MUST MATCH 'length'.");
+                Debug.Fail("The length of 'httpHeader.Value' MUST MATCH 'length'.");
                 throw new AccessViolationException();
             }
         }
index 08ec5d8..74ee0a7 100644 (file)
@@ -563,7 +563,7 @@ namespace System.Net.Mail
                             // Either TLS is already established or server does not support TLS
                             if (!(_connection._networkStream is TlsStream))
                             {
-                                throw new SmtpException(SR.Format(SR.MailServerDoesNotSupportStartTls));
+                                throw new SmtpException(SR.MailServerDoesNotSupportStartTls);
                             }
                         }
 
@@ -827,7 +827,7 @@ namespace System.Net.Mail
                     Authorization auth = _connection._authenticationModules[_currentModule].Authenticate(_authResponse, null, _connection, _connection._client.TargetName, _connection._channelBindingToken);
                     if (auth == null)
                     {
-                        throw new SmtpException(SR.Format(SR.SmtpAuthenticationFailed));
+                        throw new SmtpException(SR.SmtpAuthenticationFailed);
                     }
 
                     IAsyncResult result = AuthCommand.BeginSend(_connection, auth.Message, s_authenticateContinueCallback, this);
index e41f541..1eca3a8 100644 (file)
@@ -23,51 +23,51 @@ namespace System.Net.Mail
             {
                 default:
                 case SmtpStatusCode.CommandUnrecognized:
-                    return SR.Format(SR.SmtpCommandUnrecognized);
+                    return SR.SmtpCommandUnrecognized;
                 case SmtpStatusCode.SyntaxError:
-                    return SR.Format(SR.SmtpSyntaxError);
+                    return SR.SmtpSyntaxError;
                 case SmtpStatusCode.CommandNotImplemented:
-                    return SR.Format(SR.SmtpCommandNotImplemented);
+                    return SR.SmtpCommandNotImplemented;
                 case SmtpStatusCode.BadCommandSequence:
-                    return SR.Format(SR.SmtpBadCommandSequence);
+                    return SR.SmtpBadCommandSequence;
                 case SmtpStatusCode.CommandParameterNotImplemented:
-                    return SR.Format(SR.SmtpCommandParameterNotImplemented);
+                    return SR.SmtpCommandParameterNotImplemented;
                 case SmtpStatusCode.SystemStatus:
-                    return SR.Format(SR.SmtpSystemStatus);
+                    return SR.SmtpSystemStatus;
                 case SmtpStatusCode.HelpMessage:
-                    return SR.Format(SR.SmtpHelpMessage);
+                    return SR.SmtpHelpMessage;
                 case SmtpStatusCode.ServiceReady:
-                    return SR.Format(SR.SmtpServiceReady);
+                    return SR.SmtpServiceReady;
                 case SmtpStatusCode.ServiceClosingTransmissionChannel:
-                    return SR.Format(SR.SmtpServiceClosingTransmissionChannel);
+                    return SR.SmtpServiceClosingTransmissionChannel;
                 case SmtpStatusCode.ServiceNotAvailable:
-                    return SR.Format(SR.SmtpServiceNotAvailable);
+                    return SR.SmtpServiceNotAvailable;
                 case SmtpStatusCode.Ok:
-                    return SR.Format(SR.SmtpOK);
+                    return SR.SmtpOK;
                 case SmtpStatusCode.UserNotLocalWillForward:
-                    return SR.Format(SR.SmtpUserNotLocalWillForward);
+                    return SR.SmtpUserNotLocalWillForward;
                 case SmtpStatusCode.MailboxBusy:
-                    return SR.Format(SR.SmtpMailboxBusy);
+                    return SR.SmtpMailboxBusy;
                 case SmtpStatusCode.MailboxUnavailable:
-                    return SR.Format(SR.SmtpMailboxUnavailable);
+                    return SR.SmtpMailboxUnavailable;
                 case SmtpStatusCode.LocalErrorInProcessing:
-                    return SR.Format(SR.SmtpLocalErrorInProcessing);
+                    return SR.SmtpLocalErrorInProcessing;
                 case SmtpStatusCode.UserNotLocalTryAlternatePath:
-                    return SR.Format(SR.SmtpUserNotLocalTryAlternatePath);
+                    return SR.SmtpUserNotLocalTryAlternatePath;
                 case SmtpStatusCode.InsufficientStorage:
-                    return SR.Format(SR.SmtpInsufficientStorage);
+                    return SR.SmtpInsufficientStorage;
                 case SmtpStatusCode.ExceededStorageAllocation:
-                    return SR.Format(SR.SmtpExceededStorageAllocation);
+                    return SR.SmtpExceededStorageAllocation;
                 case SmtpStatusCode.MailboxNameNotAllowed:
-                    return SR.Format(SR.SmtpMailboxNameNotAllowed);
+                    return SR.SmtpMailboxNameNotAllowed;
                 case SmtpStatusCode.StartMailInput:
-                    return SR.Format(SR.SmtpStartMailInput);
+                    return SR.SmtpStartMailInput;
                 case SmtpStatusCode.TransactionFailed:
-                    return SR.Format(SR.SmtpTransactionFailed);
+                    return SR.SmtpTransactionFailed;
                 case SmtpStatusCode.ClientNotPermitted:
-                    return SR.Format(SR.SmtpClientNotPermitted);
+                    return SR.SmtpClientNotPermitted;
                 case SmtpStatusCode.MustIssueStartTlsFirst:
-                    return SR.Format(SR.SmtpMustIssueStartTlsFirst);
+                    return SR.SmtpMustIssueStartTlsFirst;
             }
         }
 
index 5de96a2..dc45970 100644 (file)
@@ -48,7 +48,7 @@ namespace System.Net.Mail
         }
 
         internal SmtpFailedRecipientsException(List<SmtpFailedRecipientException> innerExceptions, bool allFailed) :
-            base(allFailed ? SR.Format(SR.SmtpAllRecipientsFailed) : SR.Format(SR.SmtpRecipientFailed),
+            base(allFailed ? SR.SmtpAllRecipientsFailed : SR.SmtpRecipientFailed,
             innerExceptions != null && innerExceptions.Count > 0 ? innerExceptions[0].FailedRecipient : null,
             innerExceptions != null && innerExceptions.Count > 0 ? innerExceptions[0] : null)
         {
index 4166f54..ed54290 100644 (file)
@@ -142,7 +142,7 @@ namespace System.Net.Mime
 
             if (!MimeBasePart.IsAscii(name, false))
             {
-                throw new FormatException(SR.Format(SR.InvalidHeaderName));
+                throw new FormatException(SR.InvalidHeaderName);
             }
 
             // normalize the case of well known headers
index d7f7e99..9fe5da1 100644 (file)
@@ -181,7 +181,7 @@ namespace System.Net.Mime
 
         // outputs the RFC 2822 formatted date string including time zone
         public override string ToString() =>
-            string.Format("{0} {1}", FormatDate(_date), _unknownTimeZone ? UnknownTimeZoneDefaultOffset : TimeSpanToOffset(_timeZone));
+            FormatDate(_date) + " " + (_unknownTimeZone ? UnknownTimeZoneDefaultOffset : TimeSpanToOffset(_timeZone));
 
         // returns true if the offset is of the form [+|-]dddd and 
         // within the range 0000 to 9959
index 634663d..53d9508 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Net.NetworkInformation
         private PingReply SendPingCore(IPAddress address, byte[] buffer, int timeout, PingOptions options)
         {
             // Win32 Icmp* APIs fail with E_ACCESSDENIED when called from UWP due to Windows OS limitations.
-            throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
+            throw new PlatformNotSupportedException(SR.Format(CultureInfo.InvariantCulture,
                         SR.net_ping_not_supported_uwp));
         }
 
@@ -25,7 +25,7 @@ namespace System.Net.NetworkInformation
         private Task<PingReply> SendPingAsyncCore(IPAddress address, byte[] buffer, int timeout, PingOptions options)
         {
             // Win32 Icmp* APIs fail with E_ACCESSDENIED when called from UWP due to Windows OS limitations.
-            throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
+            throw new PlatformNotSupportedException(SR.Format(CultureInfo.InvariantCulture,
                         SR.net_ping_not_supported_uwp));
         }
     }
index 46382b1..0332d6c 100644 (file)
@@ -279,7 +279,7 @@ namespace System.Net
             {
                 if (throwOnError)
                 {
-                    throw new CookieException(SR.Format(SR.net_cookie_size, cookie.ToString(), m_maxCookieSize));
+                    throw new CookieException(SR.Format(SR.net_cookie_size, cookie, m_maxCookieSize));
                 }
                 return;
             }
index 2956534..0a615d6 100644 (file)
@@ -91,7 +91,7 @@ namespace System.Net
             {
                 Exception inner = exception.InnerException;
                 string message = inner != null ?
-                    string.Format("{0} {1}", exception.Message, inner.Message) :
+                    exception.Message + " " + inner.Message :
                     exception.Message;
 
                 return new WebException(
index 80bb59e..d262ed4 100644 (file)
@@ -92,7 +92,7 @@ namespace System.Net
                     }
                     else
                     {
-                        throw new IOException(SR.Format(SR.net_io_readfailure, SR.Format(SR.net_io_connectionclosed)));
+                        throw new IOException(SR.Format(SR.net_io_readfailure, SR.net_io_connectionclosed));
                     }
                 }
 
@@ -115,7 +115,7 @@ namespace System.Net
                 bytesRead = Transport.Read(buffer, offset, buffer.Length - offset);
                 if (bytesRead == 0)
                 {
-                    throw new IOException(SR.Format(SR.net_io_readfailure, SR.Format(SR.net_io_connectionclosed)));
+                    throw new IOException(SR.Format(SR.net_io_readfailure, SR.net_io_connectionclosed));
                 }
 
                 offset += bytesRead;
@@ -238,7 +238,7 @@ namespace System.Net
                         if (payloadSize < 0)
                         {
                             // Let's call user callback and he call us back and we will throw
-                            workerResult.InvokeCallback(new System.IO.IOException(SR.Format(SR.net_frame_read_size)));
+                            workerResult.InvokeCallback(new System.IO.IOException(SR.net_frame_read_size));
                         }
 
                         if (payloadSize == 0)
index c10b29a..49463a3 100644 (file)
@@ -1992,7 +1992,7 @@ namespace System.Net.Sockets
         {
             if (level == IPProtectionLevel.Unspecified)
             {
-                throw new ArgumentException(SR.Format(SR.net_sockets_invalid_optionValue_all), nameof(level));
+                throw new ArgumentException(SR.net_sockets_invalid_optionValue_all, nameof(level));
             }
 
             if (_addressFamily == AddressFamily.InterNetworkV6)
@@ -2041,15 +2041,15 @@ namespace System.Net.Sockets
             const int MaxSelect = 65536;
             if (checkRead != null && checkRead.Count > MaxSelect)
             {
-                throw new ArgumentOutOfRangeException(nameof(checkRead), SR.Format(SR.net_sockets_toolarge_select, nameof(checkRead), MaxSelect.ToString(NumberFormatInfo.CurrentInfo)));
+                throw new ArgumentOutOfRangeException(nameof(checkRead), SR.Format(SR.net_sockets_toolarge_select, nameof(checkRead), MaxSelect.ToString()));
             }
             if (checkWrite != null && checkWrite.Count > MaxSelect)
             {
-                throw new ArgumentOutOfRangeException(nameof(checkWrite), SR.Format(SR.net_sockets_toolarge_select, nameof(checkWrite), MaxSelect.ToString(NumberFormatInfo.CurrentInfo)));
+                throw new ArgumentOutOfRangeException(nameof(checkWrite), SR.Format(SR.net_sockets_toolarge_select, nameof(checkWrite), MaxSelect.ToString()));
             }
             if (checkError != null && checkError.Count > MaxSelect)
             {
-                throw new ArgumentOutOfRangeException(nameof(checkError), SR.Format(SR.net_sockets_toolarge_select, nameof(checkError), MaxSelect.ToString(NumberFormatInfo.CurrentInfo)));
+                throw new ArgumentOutOfRangeException(nameof(checkError), SR.Format(SR.net_sockets_toolarge_select, nameof(checkError), MaxSelect.ToString()));
             }
 
             SocketError errorCode = SocketPal.Select(checkRead, checkWrite, checkError, microSeconds);
index 244629e..8ebb1ad 100644 (file)
@@ -146,7 +146,7 @@ namespace System.Net
             {
                 if (value != null && value.Length > ushort.MaxValue)
                 {
-                    throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture,SR.net_headers_toolong, ushort.MaxValue));
+                    throw new ArgumentOutOfRangeException(nameof(value), value, SR.Format(CultureInfo.InvariantCulture,SR.net_headers_toolong, ushort.MaxValue));
                 }
             }
             InvalidateCachedArrays();
@@ -172,7 +172,7 @@ namespace System.Net
             {
                 if (value != null && value.Length > ushort.MaxValue)
                 {
-                    throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
+                    throw new ArgumentOutOfRangeException(nameof(value), value, SR.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
                 }
             }
             this.Set(header.GetName(), value);
@@ -345,7 +345,7 @@ namespace System.Net
             {
                 if (value != null && value.Length > ushort.MaxValue)
                 {
-                    throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
+                    throw new ArgumentOutOfRangeException(nameof(value), value, SR.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
                 }
             }
             this.Add(header.GetName(), value);
@@ -373,7 +373,7 @@ namespace System.Net
             {
                 if (value != null && value.Length > ushort.MaxValue)
                 {
-                    throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
+                    throw new ArgumentOutOfRangeException(nameof(value), value, SR.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
                 }
             }
             InvalidateCachedArrays();
@@ -399,7 +399,7 @@ namespace System.Net
             {
                 if (value != null && value.Length > ushort.MaxValue)
                 {
-                    throw new ArgumentOutOfRangeException(nameof(value), value,string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
+                    throw new ArgumentOutOfRangeException(nameof(value), value,SR.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
                 }
             }
             InvalidateCachedArrays();
@@ -415,7 +415,7 @@ namespace System.Net
             {
                 if (headerValue != null && headerValue.Length > ushort.MaxValue)
                 {
-                    throw new ArgumentOutOfRangeException(nameof(headerValue), headerValue, string.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
+                    throw new ArgumentOutOfRangeException(nameof(headerValue), headerValue, SR.Format(CultureInfo.InvariantCulture, SR.net_headers_toolong, ushort.MaxValue));
                 }
             }
             InvalidateCachedArrays();
@@ -428,14 +428,14 @@ namespace System.Net
             {
                 if (HeaderInfo[headerName].IsRequestRestricted)
                 {
-                    throw new ArgumentException(string.Format(SR.net_headerrestrict, headerName), nameof(headerName));
+                    throw new ArgumentException(SR.Format(SR.net_headerrestrict, headerName), nameof(headerName));
                 }
             }
             else if (_type == WebHeaderCollectionType.HttpListenerResponse)
             {
                 if (HeaderInfo[headerName].IsResponseRestricted)
                 {
-                    throw new ArgumentException(string.Format(SR.net_headerrestrict, headerName), nameof(headerName));
+                    throw new ArgumentException(SR.Format(SR.net_headerrestrict, headerName), nameof(headerName));
                 }
             }
         }
index 0abb88d..a104cc4 100644 (file)
@@ -124,7 +124,7 @@ namespace System.Net.WebSockets
             {
                 if (!MessageWebSocketClientCertificateSupported)
                 {
-                    throw new PlatformNotSupportedException(string.Format(CultureInfo.InvariantCulture,
+                    throw new PlatformNotSupportedException(SR.Format(CultureInfo.InvariantCulture,
                         SR.net_WebSockets_UWPClientCertSupportRequiresWindows10GreaterThan1703));
                 }
 
@@ -134,7 +134,7 @@ namespace System.Net.WebSockets
                     RTCertificate winRtClientCert = await CertificateHelper.ConvertDotNetClientCertToWinRtClientCertAsync(dotNetClientCert).ConfigureAwait(false);
                     if (winRtClientCert == null)
                     {
-                        throw new PlatformNotSupportedException(string.Format(
+                        throw new PlatformNotSupportedException(SR.Format(
                                     CultureInfo.InvariantCulture,
                                     SR.net_WebSockets_UWPClientCertSupportRequiresCertInPersonalCertificateStore));
                     }
index 74327b8..effd344 100644 (file)
@@ -787,11 +787,10 @@ namespace System.Numerics
         /// <returns>The string representation.</returns>
         public override string ToString()
         {
-            CultureInfo ci = CultureInfo.CurrentCulture;
-            return string.Format(ci, "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} }}",
-                                 M11.ToString(ci), M12.ToString(ci),
-                                 M21.ToString(ci), M22.ToString(ci),
-                                 M31.ToString(ci), M32.ToString(ci));
+            return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} }}",
+                                 M11, M12,
+                                 M21, M22,
+                                 M31, M32);
         }
 
         /// <summary>
index e943e04..3479339 100644 (file)
@@ -2194,13 +2194,11 @@ namespace System.Numerics
         /// <returns>The string representation.</returns>
         public override string ToString()
         {
-            CultureInfo ci = CultureInfo.CurrentCulture;
-
-            return string.Format(ci, "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} }}",
-                                 M11.ToString(ci), M12.ToString(ci), M13.ToString(ci), M14.ToString(ci),
-                                 M21.ToString(ci), M22.ToString(ci), M23.ToString(ci), M24.ToString(ci),
-                                 M31.ToString(ci), M32.ToString(ci), M33.ToString(ci), M34.ToString(ci),
-                                 M41.ToString(ci), M42.ToString(ci), M43.ToString(ci), M44.ToString(ci));
+            return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} }}",
+                                 M11, M12, M13, M14,
+                                 M21, M22, M23, M24,
+                                 M31, M32, M33, M34,
+                                 M41, M42, M43, M44);
         }
 
         /// <summary>
index c43efae..74c3116 100644 (file)
@@ -777,9 +777,7 @@ namespace System.Numerics
         /// <returns>The string representation.</returns>
         public override string ToString()
         {
-            CultureInfo ci = CultureInfo.CurrentCulture;
-
-            return string.Format(ci, "{{X:{0} Y:{1} Z:{2} W:{3}}}", X.ToString(ci), Y.ToString(ci), Z.ToString(ci), W.ToString(ci));
+            return string.Format(CultureInfo.CurrentCulture, "{{X:{0} Y:{1} Z:{2} W:{3}}}", X, Y, Z, W);
         }
 
         /// <summary>
index 4784a19..55140aa 100644 (file)
@@ -946,7 +946,7 @@ namespace System.Runtime.Serialization
                         break;
                     case TypeCode.Char:
                         DiagnosticUtility.DebugAssert("Char is not a valid schema primitive and should be treated as int in DataContract");
-                        throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.CharIsInvalidPrimitive)));
+                        throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.CharIsInvalidPrimitive));
                     case TypeCode.SByte:
                     case TypeCode.Byte:
                     case TypeCode.Int16:
index 9cff5a6..e57c73c 100644 (file)
@@ -615,7 +615,7 @@ namespace System.Runtime.Serialization
                 if (type == Globals.TypeOfArray)
                     type = Globals.TypeOfObjectArray;
                 if (type.GetArrayRank() > 1)
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SupportForMultidimensionalArraysNotPresent)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.SupportForMultidimensionalArraysNotPresent));
                 this.StableName = DataContract.GetStableName(type);
                 Init(CollectionKind.Array, type.GetElementType(), null);
             }
@@ -1524,7 +1524,7 @@ namespace System.Runtime.Serialization
 #if uapaot
                 if (XmlFormatGetOnlyCollectionReaderDelegate == null)
                 {
-                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, UnderlyingType.ToString()));
+                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, UnderlyingType));
                 }
 #endif
                 XmlFormatGetOnlyCollectionReaderDelegate(xmlReader, context, CollectionItemName, Namespace, this);
index f0997cf..b1c2806 100644 (file)
@@ -79,7 +79,7 @@ namespace System.Runtime.Serialization
                 {
                     if (DataContractSerializer.Option == SerializationOption.CodeGenOnly)
                     {
-                        throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, type.ToString()));
+                        throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, type));
                     }
                 }
             }
@@ -497,7 +497,7 @@ namespace System.Runtime.Serialization
                 DataContract dataContract = s_dataContractCache[id];
                 if (dataContract == null)
                 {
-                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.Format(SR.DataContractCacheOverflow)));
+                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.DataContractCacheOverflow));
                 }
                 return dataContract;
             }
@@ -517,7 +517,7 @@ namespace System.Runtime.Serialization
                         return i;
                     }
                 }
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.Format(SR.DataContractCacheOverflow)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.DataContractCacheOverflow));
             }
 
             private static bool ContractMatches(DataContract contract, DataContract cachedContract)
@@ -541,7 +541,7 @@ namespace System.Runtime.Serialization
                             if (newSize <= value)
                             {
                                 DiagnosticUtility.DebugAssert("DataContract cache overflow");
-                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.Format(SR.DataContractCacheOverflow)));
+                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.DataContractCacheOverflow));
                             }
                             Array.Resize<DataContract>(ref s_dataContractCache, newSize);
                         }
@@ -1202,7 +1202,7 @@ namespace System.Runtime.Serialization
             internal virtual bool IsISerializable
             {
                 get { return false; }
-                set { ThrowInvalidDataContractException(SR.Format(SR.RequiresClassDataContractToSetIsISerializable)); }
+                set { ThrowInvalidDataContractException(SR.RequiresClassDataContractToSetIsISerializable); }
             }
 
             internal XmlDictionaryString Name
@@ -1809,7 +1809,7 @@ namespace System.Runtime.Serialization
 
         internal static string GetClrTypeFullName(Type type)
         {
-            return !type.IsGenericTypeDefinition && type.ContainsGenericParameters ? string.Format(CultureInfo.InvariantCulture, "{0}.{1}", type.Namespace, type.Name) : type.FullName;
+            return !type.IsGenericTypeDefinition && type.ContainsGenericParameters ? type.Namespace + "." + type.Name : type.FullName;
         }
 
         internal static void GetClrNameAndNamespace(string fullTypeName, out string localName, out string ns)
index 05a472e..010d1ea 100644 (file)
@@ -134,7 +134,7 @@ namespace System.Runtime.Serialization
             }
 
             if (maxItemsInObjectGraph < 0)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(maxItemsInObjectGraph), SR.Format(SR.ValueMustBeNonNegative)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(maxItemsInObjectGraph), SR.ValueMustBeNonNegative));
             _maxItemsInObjectGraph = maxItemsInObjectGraph;
 
             _ignoreExtensionDataObject = ignoreExtensionDataObject;
index ebc65e7..d46d2f8 100644 (file)
@@ -34,7 +34,7 @@ namespace System.Runtime.Serialization
             set
             {
                 if (value < 0)
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.OrderCannotBeNegative)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(SR.OrderCannotBeNegative));
                 _order = value;
             }
         }
index 3e87521..62d8d59 100644 (file)
@@ -198,7 +198,7 @@ namespace System.Runtime.Serialization
         internal void AddQualifiedNameAttribute(ElementData element, string elementPrefix, string elementName, string elementNs, string valueName, string valueNs)
         {
             string prefix = ExtensionDataReader.GetPrefix(valueNs);
-            element.AddAttribute(elementPrefix, elementNs, elementName, string.Format(CultureInfo.InvariantCulture, "{0}:{1}", prefix, valueName));
+            element.AddAttribute(elementPrefix, elementNs, elementName, prefix + ":" + valueName);
 
             bool prefixDeclaredOnElement = false;
             if (element.attributes != null)
index 26dfba5..037884c 100644 (file)
@@ -50,7 +50,7 @@ namespace System.Runtime.Serialization.Json
                                 tempDelegate = tempDelegate ?? CreateJsonFormatReaderDelegate();
 
                                 if (tempDelegate == null)
-                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalClassDataContract.UnderlyingType.ToString()));
+                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalClassDataContract.UnderlyingType));
                             }
 #endif
                             else
@@ -101,7 +101,7 @@ namespace System.Runtime.Serialization.Json
                                 tempDelegate = tempDelegate ?? CreateJsonFormatWriterDelegate();
 
                                 if (tempDelegate == null)
-                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalClassDataContract.UnderlyingType.ToString()));
+                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalClassDataContract.UnderlyingType));
                             }
 #endif
                             else 
index fab9b46..4724879 100644 (file)
@@ -49,7 +49,7 @@ namespace System.Runtime.Serialization.Json
                                 tempDelegate = tempDelegate ?? CreateJsonFormatReaderDelegate();
 
                                 if (tempDelegate == null)
-                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalCollectionDataContract.UnderlyingType.ToString()));
+                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalCollectionDataContract.UnderlyingType));
                             }
 #endif
                             else 
@@ -106,7 +106,7 @@ namespace System.Runtime.Serialization.Json
                                 tempDelegate = tempDelegate ?? CreateJsonFormatGetOnlyReaderDelegate();
 
                                 if (tempDelegate == null)
-                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalCollectionDataContract.UnderlyingType.ToString()));
+                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalCollectionDataContract.UnderlyingType));
                             }
 #endif
                             else
@@ -158,7 +158,7 @@ namespace System.Runtime.Serialization.Json
                                 tempDelegate = tempDelegate ?? CreateJsonFormatWriterDelegate();
 
                                 if (tempDelegate == null)
-                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalCollectionDataContract.UnderlyingType.ToString()));
+                                    throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, TraditionalCollectionDataContract.UnderlyingType));
                             }
 #endif
                             else
index 8e738f7..2e232c8 100644 (file)
@@ -55,7 +55,7 @@ namespace System.Runtime.Serialization.Json
             JsonReadWriteDelegates result = GetGeneratedReadWriteDelegates(c);
             if (result == null)
             {
-                throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, c.UnderlyingType.ToString()));
+                throw new InvalidDataContractException(SR.Format(SR.SerializationCodeIsMissingForType, c.UnderlyingType));
             }
             else
             {
index 317cd04..efbd743 100644 (file)
@@ -90,7 +90,7 @@ namespace System.Runtime.Serialization
             }
             // m_obj must ALWAYS have at least one slot empty (null).
             DiagnosticUtility.DebugAssert("Object table overflow");
-            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.ObjectTableOverflow)));
+            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.ObjectTableOverflow));
         }
 
         private void RemoveAt(int position)
@@ -129,7 +129,7 @@ namespace System.Runtime.Serialization
             }
             // m_obj must ALWAYS have at least one slot empty (null).
             DiagnosticUtility.DebugAssert("Object table overflow");
-            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.ObjectTableOverflow)));
+            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.ObjectTableOverflow));
         }
 
         private int ComputeStartPosition(object o)
@@ -180,4 +180,4 @@ namespace System.Runtime.Serialization
             // 0X7FEFFFFF is not prime, but it is the largest possible array size. There's nowhere to go from here.
         };
     }
-}
\ No newline at end of file
+}
index 6d54b43..577a1d6 100644 (file)
@@ -63,7 +63,7 @@ namespace System.Runtime.Serialization
             {
                 return ProcessClassDataContract((ClassDataContract)contract, context, memberNode);
             }
-            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.QueryGeneratorPathToMemberNotFound)));
+            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.QueryGeneratorPathToMemberNotFound));
         }
 
         static DataContract ProcessClassDataContract(ClassDataContract contract, ExportContext context, MemberInfo memberNode)
@@ -77,7 +77,7 @@ namespace System.Runtime.Serialization
                     return member.MemberTypeContract;
                 }
             }
-            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.QueryGeneratorPathToMemberNotFound)));
+            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.QueryGeneratorPathToMemberNotFound));
         }
 
         static IEnumerable<DataMember> GetDataMembers(ClassDataContract contract)
@@ -150,4 +150,4 @@ namespace System.Runtime.Serialization
             }
         }
     }
-}
\ No newline at end of file
+}
index b990d2a..09a521d 100644 (file)
@@ -510,7 +510,7 @@ namespace System.Runtime.Serialization
 #endif
         {
             if (!xmlReader.Read())
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.UnexpectedEndOfFile)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.UnexpectedEndOfFile));
         }
 
         internal static void ParseQualifiedName(string qname, XmlReaderDelegator xmlReader, out string name, out string ns, out string prefix)
@@ -984,7 +984,7 @@ namespace System.Runtime.Serialization
             while ((nodeType = xmlReader.MoveToContent()) != XmlNodeType.EndElement)
             {
                 if (xmlReader.EOF)
-                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.UnexpectedEndOfFile)));
+                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.UnexpectedEndOfFile));
 
                 if (xmlChildNodes == null)
                     xmlChildNodes = new List<XmlNode>();
@@ -1041,7 +1041,7 @@ namespace System.Runtime.Serialization
                     }
                 }
                 else if (xmlReader.EOF)
-                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.UnexpectedEndOfFile)));
+                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.UnexpectedEndOfFile));
                 else if (IsContentNode(xmlReader.NodeType))
                     couldBeClassData = couldBeISerializableData = couldBeCollectionData = false;
 
index 8f51f6f..3d780f0 100644 (file)
@@ -247,12 +247,12 @@ namespace System.Runtime.Serialization
             if (isNew)
             {
                 xmlWriter.WriteAttributeString(Globals.SerPrefix, DictionaryGlobals.IdLocalName,
-                                            DictionaryGlobals.SerializationNamespace, string.Format(CultureInfo.InvariantCulture, "{0}{1}", "i", objectId));
+                                            DictionaryGlobals.SerializationNamespace, string.Format(CultureInfo.InvariantCulture, "i{0}", objectId));
                 return false;
             }
             else
             {
-                xmlWriter.WriteAttributeString(Globals.SerPrefix, DictionaryGlobals.RefLocalName, DictionaryGlobals.SerializationNamespace, string.Format(CultureInfo.InvariantCulture, "{0}{1}", "i", objectId));
+                xmlWriter.WriteAttributeString(Globals.SerPrefix, DictionaryGlobals.RefLocalName, DictionaryGlobals.SerializationNamespace, string.Format(CultureInfo.InvariantCulture, "i{0}", objectId));
                 return true;
             }
         }
index c94de88..8207096 100644 (file)
@@ -55,7 +55,7 @@ namespace System.Runtime.Serialization
         internal string GetAttribute(int i)
         {
             if (isEndOfEmptyElement)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(i), SR.Format(SR.XmlElementAttributes)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(i), SR.XmlElementAttributes));
             return reader.GetAttribute(i);
         }
 
@@ -155,7 +155,7 @@ namespace System.Runtime.Serialization
         internal void MoveToAttribute(int i)
         {
             if (isEndOfEmptyElement)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(i), SR.Format(SR.XmlElementAttributes)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(i), SR.XmlElementAttributes));
             reader.MoveToAttribute(i);
         }
 
index bdb6070..cbcf3aa 100644 (file)
@@ -65,7 +65,7 @@ namespace System.Runtime.Serialization
 
         public override void Close()
         {
-            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.IXmlSerializableIllegalOperation)));
+            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.IXmlSerializableIllegalOperation));
         }
 
         public override XmlReaderSettings Settings { get { return InnerReader.Settings; } }
index 56538d6..e770d97 100644 (file)
@@ -68,7 +68,7 @@ namespace System.Runtime.Serialization
 
         public override void Close()
         {
-            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.Format(SR.IXmlSerializableIllegalOperation)));
+            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.IXmlSerializableIllegalOperation));
         }
 
         public override void WriteStartAttribute(string prefix, string localName, string ns)
index eaad7ea..ce82452 100644 (file)
@@ -250,7 +250,7 @@ namespace System.Runtime.Serialization
                     {
                         Type type = knownTypes[i];
                         if (type == null)
-                            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.CannotExportNullKnownType)));
+                            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.CannotExportNullKnownType));
                         AddType(type);
                     }
                 }
@@ -434,4 +434,4 @@ namespace System.Runtime.Serialization
 
     }
 
-}
\ No newline at end of file
+}
index 9fd942b..e543fcf 100644 (file)
@@ -36,9 +36,9 @@ namespace System.Text
         public override int GetMaxByteCount(int charCount)
         {
             if (charCount < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.ValueMustBeNonNegative));
             if ((charCount % 4) != 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBase64Length, charCount.ToString(NumberFormatInfo.CurrentInfo))));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBase64Length, charCount.ToString())));
             return charCount / 4 * 3;
         }
 
@@ -59,18 +59,18 @@ namespace System.Text
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (index < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.ValueMustBeNonNegative));
             if (index > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > chars.Length - index)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - index)));
 
             if (count == 0)
                 return 0;
             if ((count % 4) != 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBase64Length, count.ToString(NumberFormatInfo.CurrentInfo))));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBase64Length, count.ToString())));
             fixed (byte* _char2val = &s_char2val[0])
             {
                 fixed (char* _chars = &chars[index])
@@ -114,26 +114,26 @@ namespace System.Text
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
 
             if (charIndex < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.ValueMustBeNonNegative));
             if (charIndex > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
 
             if (charCount < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.ValueMustBeNonNegative));
             if (charCount > chars.Length - charIndex)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - charIndex)));
 
             if (bytes == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(bytes)));
             if (byteIndex < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.ValueMustBeNonNegative));
             if (byteIndex > bytes.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.OffsetExceedsBufferSize, bytes.Length)));
 
             if (charCount == 0)
                 return 0;
             if ((charCount % 4) != 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBase64Length, charCount.ToString(NumberFormatInfo.CurrentInfo))));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBase64Length, charCount.ToString())));
             fixed (byte* _char2val = &s_char2val[0])
             {
                 fixed (char* _chars = &chars[charIndex])
@@ -167,7 +167,7 @@ namespace System.Text
 
                             int byteCount = (v4 != 64 ? 3 : (v3 != 64 ? 2 : 1));
                             if (pb + byteCount > pbMax)
-                                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlArrayTooSmall), nameof(bytes)));
+                                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlArrayTooSmall, nameof(bytes)));
 
                             pb[0] = (byte)((v1 << 2) | ((v2 >> 4) & 0x03));
                             if (byteCount > 1)
@@ -192,26 +192,26 @@ namespace System.Text
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (charIndex < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.ValueMustBeNonNegative));
             if (charIndex > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
 
             if (charCount < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.ValueMustBeNonNegative));
             if (charCount > chars.Length - charIndex)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charCount), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - charIndex)));
 
             if (bytes == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(bytes)));
             if (byteIndex < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.ValueMustBeNonNegative));
             if (byteIndex > bytes.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.OffsetExceedsBufferSize, bytes.Length)));
 
             if (charCount == 0)
                 return 0;
             if ((charCount % 4) != 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBase64Length, charCount.ToString(NumberFormatInfo.CurrentInfo))));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidBase64Length, charCount.ToString())));
             fixed (byte* _char2val = &s_char2val[0])
             {
                 fixed (byte* _chars = &chars[charIndex])
@@ -244,7 +244,7 @@ namespace System.Text
 
                             int byteCount = (v4 != 64 ? 3 : (v3 != 64 ? 2 : 1));
                             if (pb + byteCount > pbMax)
-                                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlArrayTooSmall), nameof(bytes)));
+                                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlArrayTooSmall, nameof(bytes)));
 
                             pb[0] = (byte)((v1 << 2) | ((v2 >> 4) & 0x03));
                             if (byteCount > 1)
@@ -280,11 +280,11 @@ namespace System.Text
             if (bytes == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(bytes)));
             if (byteIndex < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.ValueMustBeNonNegative));
             if (byteIndex > bytes.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.OffsetExceedsBufferSize, bytes.Length)));
             if (byteCount < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.ValueMustBeNonNegative));
             if (byteCount > bytes.Length - byteIndex)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.Format(SR.SizeExceedsRemainingBufferSpace, bytes.Length - byteIndex)));
 
@@ -292,11 +292,11 @@ namespace System.Text
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (charIndex < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.ValueMustBeNonNegative));
             if (charIndex > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
             if (charCount < 0 || charCount > chars.Length - charIndex)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlArrayTooSmall), nameof(chars)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlArrayTooSmall, nameof(chars)));
 
             // We've computed exactly how many chars there are and verified that
             // there's enough space in the char buffer, so we can proceed without
@@ -369,11 +369,11 @@ namespace System.Text
             if (bytes == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(bytes)));
             if (byteIndex < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.ValueMustBeNonNegative));
             if (byteIndex > bytes.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.OffsetExceedsBufferSize, bytes.Length)));
             if (byteCount < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.ValueMustBeNonNegative));
             if (byteCount > bytes.Length - byteIndex)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(byteCount), SR.Format(SR.SizeExceedsRemainingBufferSpace, bytes.Length - byteIndex)));
 
@@ -381,12 +381,12 @@ namespace System.Text
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (charIndex < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.ValueMustBeNonNegative));
             if (charIndex > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
 
             if (charCount < 0 || charCount > chars.Length - charIndex)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlArrayTooSmall), nameof(chars)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlArrayTooSmall, nameof(chars)));
 
             // We've computed exactly how many chars there are and verified that
             // there's enough space in the char buffer, so we can proceed without
index d0dc669..6cd16af 100644 (file)
@@ -36,7 +36,7 @@ namespace System.Text
             if (charCount < 0)
                 throw new ArgumentOutOfRangeException(nameof(charCount), SR.ValueMustBeNonNegative);
             if ((charCount % 2) != 0)
-                throw new FormatException(SR.Format(SR.XmlInvalidBinHexLength, charCount.ToString(NumberFormatInfo.CurrentInfo)));
+                throw new FormatException(SR.Format(SR.XmlInvalidBinHexLength, charCount.ToString()));
             return charCount / 2;
         }
 
@@ -161,4 +161,4 @@ namespace System.Text
             return charCount;
         }
     }
-}
\ No newline at end of file
+}
index 0d59584..2fd2e80 100644 (file)
@@ -68,7 +68,7 @@ namespace System.Xml
             if (guid == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(guid)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > guid.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, guid.Length)));
             if (guidLength > guid.Length - offset)
@@ -85,7 +85,7 @@ namespace System.Xml
             if (value == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
             if (value.Length == 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidUniqueId)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.XmlInvalidUniqueId));
             fixed (char* pch = value)
             {
                 UnsafeParse(pch, value.Length);
@@ -98,15 +98,15 @@ namespace System.Xml
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > chars.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - offset)));
             if (count == 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.Format(SR.XmlInvalidUniqueId)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.XmlInvalidUniqueId));
             fixed (char* pch = &chars[offset])
             {
                 UnsafeParse(pch, count);
@@ -207,7 +207,7 @@ namespace System.Xml
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
 
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
 
@@ -289,7 +289,7 @@ namespace System.Xml
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(buffer)));
 
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > buffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length)));
 
@@ -393,4 +393,4 @@ namespace System.Xml
             pb[3] = (byte)value;
         }
     }
-}
\ No newline at end of file
+}
index 822c665..bb9e1e9 100644 (file)
@@ -151,14 +151,14 @@ namespace System.Xml
         protected XmlDeclarationNode MoveToDeclaration()
         {
             if (_attributeCount < 1)
-                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlDeclMissingVersion)));
+                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlDeclMissingVersion));
 
             if (_attributeCount > 3)
-                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlMalformedDecl)));
+                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlMalformedDecl));
 
             // version
             if (!CheckDeclAttribute(0, "version", "1.0", false, SR.XmlInvalidVersion))
-                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlDeclMissingVersion)));
+                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlDeclMissingVersion));
 
             // encoding/standalone
             // We only validate that they are the only attributes that exist.  Encoding can have any value.
@@ -167,11 +167,11 @@ namespace System.Xml
                 if (CheckDeclAttribute(1, "encoding", null, true, SR.XmlInvalidEncoding_UTF8))
                 {
                     if (_attributeCount == 3 && !CheckStandalone(2))
-                        XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlMalformedDecl)));
+                        XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlMalformedDecl));
                 }
                 else if (!CheckStandalone(1) || _attributeCount > 2)
                 {
-                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlMalformedDecl)));
+                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlMalformedDecl));
                 }
             }
 
@@ -187,13 +187,13 @@ namespace System.Xml
         {
             XmlAttributeNode node = _attributeNodes[attr];
             if (!node.Prefix.IsEmpty)
-                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlMalformedDecl)));
+                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlMalformedDecl));
 
             if (node.LocalName != "standalone")
                 return false;
 
             if (!node.Value.Equals2("yes", false) && !node.Value.Equals2("no", false))
-                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlInvalidStandalone)));
+                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlInvalidStandalone));
 
             return true;
         }
@@ -202,7 +202,7 @@ namespace System.Xml
         {
             XmlAttributeNode node = _attributeNodes[index];
             if (!node.Prefix.IsEmpty)
-                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlMalformedDecl)));
+                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlMalformedDecl));
 
             if (node.LocalName != localName)
                 return false;
@@ -535,9 +535,9 @@ namespace System.Xml
         private XmlAttributeNode GetAttributeNode(int index)
         {
             if (!_node.CanGetAttribute)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.Format(SR.XmlElementAttributes)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.XmlElementAttributes));
             if (index < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.ValueMustBeNonNegative));
             if (index >= _attributeCount)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(index), SR.Format(SR.OffsetExceedsBufferSize, _attributeCount)));
             return _attributeNodes[index];
@@ -1159,11 +1159,11 @@ namespace System.Xml
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > chars.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - offset)));
             int actual;
@@ -1189,11 +1189,11 @@ namespace System.Xml
             if (buffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(buffer)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > buffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > buffer.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
             if (count == 0)
@@ -1256,7 +1256,7 @@ namespace System.Xml
             {
                 int nodeDepth = _node.NodeType == XmlNodeType.Element ? _depth - 1 : _depth;
                 if (nodeDepth == 0)
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlEndElementNoOpenNodes)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlEndElementNoOpenNodes));
                 // If depth is non-zero, then the document isn't what was expected
                 XmlElementNode elementNode = _elementNodes[nodeDepth];
                 XmlExceptionHelper.ThrowEndElementExpected(this, elementNode.LocalName.GetString(), elementNode.Namespace.Uri.GetString());
@@ -1349,11 +1349,11 @@ namespace System.Xml
             if (buffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(buffer)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > buffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > buffer.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
             if (count == 0)
@@ -1387,11 +1387,11 @@ namespace System.Xml
             if (buffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(buffer)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > buffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > buffer.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
             if (count == 0)
@@ -1731,7 +1731,7 @@ namespace System.Xml
 
         public override void ResolveEntity()
         {
-            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidOperation)));
+            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlInvalidOperation));
         }
 
         public override void Skip()
@@ -2030,7 +2030,7 @@ namespace System.Xml
         public override void StartCanonicalization(Stream stream, bool includeComments, string[] inclusivePrefixes)
         {
             if (_signing)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlCanonicalizationStarted)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlCanonicalizationStarted));
 
             if (_signingWriter == null)
                 _signingWriter = CreateSigningNodeWriter();
@@ -2043,7 +2043,7 @@ namespace System.Xml
         public override void EndCanonicalization()
         {
             if (!_signing)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlCanonicalizationNotStarted)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlCanonicalizationNotStarted));
 
             _signingWriter.Flush();
             _signingWriter.Close();
index e80d9b7..65f9c53 100644 (file)
@@ -111,7 +111,7 @@ namespace System.Xml
 
         protected void ThrowClosed()
         {
-            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlWriterClosed)));
+            throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlWriterClosed));
         }
 
         private static BinHexEncoding BinHexEncoding
@@ -267,7 +267,7 @@ namespace System.Xml
             {
                 // An empty namespace means no namespace; prefix must be empty
                 if (prefix.Length != 0)
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlEmptyNamespaceRequiresNullPrefix), nameof(prefix)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlEmptyNamespaceRequiresNullPrefix, nameof(prefix)));
             }
             else if (prefix.Length == 0)
             {
@@ -448,7 +448,7 @@ namespace System.Xml
             }
             else if (text.IndexOf("--", StringComparison.Ordinal) != -1 || (text.Length > 0 && text[text.Length - 1] == '-'))
             {
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlInvalidCommentChars), nameof(text)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlInvalidCommentChars, nameof(text)));
             }
 
             StartComment();
@@ -503,11 +503,11 @@ namespace System.Xml
                 ThrowClosed();
 
             if (_documentState == DocumentState.Epilog)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlOnlyOneRoot)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlOnlyOneRoot));
             if (localName == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(localName)));
             if (localName.Length == 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.InvalidLocalNameEmpty), nameof(localName)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.InvalidLocalNameEmpty, nameof(localName)));
             if (_writeState == WriteState.Attribute)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidWriteState, "WriteStartElement", WriteState.ToString())));
 
@@ -548,11 +548,11 @@ namespace System.Xml
                 ThrowClosed();
 
             if (_documentState == DocumentState.Epilog)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlOnlyOneRoot)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlOnlyOneRoot));
             if (localName == null)
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(localName)));
             if (localName.Length == 0)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.InvalidLocalNameEmpty), nameof(localName)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.InvalidLocalNameEmpty, nameof(localName)));
             if (_writeState == WriteState.Attribute)
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidWriteState, "WriteStartElement", WriteState.ToString())));
         }
@@ -733,14 +733,14 @@ namespace System.Xml
         {
             FlushElement();
             if (_depth == 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlIllegalOutsideRoot)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlIllegalOutsideRoot));
         }
 
         protected async Task StartContentAsync()
         {
             await FlushElementAsync().ConfigureAwait(false);
             if (_depth == 0)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlIllegalOutsideRoot)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlIllegalOutsideRoot));
         }
 
         protected void StartContent(char ch)
@@ -767,21 +767,21 @@ namespace System.Xml
         private void VerifyWhitespace(char ch)
         {
             if (!IsWhitespace(ch))
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlIllegalOutsideRoot)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlIllegalOutsideRoot));
         }
 
         private void VerifyWhitespace(string s)
         {
             for (int i = 0; i < s.Length; i++)
                 if (!IsWhitespace(s[i]))
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlIllegalOutsideRoot)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlIllegalOutsideRoot));
         }
 
         private void VerifyWhitespace(char[] chars, int offset, int count)
         {
             for (int i = 0; i < count; i++)
                 if (!IsWhitespace(chars[offset + i]))
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlIllegalOutsideRoot)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlIllegalOutsideRoot));
         }
 
         private bool IsWhitespace(char ch)
@@ -854,7 +854,7 @@ namespace System.Xml
             if (localName == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(localName)));
             if (localName.Length == 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.InvalidLocalNameEmpty), nameof(localName)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.InvalidLocalNameEmpty, nameof(localName)));
             if (namespaceUri == null)
                 namespaceUri = string.Empty;
             string prefix = GetQualifiedNamePrefix(namespaceUri, null);
@@ -873,7 +873,7 @@ namespace System.Xml
             if (localName == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(localName)));
             if (localName.Value.Length == 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.InvalidLocalNameEmpty), nameof(localName)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.InvalidLocalNameEmpty, nameof(localName)));
             if (namespaceUri == null)
                 namespaceUri = XmlDictionaryString.Empty;
             string prefix = GetQualifiedNamePrefix(namespaceUri.Value, namespaceUri);
@@ -918,10 +918,10 @@ namespace System.Xml
                 ThrowClosed();
 
             if (name != "xml")
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlProcessingInstructionNotSupported), nameof(name)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlProcessingInstructionNotSupported, nameof(name)));
 
             if (_writeState != WriteState.Start)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidDeclaration)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlInvalidDeclaration));
 
             // The only thing the text can legitimately contain is version, encoding, and standalone.
             // We only support version 1.0, we can only write whatever encoding we were supplied,
@@ -948,7 +948,7 @@ namespace System.Xml
                 ThrowClosed();
 
             if (_writeState == WriteState.Start || _writeState == WriteState.Prolog)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlNoRootElement)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlNoRootElement));
 
             FinishDocument();
             _writeState = WriteState.Start;
@@ -988,7 +988,7 @@ namespace System.Xml
                     c != '\t' &&
                     c != '\n' &&
                     c != '\r')
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlOnlyWhitespace), nameof(whitespace)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlOnlyWhitespace, nameof(whitespace)));
             }
 
             WriteString(whitespace);
@@ -1052,10 +1052,10 @@ namespace System.Xml
 
             // Not checking upper bound because it will be caught by "count".  This is what XmlTextWriter does.
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
 
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > chars.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - offset)));
 
@@ -1109,10 +1109,10 @@ namespace System.Xml
 
             // Not checking upper bound because it will be caught by "count".  This is what XmlTextWriter does.
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
 
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > chars.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - offset)));
 
@@ -1138,7 +1138,7 @@ namespace System.Xml
                 ThrowClosed();
 
             if (ch >= 0xd800 && ch <= 0xdfff)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlMissingLowSurrogate), nameof(ch)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlMissingLowSurrogate, nameof(ch)));
 
             if (_attributeValue != null)
                 WriteAttributeText(ch.ToString());
@@ -1258,7 +1258,7 @@ namespace System.Xml
             }
             else if (value.GetType().IsArray)
             {
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlNestedArraysNotSupported), nameof(value)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlNestedArraysNotSupported, nameof(value)));
             }
             else
             {
@@ -1487,10 +1487,10 @@ namespace System.Xml
 
             // Not checking upper bound because it will be caught by "count".  This is what XmlTextWriter does.
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
 
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > buffer.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
 
@@ -1552,10 +1552,10 @@ namespace System.Xml
 
             // Not checking upper bound because it will be caught by "count".  This is what XmlTextWriter does.
             if (offset < 0)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
 
             if (count < 0)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > buffer.Length - offset)
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
 
@@ -1634,7 +1634,7 @@ namespace System.Xml
             if (IsClosed)
                 ThrowClosed();
             if (Signing)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlCanonicalizationStarted)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlCanonicalizationStarted));
             FlushElement();
             if (_signingWriter == null)
                 _signingWriter = CreateSigningNodeWriter();
@@ -1648,7 +1648,7 @@ namespace System.Xml
             if (IsClosed)
                 ThrowClosed();
             if (!Signing)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlCanonicalizationNotStarted)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlCanonicalizationNotStarted));
             _signingWriter.Flush();
             _writer = _signingWriter.NodeWriter;
         }
@@ -1738,9 +1738,9 @@ namespace System.Xml
         {
             FlushBase64();
             if (_documentState == DocumentState.Epilog)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlOnlyOneRoot)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlOnlyOneRoot));
             if (_documentState == DocumentState.Document && count > 1 && _depth == 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlOnlyOneRoot)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlOnlyOneRoot));
             if (_writeState == WriteState.Attribute)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidWriteState, "WriteStartElement", WriteState.ToString())));
             AutoComplete(WriteState.Content);
@@ -2054,7 +2054,7 @@ namespace System.Xml
                             return;
                         if (prefix == "xmlns" && uri == xmlnsNamespace)
                             return;
-                        throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlReservedPrefix), nameof(prefix)));
+                        throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlReservedPrefix, nameof(prefix)));
                     }
                 }
                 Namespace nameSpace;
@@ -2071,7 +2071,7 @@ namespace System.Xml
                     }
                 }
                 if (prefix.Length != 0 && uri.Length == 0)
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlEmptyNamespaceRequiresNullPrefix), nameof(prefix)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.XmlEmptyNamespaceRequiresNullPrefix, nameof(prefix)));
                 if (uri.Length == xmlnsNamespace.Length && uri == xmlnsNamespace)
                     throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.XmlSpecificBindingNamespace, "xmlns", uri)));
                 // The addressing namespace and the xmlNamespace are the same length, so add a quick check to try to disambiguate
index 45df7b1..b05f535 100644 (file)
@@ -43,11 +43,11 @@ namespace System.Xml
             if (buffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(buffer));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > buffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > buffer.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
             MoveToInitial(quotas, session, null);
@@ -1219,11 +1219,11 @@ namespace System.Xml
             if (array == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(array)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > array.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, array.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > array.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, array.Length - offset)));
         }
@@ -1503,4 +1503,4 @@ namespace System.Xml
             return new XmlSigningNodeWriter(false);
         }
     }
-}
\ No newline at end of file
+}
index 7c4a0da..57a3921 100644 (file)
@@ -23,12 +23,12 @@ namespace System.Xml
         public XmlDictionaryString Add(int id, string value)
         {
             if (id < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(id), SR.Format(SR.XmlInvalidID)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(id), SR.XmlInvalidID));
             if (value == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
             XmlDictionaryString xmlString;
             if (TryLookup(id, out xmlString))
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlIDDefined)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlIDDefined));
 
             xmlString = new XmlDictionaryString(this, value, id);
             if (id >= MaxArrayEntries)
index 30a602a..ddc7778 100644 (file)
@@ -60,7 +60,7 @@ namespace System.Xml
         private void WroteAttributeValue()
         {
             if (_wroteAttributeValue && !_inList)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlOnlySingleValue)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlOnlySingleValue));
             _wroteAttributeValue = true;
         }
 
@@ -1215,11 +1215,11 @@ namespace System.Xml
             if (array == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(array)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > array.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, array.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > array.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, array.Length - offset)));
         }
@@ -1501,4 +1501,4 @@ namespace System.Xml
             }
         }
     }
-}
\ No newline at end of file
+}
index a233c12..58cf94a 100644 (file)
@@ -39,7 +39,7 @@ namespace System.Xml
                 if (key != -1)
                 {
                     // If the key is already set, then something is wrong
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlKeyAlreadyExists)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlKeyAlreadyExists));
                 }
 
                 key = Add(value.Value);
index fb53552..d8d9df0 100644 (file)
@@ -105,7 +105,7 @@ namespace System.Xml
                 {
                     if (inclusivePrefixes[i] == null)
                     {
-                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.Format(SR.InvalidInclusivePrefixListCollection));
+                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.InvalidInclusivePrefixListCollection);
                     }
                     _inclusivePrefixes[i] = inclusivePrefixes[i];
                 }
@@ -219,22 +219,22 @@ namespace System.Xml
             if (prefixBuffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(prefixBuffer)));
             if (prefixOffset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.ValueMustBeNonNegative));
             if (prefixOffset > prefixBuffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.Format(SR.OffsetExceedsBufferSize, prefixBuffer.Length)));
             if (prefixLength < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.ValueMustBeNonNegative));
             if (prefixLength > prefixBuffer.Length - prefixOffset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.Format(SR.SizeExceedsRemainingBufferSpace, prefixBuffer.Length - prefixOffset)));
 
             if (localNameBuffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(localNameBuffer)));
             if (localNameOffset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameOffset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameOffset), SR.ValueMustBeNonNegative));
             if (localNameOffset > localNameBuffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameOffset), SR.Format(SR.OffsetExceedsBufferSize, localNameBuffer.Length)));
             if (localNameLength < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameLength), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameLength), SR.ValueMustBeNonNegative));
             if (localNameLength > localNameBuffer.Length - localNameOffset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameLength), SR.Format(SR.SizeExceedsRemainingBufferSpace, localNameBuffer.Length - localNameOffset)));
             ThrowIfClosed();
@@ -399,22 +399,22 @@ namespace System.Xml
             if (prefixBuffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(prefixBuffer)));
             if (prefixOffset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.ValueMustBeNonNegative));
             if (prefixOffset > prefixBuffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.Format(SR.OffsetExceedsBufferSize, prefixBuffer.Length)));
             if (prefixLength < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.ValueMustBeNonNegative));
             if (prefixLength > prefixBuffer.Length - prefixOffset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.Format(SR.SizeExceedsRemainingBufferSpace, prefixBuffer.Length - prefixOffset)));
 
             if (nsBuffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(nsBuffer)));
             if (nsOffset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(nsOffset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(nsOffset), SR.ValueMustBeNonNegative));
             if (nsOffset > nsBuffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(nsOffset), SR.Format(SR.OffsetExceedsBufferSize, nsBuffer.Length)));
             if (nsLength < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(nsLength), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(nsLength), SR.ValueMustBeNonNegative));
             if (nsLength > nsBuffer.Length - nsOffset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(nsLength), SR.Format(SR.SizeExceedsRemainingBufferSpace, nsBuffer.Length - nsOffset)));
             ThrowIfClosed();
@@ -457,22 +457,22 @@ namespace System.Xml
             if (prefixBuffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(prefixBuffer)));
             if (prefixOffset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.ValueMustBeNonNegative));
             if (prefixOffset > prefixBuffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixOffset), SR.Format(SR.OffsetExceedsBufferSize, prefixBuffer.Length)));
             if (prefixLength < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.ValueMustBeNonNegative));
             if (prefixLength > prefixBuffer.Length - prefixOffset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(prefixLength), SR.Format(SR.SizeExceedsRemainingBufferSpace, prefixBuffer.Length - prefixOffset)));
 
             if (localNameBuffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(localNameBuffer)));
             if (localNameOffset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameOffset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameOffset), SR.ValueMustBeNonNegative));
             if (localNameOffset > localNameBuffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameOffset), SR.Format(SR.OffsetExceedsBufferSize, localNameBuffer.Length)));
             if (localNameLength < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameLength), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameLength), SR.ValueMustBeNonNegative));
             if (localNameLength > localNameBuffer.Length - localNameOffset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(localNameLength), SR.Format(SR.SizeExceedsRemainingBufferSpace, localNameBuffer.Length - localNameOffset)));
             ThrowIfClosed();
@@ -533,11 +533,11 @@ namespace System.Xml
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > chars.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - offset)));
             ThrowIfClosed();
@@ -622,11 +622,11 @@ namespace System.Xml
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > chars.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - offset)));
             if (_inStartElement)
@@ -662,11 +662,11 @@ namespace System.Xml
             if (chars == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(chars)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > chars.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, chars.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > chars.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - offset)));
             if (_inStartElement)
index c6cbb50..1251c76 100644 (file)
@@ -473,7 +473,7 @@ namespace System.Xml
                 if (this.IsEmptyElement)
                     return string.Empty;
                 if (!Read())
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidOperation)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlInvalidOperation));
                 if (this.NodeType == XmlNodeType.EndElement)
                     return string.Empty;
             }
@@ -495,7 +495,7 @@ namespace System.Xml
                     sb.Append(value);
                 }
                 if (!Read())
-                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidOperation)));
+                    throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.XmlInvalidOperation));
             }
             if (sb != null)
                 result = sb.ToString();
@@ -1018,11 +1018,11 @@ namespace System.Xml
             if (array == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(array)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > array.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, array.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > array.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, array.Length - offset)));
         }
index 8a75881..cd6defd 100644 (file)
@@ -68,7 +68,7 @@ namespace System.Xml
             if (quotas == null)
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(quotas)));
             if (quotas._readOnly)
-                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.QuotaCopyReadOnly)));
+                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.QuotaCopyReadOnly));
 
             InternalCopyTo(quotas);
         }
@@ -95,7 +95,7 @@ namespace System.Xml
                 if (_readOnly)
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.QuotaIsReadOnly, "MaxStringContentLength")));
                 if (value <= 0)
-                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.QuotaMustBePositive), nameof(value)));
+                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.QuotaMustBePositive, nameof(value)));
                 _maxStringContentLength = value;
                 _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxStringContentLength;
             }
@@ -113,7 +113,7 @@ namespace System.Xml
                 if (_readOnly)
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.QuotaIsReadOnly, "MaxArrayLength")));
                 if (value <= 0)
-                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.QuotaMustBePositive), nameof(value)));
+                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.QuotaMustBePositive, nameof(value)));
                 _maxArrayLength = value;
                 _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxArrayLength;
             }
@@ -131,7 +131,7 @@ namespace System.Xml
                 if (_readOnly)
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.QuotaIsReadOnly, "MaxBytesPerRead")));
                 if (value <= 0)
-                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.QuotaMustBePositive), nameof(value)));
+                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.QuotaMustBePositive, nameof(value)));
 
                 _maxBytesPerRead = value;
                 _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxBytesPerRead;
@@ -150,7 +150,7 @@ namespace System.Xml
                 if (_readOnly)
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.QuotaIsReadOnly, "MaxDepth")));
                 if (value <= 0)
-                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.QuotaMustBePositive), nameof(value)));
+                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.QuotaMustBePositive, nameof(value)));
 
                 _maxDepth = value;
                 _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxDepth;
@@ -169,7 +169,7 @@ namespace System.Xml
                 if (_readOnly)
                     throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.QuotaIsReadOnly, "MaxNameTableCharCount")));
                 if (value <= 0)
-                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.QuotaMustBePositive), nameof(value)));
+                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.QuotaMustBePositive, nameof(value)));
 
                 _maxNameTableCharCount = value;
                 _modifiedQuotas |= XmlDictionaryReaderQuotaTypes.MaxNameTableCharCount;
index 7e7aec2..18ea881 100644 (file)
@@ -209,7 +209,7 @@ namespace System.Xml
 
             Stream stream = value.GetStream();
             if (stream == null)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.XmlInvalidStream)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.XmlInvalidStream));
             int blockSize = 256;
             int bytesRead = 0;
             byte[] block = new byte[blockSize];
@@ -454,11 +454,11 @@ namespace System.Xml
             if (array == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(array)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > array.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, array.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > array.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, array.Length - offset)));
         }
index f52a42b..85d8ac9 100644 (file)
@@ -58,7 +58,7 @@ namespace System.Xml
         private static string GetWhatWasFound(XmlDictionaryReader reader)
         {
             if (reader.EOF)
-                return SR.Format(SR.XmlFoundEndOfFile);
+                return SR.XmlFoundEndOfFile;
             switch (reader.NodeType)
             {
                 case XmlNodeType.Element:
index ecdbb6e..1cc002d 100644 (file)
@@ -559,11 +559,11 @@ namespace System.Xml
             if (buffer == null)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(buffer)));
             if (offset < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.ValueMustBeNonNegative));
             if (offset > buffer.Length)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(offset), SR.Format(SR.OffsetExceedsBufferSize, buffer.Length)));
             if (count < 0)
-                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ValueMustBeNonNegative)));
+                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.ValueMustBeNonNegative));
             if (count > buffer.Length - offset)
                 throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.SizeExceedsRemainingBufferSpace, buffer.Length - offset)));
             MoveToInitial(quotas, onClose);
@@ -879,7 +879,7 @@ namespace System.Xml
                     break;
 
                 if (!space)
-                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlSpaceBetweenAttributes)));
+                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlSpaceBetweenAttributes));
             }
 
             if (_buffered && (BufferReader.Offset - startOffset) > _maxBytesPerRead)
@@ -912,7 +912,7 @@ namespace System.Xml
             byte[] buff = BufferReader.GetBuffer(3, out off);
             if (buff[off + 1] == 0xBF && (buff[off + 2] == 0xBE || buff[off + 2] == 0xBF))
             {
-                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlInvalidFFFE)));
+                XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlInvalidFFFE));
             }
             BufferReader.Advance(3);
         }
@@ -1048,7 +1048,7 @@ namespace System.Xml
                 {
                     if (buffer[offset + 2] == (byte)'>')
                         break;
-                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlInvalidCommentChars)));
+                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlInvalidCommentChars));
                 }
                 BufferReader.SkipByte();
             }
@@ -1181,7 +1181,7 @@ namespace System.Xml
                         }
                         else
                         {
-                            XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlInvalidFFFE)));
+                            XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlInvalidFFFE));
                         }
                     }
                     else
@@ -1340,7 +1340,7 @@ namespace System.Xml
                     else
                     {
                         if (OutsideRootElement)
-                            XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlCDATAInvalidAtTopLevel)));
+                            XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlCDATAInvalidAtTopLevel));
 
                         ReadCData();
                     }
@@ -1383,7 +1383,7 @@ namespace System.Xml
                     buffer[offset + 1] == (byte)']' &&
                     buffer[offset + 2] == (byte)'>')
                 {
-                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlCloseCData)));
+                    XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.XmlCloseCData));
                 }
 
                 BufferReader.SkipByte();
index 9c272c8..c710f54 100644 (file)
@@ -2684,7 +2684,7 @@ namespace System
                 {
                     int val = portStr[idx] - '0';
                     if (val < 0 || val > 9 || (port = (port * 10 + val)) > 0xFFFF)
-                        throw new UriFormatException(SR.Format(SR.net_uri_PortOutOfRange, _syntax.GetType().ToString(), portStr));
+                        throw new UriFormatException(SR.Format(SR.net_uri_PortOutOfRange, _syntax.GetType(), portStr));
                 }
                 if (port != _info.Offset.PortValue)
                 {
index b5bfeea..6718b57 100644 (file)
@@ -386,7 +386,7 @@ namespace System
         internal unsafe bool InternalIsWellFormedOriginalString()
         {
             if (UserDrivenParsing)
-                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType().ToString()));
+                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType()));
 
             fixed (char* str = _string)
             {
@@ -935,7 +935,7 @@ namespace System
                     if (otherUri._string[portIndex] != ':')
                     {
                         // Something wrong with the NotDefaultPort flag.  Reset to path index
-                        Debug.Assert(false, "Uri failed to locate custom port at index: " + portIndex);
+                        Debug.Fail("Uri failed to locate custom port at index: " + portIndex);
                         portIndex = otherUri._info.Offset.Path;
                     }
                 }
index 0b066aa..9ec4b11 100644 (file)
@@ -78,7 +78,7 @@ namespace System
         protected virtual string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError)
         {
             if (baseUri.UserDrivenParsing)
-                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType().ToString()));
+                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType()));
 
             if (!baseUri.IsAbsoluteUri)
                 throw new InvalidOperationException(SR.net_uri_NotAbsolute);
@@ -123,7 +123,7 @@ namespace System
                 throw new ArgumentOutOfRangeException(nameof(format));
 
             if (uri.UserDrivenParsing)
-                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType().ToString()));
+                throw new InvalidOperationException(SR.Format(SR.net_uri_UserDrivenParsing, this.GetType()));
 
             if (!uri.IsAbsoluteUri)
                 throw new InvalidOperationException(SR.net_uri_NotAbsolute);
index 4eebf3a..bebaacc 100644 (file)
@@ -47,14 +47,14 @@ namespace System.Xml.Schema
             {
                 case XmlNodeType.Document:
                     source = ((XDocument)source).Root;
-                    if (source == null) throw new InvalidOperationException(SR.Format(SR.InvalidOperation_MissingRoot));
+                    if (source == null) throw new InvalidOperationException(SR.InvalidOperation_MissingRoot);
                     validationFlags |= XmlSchemaValidationFlags.ProcessIdentityConstraints;
                     break;
                 case XmlNodeType.Element:
                     break;
                 case XmlNodeType.Attribute:
                     if (((XAttribute)source).IsNamespaceDeclaration) goto default;
-                    if (source.Parent == null) throw new InvalidOperationException(SR.Format(SR.InvalidOperation_MissingParent));
+                    if (source.Parent == null) throw new InvalidOperationException(SR.InvalidOperation_MissingParent);
                     break;
                 default:
                     throw new InvalidOperationException(SR.Format(SR.InvalidOperation_BadNodeType, nt));
index 33ff87e..f0c20bd 100644 (file)
@@ -104,7 +104,7 @@ namespace System.Xml
                 case State.InReadElementContent:
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
 
@@ -160,7 +160,7 @@ namespace System.Xml
                 case State.InReadElementContent:
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
 
@@ -216,7 +216,7 @@ namespace System.Xml
                     }
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
 
@@ -272,7 +272,7 @@ namespace System.Xml
                     }
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
 
index 84d3cdf..741bd3b 100644 (file)
@@ -55,7 +55,7 @@ namespace System.Xml
                 case State.InReadElementContent:
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
 
@@ -111,7 +111,7 @@ namespace System.Xml
                 case State.InReadElementContent:
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
 
@@ -167,7 +167,7 @@ namespace System.Xml
                     }
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
 
@@ -223,7 +223,7 @@ namespace System.Xml
                     }
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
 
index 82a7d4d..5fe42ae 100644 (file)
@@ -192,7 +192,7 @@ namespace System.Xml
                     break;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return false;
             }
 
index 3471b78..be02d29 100644 (file)
@@ -45,7 +45,7 @@ namespace System.Xml
                     break;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return false;
             }
 
index c72bd0b..a0187e7 100644 (file)
@@ -340,7 +340,7 @@ namespace System.Xml
             int len = ValidateNames.ParseNCName(ncname, 0);
             if (len != ncname.Length)
             {
-                throw new ArgumentException(string.Format(len == 0 ? SR.Xml_BadStartNameChar : SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(ncname, len)));
+                throw new ArgumentException(SR.Format(len == 0 ? SR.Xml_BadStartNameChar : SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(ncname, len)));
             }
         }
 
index 7630089..ac8c064 100644 (file)
@@ -243,13 +243,13 @@ namespace System.Xml
                             break;
 
                         default:
-                            Debug.Assert(false, "Unknown event: " + page[idxEvent].EventType);
+                            Debug.Fail("Unknown event: " + page[idxEvent].EventType);
                             break;
                     }
                 }
             }
 
-            Debug.Assert(false, "Unknown event should be added to end of event sequence.");
+            Debug.Fail("Unknown event should be added to end of event sequence.");
         }
 
         /// <summary>
@@ -306,7 +306,7 @@ namespace System.Xml
                 }
             }
 
-            Debug.Assert(false, "Unknown event should be added to end of event sequence.");
+            Debug.Fail("Unknown event should be added to end of event sequence.");
             return string.Empty;
         }
 
index 04178b0..77dbbe9 100644 (file)
@@ -1574,12 +1574,12 @@ namespace System.Xml
 
         internal static Exception CreateReadContentAsException(string methodName, XmlNodeType nodeType, IXmlLineInfo lineInfo)
         {
-            return new InvalidOperationException(AddLineInfo(SR.Format(SR.Xml_InvalidReadContentAs, new string[] { methodName, nodeType.ToString() }), lineInfo));
+            return new InvalidOperationException(AddLineInfo(SR.Format(SR.Xml_InvalidReadContentAs, methodName, nodeType), lineInfo));
         }
 
         internal static Exception CreateReadElementContentAsException(string methodName, XmlNodeType nodeType, IXmlLineInfo lineInfo)
         {
-            return new InvalidOperationException(AddLineInfo(SR.Format(SR.Xml_InvalidReadElementContentAs, new string[] { methodName, nodeType.ToString() }), lineInfo));
+            return new InvalidOperationException(AddLineInfo(SR.Format(SR.Xml_InvalidReadElementContentAs, methodName, nodeType), lineInfo));
         }
 
         private static string AddLineInfo(string message, IXmlLineInfo lineInfo)
index 1c90b21..70769f4 100644 (file)
@@ -520,7 +520,7 @@ namespace System.Xml
                     return Read();
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return false;
             }
         }
@@ -639,7 +639,7 @@ namespace System.Xml
                     return;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return;
             }
         }
@@ -863,7 +863,7 @@ namespace System.Xml
                             Debug.Assert(AttributeCount > 0);
                             return reader.ReadContentAsBase64(buffer, index, count);
                         default:
-                            Debug.Assert(false);
+                            Debug.Fail($"Unexpected state {_state}");
                             return 0;
                     }
 
@@ -886,7 +886,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -943,7 +943,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -999,7 +999,7 @@ namespace System.Xml
                             Debug.Assert(AttributeCount > 0);
                             return reader.ReadContentAsBinHex(buffer, index, count);
                         default:
-                            Debug.Assert(false);
+                            Debug.Fail($"Unexpected state {_state}");
                             return 0;
                     }
 
@@ -1022,7 +1022,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -1078,7 +1078,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -1137,7 +1137,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingReadValueChunkWithBinary);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -1526,7 +1526,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingReadValueChunkWithBinary);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     break;
             }
             throw CreateReadContentAsException(methodName);
index 48253c6..c0fd7ba 100644 (file)
@@ -95,7 +95,7 @@ namespace System.Xml
                     return await ReadAsync().ConfigureAwait(false);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return false;
             }
         }
@@ -177,7 +177,7 @@ namespace System.Xml
                     return;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return;
             }
         }
@@ -281,7 +281,7 @@ namespace System.Xml
                             Debug.Assert(AttributeCount > 0);
                             return await reader.ReadContentAsBase64Async(buffer, index, count).ConfigureAwait(false);
                         default:
-                            Debug.Assert(false);
+                            Debug.Fail($"Unexpected state {_state}");
                             return 0;
                     }
 
@@ -304,7 +304,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -361,7 +361,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -417,7 +417,7 @@ namespace System.Xml
                             Debug.Assert(AttributeCount > 0);
                             return await reader.ReadContentAsBinHexAsync(buffer, index, count).ConfigureAwait(false);
                         default:
-                            Debug.Assert(false);
+                            Debug.Fail($"Unexpected state {_state}");
                             return 0;
                     }
 
@@ -440,7 +440,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -496,7 +496,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingBinaryContentMethods);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return 0;
             }
         }
@@ -547,7 +547,7 @@ namespace System.Xml
                     throw new InvalidOperationException(SR.Xml_MixingReadValueChunkWithBinary);
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected state {_state}");
                     return AsyncHelper.DoneTaskZero;
             }
         }
index 097b584..92b99f3 100644 (file)
@@ -436,7 +436,7 @@ namespace System.Xml
                     _fragmentType = XmlNodeType.Document;
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected conformance level {settings.ConformanceLevel}");
                     goto case ConformanceLevel.Document;
             }
         }
@@ -814,7 +814,7 @@ namespace System.Xml
                     case XmlNodeType.None: settings.ConformanceLevel = ConformanceLevel.Auto; break;
                     case XmlNodeType.Element: settings.ConformanceLevel = ConformanceLevel.Fragment; break;
                     case XmlNodeType.Document: settings.ConformanceLevel = ConformanceLevel.Document; break;
-                    default: Debug.Assert(false); goto case XmlNodeType.None;
+                    default: Debug.Fail($"Unexpected fragment type {_fragmentType}"); goto case XmlNodeType.None;
                 }
                 settings.CheckCharacters = _checkCharacters;
                 settings.LineNumberOffset = _lineNumberOffset;
@@ -1180,7 +1180,7 @@ namespace System.Xml
                     break;
                 default:
                     //should never hit here
-                    Debug.Assert(false, "Invalid InitInputType");
+                    Debug.Fail("Invalid InitInputType");
                     break;
             }
         }
@@ -1304,7 +1304,7 @@ namespace System.Xml
                         FinishReadElementContentAsBinary();
                         continue;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected parsing function {_parsingFunction}");
                         break;
                 }
             }
@@ -1332,7 +1332,7 @@ namespace System.Xml
                 switch (_parsingFunction)
                 {
                     case ParsingFunction.InReadAttributeValue:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected parsing function {_parsingFunction}");
                         break;
                     case ParsingFunction.InIncrementalRead:
                         FinishIncrementalRead();
@@ -1486,7 +1486,7 @@ namespace System.Xml
                         _emptyEntityInAttributeResolved = true;
                         break;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail("Unexpected entity type");
                         throw new XmlException(SR.Xml_InternalError, string.Empty);
                 }
             }
@@ -1512,7 +1512,7 @@ namespace System.Xml
                         _parsingFunction = ParsingFunction.AfterResolveEmptyEntityInContent;
                         break;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail("Unexpected entity type");
                         throw new XmlException(SR.Xml_InternalError, string.Empty);
                 }
             }
@@ -3064,7 +3064,7 @@ namespace System.Xml
                     ParseDtdFromParserContext();
                     break;
                 default:
-                    Debug.Assert(false, "Unhandled DtdProcessing enumeration value.");
+                    Debug.Fail("Unhandled DtdProcessing enumeration value.");
                     break;
             }
         }
@@ -3544,7 +3544,7 @@ namespace System.Xml
                     charsDecoded += chDec;
                     bytesDecoded += bDec;
                 }
-                Debug.Assert(false, "We should get an exception again.");
+                Debug.Fail("We should get an exception again.");
             }
             catch (ArgumentException)
             {
@@ -3849,7 +3849,7 @@ namespace System.Xml
                             xmlDeclState = 3;
                             break;
                         default:
-                            Debug.Assert(false);
+                            Debug.Fail($"Unexpected xmlDeclState {xmlDeclState}");
                             break;
                     }
                     sb.Append(chars, _ps.charPos, pos - _ps.charPos);
@@ -4682,7 +4682,7 @@ namespace System.Xml
                     ThrowUnexpectedToken(pos, ">");
                 }
 
-                Debug.Assert(false, "We should never get to this point.");
+                Debug.Fail("We should never get to this point.");
 
             ReadData:
                 if (ReadData() == 0)
@@ -5398,7 +5398,7 @@ namespace System.Xml
                     {
                         if (_ps.chars[_ps.charPos] != (char)0xD)
                         {
-                            Debug.Assert(false, "We should never get to this point.");
+                            Debug.Fail("We should never get to this point.");
                             Throw(SR.Xml_UnexpectedEOF1);
                         }
                         Debug.Assert(_ps.isEof);
@@ -5418,8 +5418,8 @@ namespace System.Xml
                             Throw(SR.Xml_UnclosedQuote);
                         }
                         if (HandleEntityEnd(true))
-                        { // no EndEntity reporting while parsing attributes
-                            Debug.Assert(false);
+                        {
+                            Debug.Fail("no EndEntity reporting while parsing attributes");
                             Throw(SR.Xml_InternalError);
                         }
                         // update info for the next attribute value chunk
@@ -6202,7 +6202,7 @@ namespace System.Xml
         {
             if (_parsingStatesStackTop == -1)
             {
-                Debug.Assert(false);
+                Debug.Fail($"Unexpected parsing states stack top {_parsingStatesStackTop}");
                 Throw(SR.Xml_InternalError);
             }
 
@@ -7122,7 +7122,7 @@ namespace System.Xml
                     {
                         if (_ps.chars[_ps.charPos] != (char)0xD)
                         {
-                            Debug.Assert(false, "We should never get to this point.");
+                            Debug.Fail("We should never get to this point.");
                             Throw(SR.Xml_UnexpectedEOF1);
                         }
                         Debug.Assert(_ps.isEof);
@@ -7228,7 +7228,7 @@ namespace System.Xml
                     }
                     if (_ps.chars[_ps.charPos] != (char)0xD)
                     {
-                        Debug.Assert(false, "We should never get to this point.");
+                        Debug.Fail("We should never get to this point.");
                         Throw(SR.Xml_UnexpectedEOF1);
                     }
                     Debug.Assert(_ps.isEof);
@@ -8352,7 +8352,7 @@ namespace System.Xml
                         pos = startPos;
                         break;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected read state {_incReadState}");
                         break;
                 }
                 Debug.Assert(_incReadState == IncrementalReadState.Text ||
@@ -8739,7 +8739,7 @@ namespace System.Xml
                                     goto ReturnText;
                                 }
                             default:
-                                Debug.Assert(false, "We should never get to this point.");
+                                Debug.Fail("We should never get to this point.");
                                 break;
                         }
                         chars = _ps.chars;
@@ -8794,7 +8794,7 @@ namespace System.Xml
                         }
                         else
                         {
-                            Debug.Assert(false, "We should never get to this point.");
+                            Debug.Fail("We should never get to this point.");
                         }
                     }
                 }
index dba5c77..5e49ee3 100644 (file)
@@ -67,7 +67,7 @@ namespace System.Xml
                     return FinishInitTextReaderAsync();
                 default:
                     //should never hit here
-                    Debug.Assert(false, "Invalid InitInputType");
+                    Debug.Fail("Invalid InitInputType");
                     return Task.CompletedTask;
             }
         }
@@ -171,7 +171,7 @@ namespace System.Xml
                     // Needed only for XmlTextReader
                     //XmlTextReader can't execute Async method.
                     case ParsingFunction.OpenUrl:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected parsing function {_parsingFunction}");
                         break;
                     case ParsingFunction.SwitchToInteractive:
                         Debug.Assert(!_ps.appendMode);
@@ -260,7 +260,7 @@ namespace System.Xml
                     case ParsingFunction.InReadElementContentAsBinary:
                         return FinishReadElementContentAsBinaryAsync().CallBoolTaskFuncWhenFinishAsync(thisRef => thisRef.ReadAsync(), this);
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected parsing function {_parsingFunction}");
                         break;
                 }
             }
@@ -319,7 +319,7 @@ namespace System.Xml
                 switch (_parsingFunction)
                 {
                     case ParsingFunction.InReadAttributeValue:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected parsing function {_parsingFunction}");
                         break;
                     // Needed only for XmlTextReader (ReadChars, ReadBase64, ReadBinHex)
                     case ParsingFunction.InIncrementalRead:
@@ -1056,7 +1056,7 @@ namespace System.Xml
                     return ParseDtdFromParserContextAsync();
 
                 default:
-                    Debug.Assert(false, "Unhandled DtdProcessing enumeration value.");
+                    Debug.Fail("Unhandled DtdProcessing enumeration value.");
                     break;
             }
 
@@ -1492,7 +1492,7 @@ namespace System.Xml
                             xmlDeclState = 3;
                             break;
                         default:
-                            Debug.Assert(false);
+                            Debug.Fail($"Unexpected xmlDeclState {xmlDeclState}");
                             break;
                     }
                     sb.Append(chars, _ps.charPos, pos - _ps.charPos);
@@ -2356,7 +2356,7 @@ namespace System.Xml
                     ThrowUnexpectedToken(pos, ">");
                 }
 
-                Debug.Assert(false, "We should never get to this point.");
+                Debug.Fail("We should never get to this point.");
             }
 
             Debug.Assert(_index > 0);
@@ -2961,7 +2961,7 @@ namespace System.Xml
                     {
                         if (_ps.chars[_ps.charPos] != (char)0xD)
                         {
-                            Debug.Assert(false, "We should never get to this point.");
+                            Debug.Fail("We should never get to this point.");
                             Throw(SR.Xml_UnexpectedEOF1);
                         }
                         Debug.Assert(_ps.isEof);
@@ -2982,8 +2982,8 @@ namespace System.Xml
                         }
 
                         if (HandleEntityEnd(true))
-                        { // no EndEntity reporting while parsing attributes
-                            Debug.Assert(false);
+                        {
+                            Debug.Fail("no EndEntity reporting while parsing attributes");
                             Throw(SR.Xml_InternalError);
                         }
                         // update info for the next attribute value chunk
@@ -4935,7 +4935,7 @@ namespace System.Xml
                     {
                         if (_ps.chars[_ps.charPos] != (char)0xD)
                         {
-                            Debug.Assert(false, "We should never get to this point.");
+                            Debug.Fail("We should never get to this point.");
                             Throw(SR.Xml_UnexpectedEOF1);
                         }
                         Debug.Assert(_ps.isEof);
@@ -5041,7 +5041,7 @@ namespace System.Xml
                     }
                     if (_ps.chars[_ps.charPos] != (char)0xD)
                     {
-                        Debug.Assert(false, "We should never get to this point.");
+                        Debug.Fail("We should never get to this point.");
                         Throw(SR.Xml_UnexpectedEOF1);
                     }
                     Debug.Assert(_ps.isEof);
index 404f150..209dd7d 100644 (file)
@@ -695,7 +695,7 @@ namespace System.Xml
                 }
                 else
                 {
-                    Debug.Assert(false, "We should never get to this point.");
+                    Debug.Fail("We should never get to this point.");
                     // 'other' is null, 'this' is not null. Always return 1, like "".CompareTo(null).
                     return 1;
                 }
index 10f6213..15adb55 100644 (file)
@@ -993,7 +993,7 @@ namespace System.Xml
                     case State.Closed:
                         return WriteState.Closed;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected state {_currentState}");
                         return WriteState.Error;
                 }
             }
@@ -1465,7 +1465,7 @@ namespace System.Xml
                         _stack[_top].defaultNs = ns;
                         break;
                     default:
-                        Debug.Assert(false, "Should have never come here");
+                        Debug.Fail("Should have never come here");
                         return;
                 }
                 _stack[_top].defaultNsState = (declared ? NamespaceState.DeclaredAndWrittenOut : NamespaceState.DeclaredButNotWrittenOut);
index 0f61b75..594ed19 100644 (file)
@@ -569,7 +569,7 @@ namespace System.Xml
                     _readBinaryHelper.Finish();
                     goto case ParsingFunction.Read;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected parsing function {_parsingFunction}");
                     return false;
             }
         }
index 73cde00..a9a8f92 100644 (file)
@@ -67,7 +67,7 @@ namespace System.Xml
                     await _readBinaryHelper.FinishAsync().ConfigureAwait(false);
                     goto case ParsingFunction.Read;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected parsing function {_parsingFunction}");
                     return false;
             }
         }
index a70912b..0243b14 100644 (file)
@@ -305,7 +305,7 @@ namespace System.Xml
                 }
                 else
                 {
-                    Debug.Assert(false, "Expected currentState <= State.Error ");
+                    Debug.Fail("Expected currentState <= State.Error ");
                     return WriteState.Error;
                 }
             }
@@ -1614,7 +1614,7 @@ namespace System.Xml
             else if (State.RootLevelAttr == _currentState)
                 _currentState = State.RootLevelSpecAttr;
             else
-                Debug.Assert(false, "State.Attribute == currentState || State.RootLevelAttr == currentState");
+                Debug.Fail("State.Attribute == currentState || State.RootLevelAttr == currentState");
 
             if (_attrValueCache == null)
             {
@@ -2041,7 +2041,7 @@ namespace System.Xml
                         break;
 
                     default:
-                        Debug.Assert(false, "We should not get to this point.");
+                        Debug.Fail("We should not get to this point.");
                         break;
                 }
             }
@@ -2071,7 +2071,7 @@ namespace System.Xml
         {
             if (state >= State.Error)
             {
-                Debug.Assert(false, "We should never get to this point. State = " + state);
+                Debug.Fail("We should never get to this point. State = " + state);
                 return "Error";
             }
             else
index b082189..dca7ec5 100644 (file)
@@ -1433,7 +1433,7 @@ namespace System.Xml
 
 
                     default:
-                        Debug.Assert(false, "We should not get to this point.");
+                        Debug.Fail("We should not get to this point.");
                         break;
                 }
             }
index d2b80d8..7870362 100644 (file)
@@ -379,7 +379,7 @@ namespace System.Xml
                             writer.WriteValue((string)item.data);
                             break;
                         default:
-                            Debug.Assert(false, "Unexpected ItemType value.");
+                            Debug.Fail("Unexpected ItemType value.");
                             break;
                     }
                 }
index 498e7c3..34973d9 100644 (file)
@@ -98,7 +98,7 @@ namespace System.Xml
                             await writer.WriteStringAsync((string)item.data).ConfigureAwait(false);
                             break;
                         default:
-                            Debug.Assert(false, "Unexpected ItemType value.");
+                            Debug.Fail("Unexpected ItemType value.");
                             break;
                     }
                 }
index c73f8e9..00bd6ca 100644 (file)
@@ -532,7 +532,7 @@ namespace System.Xml
                         // do nothing on root level namespace
                         break;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected node type {nodeType}");
                         break;
                 }
 
index b612740..e5e94b2 100644 (file)
@@ -510,7 +510,7 @@ namespace System.Xml
                         // do nothing on root level namespace
                         break;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected node type {nodeType}");
                         break;
                 }
 
index 3041ae1..7ca70cf 100644 (file)
@@ -563,7 +563,7 @@ namespace System.Xml
                         writer = new XmlAutoDetectWriter(output, this);
                         break;
                     default:
-                        Debug.Assert(false, "Invalid XmlOutputMethod setting.");
+                        Debug.Fail("Invalid XmlOutputMethod setting.");
                         return null;
                 }
             }
@@ -599,7 +599,7 @@ namespace System.Xml
                         writer = new XmlAutoDetectWriter(output, this);
                         break;
                     default:
-                        Debug.Assert(false, "Invalid XmlOutputMethod setting.");
+                        Debug.Fail("Invalid XmlOutputMethod setting.");
                         return null;
                 }
             }
@@ -665,7 +665,7 @@ namespace System.Xml
                     writer = new XmlAutoDetectWriter(output, this);
                     break;
                 default:
-                    Debug.Assert(false, "Invalid XmlOutputMethod setting.");
+                    Debug.Fail("Invalid XmlOutputMethod setting.");
                     return null;
             }
 
index 9ceff52..34db9fd 100644 (file)
@@ -2448,7 +2448,7 @@ namespace System.Xml
                 switch (_coreReader.NodeType)
                 {
                     case XmlNodeType.Element:
-                        Debug.Assert(false); //Should not happen as the caching reader does not cache elements in simple content
+                        Debug.Fail("Should not happen as the caching reader does not cache elements in simple content");
                         break;
 
                     case XmlNodeType.Text:
@@ -2501,7 +2501,7 @@ namespace System.Xml
                         switch (_coreReader.NodeType)
                         {
                             case XmlNodeType.Element:
-                                Debug.Assert(false); //Should not happen as the caching reader does not cache elements in simple content
+                                Debug.Fail("Should not happen as the caching reader does not cache elements in simple content");
                                 break;
 
                             case XmlNodeType.Text:
index e17635c..4b3be04 100644 (file)
@@ -325,7 +325,7 @@ namespace System.Xml
                     break;
 
                 default:
-                    throw new InvalidOperationException(SR.Format(SR.Xml_UnexpectedNodeType, new string[] { _currentNode.NodeType.ToString() }));
+                    throw new InvalidOperationException(SR.Format(SR.Xml_UnexpectedNodeType, _currentNode.NodeType));
             }
         }
 
@@ -762,7 +762,7 @@ namespace System.Xml
                         break;
 
                     default:
-                        throw new InvalidOperationException(SR.Format(SR.Xml_UnexpectedNodeType, new string[] { _currentNode.NodeType.ToString() }));
+                        throw new InvalidOperationException(SR.Format(SR.Xml_UnexpectedNodeType, _currentNode.NodeType));
                 }
             }
             Debug.Assert(child == childToStopAt);
index 6428647..d94bce9 100644 (file)
@@ -525,7 +525,7 @@ namespace System.Xml
                     _namespaceParent = element;
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected scope {scope}");
                     return false;
             }
             return true;
@@ -639,7 +639,7 @@ namespace System.Xml
                     _attributeIndex = index;
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected scope {scope}");
                     return false;
             }
             return true;
index 9fec905..5ac3656 100644 (file)
@@ -1029,7 +1029,7 @@ namespace System.Xml
                         break;
 
                     default:
-                        throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, SR.Xdom_Import, node.NodeType.ToString()));
+                        throw new InvalidOperationException(SR.Format(CultureInfo.InvariantCulture, SR.Xdom_Import, node.NodeType));
                 }
             }
 
index c6fe126..24f4b31 100644 (file)
@@ -1002,7 +1002,7 @@ namespace System.Xml
 
         internal static Exception UnexpectedNodeType(XmlNodeType nodetype)
         {
-            return new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, SR.Xml_UnexpectedNodeType, nodetype.ToString()));
+            return new InvalidOperationException(SR.Format(CultureInfo.InvariantCulture, SR.Xml_UnexpectedNodeType, nodetype.ToString()));
         }
     }
 }
index 67f1dfc..e571bfc 100644 (file)
@@ -98,7 +98,7 @@ namespace System.Xml
         public virtual string Value
         {
             get { return null; }
-            set { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, SR.Xdom_Node_SetVal, NodeType.ToString())); }
+            set { throw new InvalidOperationException(SR.Format(CultureInfo.InvariantCulture, SR.Xdom_Node_SetVal, NodeType.ToString())); }
         }
 
         // Gets the type of the current node.
index dd9503f..18ed298 100644 (file)
@@ -15,7 +15,7 @@ namespace System.Xml
         {
 #if DEBUG
             if (((object)strA != (object)strB) && string.Equals(strA, strB))
-                Debug.Assert(false, "Ref.Equal: Object comparison used for non-atomized string '" + strA + "'");
+                Debug.Fail("Ref.Equal: Object comparison used for non-atomized string '" + strA + "'");
 #endif
             return (object)strA == (object)strB;
         }
index 7769259..b313a79 100644 (file)
@@ -234,7 +234,7 @@ namespace System.Xml.Resolvers
                 {
                     return _fallbackResolver.GetEntity(absoluteUri, role, ofObjectToReturn);
                 }
-                throw new XmlException(SR.Format(SR.Xml_CannotResolveUrl, absoluteUri.ToString()));
+                throw new XmlException(SR.Format(SR.Xml_CannotResolveUrl, absoluteUri));
             }
 
             if (ofObjectToReturn == null || ofObjectToReturn == typeof(Stream) || ofObjectToReturn == typeof(object))
index 0849bb8..52fa8fd 100644 (file)
@@ -31,7 +31,7 @@ namespace System.Xml.Resolvers
                 {
                     return _fallbackResolver.GetEntityAsync(absoluteUri, role, ofObjectToReturn);
                 }
-                throw new XmlException(SR.Format(SR.Xml_CannotResolveUrl, absoluteUri.ToString()));
+                throw new XmlException(SR.Format(SR.Xml_CannotResolveUrl, absoluteUri));
             }
 
             if (ofObjectToReturn == null || ofObjectToReturn == typeof(Stream) || ofObjectToReturn == typeof(object))
index 64ad845..3b0f2d6 100644 (file)
@@ -441,7 +441,6 @@ namespace System.Xml.Schema
 
         internal override bool IsEqual(object o1, object o2)
         {
-            //Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceVerbose, string.Format("\t\tSchemaDatatype.IsEqual({0}, {1})", o1, o2));
             return Compare(o1, o2) == 0;
         }
 
index 161ed20..07643b1 100644 (file)
@@ -624,7 +624,7 @@ namespace System.Xml
                         }
                         return;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected token {token}");
                         break;
                 }
 
@@ -1671,7 +1671,7 @@ namespace System.Xml
                                 _scanningFunction = _savedScanningFunction;
                                 goto SwitchAgain;
                             default:
-                                Debug.Assert(false);
+                                Debug.Fail($"Unexpected scanning function {_scanningFunction}");
                                 return Token.None;
                         }
                 }
@@ -3508,7 +3508,7 @@ namespace System.Xml
 
         private void OnUnexpectedError()
         {
-            Debug.Assert(false, "This is an unexpected error that should have been handled in the ScanXXX methods.");
+            Debug.Fail("This is an unexpected error that should have been handled in the ScanXXX methods.");
             Throw(_curPos, SR.Xml_InternalError);
         }
 
index 17e2ba3..91f0cf2 100644 (file)
@@ -264,7 +264,7 @@ namespace System.Xml
                         }
                         return;
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected token {token}");
                         break;
                 }
 
@@ -1290,7 +1290,7 @@ namespace System.Xml
                                 _scanningFunction = _savedScanningFunction;
                                 goto SwitchAgain;
                             default:
-                                Debug.Assert(false);
+                                Debug.Fail($"Unexpected scanning function {_scanningFunction}");
                                 return Token.None;
                         }
                 }
index a70276b..a916a0c 100644 (file)
@@ -461,7 +461,7 @@ namespace System.Xml.Schema
                         break;
 
                     default:
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected facet type {facet.FacetType}");
                         break;
                 }
             }
index 67d7491..a7056f0 100644 (file)
@@ -1737,7 +1737,7 @@ namespace System.Xml.Schema
                     return ST_double;
 
                 default:
-                    Debug.Assert(false, "Expected type not matched");
+                    Debug.Fail("Expected type not matched");
                     return ST_string;
             }
             /*          if (currentType == null)
@@ -2383,7 +2383,7 @@ namespace System.Xml.Schema
                 return TF_time | TF_string;
             else
             {
-                Debug.Assert(false, "Expected date, time or dateTime");
+                Debug.Fail("Expected date, time or dateTime");
                 return TF_string;
             }
         }
index 407bce2..aeb8cd2 100644 (file)
@@ -110,7 +110,7 @@ namespace System.Xml.Schema
                 case ListType.Set:
                     return _set[ns] != null;
             }
-            Debug.Assert(false);
+            Debug.Fail($"Unexpected type {_type}");
             return false;
         }
 
@@ -155,7 +155,7 @@ namespace System.Xml.Schema
                     }
                     return sb.ToString();
             }
-            Debug.Assert(false);
+            Debug.Fail($"Unexpected type {_type}");
             return string.Empty;
         }
 
index 728fc77..fe65661 100644 (file)
@@ -138,7 +138,7 @@ namespace System.Xml.Schema
                     return false;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected root type {rootType}");
                     break;
             }
             return true;
index 4e34a7d..ea7e6de 100644 (file)
@@ -718,7 +718,7 @@ namespace System.Xml.Schema
                             break;
 
                         default:
-                            Debug.Assert(false);
+                            Debug.Fail($"Unexpected compositor {external.Compositor}");
                             break;
                     }
                 }
index db26392..898b464 100644 (file)
@@ -1402,7 +1402,7 @@ namespace System.Xml.Schema
             }
             else
             {
-                Debug.Assert(false);
+                Debug.Fail("Unexpected particle");
             }
 
             return false;
@@ -2643,7 +2643,7 @@ namespace System.Xml.Schema
             }
             else
             {
-                Debug.Assert(false);
+                Debug.Fail("Unexpected particle");
             }
             if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.One)
             {
index 67fa0ff..8c63c00 100644 (file)
@@ -303,7 +303,7 @@ namespace System.Xml.Schema
                     break;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected match state {attributeMatchState}");
                     break;
             }
             return attDef;
index ff0f66e..05af1e9 100644 (file)
@@ -1621,7 +1621,7 @@ namespace System.Xml.Schema
             }
             else
             {
-                Debug.Assert(false);
+                Debug.Fail("Unexpected particle");
             }
 
             return false;
@@ -3081,7 +3081,7 @@ namespace System.Xml.Schema
             }
             else
             {
-                Debug.Assert(false);
+                Debug.Fail("Unexpected particle");
             }
             if (particle.MinOccurs == decimal.One && particle.MaxOccurs == decimal.One)
             {
index b90da20..f2e2dda 100644 (file)
@@ -219,7 +219,7 @@ namespace System.Xml.Schema
                         case TypeCode.Int64: return valueConverter.ChangeType(_unionVal.i64Val, ValueType);
                         case TypeCode.Double: return valueConverter.ChangeType(_unionVal.dblVal, ValueType);
                         case TypeCode.DateTime: return valueConverter.ChangeType(_unionVal.dtVal, ValueType);
-                        default: Debug.Assert(false, "Should never get here"); break;
+                        default: Debug.Fail("Should never get here"); break;
                     }
                 }
                 return valueConverter.ChangeType(_objVal, ValueType, _nsPrefix);
@@ -241,7 +241,7 @@ namespace System.Xml.Schema
                         case TypeCode.Int64: return valueConverter.ToBoolean(_unionVal.i64Val);
                         case TypeCode.Double: return valueConverter.ToBoolean(_unionVal.dblVal);
                         case TypeCode.DateTime: return valueConverter.ToBoolean(_unionVal.dtVal);
-                        default: Debug.Assert(false, "Should never get here"); break;
+                        default: Debug.Fail("Should never get here"); break;
                     }
                 }
 
@@ -264,7 +264,7 @@ namespace System.Xml.Schema
                         case TypeCode.Int64: return valueConverter.ToDateTime(_unionVal.i64Val);
                         case TypeCode.Double: return valueConverter.ToDateTime(_unionVal.dblVal);
                         case TypeCode.DateTime: return _unionVal.dtVal;
-                        default: Debug.Assert(false, "Should never get here"); break;
+                        default: Debug.Fail("Should never get here"); break;
                     }
                 }
 
@@ -288,7 +288,7 @@ namespace System.Xml.Schema
                         case TypeCode.Int64: return valueConverter.ToDouble(_unionVal.i64Val);
                         case TypeCode.Double: return _unionVal.dblVal;
                         case TypeCode.DateTime: return valueConverter.ToDouble(_unionVal.dtVal);
-                        default: Debug.Assert(false, "Should never get here"); break;
+                        default: Debug.Fail("Should never get here"); break;
                     }
                 }
 
@@ -311,7 +311,7 @@ namespace System.Xml.Schema
                         case TypeCode.Int64: return valueConverter.ToInt32(_unionVal.i64Val);
                         case TypeCode.Double: return valueConverter.ToInt32(_unionVal.dblVal);
                         case TypeCode.DateTime: return valueConverter.ToInt32(_unionVal.dtVal);
-                        default: Debug.Assert(false, "Should never get here"); break;
+                        default: Debug.Fail("Should never get here"); break;
                     }
                 }
 
@@ -334,7 +334,7 @@ namespace System.Xml.Schema
                         case TypeCode.Int64: return _unionVal.i64Val;
                         case TypeCode.Double: return valueConverter.ToInt64(_unionVal.dblVal);
                         case TypeCode.DateTime: return valueConverter.ToInt64(_unionVal.dtVal);
-                        default: Debug.Assert(false, "Should never get here"); break;
+                        default: Debug.Fail("Should never get here"); break;
                     }
                 }
 
@@ -358,7 +358,7 @@ namespace System.Xml.Schema
                     case TypeCode.Int64: return valueConverter.ChangeType(_unionVal.i64Val, type);
                     case TypeCode.Double: return valueConverter.ChangeType(_unionVal.dblVal, type);
                     case TypeCode.DateTime: return valueConverter.ChangeType(_unionVal.dtVal, type);
-                    default: Debug.Assert(false, "Should never get here"); break;
+                    default: Debug.Fail("Should never get here"); break;
                 }
             }
 
@@ -380,7 +380,7 @@ namespace System.Xml.Schema
                         case TypeCode.Int64: return valueConverter.ToString(_unionVal.i64Val);
                         case TypeCode.Double: return valueConverter.ToString(_unionVal.dblVal);
                         case TypeCode.DateTime: return valueConverter.ToString(_unionVal.dtVal);
-                        default: Debug.Assert(false, "Should never get here"); break;
+                        default: Debug.Fail("Should never get here"); break;
                     }
                 }
                 return valueConverter.ToString(_objVal, _nsPrefix);
index 116f4d1..19315c6 100644 (file)
@@ -342,7 +342,7 @@ namespace System.Xml.Schema
 
         internal override XmlSchemaObject Clone()
         {
-            System.Diagnostics.Debug.Assert(false, "Should never call Clone() on XmlSchemaComplexType. Call Clone(XmlSchema) instead.");
+            System.Diagnostics.Debug.Fail("Should never call Clone() on XmlSchemaComplexType. Call Clone(XmlSchema) instead.");
             return Clone(null);
         }
 
index aaae90f..519ce40 100644 (file)
@@ -275,7 +275,7 @@ namespace System.Xml.Schema
 
         internal override XmlSchemaObject Clone()
         {
-            System.Diagnostics.Debug.Assert(false, "Should never call Clone() on XmlSchemaElement. Call Clone(XmlSchema) instead.");
+            System.Diagnostics.Debug.Fail("Should never call Clone() on XmlSchemaElement. Call Clone(XmlSchema) instead.");
             return Clone(null);
         }
 
index 404e7b6..fb27097 100644 (file)
@@ -72,7 +72,7 @@ namespace System.Xml.Schema
 
         internal override XmlSchemaObject Clone()
         {
-            System.Diagnostics.Debug.Assert(false, "Should never call Clone() on XmlSchemaGroup. Call Clone(XmlSchema) instead.");
+            System.Diagnostics.Debug.Fail("Should never call Clone() on XmlSchemaGroup. Call Clone(XmlSchema) instead.");
             return Clone(null);
         }
 
index e7c4869..d3f805e 100644 (file)
@@ -65,8 +65,8 @@ namespace System.Xml.Schema
         [XmlIgnore]
         internal virtual string IdAttribute
         {
-            get { Debug.Assert(false); return null; }
-            set { Debug.Assert(false); }
+            get { Debug.Fail("Should not use base property"); return null; }
+            set { Debug.Fail("Should not use base property"); }
         }
 
         internal virtual void SetUnhandledAttributes(XmlAttribute[] moreAttributes) { }
@@ -75,8 +75,8 @@ namespace System.Xml.Schema
         [XmlIgnore]
         internal virtual string NameAttribute
         {
-            get { Debug.Assert(false); return null; }
-            set { Debug.Assert(false); }
+            get { Debug.Fail("Should not use base property"); return null; }
+            set { Debug.Fail("Should not use base property"); }
         }
 
         [XmlIgnore]
index 173a17f..480ccf3 100644 (file)
@@ -2717,11 +2717,11 @@ namespace System.Xml.Schema
                 {
                     if (name.Namespace.Length != 0)
                     {
-                        builder.Append(SR.Format(SR.Sch_ElementNameAndNamespace, subBuilder.ToString(), name.Namespace));
+                        builder.Append(SR.Format(SR.Sch_ElementNameAndNamespace, subBuilder, name.Namespace));
                     }
                     else
                     {
-                        builder.Append(SR.Format(SR.Sch_ElementName, subBuilder.ToString()));
+                        builder.Append(SR.Format(SR.Sch_ElementName, subBuilder));
                     }
                 }
             }
@@ -2745,7 +2745,7 @@ namespace System.Xml.Schema
                     subBuilder.Append(nsList[i]);
                 }
             }
-            builder.Append(SR.Format(SR.Sch_AnyElementNS, subBuilder.ToString()));
+            builder.Append(SR.Format(SR.Sch_AnyElementNS, subBuilder));
         }
 
         internal static string QNameString(string localName, string ns)
index 9c4278c..8c61eb7 100644 (file)
@@ -265,7 +265,7 @@ namespace System.Xml.Schema
                     break;
 
                 default:
-                    Debug.Assert(false, "Type code " + typeCode + " is not supported.");
+                    Debug.Fail("Type code " + typeCode + " is not supported.");
                     break;
             }
 
@@ -749,7 +749,7 @@ namespace System.Xml.Schema
 
             prefix = nsResolver.LookupPrefix(qname.Namespace);
             if (prefix == null)
-                throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoPrefix, qname.ToString(), qname.Namespace));
+                throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoPrefix, qname, qname.Namespace));
 
             return (prefix.Length != 0) ? string.Concat(prefix, ":", qname.Name) : qname.Name;
         }
index d354a04..b76d4a8 100644 (file)
@@ -970,7 +970,7 @@ namespace System.Xml.Schema
                     container = _redefine;
                     break;
                 default:
-                    Debug.Assert(false, "State is " + state);
+                    Debug.Fail("State is " + state);
                     break;
             }
             return container;
@@ -1095,7 +1095,7 @@ namespace System.Xml.Schema
                     _redefine = (XmlSchemaRedefine)container;
                     break;
                 default:
-                    Debug.Assert(false, "State is " + state);
+                    Debug.Fail("State is " + state);
                     break;
             }
         }
@@ -1335,7 +1335,7 @@ namespace System.Xml.Schema
                     builder._sequence.Items.Add(builder._element);
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected parent element {builder.ParentElement}");
                     break;
             }
         }
@@ -2376,7 +2376,7 @@ namespace System.Xml.Schema
                     _attributeGroup.Attributes.Add(value);
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected parent element {this.ParentElement}");
                     break;
             }
         }
@@ -2425,7 +2425,7 @@ namespace System.Xml.Schema
                     ((XmlSchemaGroupBase)this.ParentContainer).Items.Add(particle);
                     break;
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected parent element {this.ParentElement}");
                     break;
             }
         }
index cc6ab5c..cba0483 100644 (file)
@@ -67,7 +67,7 @@ namespace System.Xml.Serialization
                 if (iFace == iType)
                     return;
             }
-            Debug.Assert(false);
+            Debug.Fail("Interface not found");
 #endif
         }
 
@@ -186,7 +186,7 @@ namespace System.Xml.Serialization
             object var;
             if (TryGetVariable(name, out var))
                 return var;
-            System.Diagnostics.Debug.Assert(false);
+            System.Diagnostics.Debug.Fail("Variable not found");
             return null;
         }
 
@@ -786,7 +786,7 @@ namespace System.Xml.Serialization
                         Ldc((bool)o);
                         break;
                     case TypeCode.Char:
-                        Debug.Assert(false, "Char is not a valid schema primitive and should be treated as int in DataContract");
+                        Debug.Fail("Char is not a valid schema primitive and should be treated as int in DataContract");
                         throw new NotSupportedException(SR.XmlInvalidCharSchemaPrimitive);
                     case TypeCode.SByte:
                     case TypeCode.Byte:
index caaadb7..eb7298a 100644 (file)
@@ -14,7 +14,7 @@ namespace System.Xml.Serialization
     {
         internal static Exception NotSupported(string msg)
         {
-            System.Diagnostics.Debug.Assert(false, msg);
+            System.Diagnostics.Debug.Fail(msg);
             return new NotSupportedException(msg);
         }
     }
index fcd2990..b05b7db 100644 (file)
@@ -592,7 +592,7 @@ namespace System.Xml.Serialization
                 MethodInfo addMethod = targetCollectionType.GetMethod("Add");
                 if (addMethod == null)
                 {
-                    throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                    throw new InvalidOperationException(SR.XmlInternalError);
                 }
 
                 object[] arguments = new object[1];
@@ -626,7 +626,7 @@ namespace System.Xml.Serialization
                 }
                 else
                 {
-                    throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                    throw new InvalidOperationException(SR.XmlInternalError);
                 }
 
                 var typeMemberTypeTuple = Tuple.Create(o.GetType(), memberType);
@@ -651,7 +651,7 @@ namespace System.Xml.Serialization
                 return fieldInfo.GetValue(o);
             }
 
-            throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+            throw new InvalidOperationException(SR.XmlInternalError);
         }
 
         private bool WriteMemberText(Member anyText)
@@ -672,7 +672,7 @@ namespace System.Xml.Serialization
                     }
                     else
                     {
-                        throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                        throw new InvalidOperationException(SR.XmlInternalError);
                     }
                 }
                 else
@@ -899,7 +899,7 @@ namespace System.Xml.Serialization
                     {
                         if (member == null)
                         {
-                            throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                            throw new InvalidOperationException(SR.XmlInternalError);
                         }
 
                         member.Source(value);
@@ -970,12 +970,12 @@ namespace System.Xml.Serialization
                         }
                         break;
                     default:
-                        throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                        throw new InvalidOperationException(SR.XmlInternalError);
                 }
             }
             else
             {
-                throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                throw new InvalidOperationException(SR.XmlInternalError);
             }
 
             member?.ChoiceSource?.Invoke(element.Name);
@@ -1035,7 +1035,7 @@ namespace System.Xml.Serialization
             }
             else
             {
-                throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                throw new InvalidOperationException(SR.XmlInternalError);
             }
 
             return memberType;
@@ -1080,7 +1080,7 @@ namespace System.Xml.Serialization
                     {
                         if (member == null)
                         {
-                            throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                            throw new InvalidOperationException(SR.XmlInternalError);
                         }
 
                         member.Source(rre);
@@ -1515,7 +1515,7 @@ namespace System.Xml.Serialization
                 }
                 else
                 {
-                    throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                    throw new InvalidOperationException(SR.XmlInternalError);
                 }
 
                 AddObjectsIntoTargetCollection(collection, listOfItems, collectionType);
@@ -1959,7 +1959,7 @@ namespace System.Xml.Serialization
                     throw new NotImplementedException("special.TypeDesc.CanBeAttributeValue");
                 }
                 else
-                    throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                    throw new InvalidOperationException(SR.XmlInternalError);
             }
             else
             {
@@ -2111,7 +2111,7 @@ namespace System.Xml.Serialization
                     };
                 }
 
-                throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                throw new InvalidOperationException(SR.XmlInternalError);
             }
             else
             {
index 86377e0..1fd4996 100644 (file)
@@ -316,7 +316,7 @@ namespace System.Xml.Serialization
                         ((XmlNode)o).WriteTo(Writer);
                         break;
                     default:
-                        throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                        throw new InvalidOperationException(SR.XmlInternalError);
                 }
             }
         }
@@ -468,7 +468,7 @@ namespace System.Xml.Serialization
             }
             else
             {
-                throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                throw new InvalidOperationException(SR.XmlInternalError);
             }
         }
 
@@ -673,7 +673,7 @@ namespace System.Xml.Serialization
                 }
 
                 if (enumMapping == null)
-                    throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                    throw new InvalidOperationException(SR.XmlInternalError);
 
                 WriteXsiType(enumMapping.TypeName, ns);
                 Writer.WriteString(WriteEnumMethod(enumMapping, o));
@@ -696,7 +696,7 @@ namespace System.Xml.Serialization
                 }
 
                 if (arrayMapping == null)
-                    throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                    throw new InvalidOperationException(SR.XmlInternalError);
 
                 WriteXsiType(arrayMapping.TypeName, ns);
                 WriteMember(o, null, arrayMapping.ElementsSortedByDerivation, null, null, arrayMapping.TypeDesc, true);
@@ -779,7 +779,7 @@ namespace System.Xml.Serialization
                 return memberField.GetValue(o);
             }
 
-            throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+            throw new InvalidOperationException(SR.XmlInternalError);
         }
 
         private void WriteMember(object memberValue, AttributeAccessor attribute, TypeDesc memberTypeDesc, object container)
@@ -1040,8 +1040,7 @@ namespace System.Xml.Serialization
                 }
                 else
                 {
-                    // #10593: Add More Tests for Serialization Code
-                    Debug.Assert(false);
+                    Debug.Fail("#10593: Add More Tests for Serialization Code");
                 }
             }
             else if (o is byte[] a)
@@ -1060,14 +1059,12 @@ namespace System.Xml.Serialization
                 }
                 else
                 {
-                    // #10593: Add More Tests for Serialization Code
-                    Debug.Assert(false);
+                    Debug.Fail("#10593: Add More Tests for Serialization Code");
                 }
             }
             else
             {
-                // #10593: Add More Tests for Serialization Code
-                Debug.Assert(false);
+                Debug.Fail("#10593: Add More Tests for Serialization Code");
             }
         }
 
@@ -1169,7 +1166,7 @@ namespace System.Xml.Serialization
                 }
                 else
                 {
-                    throw new InvalidOperationException(SR.Format(SR.XmlInternalError));
+                    throw new InvalidOperationException(SR.XmlInternalError);
                 }
             }
 
@@ -1412,7 +1409,7 @@ namespace System.Xml.Serialization
 
                 if (!foundMatchedMember)
                 {
-                    throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, $"Could not find member named {memberName} of type {declaringType.ToString()}"));
+                    throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, $"Could not find member named {memberName} of type {declaringType}"));
                 }
 
                 declaringType = currentType;
index d1a7b6c..7f6b0bf 100644 (file)
@@ -694,7 +694,7 @@ namespace System.Xml.Serialization
         {
             if (type.ContainsGenericParameters)
             {
-                throw new InvalidOperationException(SR.Format(SR.XmlUnsupportedOpenGenericType, type.ToString()));
+                throw new InvalidOperationException(SR.Format(SR.XmlUnsupportedOpenGenericType, type));
             }
             TypeDesc typeDesc = (TypeDesc)s_primitiveTypes[type];
             if (typeDesc == null)
index 546460f..7813707 100644 (file)
@@ -891,7 +891,7 @@ namespace System.Xml.Serialization
 
 #if DEBUG
                 // use exception in the place of Debug.Assert to avoid throwing asserts from a server process such as aspnet_ewp.exe
-                if (value.GetType() != typeof(string)) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, SR.Format(SR.XmlInvalidDefaultValue, value.ToString(), value.GetType().FullName)));
+                if (value.GetType() != typeof(string)) throw new InvalidOperationException(SR.Format(SR.XmlInternalErrorDetails, SR.Format(SR.XmlInvalidDefaultValue, value, value.GetType().FullName)));
 #endif
 
                 // check the validity of the value
@@ -947,10 +947,10 @@ namespace System.Xml.Serialization
             {
                 string defaultValue = XmlCustomFormatter.FromDefaultValue(value, pm.TypeDesc.FormatterName);
                 if (defaultValue == null)
-                    throw new InvalidOperationException(SR.Format(SR.XmlInvalidDefaultValue, value.ToString(), pm.TypeDesc.Name));
+                    throw new InvalidOperationException(SR.Format(SR.XmlInvalidDefaultValue, value, pm.TypeDesc.Name));
                 return defaultValue;
             }
-            throw new InvalidOperationException(SR.Format(SR.XmlInvalidDefaultValue, value.ToString(), pm.TypeDesc.Name));
+            throw new InvalidOperationException(SR.Format(SR.XmlInvalidDefaultValue, value, pm.TypeDesc.Name));
         }
 
         private void ExportRootIfNecessary(TypeScope typeScope)
index 51c8576..53d409f 100644 (file)
@@ -1892,11 +1892,11 @@ namespace System.Xml.Serialization
             {
                 if (name.Name == Soap.Array && name.Namespace == Soap.Encoding)
                 {
-                    throw new InvalidOperationException(SR.Format(SR.XmlInvalidEncoding, name.ToString()));
+                    throw new InvalidOperationException(SR.Format(SR.XmlInvalidEncoding, name));
                 }
                 else
                 {
-                    throw new InvalidOperationException(SR.Format(SR.XmlMissingDataType, name.ToString()));
+                    throw new InvalidOperationException(SR.Format(SR.XmlMissingDataType, name));
                 }
             }
         }
@@ -1919,7 +1919,7 @@ namespace System.Xml.Serialization
         {
             XmlSchemaElement element = (XmlSchemaElement)Schemas.Find(name, typeof(XmlSchemaElement));
             if (element == null)
-                throw new InvalidOperationException(SR.Format(SR.XmlMissingElement, name.ToString()));
+                throw new InvalidOperationException(SR.Format(SR.XmlMissingElement, name));
             return element;
         }
 
index 24f3e0d..8cc842b 100644 (file)
@@ -1752,7 +1752,7 @@ namespace System.Xml.Serialization
                     return fieldVariable;
                 }
             }
-            throw new InvalidOperationException(SR.Format(SR.XmlSerializerUnsupportedType, memberInfos[0].ToString()));
+            throw new InvalidOperationException(SR.Format(SR.XmlSerializerUnsupportedType, memberInfos[0]));
         }
 
         private string WriteMethodInfo(string escapedName, string typeVariable, string memberName, bool isNonPublic, params string[] paramTypes)
index fb80d8e..821c050 100644 (file)
@@ -714,7 +714,7 @@ namespace System.Xml.Serialization
 
             if (XmlMapping.IsShallow(mappings))
             {
-                throw new InvalidOperationException(SR.Format(SR.XmlMelformMapping));
+                throw new InvalidOperationException(SR.XmlMelformMapping);
             }
 
             Assembly assembly = null;
index 81448ca..3d5a9d1 100644 (file)
@@ -627,7 +627,7 @@ namespace System.Xml.Xsl.IlGen
                     case 6: opcode = OpCodes.Ldc_I4_6; break;
                     case 7: opcode = OpCodes.Ldc_I4_7; break;
                     case 8: opcode = OpCodes.Ldc_I4_8; break;
-                    default: Debug.Assert(false); return;
+                    default: Debug.Fail($"Unexpected int val {intVal}"); return;
                 }
                 Emit(opcode);
             }
@@ -890,7 +890,7 @@ namespace System.Xml.Xsl.IlGen
                     Call(XmlILMethods.StrCat4);
                     break;
                 default:
-                    Debug.Assert(false, "Shouldn't be called");
+                    Debug.Fail("Shouldn't be called");
                     break;
             }
         }
@@ -978,7 +978,7 @@ namespace System.Xml.Xsl.IlGen
                         case QilNodeType.Divide: Emit(OpCodes.Div); break;
                         case QilNodeType.Modulo: Emit(OpCodes.Rem); break;
                         case QilNodeType.Negate: Emit(OpCodes.Neg); break;
-                        default: Debug.Assert(false, opType + " must be an arithmetic operation."); break;
+                        default: Debug.Fail($"{opType} must be an arithmetic operation."); break;
                     }
                     break;
 
@@ -991,14 +991,14 @@ namespace System.Xml.Xsl.IlGen
                         case QilNodeType.Divide: meth = XmlILMethods.DecDiv; break;
                         case QilNodeType.Modulo: meth = XmlILMethods.DecRem; break;
                         case QilNodeType.Negate: meth = XmlILMethods.DecNeg; break;
-                        default: Debug.Assert(false, opType + " must be an arithmetic operation."); break;
+                        default: Debug.Fail($"{opType} must be an arithmetic operation."); break;
                     }
 
                     Call(meth);
                     break;
 
                 default:
-                    Debug.Assert(false, "The " + opType + " arithmetic operation cannot be performed on values of type " + code + ".");
+                    Debug.Fail($"The {opType} arithmetic operation cannot be performed on values of type {code}.");
                     break;
             }
         }
@@ -1013,7 +1013,7 @@ namespace System.Xml.Xsl.IlGen
                 case XmlTypeCode.QName: meth = XmlILMethods.QNameEq; break;
                 case XmlTypeCode.Decimal: meth = XmlILMethods.DecEq; break;
                 default:
-                    Debug.Assert(false, "Type " + code + " does not support the equals operation.");
+                    Debug.Fail($"Type {code} does not support the equals operation.");
                     break;
             }
 
@@ -1029,7 +1029,7 @@ namespace System.Xml.Xsl.IlGen
                 case XmlTypeCode.String: meth = XmlILMethods.StrCmp; break;
                 case XmlTypeCode.Decimal: meth = XmlILMethods.DecCmp; break;
                 default:
-                    Debug.Assert(false, "Type " + code + " does not support the equals operation.");
+                    Debug.Fail($"Type {code} does not support the equals operation.");
                     break;
             }
 
@@ -1205,7 +1205,7 @@ namespace System.Xml.Xsl.IlGen
                     case GenerateNameType.TagNameAndMappings: meth = XmlILMethods.StartElemMapName; break;
                     case GenerateNameType.TagNameAndNamespace: meth = XmlILMethods.StartElemNmspName; break;
                     case GenerateNameType.QName: meth = XmlILMethods.StartElemQName; break;
-                    default: Debug.Assert(false, nameType + " is invalid here."); break;
+                    default: Debug.Fail($"{nameType} is invalid here."); break;
                 }
             }
             else
@@ -1215,7 +1215,7 @@ namespace System.Xml.Xsl.IlGen
                 {
                     case GenerateNameType.LiteralLocalName: meth = XmlILMethods.StartElemLocNameUn; break;
                     case GenerateNameType.LiteralName: meth = XmlILMethods.StartElemLitNameUn; break;
-                    default: Debug.Assert(false, nameType + " is invalid here."); break;
+                    default: Debug.Fail($"{nameType} is invalid here."); break;
                 }
             }
 
@@ -1239,7 +1239,7 @@ namespace System.Xml.Xsl.IlGen
                 {
                     case GenerateNameType.LiteralLocalName: meth = XmlILMethods.EndElemLocNameUn; break;
                     case GenerateNameType.LiteralName: meth = XmlILMethods.EndElemLitNameUn; break;
-                    default: Debug.Assert(false, nameType + " is invalid here."); break;
+                    default: Debug.Fail($"{nameType} is invalid here."); break;
                 }
             }
 
@@ -1268,7 +1268,7 @@ namespace System.Xml.Xsl.IlGen
                     case GenerateNameType.TagNameAndMappings: meth = XmlILMethods.StartAttrMapName; break;
                     case GenerateNameType.TagNameAndNamespace: meth = XmlILMethods.StartAttrNmspName; break;
                     case GenerateNameType.QName: meth = XmlILMethods.StartAttrQName; break;
-                    default: Debug.Assert(false, nameType + " is invalid here."); break;
+                    default: Debug.Fail($"{nameType} is invalid here."); break;
                 }
             }
             else
@@ -1278,7 +1278,7 @@ namespace System.Xml.Xsl.IlGen
                 {
                     case GenerateNameType.LiteralLocalName: meth = XmlILMethods.StartAttrLocNameUn; break;
                     case GenerateNameType.LiteralName: meth = XmlILMethods.StartAttrLitNameUn; break;
-                    default: Debug.Assert(false, nameType + " is invalid here."); break;
+                    default: Debug.Fail($"{nameType} is invalid here."); break;
                 }
             }
 
@@ -1438,11 +1438,11 @@ namespace System.Xml.Xsl.IlGen
                         break;
 
                     case XmlTypeCode.AnyAtomicType:
-                        Debug.Assert(false, "Heterogenous sort key is not allowed.");
+                        Debug.Fail("Heterogenous sort key is not allowed.");
                         return;
 
                     default:
-                        Debug.Assert(false, "Sorting over datatype " + keyType.TypeCode + " is not allowed.");
+                        Debug.Fail($"Sorting over datatype {keyType.TypeCode} is not allowed.");
                         break;
                 }
             }
index 3344392..191ff57 100644 (file)
@@ -519,7 +519,7 @@ namespace System.Xml.Xsl.IlGen
                     break;
 
                 default:
-                    Debug.Assert(false, "Invalid location: " + _storage.Location);
+                    Debug.Fail($"Invalid location: {_storage.Location}");
                     break;
             }
         }
@@ -548,7 +548,7 @@ namespace System.Xml.Xsl.IlGen
                     break;
 
                 default:
-                    Debug.Assert(false, "Invalid location: " + _storage.Location);
+                    Debug.Fail($"Invalid location: {_storage.Location}");
                     break;
             }
 
index 4df01af..1d48e33 100644 (file)
@@ -215,7 +215,7 @@ namespace System.Xml.Xsl.IlGen
                 case 1: _arg1 = arg; break;
                 case 2: _arg2 = arg; break;
                 default:
-                    Debug.Assert(false, "Cannot handle more than 2 arguments.");
+                    Debug.Fail("Cannot handle more than 2 arguments.");
                     break;
             }
         }
index 5e308fb..af598ff 100644 (file)
@@ -508,7 +508,7 @@ namespace System.Xml.Xsl.IlGen
                     case QilNodeType.Function: this.xstates = this.parentInfo.InitialStates; break;
                     case QilNodeType.RtfCtor: this.xstates = PossibleXmlStates.WithinContent; break;
                     case QilNodeType.Choice: this.xstates = PossibleXmlStates.Any; break;
-                    default: Debug.Assert(false, ndConstr.NodeType + " is not handled by XmlILStateAnalyzer."); break;
+                    default: Debug.Fail($"{ndConstr.NodeType} is not handled by XmlILStateAnalyzer."); break;
                 }
 
                 if (ndContent != null)
index 31d62cb..11f340c 100644 (file)
@@ -5473,7 +5473,7 @@ namespace System.Xml.Xsl.IlGen
                 case QilNodeType.Le: return cmp <= 0 ? f.True() : f.False();
             }
 
-            Debug.Assert(false, "Cannot fold this comparison operation: " + opType);
+            Debug.Fail($"Cannot fold this comparison operation: {opType}");
             return null;
         }
 
@@ -5585,7 +5585,7 @@ namespace System.Xml.Xsl.IlGen
                 case QilNodeType.Modulo: return f.Modulo(left, right);
             }
 
-            Debug.Assert(false, "Cannot fold this arithmetic operation: " + opType);
+            Debug.Fail($"Cannot fold this arithmetic operation: {opType}");
             return null;
         }
 
index 923100a..3d66fae 100644 (file)
@@ -2022,7 +2022,7 @@ namespace System.Xml.Xsl.IlGen
                         return true;
 
                     default:
-                        Debug.Assert(false, "Pattern " + step.NodeType + " should have been handled.");
+                        Debug.Fail($"Pattern {step.NodeType} should have been handled.");
                         break;
                 }
             }
@@ -2466,7 +2466,7 @@ namespace System.Xml.Xsl.IlGen
                             return true;
 
                         default:
-                            Debug.Assert(false, "Pattern " + step.NodeType + " should have been handled.");
+                            Debug.Fail($"Pattern {step.NodeType} should have been handled.");
                             break;
                     }
                 }
@@ -2492,7 +2492,7 @@ namespace System.Xml.Xsl.IlGen
                             return true;
 
                         default:
-                            Debug.Assert(false, "Pattern " + step.NodeType + " should have been handled.");
+                            Debug.Fail($"Pattern {step.NodeType} should have been handled.");
                             break;
                     }
                 }
@@ -3129,7 +3129,7 @@ namespace System.Xml.Xsl.IlGen
                     break;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected node type {ndProp.NodeType}");
                     break;
             }
 
@@ -4297,7 +4297,7 @@ namespace System.Xml.Xsl.IlGen
                             case QilNodeType.Le: opcode = OpCodes.Bgt_Un; break;
                             case QilNodeType.Eq: opcode = OpCodes.Bne_Un; break;
                             case QilNodeType.Ne: opcode = OpCodes.Beq; break;
-                            default: Debug.Assert(false); opcode = OpCodes.Nop; break;
+                            default: Debug.Fail($"Unexpected rel op {relOp}"); opcode = OpCodes.Nop; break;
                         }
                     }
                     else
@@ -4310,7 +4310,7 @@ namespace System.Xml.Xsl.IlGen
                             case QilNodeType.Le: opcode = OpCodes.Bgt; break;
                             case QilNodeType.Eq: opcode = OpCodes.Bne_Un; break;
                             case QilNodeType.Ne: opcode = OpCodes.Beq; break;
-                            default: Debug.Assert(false); opcode = OpCodes.Nop; break;
+                            default: Debug.Fail($"Unexpected rel op {relOp}"); opcode = OpCodes.Nop; break;
                         }
                     }
                     _helper.Emit(opcode, _iterCurr.LabelBranch);
@@ -4326,7 +4326,7 @@ namespace System.Xml.Xsl.IlGen
                         case QilNodeType.Le: opcode = OpCodes.Ble; break;
                         case QilNodeType.Eq: opcode = OpCodes.Beq; break;
                         case QilNodeType.Ne: opcode = OpCodes.Bne_Un; break;
-                        default: Debug.Assert(false); opcode = OpCodes.Nop; break;
+                        default: Debug.Fail($"Unexpected rel op {relOp}"); opcode = OpCodes.Nop; break;
                     }
                     _helper.Emit(opcode, _iterCurr.LabelBranch);
                     _iterCurr.Storage = StorageDescriptor.None();
@@ -4345,7 +4345,7 @@ namespace System.Xml.Xsl.IlGen
                                 case QilNodeType.Ge: opcode = OpCodes.Bge_S; break;
                                 case QilNodeType.Le: opcode = OpCodes.Ble_S; break;
                                 case QilNodeType.Ne: opcode = OpCodes.Bne_Un_S; break;
-                                default: Debug.Assert(false); opcode = OpCodes.Nop; break;
+                                default: Debug.Fail($"Unexpected rel op {relOp}"); opcode = OpCodes.Nop; break;
                             }
 
                             // Push "true" if comparison succeeds, "false" otherwise
@@ -4592,7 +4592,7 @@ namespace System.Xml.Xsl.IlGen
                 case QilNodeType.NamespaceDecl: return XPathNodeType.Namespace;
             }
 
-            Debug.Assert(false, "Cannot map QilNodeType " + typ + " to an XPathNodeType");
+            Debug.Fail($"Cannot map QilNodeType {typ} to an XPathNodeType");
             return XPathNodeType.All;
         }
 
index 54855f6..e461da2 100644 (file)
@@ -188,7 +188,7 @@ namespace System.Xml.Xsl.Qil
                 message = s + "\n" + message;
             }
             n.Annotation = message;
-            Debug.Assert(false, message);
+            Debug.Fail(message);
         }
     }
 }
index 3539f30..69ae48f 100644 (file)
@@ -416,7 +416,7 @@ namespace System.Xml.Xsl.Runtime
                     return DocOrderMerge();
             }
 
-            Debug.Assert(false, "Invalid IteratorState " + _state);
+            Debug.Fail($"Invalid IteratorState {_state}");
             return IteratorResult.NoMoreNodes;
         }
 
index b14a2cd..68b4492 100644 (file)
@@ -180,23 +180,23 @@ namespace System.Xml.Xsl.Runtime
 
         public override void WriteStartElement(string prefix, string localName, string ns)
         {
-            Debug.Assert(false, "Should never be called on XmlAttributeCache.");
+            Debug.Fail("Should never be called on XmlAttributeCache.");
         }
         internal override void WriteEndElement(string prefix, string localName, string ns)
         {
-            Debug.Assert(false, "Should never be called on XmlAttributeCache.");
+            Debug.Fail("Should never be called on XmlAttributeCache.");
         }
         public override void WriteComment(string text)
         {
-            Debug.Assert(false, "Should never be called on XmlAttributeCache.");
+            Debug.Fail("Should never be called on XmlAttributeCache.");
         }
         public override void WriteProcessingInstruction(string name, string text)
         {
-            Debug.Assert(false, "Should never be called on XmlAttributeCache.");
+            Debug.Fail("Should never be called on XmlAttributeCache.");
         }
         public override void WriteEntityRef(string name)
         {
-            Debug.Assert(false, "Should never be called on XmlAttributeCache.");
+            Debug.Fail("Should never be called on XmlAttributeCache.");
         }
 
         /// <summary>
index 0477955..f2d22ad 100644 (file)
@@ -1020,7 +1020,7 @@ namespace System.Xml.Xsl.Runtime
                     break;
 
                 default:
-                    Debug.Assert(false, "Text cannot be output in the " + _xstate + " state.");
+                    Debug.Fail("Text cannot be output in the " + _xstate + " state.");
                     break;
             }
 
@@ -1191,7 +1191,7 @@ namespace System.Xml.Xsl.Runtime
                     break;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected node type {navigator.NodeType}");
                     break;
             }
 
@@ -1339,7 +1339,7 @@ namespace System.Xml.Xsl.Runtime
                 case XmlState.WithinPI: return XPathNodeType.ProcessingInstruction;
             }
 
-            Debug.Assert(false, xstate.ToString() + " is not a valid XmlState.");
+            Debug.Fail(xstate.ToString() + " is not a valid XmlState.");
             return XPathNodeType.Element;
         }
 
index 17909ab..a4aa84c 100644 (file)
@@ -317,7 +317,7 @@ namespace System.Xml.Xsl.Runtime
                     break;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Fail($"Unexpected node type {nav.NodeType}");
                     break;
             }
 
index b8f83b4..83781fe 100644 (file)
@@ -2160,7 +2160,7 @@ namespace System.Xml.Xsl
 
             LNegative:
                 // bi was bigger than this.
-                Debug.Assert(false, "Who's subtracting to negative?");
+                Debug.Fail("Who's subtracting to negative?");
                 _length = 0;
                 AssertValid();
             }
index e2d9720..87ffd51 100644 (file)
@@ -464,7 +464,6 @@ namespace System.Xml.Xsl
             {
                 case 0:
                     // This assert depends on the way we are going to represent None
-                    // Debug.Assert(false);
                     sb.Append("none");
                     break;
                 case 1:
index 45a4916..522e378 100644 (file)
@@ -1917,7 +1917,7 @@ namespace System.Xml.Xsl
                 return XmlQueryCardinality.ZeroOrMore;
 
             default:
-                Debug.Assert(false);
+                Debug.Fail($"Unexpected type code {typeCode}");
                 return XmlQueryCardinality.None;
             }
         }
index 8c1fdc9..a3e5798 100644 (file)
@@ -225,7 +225,7 @@ namespace System.Xml.Xsl.Xslt
 
         QilNode IXPathBuilder<QilNode>.Predicate(QilNode node, QilNode condition, bool isReverseStep)
         {
-            Debug.Assert(false, "Should not call to this function.");
+            Debug.Fail("Should not call to this function.");
             return null;
         }
 
index 62a8b3f..69c12cc 100644 (file)
@@ -793,7 +793,7 @@ namespace System.Xml.Xsl.XsltOld
                     break;
 
                 default:
-                    Debug.Assert(false, "Unexpected node type.");
+                    Debug.Fail("Unexpected node type.");
                     break;
             }
         }
index 62bcd1f..ca2ee6a 100644 (file)
@@ -50,7 +50,7 @@ namespace System.Xml.Xsl.XsltOld
                     _writer.WriteString(mainNode.Value);
                     break;
                 case XmlNodeType.CDATA:
-                    Debug.Assert(false, "XSLT never gives us CDATA");
+                    Debug.Fail("XSLT never gives us CDATA");
                     _writer.WriteCData(mainNode.Value);
                     break;
                 case XmlNodeType.EntityReference:
index 7c422da..bf881b6 100644 (file)
@@ -726,7 +726,7 @@ namespace System.Xml.Xsl.XsltOld
                     case XPathResultType.Error:
                         return val;
                     default:
-                        Debug.Assert(false, "unexpected XPath type");
+                        Debug.Fail("unexpected XPath type");
                         return val;
                 }
             }
index e7f6e8f..ec55411 100644 (file)
@@ -220,7 +220,7 @@ namespace System.Xml.Xsl.XsltOld
 
         internal override void Execute(Processor processor, ActionFrame frame)
         {
-            Debug.Assert(false);
+            Debug.Fail("Override invoked");
         }
 
         private static OutputMethod ParseOutputMethod(string value, Compiler compiler)
index f309729..459a201 100644 (file)
@@ -192,7 +192,7 @@ namespace System.Reflection.Context.Custom
                 allowMultiple = usage.AllowMultiple;
             }
             else
-                throw new FormatException(SR.Format(SR.Format_AttributeUsage, attributeFilterType.ToString()));
+                throw new FormatException(SR.Format(SR.Format_AttributeUsage, attributeFilterType));
         }
 
         internal static IEnumerable<object> FilterCustomAttributes(IEnumerable<object> attributes, Type attributeFilterType)
@@ -200,7 +200,7 @@ namespace System.Reflection.Context.Custom
             foreach (object attr in attributes)
             {
                 if (attr == null)
-                    throw new InvalidOperationException(SR.Format(SR.InvalidOperation_NullAttribute));
+                    throw new InvalidOperationException(SR.InvalidOperation_NullAttribute);
 
                 if (attributeFilterType.IsInstanceOfType(attr))
                     yield return attr;
index 916dd95..1d3c802 100644 (file)
@@ -48,7 +48,7 @@ namespace System.Reflection.Internal
                 // don't expect to hit this as the parameter types we pass are
                 // specified to match known definitions precisely.
 
-                Debug.Assert(false, "Current platform has ambiguous match for: " + type.FullName + "." + name);
+                Debug.Assert(false, $"Current platform has ambiguous match for: {type.FullName}.{name}");
                 return null;
             }
         }
index 94d7ba9..ee10249 100644 (file)
@@ -191,7 +191,7 @@ namespace System.Reflection.Metadata.Ecma335
             int separator = blobReader.ReadByte();
             if (separator > 0x7f)
             {
-                throw new BadImageFormatException(string.Format(SR.InvalidDocumentName, separator));
+                throw new BadImageFormatException(SR.Format(SR.InvalidDocumentName, separator));
             }
 
             var pooledBuilder = PooledStringBuilder.GetInstance();
index 27b4796..419ed1b 100644 (file)
@@ -540,7 +540,7 @@ namespace System.Reflection.Metadata
             int entryPointRowId = (int)(entryPointToken & TokenTypeIds.RIDMask);
             if (entryPointToken != 0 && ((entryPointToken & TokenTypeIds.TypeMask) != TokenTypeIds.MethodDef || entryPointRowId == 0))
             {
-                throw new BadImageFormatException(string.Format(SR.InvalidEntryPointToken, entryPointToken));
+                throw new BadImageFormatException(SR.Format(SR.InvalidEntryPointToken, entryPointToken));
             }
 
             ulong externalTableMask = reader.ReadUInt64();
@@ -550,7 +550,7 @@ namespace System.Reflection.Metadata
 
             if ((externalTableMask & ~validTables) != 0)
             {
-                throw new BadImageFormatException(string.Format(SR.UnknownTables, externalTableMask));
+                throw new BadImageFormatException(SR.Format(SR.UnknownTables, externalTableMask));
             }
 
             externalTableRowCounts = ReadMetadataTableRowCounts(ref reader, externalTableMask);
index b4d62b1..3429210 100644 (file)
@@ -121,7 +121,7 @@ namespace System.Reflection.Metadata
                         break;
 
                     default:
-                        throw new BadImageFormatException(string.Format(SR.InvalidImportDefinitionKind, kind));
+                        throw new BadImageFormatException(SR.Format(SR.InvalidImportDefinitionKind, kind));
                 }
 
                 return true;
index 17c74ad..d09cbab 100644 (file)
@@ -139,7 +139,7 @@ namespace System.Reflection.Metadata
                     break;
 
                 default:
-                    Debug.Assert(false);
+                    Debug.Assert(false, $"Unexpected treatment {treatment}");
                     return default(BlobHandle);
             }
 
index 37f5b79..fb75956 100644 (file)
@@ -39,7 +39,7 @@ namespace System.Reflection
         [MethodImpl(MethodImplOptions.NoInlining)]
         internal static Exception InvalidArgument_Handle(string parameterName)
         {
-            throw new ArgumentException(SR.Format(SR.InvalidHandle), parameterName);
+            throw new ArgumentException(SR.InvalidHandle, parameterName);
         }
 
         [MethodImpl(MethodImplOptions.NoInlining)]
index 143f1c3..3936e0e 100644 (file)
@@ -45,7 +45,7 @@ namespace System.Reflection
                 }
             }
 
-            e = new FileNotFoundException(SR.Format(SR.UnableToDetermineCoreAssembly));
+            e = new FileNotFoundException(SR.UnableToDetermineCoreAssembly);
             return null;
         }
 
index 12c54e9..a6ecedc 100644 (file)
@@ -51,7 +51,7 @@ namespace System.Reflection.TypeLoading.Ecma
                 case PrimitiveTypeCode.UIntPtr: return CoreType.UIntPtr;
                 case PrimitiveTypeCode.Void: return CoreType.Void;
                 default:
-                    Debug.Assert(false, "Unexpected PrimitiveTypeCode: " + typeCode);
+                    Debug.Fail("Unexpected PrimitiveTypeCode: " + typeCode);
                     return CoreType.Void;
             }
         }
index 732f72d..99700dc 100644 (file)
@@ -35,7 +35,7 @@ namespace System.Reflection.TypeLoading.Ecma
                     return ((TypeSpecificationHandle)handle).ToTypeString(reader, typeContext);
 
                 default:
-                    Debug.Assert(false, $"Invalid handle passed to ToTypeString: 0x{handle.GetToken():x8}");
+                    Debug.Fail($"Invalid handle passed to ToTypeString: 0x{handle.GetToken():x8}");
                     return "?";
             }
         }
index 0634364..9be007a 100644 (file)
@@ -642,7 +642,7 @@ namespace System.Resources
                     }
 
                 default:
-                    Debug.Assert(typeCode >= ResourceTypeCode.StartOfUserTypes, string.Format(CultureInfo.InvariantCulture, "ResourceReader: Unsupported ResourceTypeCode in .resources file!  {0}", typeCode));
+                    Debug.Assert(typeCode >= ResourceTypeCode.StartOfUserTypes, $"ResourceReader: Unsupported ResourceTypeCode in .resources file!  {typeCode}");
                     throw new PlatformNotSupportedException(SR.NotSupported_BinarySerializedResources);
             }
         }
index b92c19b..02bfed6 100644 (file)
@@ -225,7 +225,7 @@ namespace System.Runtime.Caching
                 }
 
 #if PERF
-                Debug.WriteLine(String.Format("CacheMemoryMonitor.GetPercentToTrim: percent={0:N}, lastTrimPercent={1:N}{Environment.NewLine}",
+                Debug.WriteLine(string.Format("CacheMemoryMonitor.GetPercentToTrim: percent={0:N}, lastTrimPercent={1:N}{Environment.NewLine}",
                                                     percent,
                                                     lastTrimPercent));
 #endif
index a60b0ed..b990c41 100644 (file)
@@ -92,7 +92,7 @@ namespace System.Runtime.Caching
                 }
 
 #if PERF
-                Debug.WriteLine(String.Format("PhysicalMemoryMonitor.GetPercentToTrim: percent={0:N}, lastTrimPercent={1:N}, secondsSinceTrim={2:N}{3}",
+                Debug.WriteLine(string.Format("PhysicalMemoryMonitor.GetPercentToTrim: percent={0:N}, lastTrimPercent={1:N}, secondsSinceTrim={2:N}{3}",
                                                     percent,
                                                     lastTrimPercent,
                                                     ticksSinceTrim/TimeSpan.TicksPerSecond,
index 263ad3b..b19af26 100644 (file)
@@ -52,9 +52,9 @@ namespace System.Runtime.CompilerServices
                 {
                     return base.Message;
                 }
-                string valueMessage = SR.Format(SR.SwitchExpressionException_UnmatchedValue, UnmatchedValue.ToString());
+                string valueMessage = SR.Format(SR.SwitchExpressionException_UnmatchedValue, UnmatchedValue);
                 return base.Message + Environment.NewLine + valueMessage;
             }
         }
     }
-}
\ No newline at end of file
+}
index 5d991a2..b659347 100644 (file)
@@ -38,7 +38,7 @@ namespace System.Runtime.InteropServices
                     Marshal.Release(pUnknown);
                 }
             }
-            throw new InvalidOperationException(string.Format(SR.StandardOleMarshalObjectGetMarshalerFailed, riid.ToString()));
+            throw new InvalidOperationException(SR.Format(SR.StandardOleMarshalObjectGetMarshalerFailed, riid.ToString()));
         }
 
         int IMarshal.GetUnmarshalClass(ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags, out Guid pCid)
index d38185e..2ebf104 100644 (file)
@@ -137,7 +137,7 @@ namespace System.Runtime.Serialization.Formatters.Binary
         {
             if (!t.IsSerializable && !HasSurrogate(t))
             {
-                throw new SerializationException(string.Format(CultureInfo.InvariantCulture, SR.Serialization_NonSerType, t.FullName, t.Assembly.FullName));
+                throw new SerializationException(SR.Format(CultureInfo.InvariantCulture, SR.Serialization_NonSerType, t.FullName, t.Assembly.FullName));
             }
         }
 
index cf22167..86b73d2 100644 (file)
@@ -184,7 +184,7 @@ namespace System.Runtime.Serialization
                 {
                     if (!holder.CanSurrogatedObjectValueChange && returnValue != holder.ObjectValue)
                     {
-                        throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SR.Serialization_NotCyclicallyReferenceableSurrogate, surrogate.GetType().FullName));
+                        throw new SerializationException(SR.Format(SR.Serialization_NotCyclicallyReferenceableSurrogate, surrogate.GetType().FullName));
                     }
                     holder.SetObjectValue(returnValue, this);
                 }
@@ -917,7 +917,7 @@ namespace System.Runtime.Serialization
             }
             if (!(member is FieldInfo)) // desktop checks specifically for RuntimeFieldInfo and SerializationFieldInfo, but the former is an implementation detail in corelib
             {
-                throw new SerializationException(SR.Format(SR.Serialization_InvalidType, member.GetType().ToString()));
+                throw new SerializationException(SR.Format(SR.Serialization_InvalidType, member.GetType()));
             }
 
             //Create a new fixup holder
index f935ccd..021c767 100644 (file)
@@ -275,7 +275,7 @@ namespace System.IO
                 //    break;
 
                 default:
-                    Debug.Assert(false, "We should never get here. Someone forgot to handle an input stream optimisation option.");
+                    Debug.Fail("We should never get here. Someone forgot to handle an input stream optimisation option.");
                     readAsyncOperation = null;
                     break;
             }
index 2396c57..f3de694 100644 (file)
@@ -128,9 +128,8 @@ namespace System.IO
                 return null;
 
             Debug.Assert(wrtStr is TWinRtStream,
-                            string.Format("Attempted to get the underlying WinRT stream typed as \"{0}\"," +
-                                          " but the underlying WinRT stream cannot be cast to that type. Its actual type is \"{1}\".",
-                                          typeof(TWinRtStream).ToString(), wrtStr.GetType().ToString()));
+                $"Attempted to get the underlying WinRT stream typed as \"{typeof(TWinRtStream)}\", " +
+                $"but the underlying WinRT stream cannot be cast to that type. Its actual type is \"{wrtStr.GetType()}\".");
 
             return wrtStr as TWinRtStream;
         }
index 3734c00..9653fe0 100644 (file)
@@ -259,7 +259,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
     {
         private NotifyCollectionChangedToManagedAdapter()
         {
-            Debug.Assert(false, "This class is never instantiated");
+            Debug.Fail("This class is never instantiated");
         }
 
         internal event NotifyCollectionChangedEventHandler CollectionChanged
@@ -299,7 +299,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
     {
         private NotifyCollectionChangedToWinRTAdapter()
         {
-            Debug.Assert(false, "This class is never instantiated");
+            Debug.Fail("This class is never instantiated");
         }
 
         // An instance field typed as EventRegistrationTokenTable is injected into managed classed by the compiler when compiling for /t:winmdobj.
@@ -340,7 +340,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
     {
         private NotifyPropertyChangedToManagedAdapter()
         {
-            Debug.Assert(false, "This class is never instantiated");
+            Debug.Fail("This class is never instantiated");
         }
 
         internal event PropertyChangedEventHandler PropertyChanged
@@ -380,7 +380,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
     {
         private NotifyPropertyChangedToWinRTAdapter()
         {
-            Debug.Assert(false, "This class is never instantiated");
+            Debug.Fail("This class is never instantiated");
         }
 
         // An instance field typed as EventRegistrationTokenTable is injected into managed classed by the compiler when compiling for /t:winmdobj.
@@ -425,7 +425,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
 
         private ICommandToManagedAdapter()
         {
-            Debug.Assert(false, "This class is never instantiated");
+            Debug.Fail("This class is never instantiated");
         }
 
         private event EventHandler CanExecuteChanged
@@ -486,7 +486,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
     {
         private ICommandToWinRTAdapter()
         {
-            Debug.Assert(false, "This class is never instantiated");
+            Debug.Fail("This class is never instantiated");
         }
 
         // An instance field typed as EventRegistrationTokenTable is injected into managed classed by the compiler when compiling for /t:winmdobj.
index 36ccc04..b644a72 100644 (file)
@@ -79,7 +79,7 @@ namespace System.Threading.Tasks
 
                 if (!base.Task.IsFaulted)
                 {
-                    Debug.Assert(false, string.Format("Expected base task to already be faulted but found it in state {0}", base.Task.Status));
+                    Debug.Fail($"Expected base task to already be faulted but found it in state {base.Task.Status}");
                     base.TrySetException(ex);
                 }
             }
@@ -171,7 +171,7 @@ namespace System.Threading.Tasks
                         // Defend against a faulty IAsyncInfo implementation:
                         if (error == null)
                         {
-                            Debug.Assert(false, "IAsyncInfo.Status == Error, but ErrorCode returns a null Exception (implying S_OK).");
+                            Debug.Fail("IAsyncInfo.Status == Error, but ErrorCode returns a null Exception (implying S_OK).");
                             error = new InvalidOperationException(SR.InvalidOperation_InvalidAsyncCompletion);
                         }
                         else
@@ -221,7 +221,7 @@ namespace System.Threading.Tasks
                 {
                     // This really shouldn't happen, but could in a variety of misuse cases
                     // such as a faulty underlying IAsyncInfo implementation.
-                    Debug.Assert(false, string.Format("Unexpected exception in Complete: {0}", exc.ToString()));
+                    Debug.Fail($"Unexpected exception in Complete: {exc}");
 
                     if (AsyncCausalitySupport.LoggingOn)
                         AsyncCausalitySupport.TraceOperationCompletedError(this.Task);
@@ -231,7 +231,7 @@ namespace System.Threading.Tasks
                     // do we allow it to be propagated out to the invoker of the Completed handler.
                     if (!base.TrySetException(exc))
                     {
-                        Debug.Assert(false, "The task was already completed and thus the exception couldn't be stored.");
+                        Debug.Fail("The task was already completed and thus the exception couldn't be stored.");
                         throw;
                     }
                 }
index bb43d4d..b5e556e 100644 (file)
@@ -72,7 +72,7 @@ namespace System.Threading.Tasks
 
                 if (!base.Task.IsFaulted)
                 {
-                    Debug.Assert(false, string.Format("Expected base task to already be faulted but found it in state {0}", base.Task.Status));
+                    Debug.Fail($"Expected base task to already be faulted but found it in state {base.Task.Status}");
                     base.TrySetException(ex);
                 }
             }
@@ -170,7 +170,7 @@ namespace System.Threading.Tasks
                         // Defend against a faulty IAsyncInfo implementation:
                         if (error == null)
                         {
-                            Debug.Assert(false, "IAsyncInfo.Status == Error, but ErrorCode returns a null Exception (implying S_OK).");
+                            Debug.Fail("IAsyncInfo.Status == Error, but ErrorCode returns a null Exception (implying S_OK).");
                             error = new InvalidOperationException(SR.InvalidOperation_InvalidAsyncCompletion);
                         }
                         else
@@ -220,7 +220,7 @@ namespace System.Threading.Tasks
                 {
                     // This really shouldn't happen, but could in a variety of misuse cases
                     // such as a faulty underlying IAsyncInfo implementation.
-                    Debug.Assert(false, string.Format("Unexpected exception in Complete: {0}", exc.ToString()));
+                    Debug.Fail($"Unexpected exception in Complete: {exc}");
 
                     if (AsyncCausalitySupport.LoggingOn)
                         AsyncCausalitySupport.TraceOperationCompletedError(this.Task);
@@ -230,7 +230,7 @@ namespace System.Threading.Tasks
                     // do we allow it to be propagated out to the invoker of the Completed handler.
                     if (!base.TrySetException(exc))
                     {
-                        Debug.Assert(false, "The task was already completed and thus the exception couldn't be stored.");
+                        Debug.Fail("The task was already completed and thus the exception couldn't be stored.");
                         throw;
                     }
                 }
index 48677d5..c8b5964 100644 (file)
@@ -399,14 +399,14 @@ namespace System.Threading.Tasks
 
         internal virtual void OnCompleted(TCompletedHandler userCompletionHandler, AsyncStatus asyncStatus)
         {
-            Debug.Assert(false, "This (sub-)type of IAsyncInfo does not support completion notifications "
+            Debug.Fail("This (sub-)type of IAsyncInfo does not support completion notifications "
                                  + " (" + this.GetType().ToString() + ")");
         }
 
 
         internal virtual void OnProgress(TProgressHandler userProgressHandler, TProgressInfo progressInfo)
         {
-            Debug.Assert(false, "This (sub-)type of IAsyncInfo does not support progress notifications "
+            Debug.Fail("This (sub-)type of IAsyncInfo does not support progress notifications "
                                  + " (" + this.GetType().ToString() + ")");
         }
 
@@ -621,7 +621,7 @@ namespace System.Threading.Tasks
                     break;
 
                 default:
-                    Debug.Assert(false, "Unexpected task.Status: It should be terminal if TaskCompleted() is called.");
+                    Debug.Fail("Unexpected task.Status: It should be terminal if TaskCompleted() is called.");
                     break;
             }
 
@@ -685,7 +685,7 @@ namespace System.Threading.Tasks
             switch (asyncState)
             {
                 case STATE_NOT_INITIALIZED:
-                    Debug.Assert(false, "STATE_NOT_INITIALIZED should only occur when this object was not"
+                    Debug.Fail("STATE_NOT_INITIALIZED should only occur when this object was not"
                                          + " fully constructed, in which case we should never get here");
                     return AsyncStatus.Error;
 
@@ -703,11 +703,11 @@ namespace System.Threading.Tasks
                     return AsyncStatus.Error;
 
                 case STATE_CLOSED:
-                    Debug.Assert(false, "This method should never be called is this IAsyncInfo is CLOSED");
+                    Debug.Fail("This method should never be called is this IAsyncInfo is CLOSED");
                     return AsyncStatus.Error;
             }
 
-            Debug.Assert(false, "The switch above is missing a case");
+            Debug.Fail("The switch above is missing a case");
             return AsyncStatus.Error;
         }
 
@@ -789,7 +789,7 @@ namespace System.Threading.Tasks
                 return funcCTokIPrgrTask(_cancelTokenSource.Token, this);
             }
 
-            Debug.Assert(false, "We should never get here!"
+            Debug.Fail("We should never get here!"
                                  + " Public methods creating instances of this class must be typesafe to ensure that taskProvider"
                                  + " can always be cast to one of the above Func types."
                                  + " The taskProvider is " + (taskProvider == null
index 512ef47..ffeea0c 100644 (file)
@@ -139,7 +139,7 @@ nameof(binaryForm),
                 // Indicates a bug in the implementation, not in user's code.
                 //
 
-                Debug.Assert(false, "Length > ushort.MaxValue");
+                Debug.Fail("Length > ushort.MaxValue");
                 // Replacing SystemException with InvalidOperationException. It's not a perfect fit,
                 // but it's the best exception type available to indicate a failure because
                 // of a bug in the ACE itself.
@@ -850,13 +850,13 @@ nameof(type),
                 {
                     throw new ArgumentOutOfRangeException(
 nameof(opaque),
-                        string.Format(CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_ArrayLength, 0, MaxOpaqueLength));
+                        SR.Format(SR.ArgumentOutOfRange_ArrayLength, 0, MaxOpaqueLength));
                 }
                 else if (opaque.Length % 4 != 0)
                 {
                     throw new ArgumentOutOfRangeException(
 nameof(opaque),
-                        string.Format(CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_ArrayLengthMultiple, 4));
+                        SR.Format(SR.ArgumentOutOfRange_ArrayLengthMultiple, 4));
                 }
             }
 
@@ -885,7 +885,7 @@ nameof(opaque),
             {
                 if (OpaqueLength > MaxOpaqueLength)
                 {
-                    Debug.Assert(false, "OpaqueLength somehow managed to exceed MaxOpaqueLength");
+                    Debug.Fail("OpaqueLength somehow managed to exceed MaxOpaqueLength");
                     // Replacing SystemException with InvalidOperationException. It's not a perfect fit,
                     // but it's the best exception type available to indicate a failure because
                     // of a bug in the ACE itself.
@@ -1202,7 +1202,7 @@ nameof(opaque),
                     // Indicates a bug in the implementation, not in user's code
                     //
 
-                    Debug.Assert(false, "Invalid ACE type");
+                    Debug.Fail("Invalid ACE type");
                     // Replacing SystemException with InvalidOperationException. It's not a perfect fit,
                     // but it's the best exception type available to indicate a failure because
                     // of a bug in the ACE itself.
@@ -1303,13 +1303,13 @@ nameof(opaque),
                 {
                     throw new ArgumentOutOfRangeException(
 nameof(opaque),
-                        string.Format(CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_ArrayLength, 0, MaxOpaqueLengthInternal));
+                        SR.Format(SR.ArgumentOutOfRange_ArrayLength, 0, MaxOpaqueLengthInternal));
                 }
                 else if (opaque.Length % 4 != 0)
                 {
                     throw new ArgumentOutOfRangeException(
 nameof(opaque),
-                        string.Format(CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_ArrayLengthMultiple, 4));
+                        SR.Format(SR.ArgumentOutOfRange_ArrayLengthMultiple, 4));
                 }
             }
 
@@ -1646,7 +1646,7 @@ nameof(qualifier),
             {
                 if (OpaqueLength > MaxOpaqueLengthInternal)
                 {
-                    Debug.Assert(false, "OpaqueLength somehow managed to exceed MaxOpaqueLength");
+                    Debug.Fail("OpaqueLength somehow managed to exceed MaxOpaqueLength");
                     // Replacing SystemException with InvalidOperationException. It's not a perfect fit,
                     // but it's the best exception type available to indicate a failure because
                     // of a bug in the ACE itself.
@@ -2212,7 +2212,7 @@ nameof(qualifier),
             {
                 if (OpaqueLength > MaxOpaqueLengthInternal)
                 {
-                    Debug.Assert(false, "OpaqueLength somehow managed to exceed MaxOpaqueLength");
+                    Debug.Fail("OpaqueLength somehow managed to exceed MaxOpaqueLength");
                     // Replacing SystemException with InvalidOperationException. It's not a perfect fit,
                     // but it's the best exception type available to indicate a failure because
                     // of a bug in the ACE itself.
index b635db4..0b5a9cc 100644 (file)
@@ -275,7 +275,7 @@ nameof(targetType));
                             result = _securityDescriptor.DiscretionaryAcl.RemoveAccess(AccessControlType.Allow, sid, -1, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, 0);
                             if (result == false)
                             {
-                                Debug.Assert(false, "Invalid operation");
+                                Debug.Fail("Invalid operation");
                                 throw new InvalidOperationException();
                             }
 
@@ -316,7 +316,7 @@ nameof(modification),
                             result = _securityDescriptor.DiscretionaryAcl.RemoveAccess(AccessControlType.Deny, sid, -1, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, 0);
                             if (result == false)
                             {
-                                Debug.Assert(false, "Invalid operation");
+                                Debug.Fail("Invalid operation");
                                 throw new InvalidOperationException();
                             }
 
@@ -334,7 +334,7 @@ nameof(modification),
                 }
                 else
                 {
-                    Debug.Assert(false, "rule.AccessControlType unrecognized");
+                    Debug.Fail("rule.AccessControlType unrecognized");
                     throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)rule.AccessControlType), "rule.AccessControlType");
                 }
 
index 1f58aa2..e417332 100644 (file)
@@ -157,7 +157,7 @@ nameof(name));
                     }
                     else
                     {
-                        Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32GetSecurityInfo() failed with unexpected error code {0}", error));
+                        Debug.Fail($"Win32GetSecurityInfo() failed with unexpected error code {error}");
                         exception = new InvalidOperationException(SR.Format(SR.AccessControl_UnexpectedError, error));
                     }
                 }
@@ -299,7 +299,7 @@ nameof(name));
                         }
                         else
                         {
-                            Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unexpected error code {0}", error));
+                            Debug.Fail($"Unexpected error code {error}");
                             exception = new InvalidOperationException(SR.Format(SR.AccessControl_UnexpectedError, error));
                         }
                     }
index 1cc6584..7561f55 100644 (file)
@@ -129,7 +129,7 @@ namespace System.Security.AccessControl
                         }
                         else
                         {
-                            System.Diagnostics.Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "LookupPrivilegeValue() failed with unrecognized error code {0}", error));
+                            System.Diagnostics.Debug.Fail($"LookupPrivilegeValue() failed with unrecognized error code {error}");
                             throw new InvalidOperationException();
                         }
                     }
@@ -292,7 +292,7 @@ namespace System.Security.AccessControl
                 }
                 else if (error != 0)
                 {
-                    System.Diagnostics.Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "WindowsIdentity.GetCurrentThreadToken() failed with unrecognized error code {0}", error));
+                    System.Diagnostics.Debug.Fail($"WindowsIdentity.GetCurrentThreadToken() failed with unrecognized error code {error}");
                     throw new InvalidOperationException();
                 }
             }
@@ -542,7 +542,7 @@ namespace System.Security.AccessControl
             }
             else if (error != 0)
             {
-                System.Diagnostics.Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "AdjustTokenPrivileges() failed with unrecognized error code {0}", error));
+                System.Diagnostics.Debug.Fail($"AdjustTokenPrivileges() failed with unrecognized error code {error}");
                 throw new InvalidOperationException();
             }
         }
@@ -625,7 +625,7 @@ namespace System.Security.AccessControl
             }
             else if (error != 0)
             {
-                System.Diagnostics.Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "AdjustTokenPrivileges() failed with unrecognized error code {0}", error));
+                System.Diagnostics.Debug.Fail($"AdjustTokenPrivileges() failed with unrecognized error code {error}");
                 throw new InvalidOperationException();
             }
         }
index cc4a822..6a5e68b 100644 (file)
@@ -20,13 +20,13 @@ namespace System.Security.AccessControl
         }
 
         public PrivilegeNotHeldException(string privilege)
-            : base(string.Format(CultureInfo.CurrentCulture, SR.PrivilegeNotHeld_Named, privilege))
+            : base(SR.Format(SR.PrivilegeNotHeld_Named, privilege))
         {
             _privilegeName = privilege;
         }
 
         public PrivilegeNotHeldException(string privilege, Exception inner)
-            : base(string.Format(CultureInfo.CurrentCulture, SR.PrivilegeNotHeld_Named, privilege), inner)
+            : base(SR.Format(SR.PrivilegeNotHeld_Named, privilege), inner)
         {
             _privilegeName = privilege;
         }
index c490293..05b0e02 100644 (file)
@@ -240,12 +240,12 @@ namespace System.Security.AccessControl
                 // Indicates that the marshaling logic in GetBinaryForm is busted
                 //
 
-                Debug.Assert(false, "binaryForm produced invalid output");
+                Debug.Fail("binaryForm produced invalid output");
                 throw new InvalidOperationException();
             }
             else if (error != Interop.Errors.ERROR_SUCCESS)
             {
-                Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32.ConvertSdToSddl returned {0}", error));
+                Debug.Fail($"Win32.ConvertSdToSddl returned {error}");
                 throw new InvalidOperationException();
             }
 
@@ -666,7 +666,7 @@ nameof(sddlForm));
                     }
                     else if (error != Interop.Errors.ERROR_SUCCESS)
                     {
-                        Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unexpected error out of Win32.ConvertStringSdToSd: {0}", error));
+                        Debug.Fail($"Unexpected error out of Win32.ConvertStringSdToSd: {error}");
                         throw new Win32Exception(error, SR.Format(SR.AccessControl_UnexpectedError, error));
                     }
                 }
index d58f46e..720d225 100644 (file)
@@ -300,7 +300,7 @@ nameof(handle));
                 else
                 {
                     // both are null, shouldn't happen
-                    Debug.Assert(false, "Internal error: both name and handle are null");
+                    Debug.Fail("Internal error: both name and handle are null");
                     throw new ArgumentException();
                 }
 
index ef1df78..0d5cc03 100644 (file)
@@ -513,7 +513,7 @@ namespace System.Security.Claims
         {
             if (!TryRemoveClaim(claim))
             {
-                throw new InvalidOperationException(string.Format(SR.InvalidOperation_ClaimCannotBeRemoved, claim));
+                throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ClaimCannotBeRemoved, claim));
             }
         }
 
index fcd82d3..21e8e01 100644 (file)
@@ -114,7 +114,7 @@ namespace System.Security.Cryptography
                 if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
                 {
                     throw new PlatformNotSupportedException(
-                        string.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
+                        SR.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
                 }
 
                 // Map curve name to algorithm to support pre-Win10 curves
@@ -144,7 +144,7 @@ namespace System.Security.Cryptography
                             errorCode == Interop.NCrypt.ErrorCode.NTE_NOT_SUPPORTED)
                         {
                             throw new PlatformNotSupportedException(
-                                string.Format(SR.Cryptography_CurveNotSupported, curve.Oid.FriendlyName), e);
+                                SR.Format(SR.Cryptography_CurveNotSupported, curve.Oid.FriendlyName), e);
                         }
 
                         throw;
@@ -168,7 +168,7 @@ namespace System.Security.Cryptography
                             keySize = 521;
                             break;
                         default:
-                            Debug.Fail(string.Format("Unknown algorithm {0}", algorithm.ToString()));
+                            Debug.Fail($"Unknown algorithm {algorithm}");
                             throw new ArgumentException(SR.Cryptography_InvalidKeySize);
                     }
 
@@ -184,7 +184,7 @@ namespace System.Security.Cryptography
             else
             {
                 throw new PlatformNotSupportedException(
-                    string.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
+                    SR.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
             }
 
             _lastAlgorithm = algorithm;
index 0078075..b4ac0de 100644 (file)
@@ -84,7 +84,7 @@ namespace System.Security.Cryptography
                     throw new ArgumentNullException(nameof(Oid));
 
                 if (string.IsNullOrEmpty(value.Value) && string.IsNullOrEmpty(value.FriendlyName))
-                    throw new ArgumentException(string.Format(SR.Cryptography_InvalidCurveOid));
+                    throw new ArgumentException(SR.Cryptography_InvalidCurveOid);
 
                 _oid = value;
             }
@@ -247,7 +247,7 @@ namespace System.Security.Cryptography
                 Debug.Assert(CurveType == ECCurveType.Implicit);
                 if (HasAnyExplicitParameters() || Oid != null)
                 {
-                    throw new CryptographicException(string.Format(SR.Cryptography_CurveNotSupported, CurveType.ToString()));
+                    throw new CryptographicException(SR.Format(SR.Cryptography_CurveNotSupported, CurveType.ToString()));
                 }
             }
         }
index b6bf91e..43ae9aa 100644 (file)
@@ -97,7 +97,7 @@ namespace Internal.Cryptography
             }
             else
             {
-                throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, curve.Value.CurveType.ToString()));
+                throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, curve.Value.CurveType.ToString()));
             }
 
             try
@@ -112,7 +112,7 @@ namespace Internal.Cryptography
                 if (curve.Value.IsNamed &&
                     errorCode == ErrorCode.NTE_INVALID_PARAMETER || errorCode == ErrorCode.NTE_NOT_SUPPORTED)
                 {
-                    throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, curve.Value.Oid.FriendlyName), e);
+                    throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, curve.Value.Oid.FriendlyName), e);
                 }
                 throw;
             }
index 22d5d3b..3065f22 100644 (file)
@@ -63,8 +63,8 @@ namespace System.Security.Cryptography
                 return "nistP521";
             }
 
-            Debug.Fail(string.Format("Unknown curve {0}", algorithm));
-            throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, algorithm));
+            Debug.Fail($"Unknown curve {algorithm}");
+            throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, algorithm));
         }
 
         /// <summary>
@@ -147,7 +147,7 @@ namespace System.Security.Cryptography
             if (curve.IsNamed)
             {
                 if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
-                    throw new PlatformNotSupportedException(string.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
+                    throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
 
                 // Map curve name to algorithm to support pre-Win10 curves
                 alg = algorithmResolver(curve.Oid.FriendlyName);
@@ -166,7 +166,7 @@ namespace System.Security.Cryptography
                     }
                     else
                     {
-                        Debug.Fail(string.Format("Unknown algorithm {0}", alg.ToString()));
+                        Debug.Fail($"Unknown algorithm {alg}");
                         throw new ArgumentException(SR.Cryptography_InvalidKeySize);
                     }
                 }
@@ -185,7 +185,7 @@ namespace System.Security.Cryptography
             }
             else
             {
-                throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
+                throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
             }
 
             try
@@ -200,7 +200,7 @@ namespace System.Security.Cryptography
                     errorCode == Interop.NCrypt.ErrorCode.NTE_NOT_SUPPORTED)
                 {
                     string target = curve.IsNamed ? curve.Oid.FriendlyName : curve.CurveType.ToString();
-                    throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, target), e);
+                    throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, target), e);
                 }
 
                 throw;
index bcf4c70..c6533e0 100644 (file)
@@ -58,7 +58,7 @@ namespace System.Security.Cryptography
             if (curve.IsNamed)
             {
                 if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
-                    throw new PlatformNotSupportedException(string.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
+                    throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
 
                 // Map curve name to algorithm to support pre-Win10 curves
                 CngAlgorithm alg = CngKey.EcdhCurveNameToAlgorithm(curve.Oid.FriendlyName);
@@ -79,7 +79,7 @@ namespace System.Security.Cryptography
                         keySize = 521;
                     else
                     {
-                        Debug.Fail(string.Format("Unknown algorithm {0}", alg.ToString()));
+                        Debug.Fail($"Unknown algorithm {alg}");
                         throw new ArgumentException(SR.Cryptography_InvalidKeySize);
                     }
                     CngKey key = _core.GetOrGenerateKey(keySize, alg);
@@ -93,7 +93,7 @@ namespace System.Security.Cryptography
             }
             else
             {
-                throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
+                throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
             }
         }
 
index e150479..42bc482 100644 (file)
@@ -47,7 +47,7 @@ namespace System.Security.Cryptography
             if (curve.IsNamed)
             {
                 if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
-                    throw new PlatformNotSupportedException(string.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
+                    throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
 
                 // Map curve name to algorithm to support pre-Win10 curves
                 CngAlgorithm alg = CngKey.EcdsaCurveNameToAlgorithm(curve.Oid.FriendlyName);
@@ -67,7 +67,7 @@ namespace System.Security.Cryptography
                         keySize = 521;
                     else
                     {
-                        Debug.Fail(string.Format("Unknown algorithm {0}", alg.ToString()));
+                        Debug.Fail($"Unknown algorithm {alg}");
                         throw new ArgumentException(SR.Cryptography_InvalidKeySize);
                     }
                     CngKey key = _core.GetOrGenerateKey(keySize, alg);
@@ -81,7 +81,7 @@ namespace System.Security.Cryptography
             }
             else
             {
-                throw new PlatformNotSupportedException(string.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
+                throw new PlatformNotSupportedException(SR.Format(SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
             }
         }
 
index 854398c..270f634 100644 (file)
@@ -436,7 +436,7 @@ namespace Internal.NativeCrypto
                     }
                     default:
                     {
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected key param {keyParam}");
                         break;
                     }
                 }
@@ -593,7 +593,7 @@ namespace Internal.NativeCrypto
                     }
                 default:
                     {
-                        Debug.Assert(false);
+                        Debug.Fail($"Unexpected key param {keyParam}");
                         break;
                     }
             }
index f10c5a3..02b35e7 100644 (file)
@@ -196,7 +196,7 @@ namespace System.Security.Cryptography
             if (PublicOnly)
                 throw new CryptographicException(SR.Cryptography_CSP_NoPrivateKey);
             if (rgbHash.Length != SHA1_HASHSIZE)
-                throw new CryptographicException(string.Format(SR.Cryptography_InvalidHashSize, "SHA1", SHA1_HASHSIZE));
+                throw new CryptographicException(SR.Format(SR.Cryptography_InvalidHashSize, "SHA1", SHA1_HASHSIZE));
 
             // Only SHA1 allowed; the default value is SHA1
             if (str != null && !string.Equals(str, "SHA1", StringComparison.OrdinalIgnoreCase))
index 6bd2e33..015cff1 100644 (file)
@@ -458,7 +458,7 @@ namespace System.Security.Cryptography
             int calgHash = CapiHelper.NameOrOidToHashAlgId(str, OidGroup.HashAlgorithm);
 
             if (rgbHash.Length != _sha1.HashSize / 8)
-                throw new CryptographicException(string.Format(SR.Cryptography_InvalidHashSize, "SHA1", _sha1.HashSize / 8));
+                throw new CryptographicException(SR.Format(SR.Cryptography_InvalidHashSize, "SHA1", _sha1.HashSize / 8));
 
             return CapiHelper.SignValue(
                 SafeProvHandle,
index c1db134..1133625 100644 (file)
@@ -227,7 +227,7 @@ namespace Internal.Cryptography.Pal.Windows
                     return new SubjectIdentifierOrKey(SubjectIdentifierOrKeyType.SubjectKeyIdentifier, subjectIdentifier.Value);
 
                 default:
-                    Debug.Assert(false);  // Only the framework can construct SubjectIdentifier's so if we got a bad value here, that's our fault.
+                    Debug.Fail("Only the framework can construct SubjectIdentifier's so if we got a bad value here, that's our fault.");
                     throw new CryptographicException(SR.Format(SR.Cryptography_Cms_Invalid_Subject_Identifier_Type, subjectIdentifierType));
             }
         }
index 5e36047..32f1e91 100644 (file)
@@ -420,14 +420,7 @@ namespace Internal.Cryptography.Pal
                         break;
 
                     default:
-                        Debug.Fail(
-                            string.Format(
-                                "Invalid parser state. Position {0}, State {1}, Character {2}, String \"{3}\"",
-                                pos,
-                                state,
-                                c,
-                                stringForm));
-
+                        Debug.Fail($"Invalid parser state. Position {pos}, State {state}, Character {c}, String \"{stringForm}\"");
                         throw new CryptographicException(SR.Cryptography_Invalid_X500Name);
                 }
 
index 1558d90..bbf75e8 100644 (file)
@@ -82,7 +82,7 @@ namespace System.Security.Cryptography.X509Certificates
             uint allFlags = 0x71F1;
             uint dwFlags = (uint)flags;
             if ((dwFlags & ~allFlags) != 0)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Arg_EnumIllegalVal, "flag"));
+                throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, "flag"));
         }
 
         private volatile string _lazyDistinguishedName;
index 1270944..82eec16 100644 (file)
@@ -35,7 +35,7 @@ namespace System.Security.Cryptography.X509Certificates
             set
             {
                 if (value < X509RevocationMode.NoCheck || value > X509RevocationMode.Offline)
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Arg_EnumIllegalVal, nameof(value)));
+                    throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, nameof(value)));
                 _revocationMode = value;
             }
         }
@@ -49,7 +49,7 @@ namespace System.Security.Cryptography.X509Certificates
             set
             {
                 if (value < X509RevocationFlag.EndCertificateOnly || value > X509RevocationFlag.ExcludeRoot)
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Arg_EnumIllegalVal, nameof(value)));
+                    throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, nameof(value)));
                 _revocationFlag = value;
             }
         }
@@ -63,7 +63,7 @@ namespace System.Security.Cryptography.X509Certificates
             set
             {
                 if (value < X509VerificationFlags.NoFlag || value > X509VerificationFlags.AllFlags)
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Arg_EnumIllegalVal, nameof(value)));
+                    throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, nameof(value)));
                 _verificationFlags = value;
             }
         }
index f432a2e..1e04f6b 100644 (file)
@@ -40,7 +40,7 @@ namespace System.Security.Cryptography.X509Certificates
         public X509Store(StoreName storeName, StoreLocation storeLocation)
         {
             if (storeLocation != StoreLocation.CurrentUser && storeLocation != StoreLocation.LocalMachine)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Arg_EnumIllegalVal, nameof(storeLocation)));
+                throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, nameof(storeLocation)));
 
             switch (storeName)
             {
@@ -69,7 +69,7 @@ namespace System.Security.Cryptography.X509Certificates
                     Name = "TrustedPublisher";
                     break;
                 default:
-                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Arg_EnumIllegalVal, nameof(storeName)));
+                    throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, nameof(storeName)));
             }
 
             Location = storeLocation;
@@ -84,7 +84,7 @@ namespace System.Security.Cryptography.X509Certificates
         public X509Store(string storeName, StoreLocation storeLocation)
         {
             if (storeLocation != StoreLocation.CurrentUser && storeLocation != StoreLocation.LocalMachine)
-                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Arg_EnumIllegalVal, nameof(storeLocation)));
+                throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, nameof(storeLocation)));
 
             Location = storeLocation;
             Name = storeName;
index 03b1325..7cff5aa 100644 (file)
@@ -378,7 +378,7 @@ namespace System.Security.Cryptography.Xml
                             // This is the self-referential case. First, check that we have a document context.
                             // The Enveloped Signature does not discard comments as per spec; those will be omitted during the transform chain process
                             if (document == null)
-                                throw new CryptographicException(string.Format(CultureInfo.CurrentCulture, SR.Cryptography_Xml_SelfReferenceRequiresContext, _uri));
+                                throw new CryptographicException(SR.Format(SR.Cryptography_Xml_SelfReferenceRequiresContext, _uri));
 
                             // Normalize the containing document
                             resolver = (SignedXml.ResolverSet ? SignedXml._xmlResolver : new XmlSecureResolver(new XmlUrlResolver(), baseUri));
@@ -395,7 +395,7 @@ namespace System.Security.Cryptography.Xml
                             {
                                 // This is a self referencial case
                                 if (document == null)
-                                    throw new CryptographicException(string.Format(CultureInfo.CurrentCulture, SR.Cryptography_Xml_SelfReferenceRequiresContext, _uri));
+                                    throw new CryptographicException(SR.Format(SR.Cryptography_Xml_SelfReferenceRequiresContext, _uri));
 
                                 // We should not discard comments here!!!
                                 resolver = (SignedXml.ResolverSet ? SignedXml._xmlResolver : new XmlSecureResolver(new XmlUrlResolver(), baseUri));
index f87416e..797ed6d 100644 (file)
@@ -100,7 +100,7 @@ namespace System.Security.Cryptography.Xml
                 {
                     _canonicalizationMethodTransform = CryptoHelpers.CreateFromName<Transform>(CanonicalizationMethod);
                     if (_canonicalizationMethodTransform == null)
-                        throw new CryptographicException(string.Format(CultureInfo.CurrentCulture, SR.Cryptography_Xml_CreateTransformFailed, CanonicalizationMethod));
+                        throw new CryptographicException(SR.Format(SR.Cryptography_Xml_CreateTransformFailed, CanonicalizationMethod));
                     _canonicalizationMethodTransform.SignedXml = SignedXml;
                     _canonicalizationMethodTransform.Reference = null;
                 }
index aa1993c..e71fb29 100644 (file)
@@ -231,21 +231,15 @@ namespace System.Security.Cryptography.Xml
             string keyName = null;
             if (cspKey != null && cspKey.CspKeyContainerInfo.KeyContainerName != null)
             {
-                keyName = string.Format(CultureInfo.InvariantCulture,
-                                        "\"{0}\"",
-                                        cspKey.CspKeyContainerInfo.KeyContainerName);
+                keyName = "\"" + cspKey.CspKeyContainerInfo.KeyContainerName + "\"";
             }
             else if (certificate2 != null)
             {
-                keyName = string.Format(CultureInfo.InvariantCulture,
-                                        "\"{0}\"",
-                                        certificate2.GetNameInfo(X509NameType.SimpleName, false));
+                keyName = "\"" + certificate2.GetNameInfo(X509NameType.SimpleName, false) + "\"";
             }
             else if (certificate != null)
             {
-                keyName = string.Format(CultureInfo.InvariantCulture,
-                                        "\"{0}\"",
-                                        certificate.Subject);
+                keyName = "\"" + certificate.Subject + "\"";
             }
             else
             {
@@ -293,7 +287,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_BeginCanonicalization,
                                                   canonicalizationTransform.Algorithm,
                                                   canonicalizationTransform.GetType().Name);
@@ -305,7 +299,7 @@ namespace System.Security.Cryptography.Xml
 
             if (VerboseLoggingEnabled)
             {
-                string canonicalizationSettings = string.Format(CultureInfo.InvariantCulture,
+                string canonicalizationSettings = SR.Format(CultureInfo.InvariantCulture,
                                                                 SR.Log_CanonicalizationSettings,
                                                                 canonicalizationTransform.Resolver.GetType(),
                                                                 canonicalizationTransform.BaseURI);
@@ -330,7 +324,7 @@ namespace System.Security.Cryptography.Xml
             {
                 MethodInfo validationMethod = formatValidator.Method;
 
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_CheckSignatureFormat,
                                                   validationMethod.Module.Assembly.FullName,
                                                   validationMethod.DeclaringType.FullName,
@@ -351,7 +345,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_CheckSignedInfo,
                                                   signedInfo.Id != null ? signedInfo.Id : NullString);
                 WriteLine(signedXml, TraceEventType.Information, SignedXmlDebugEvent.BeginCheckSignedInfo, logMessage);
@@ -377,7 +371,7 @@ namespace System.Security.Cryptography.Xml
 
             if (VerboseLoggingEnabled)
             {
-                string contextData = string.Format(CultureInfo.InvariantCulture,
+                string contextData = SR.Format(CultureInfo.InvariantCulture,
                                                    SR.Log_XmlContext,
                                                    context != null ? context.OuterXml : NullString);
 
@@ -407,7 +401,7 @@ namespace System.Security.Cryptography.Xml
 
             if (VerboseLoggingEnabled)
             {
-                string contextData = string.Format(CultureInfo.InvariantCulture,
+                string contextData = SR.Format(CultureInfo.InvariantCulture,
                                                    SR.Log_XmlContext,
                                                    context != null ? context.OuterXml : NullString);
 
@@ -432,7 +426,7 @@ namespace System.Security.Cryptography.Xml
             {
                 using (StreamReader reader = new StreamReader(canonicalizationTransform.GetOutput(typeof(Stream)) as Stream))
                 {
-                    string logMessage = string.Format(CultureInfo.InvariantCulture,
+                    string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                       SR.Log_CanonicalizedOutput,
                                                       reader.ReadToEnd());
                     WriteLine(signedXml,
@@ -485,7 +479,7 @@ namespace System.Security.Cryptography.Xml
                     validAlgorithmBuilder.AppendFormat("\"{0}\"", validAlgorithm);
                 }
 
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_UnsafeCanonicalizationMethod,
                                                   algorithm,
                                                   validAlgorithmBuilder.ToString());
@@ -535,7 +529,7 @@ namespace System.Security.Cryptography.Xml
                     validAlgorithmBuilder.AppendFormat("\"{0}\"", validAlgorithm);
                 }
 
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_UnsafeTransformMethod,
                                                   algorithm,
                                                   validAlgorithmBuilder.ToString());
@@ -559,7 +553,7 @@ namespace System.Security.Cryptography.Xml
                 {
                     foreach (XmlAttribute propagatedNamespace in namespaces)
                     {
-                        string propagationMessage = string.Format(CultureInfo.InvariantCulture,
+                        string propagationMessage = SR.Format(CultureInfo.InvariantCulture,
                                                                   SR.Log_PropagatingNamespace,
                                                                   propagatedNamespace.Name,
                                                                   propagatedNamespace.Value);
@@ -609,7 +603,7 @@ namespace System.Security.Cryptography.Xml
                 } while (readBytes == buffer.Length);
 
                 // Log out information about it
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_TransformedReferenceContents,
                                                   Encoding.UTF8.GetString(ms.ToArray()));
                 WriteLine(reference,
@@ -648,7 +642,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_SigningAsymmetric,
                                                   GetKeyName(key),
                                                   signatureDescription.GetType().Name,
@@ -674,7 +668,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_SigningHmac,
                                                   key.GetType().Name);
 
@@ -699,7 +693,7 @@ namespace System.Security.Cryptography.Xml
             {
                 HashAlgorithm hashAlgorithm = CryptoHelpers.CreateFromName<HashAlgorithm>(reference.DigestMethod);
                 string hashAlgorithmName = hashAlgorithm == null ? "null" : hashAlgorithm.GetType().Name;
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_SigningReference,
                                                   GetObjectId(reference),
                                                   reference.Uri,
@@ -724,7 +718,7 @@ namespace System.Security.Cryptography.Xml
         {
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_VerificationFailed,
                                                   failureLocation);
 
@@ -774,7 +768,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_KeyUsages,
                                                   keyUsages.KeyUsages,
                                                   GetOidName(keyUsages.Oid),
@@ -799,7 +793,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_VerifyReference,
                                                   GetObjectId(reference),
                                                   reference.Uri,
@@ -834,7 +828,7 @@ namespace System.Security.Cryptography.Xml
             {
                 HashAlgorithm hashAlgorithm = CryptoHelpers.CreateFromName<HashAlgorithm>(reference.DigestMethod);
                 string hashAlgorithmName = hashAlgorithm == null ? "null" : hashAlgorithm.GetType().Name;
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_ReferenceHash,
                                                   GetObjectId(reference),
                                                   reference.DigestMethod,
@@ -875,7 +869,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_VerifySignedInfoAsymmetric,
                                                   GetKeyName(key),
                                                   signatureDescription.GetType().Name,
@@ -889,12 +883,12 @@ namespace System.Security.Cryptography.Xml
 
             if (VerboseLoggingEnabled)
             {
-                string hashLog = string.Format(CultureInfo.InvariantCulture,
+                string hashLog = SR.Format(CultureInfo.InvariantCulture,
                                                SR.Log_ActualHashValue,
                                                FormatBytes(actualHashValue));
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, hashLog);
 
-                string signatureLog = string.Format(CultureInfo.InvariantCulture,
+                string signatureLog = SR.Format(CultureInfo.InvariantCulture,
                                                     SR.Log_RawSignatureValue,
                                                     FormatBytes(signatureValue));
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, signatureLog);
@@ -919,7 +913,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_VerifySignedInfoHmac,
                                                   mac.GetType().Name);
                 WriteLine(signedXml,
@@ -930,12 +924,12 @@ namespace System.Security.Cryptography.Xml
 
             if (VerboseLoggingEnabled)
             {
-                string hashLog = string.Format(CultureInfo.InvariantCulture,
+                string hashLog = SR.Format(CultureInfo.InvariantCulture,
                                                SR.Log_ActualHashValue,
                                                FormatBytes(actualHashValue));
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, hashLog);
 
-                string signatureLog = string.Format(CultureInfo.InvariantCulture,
+                string signatureLog = SR.Format(CultureInfo.InvariantCulture,
                                                     SR.Log_RawSignatureValue,
                                                     FormatBytes(signatureValue));
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, signatureLog);
@@ -956,7 +950,7 @@ namespace System.Security.Cryptography.Xml
 
             if (InformationLoggingEnabled)
             {
-                string buildMessage = string.Format(CultureInfo.InvariantCulture,
+                string buildMessage = SR.Format(CultureInfo.InvariantCulture,
                                                     SR.Log_BuildX509Chain,
                                                     GetKeyName(certificate));
                 WriteLine(signedXml,
@@ -968,27 +962,27 @@ namespace System.Security.Cryptography.Xml
             if (VerboseLoggingEnabled)
             {
                 // Dump out the flags and other miscelanious information used for building
-                string revocationMode = string.Format(CultureInfo.InvariantCulture,
+                string revocationMode = SR.Format(CultureInfo.InvariantCulture,
                                                       SR.Log_RevocationMode,
                                                       chain.ChainPolicy.RevocationFlag);
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.X509Verification, revocationMode);
 
-                string revocationFlag = string.Format(CultureInfo.InvariantCulture,
+                string revocationFlag = SR.Format(CultureInfo.InvariantCulture,
                                                       SR.Log_RevocationFlag,
                                                       chain.ChainPolicy.RevocationFlag);
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.X509Verification, revocationFlag);
 
-                string verificationFlags = string.Format(CultureInfo.InvariantCulture,
+                string verificationFlags = SR.Format(CultureInfo.InvariantCulture,
                                                          SR.Log_VerificationFlag,
                                                          chain.ChainPolicy.VerificationFlags);
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.X509Verification, verificationFlags);
 
-                string verificationTime = string.Format(CultureInfo.InvariantCulture,
+                string verificationTime = SR.Format(CultureInfo.InvariantCulture,
                                                         SR.Log_VerificationTime,
                                                         chain.ChainPolicy.VerificationTime);
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.X509Verification, verificationTime);
 
-                string urlTimeout = string.Format(CultureInfo.InvariantCulture,
+                string urlTimeout = SR.Format(CultureInfo.InvariantCulture,
                                                   SR.Log_UrlTimeout,
                                                   chain.ChainPolicy.UrlRetrievalTimeout);
                 WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.X509Verification, urlTimeout);
@@ -1001,7 +995,7 @@ namespace System.Security.Cryptography.Xml
                 {
                     if (status.Status != X509ChainStatusFlags.NoError)
                     {
-                        string logMessage = string.Format(CultureInfo.InvariantCulture,
+                        string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                           SR.Log_X509ChainError,
                                                           status.Status,
                                                           status.StatusInformation);
@@ -1048,7 +1042,7 @@ namespace System.Security.Cryptography.Xml
             {
                 HashAlgorithm hashAlgorithm = CryptoHelpers.CreateFromName<HashAlgorithm>(reference.DigestMethod);
                 string hashAlgorithmName = hashAlgorithm == null ? "null" : hashAlgorithm.GetType().Name;
-                string logMessage = string.Format(CultureInfo.InvariantCulture,
+                string logMessage = SR.Format(CultureInfo.InvariantCulture,
                                                     SR.Log_SignedXmlRecursionLimit,
                                                     GetObjectId(reference),
                                                     reference.DigestMethod,
index 4d476db..35f78db 100644 (file)
@@ -210,7 +210,7 @@ namespace System.Security.Principal
                     // Rare case that we have defined a type of identity reference and not included it in the code logic above.  
                     // To avoid this we do not allow IdentityReference to be subclassed outside of the BCL.
                     // 
-                    Debug.Assert(false, "Source type is an IdentityReference type which has not been included in translation logic.");
+                    Debug.Fail("Source type is an IdentityReference type which has not been included in translation logic.");
                     throw new NotSupportedException();
                 }
             }
@@ -272,7 +272,7 @@ namespace System.Security.Principal
                         // Rare case that we have defined a type of identity reference and not included it in the code logic above.  
                         // To avoid this we do not allow IdentityReference to be subclassed outside of the BCL.
                         // 
-                        Debug.Assert(false, "Source type is an IdentityReference type which has not been included in translation logic.");
+                        Debug.Fail("Source type is an IdentityReference type which has not been included in translation logic.");
                         throw new NotSupportedException();
                     }
                 }
@@ -365,7 +365,7 @@ namespace System.Security.Principal
                         // Rare case that we have defined a type of identity reference and not included it in the code logic above.  
                         // To avoid this we do not allow IdentityReference to be subclassed outside of the BCL.
                         // 
-                        Debug.Assert(false, "Source type is an IdentityReference type which has not been included in translation logic.");
+                        Debug.Fail("Source type is an IdentityReference type which has not been included in translation logic.");
                         throw new NotSupportedException();
                     }
                 }
index 8d515f0..8ccf20b 100644 (file)
@@ -265,7 +265,7 @@ namespace System.Security.Principal
                     {
                         // this should never happen since we are already validating account name length in constructor and 
                         // it is less than this limit
-                        Debug.Assert(false, "NTAccount::TranslateToSids - source account name is too long.");
+                        Debug.Fail("NTAccount::TranslateToSids - source account name is too long.");
                         throw new InvalidOperationException();
                     }
 
@@ -314,7 +314,7 @@ namespace System.Security.Principal
 
                     if (unchecked((int)win32ErrorCode) != Interop.Errors.ERROR_TRUSTED_RELATIONSHIP_FAILURE)
                     {
-                        Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Interop.LsaLookupNames(2) returned unrecognized error {0}", win32ErrorCode));
+                        Debug.Fail($"Interop.LsaLookupNames(2) returned unrecognized error {win32ErrorCode}");
                     }
 
                     throw new Win32Exception(unchecked((int)win32ErrorCode));
index a0da206..32a4412 100644 (file)
@@ -540,7 +540,7 @@ nameof(binaryForm));
             }
             else if (Error != Interop.Errors.ERROR_SUCCESS)
             {
-                Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32.CreateSidFromString returned unrecognized error {0}", Error));
+                Debug.Fail($"Win32.CreateSidFromString returned unrecognized error {Error}");
                 throw new Win32Exception(Error);
             }
 
@@ -635,7 +635,7 @@ nameof(binaryForm));
                 }
                 else if (ErrorCode != Interop.Errors.ERROR_SUCCESS)
                 {
-                    Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32.GetWindowsAccountDomainSid returned unrecognized error {0}", ErrorCode));
+                    Debug.Fail($"Win32.GetWindowsAccountDomainSid returned unrecognized error {ErrorCode}");
                     throw new Win32Exception(ErrorCode);
                 }
 
@@ -658,7 +658,7 @@ nameof(binaryForm));
             }
             else if (Error != Interop.Errors.ERROR_SUCCESS)
             {
-                Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32.CreateWellKnownSid returned unrecognized error {0}", Error));
+                Debug.Fail($"Win32.CreateWellKnownSid returned unrecognized error {Error}");
                 throw new Win32Exception(Error);
             }
 
@@ -882,7 +882,7 @@ nameof(binaryForm));
             }
             else if (Error != Interop.Errors.ERROR_SUCCESS)
             {
-                Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Win32.GetWindowsAccountDomainSid returned unrecognized error {0}", Error));
+                Debug.Fail($"Win32.GetWindowsAccountDomainSid returned unrecognized error {Error}");
                 throw new Win32Exception(Error);
             }
             return ResultSid;
@@ -1120,7 +1120,7 @@ nameof(binaryForm));
                 {
                     uint win32ErrorCode = Interop.Advapi32.LsaNtStatusToWinError(ReturnCode);
 
-                    Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Interop.LsaLookupSids returned {0}", win32ErrorCode));
+                    Debug.Fail($"Interop.LsaLookupSids returned {win32ErrorCode}");
                     throw new Win32Exception(unchecked((int)win32ErrorCode));
                 }
 
index a4650d1..9b5e0c3 100644 (file)
@@ -307,7 +307,7 @@ namespace System.ServiceModel.Syndication
 
                         if (!parsed || (hour < 0 || hour > 23))
                         {
-                            throw new FormatException(string.Format(SR.InvalidSkipHourValue, value));
+                            throw new FormatException(SR.Format(SR.InvalidSkipHourValue, value));
                         }
 
                         skipHours.Add(hour);
index 0f0b680..dba9184 100644 (file)
@@ -416,7 +416,7 @@ namespace System.ServiceProcess
                 catch (Exception e)
                 {
                     _status.currentState = ServiceControlStatus.STATE_PAUSED;
-                    WriteLogEntry(SR.Format(SR.ContinueFailed, e.ToString()), true);
+                    WriteLogEntry(SR.Format(SR.ContinueFailed, e), true);
 
                     // We re-throw the exception so that the advapi32 code can report
                     // ERROR_EXCEPTION_IN_SERVICE as it would for native services.
@@ -438,7 +438,7 @@ namespace System.ServiceProcess
             }
             catch (Exception e)
             {
-                WriteLogEntry(SR.Format(SR.CommandFailed, e.ToString()), true);
+                WriteLogEntry(SR.Format(SR.CommandFailed, e), true);
 
                 // We should re-throw the exception so that the advapi32 code can report
                 // ERROR_EXCEPTION_IN_SERVICE as it would for native services.
@@ -459,7 +459,7 @@ namespace System.ServiceProcess
                 catch (Exception e)
                 {
                     _status.currentState = ServiceControlStatus.STATE_RUNNING;
-                    WriteLogEntry(SR.Format(SR.PauseFailed, e.ToString()), true);
+                    WriteLogEntry(SR.Format(SR.PauseFailed, e), true);
 
                     // We re-throw the exception so that the advapi32 code can report
                     // ERROR_EXCEPTION_IN_SERVICE as it would for native services.
@@ -487,7 +487,7 @@ namespace System.ServiceProcess
             }
             catch (Exception e)
             {
-                WriteLogEntry(SR.Format(SR.PowerEventFailed, e.ToString()), true);
+                WriteLogEntry(SR.Format(SR.PowerEventFailed, e), true);
 
                 // We rethrow the exception so that advapi32 code can report
                 // ERROR_EXCEPTION_IN_SERVICE as it would for native services.
@@ -503,7 +503,7 @@ namespace System.ServiceProcess
             }
             catch (Exception e)
             {
-                WriteLogEntry(SR.Format(SR.SessionChangeFailed, e.ToString()), true);
+                WriteLogEntry(SR.Format(SR.SessionChangeFailed, e), true);
 
                 // We rethrow the exception so that advapi32 code can report
                 // ERROR_EXCEPTION_IN_SERVICE as it would for native services.
@@ -535,7 +535,7 @@ namespace System.ServiceProcess
                 {
                     _status.currentState = previousState;
                     SetServiceStatus(_statusHandle, pStatus);
-                    WriteLogEntry(SR.Format(SR.StopFailed, e.ToString()), true);
+                    WriteLogEntry(SR.Format(SR.StopFailed, e), true);
                     throw;
                 }
             }
@@ -546,7 +546,7 @@ namespace System.ServiceProcess
             try
             {
                 OnShutdown();
-                WriteLogEntry(SR.Format(SR.ShutdownOK));
+                WriteLogEntry(SR.ShutdownOK);
 
                 if (_status.currentState == ServiceControlStatus.STATE_PAUSED || _status.currentState == ServiceControlStatus.STATE_RUNNING)
                 {
@@ -561,7 +561,7 @@ namespace System.ServiceProcess
             }
             catch (Exception e)
             {
-                WriteLogEntry(SR.Format(SR.ShutdownFailed, e.ToString()), true);
+                WriteLogEntry(SR.Format(SR.ShutdownFailed, e), true);
                 throw;
             }
         }
@@ -851,7 +851,7 @@ namespace System.ServiceProcess
             }
             catch (Exception e)
             {
-                WriteLogEntry(SR.Format(SR.StartFailed, e.ToString()), true);
+                WriteLogEntry(SR.Format(SR.StartFailed, e), true);
                 _status.currentState = ServiceControlStatus.STATE_STOPPED;
 
                 // We capture the exception so that it can be propagated
index 9372f66..8d0c2a6 100644 (file)
@@ -259,7 +259,7 @@ namespace System.ServiceProcess
                 }
 
                 if (!ServiceBase.ValidServiceName(value))
-                    throw new ArgumentException(SR.Format(SR.ServiceName, value, ServiceBase.MaxNameLength.ToString(CultureInfo.CurrentCulture)));
+                    throw new ArgumentException(SR.Format(SR.ServiceName, value, ServiceBase.MaxNameLength.ToString()));
 
                 Close();
                 _name = value;
@@ -488,7 +488,7 @@ namespace System.ServiceProcess
                 string userGivenName = String.IsNullOrEmpty(_eitherName) ? _displayName : _eitherName;
 
                 if (String.IsNullOrEmpty(userGivenName))
-                    throw new InvalidOperationException(SR.Format(SR.ServiceName, userGivenName, ServiceBase.MaxNameLength.ToString(CultureInfo.CurrentCulture)));
+                    throw new InvalidOperationException(SR.Format(SR.ServiceName, userGivenName, ServiceBase.MaxNameLength.ToString()));
 
                 // Try it as a display name
                 string result = GetServiceKeyName(_serviceManagerHandle, userGivenName);
index fc23149..570c548 100644 (file)
@@ -385,9 +385,7 @@ namespace System.Text
                     Debug.Assert(((bLastVirama ? 1 : 0) + (bLastATR ? 1 : 0) +
                                (bLastDevenagariStressAbbr ? 1 : 0) +
                                ((cLastCharForNextNukta > 0) ? 1 : 0)) == 1,
-                        string.Format(CultureInfo.InvariantCulture,
-                            "[ISCIIEncoding.GetChars]Special cases require 1 and only 1 special case flag: LastATR {0} Dev. {1} Nukta {2}",
-                            bLastATR, bLastDevenagariStressAbbr, cLastCharForNextNukta));
+                        $"[ISCIIEncoding.GetChars]Special cases require 1 and only 1 special case flag: LastATR {bLastATR} Dev. {bLastDevenagariStressAbbr} Nukta {cLastCharForNextNukta}");
                     // If the last one was an ATR, then we'll have to do ATR stuff
                     if (bLastATR)
                     {
@@ -613,9 +611,7 @@ namespace System.Text
 
                 // We must be the Devenagari special case for F0, B8 & F0, BF
                 Debug.Assert(currentCodePage == CodeDevanagari && b == DevenagariExt,
-                    string.Format(CultureInfo.InvariantCulture,
-                        "[ISCIIEncoding.GetChars] Devenagari special case must {0} not {1} or in Devanagari code page {2} not {3}.",
-                        DevenagariExt, b, CodeDevanagari, currentCodePage));
+                    $"[ISCIIEncoding.GetChars] Devenagari special case must {DevenagariExt} not {b} or in Devanagari code page {CodeDevanagari} not {currentCodePage}.");
                 bLastDevenagariStressAbbr = bLastSpecial = true;
             }
 
index 081641a..59e36c9 100644 (file)
@@ -165,9 +165,7 @@ namespace System.Text
                         ushort byteTemp;
                         while ((byteTemp = *((ushort*)pData)) != 0)
                         {
-                            Debug.Assert(arrayTemp[byteTemp] == UNKNOWN_CHAR, string.Format(CultureInfo.InvariantCulture,
-                                "[SBCSCodePageEncoding::ReadBestFitTable] Expected unallocated byte (not 0x{2:X2}) for best fit byte at 0x{0:X2} for code page {1}",
-                                byteTemp, CodePage, (int)arrayTemp[byteTemp]));
+                            Debug.Assert(arrayTemp[byteTemp] == UNKNOWN_CHAR, $"[SBCSCodePageEncoding::ReadBestFitTable] Expected unallocated byte (not 0x{(int)arrayTemp[byteTemp]:X2}) for best fit byte at 0x{byteTemp:X2} for code page {CodePage}");
                             pData += 2;
 
                             arrayTemp[byteTemp] = *((char*)pData);
@@ -267,9 +265,7 @@ namespace System.Text
 
                                     // This won't work if it won't round trip.
                                     Debug.Assert(arrayTemp[iBestFitCount - 1] != (char)0,
-                                        string.Format(CultureInfo.InvariantCulture,
-                                        "[SBCSCodePageEncoding.ReadBestFitTable] No valid Unicode value {0:X4} for round trip bytes {1:X4}, encoding {2}",
-                                        (int)_mapBytesToUnicode[input], (int)input, CodePage));
+                                        $"[SBCSCodePageEncoding.ReadBestFitTable] No valid Unicode value {(int)_mapBytesToUnicode[input]:X4} for round trip bytes {(int)input:X4}, encoding {CodePage}");
                                 }
                                 unicodePosition++;
                             }
index 74fdf90..a0fab7f 100644 (file)
@@ -150,7 +150,7 @@ namespace System.Text.Json
             }
             else
             {
-                return new InvalidOperationException(SR.Format(SR.EmptyJsonIsInvalid));
+                return new InvalidOperationException(SR.EmptyJsonIsInvalid);
             }
         }
 
@@ -350,7 +350,7 @@ namespace System.Text.Json
                 builder.Append("...");
             }
 
-            throw new ArgumentException(SR.Format(SR.CannotWriteInvalidUTF8, builder.ToString()));
+            throw new ArgumentException(SR.Format(SR.CannotWriteInvalidUTF8, builder));
         }
 
         public static void ThrowArgumentException_InvalidUTF16(int charAsInt)
index 2173841..7cae75a 100644 (file)
@@ -207,7 +207,7 @@ namespace System.Text.RegularExpressions
                     return 3;
 
                 default:
-                    throw new ArgumentException(SR.Format(SR.UnexpectedOpcode, opcode.ToString(CultureInfo.CurrentCulture)));
+                    throw new ArgumentException(SR.Format(SR.UnexpectedOpcode, opcode.ToString()));
             }
         }
 
index d9c7500..1cff160 100644 (file)
@@ -884,10 +884,10 @@ namespace System.Text.RegularExpressions
                                     if (IsCaptureSlot(capnum))
                                         return new RegexNode(RegexNode.Testref, _options, capnum);
                                     else
-                                        throw MakeException(RegexParseError.UndefinedReference, SR.Format(SR.UndefinedReference, capnum.ToString(CultureInfo.CurrentCulture)));
+                                        throw MakeException(RegexParseError.UndefinedReference, SR.Format(SR.UndefinedReference, capnum.ToString()));
                                 }
                                 else
-                                    throw MakeException(RegexParseError.MalformedReference, SR.Format(SR.MalformedReference, capnum.ToString(CultureInfo.CurrentCulture)));
+                                    throw MakeException(RegexParseError.MalformedReference, SR.Format(SR.MalformedReference, capnum.ToString()));
                             }
                             else if (RegexCharClass.IsWordChar(ch))
                             {
@@ -1148,7 +1148,7 @@ namespace System.Text.RegularExpressions
                     if (IsCaptureSlot(capnum))
                         return new RegexNode(RegexNode.Ref, _options, capnum);
                     else
-                        throw MakeException(RegexParseError.UndefinedBackref, SR.Format(SR.UndefinedBackref, capnum.ToString(CultureInfo.CurrentCulture)));
+                        throw MakeException(RegexParseError.UndefinedBackref, SR.Format(SR.UndefinedBackref, capnum.ToString()));
                 }
             }
 
@@ -1181,7 +1181,7 @@ namespace System.Text.RegularExpressions
                     if (IsCaptureSlot(capnum))
                         return new RegexNode(RegexNode.Ref, _options, capnum);
                     else if (capnum <= 9)
-                        throw MakeException(RegexParseError.UndefinedBackref, SR.Format(SR.UndefinedBackref, capnum.ToString(CultureInfo.CurrentCulture)));
+                        throw MakeException(RegexParseError.UndefinedBackref, SR.Format(SR.UndefinedBackref, capnum.ToString()));
                 }
             }
 
index b0bc0d1..df2236c 100644 (file)
@@ -492,7 +492,7 @@ namespace System.Text.RegularExpressions
                     break;
 
                 default:
-                    throw new ArgumentException(SR.Format(SR.UnexpectedOpcode, nodetype.ToString(CultureInfo.CurrentCulture)));
+                    throw new ArgumentException(SR.Format(SR.UnexpectedOpcode, nodetype.ToString()));
             }
         }
     }
index 9d00f25..e5ab21b 100644 (file)
@@ -190,7 +190,7 @@ namespace System.Transactions
         {
             get
             {
-                Debug.Assert(false, "PromotableSinglePhaseNotification called for a non promotable enlistment.");
+                Debug.Fail("PromotableSinglePhaseNotification called for a non promotable enlistment.");
                 throw new NotImplementedException();
             }
         }
@@ -263,7 +263,7 @@ namespace System.Transactions
         {
             get
             {
-                Debug.Assert(false, "ResourceManagerIdentifier called for non durable enlistment");
+                Debug.Fail("ResourceManagerIdentifier called for non durable enlistment");
                 throw new NotImplementedException();
             }
         }
index 7acf2a6..e1a6f78 100644 (file)
@@ -57,49 +57,49 @@ namespace System.Transactions
 
         internal virtual void InternalAborted(InternalEnlistment enlistment)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for InternalEnlistment State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for InternalEnlistment State; Current State: {GetType()}");
             throw TransactionException.CreateEnlistmentStateException(null, enlistment == null ? Guid.Empty : enlistment.DistributedTxId);
         }
 
         internal virtual void InternalCommitted(InternalEnlistment enlistment)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for InternalEnlistment State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for InternalEnlistment State; Current State: {GetType()}");
             throw TransactionException.CreateEnlistmentStateException(null, enlistment == null ? Guid.Empty : enlistment.DistributedTxId);
         }
 
         internal virtual void InternalIndoubt(InternalEnlistment enlistment)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for InternalEnlistment State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for InternalEnlistment State; Current State: {GetType()}");
             throw TransactionException.CreateEnlistmentStateException(null, enlistment == null ? Guid.Empty : enlistment.DistributedTxId);
         }
 
         internal virtual void ChangeStateCommitting(InternalEnlistment enlistment)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for InternalEnlistment State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for InternalEnlistment State; Current State: {GetType()}");
             throw TransactionException.CreateEnlistmentStateException(null, enlistment == null ? Guid.Empty : enlistment.DistributedTxId);
         }
 
         internal virtual void ChangeStatePromoted(InternalEnlistment enlistment, IPromotedEnlistment promotedEnlistment)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for InternalEnlistment State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for InternalEnlistment State; Current State: {GetType()}");
             throw TransactionException.CreateEnlistmentStateException(null, enlistment == null ? Guid.Empty : enlistment.DistributedTxId);
         }
 
         internal virtual void ChangeStateDelegated(InternalEnlistment enlistment)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for InternalEnlistment State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for InternalEnlistment State; Current State: {GetType()}");
             throw TransactionException.CreateEnlistmentStateException(null, enlistment == null ? Guid.Empty : enlistment.DistributedTxId);
         }
 
         internal virtual void ChangeStatePreparing(InternalEnlistment enlistment)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for InternalEnlistment State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for InternalEnlistment State; Current State: {GetType()}");
             throw TransactionException.CreateEnlistmentStateException(null, enlistment == null ? Guid.Empty : enlistment.DistributedTxId);
         }
 
         internal virtual void ChangeStateSinglePhaseCommit(InternalEnlistment enlistment)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for InternalEnlistment State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for InternalEnlistment State; Current State: {GetType()}");
             throw TransactionException.CreateEnlistmentStateException(null, enlistment == null ? Guid.Empty : enlistment.DistributedTxId);
         }
     }
index 3d04edd..5f10e6c 100644 (file)
@@ -322,7 +322,7 @@ namespace System.Transactions
 
                     default:
                         {
-                            Debug.Assert(false, "InternalTransaction.DistributedTransactionOutcome - Unexpected TransactionStatus");
+                            Debug.Fail("InternalTransaction.DistributedTransactionOutcome - Unexpected TransactionStatus");
                             TransactionException.CreateInvalidOperationException(TraceSourceType.TraceSourceLtm,
                                 "",
                                 null,
index f00e11d..c6fbbba 100644 (file)
@@ -49,7 +49,7 @@ namespace System.Transactions
         {
             string messagewithTxId = SR.EnlistmentStateException;
             if (IncludeDistributedTxId(distributedTxId))
-                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
+                messagewithTxId = SR.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
 
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
@@ -107,7 +107,7 @@ namespace System.Transactions
         {
             if (IncludeDistributedTxId(distributedTxId))
             {
-                return new TransactionException(string.Format(SR.DistributedTxIDInTransactionException, message, distributedTxId));
+                return new TransactionException(SR.Format(SR.DistributedTxIDInTransactionException, message, distributedTxId));
             }
             return new TransactionException(message);
         }
@@ -116,7 +116,7 @@ namespace System.Transactions
         {
             string messagewithTxId = message;
             if (IncludeDistributedTxId(distributedTxId))
-                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
+                messagewithTxId = SR.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
 
             return Create(messagewithTxId, innerException);
         }
@@ -125,7 +125,7 @@ namespace System.Transactions
         {
             string messagewithTxId = message;
             if (IncludeDistributedTxId(distributedTxId))
-                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
+                messagewithTxId = SR.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
 
             return Create(traceSource, messagewithTxId, innerException);
         }
@@ -134,7 +134,7 @@ namespace System.Transactions
         {
             if (IncludeDistributedTxId(distributedTxId))
             {
-                return new TransactionException(string.Format(SR.DistributedTxIDInTransactionException, message, distributedTxId));
+                return new TransactionException(SR.Format(SR.DistributedTxIDInTransactionException, message, distributedTxId));
             }
             return new TransactionException(message);
         }
@@ -148,7 +148,7 @@ namespace System.Transactions
         {
             string messagewithTxId = SR.TransactionAlreadyCompleted;
             if (IncludeDistributedTxId(distributedTxId))
-                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
+                messagewithTxId = SR.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
 
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
@@ -163,7 +163,7 @@ namespace System.Transactions
         {
             string messagewithTxId = message;
             if (IncludeDistributedTxId(distributedTxId))
-                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
+                messagewithTxId = SR.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
 
             return CreateInvalidOperationException(traceSource, messagewithTxId, innerException);
         }
@@ -181,7 +181,7 @@ namespace System.Transactions
         {
             string messagewithTxId = message;
             if (IncludeDistributedTxId(distributedTxId))
-                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
+                messagewithTxId = SR.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
 
             return TransactionAbortedException.Create(messagewithTxId, innerException);
         }
@@ -230,7 +230,7 @@ namespace System.Transactions
 
         internal TransactionAbortedException(Exception innerException, Guid distributedTxId) :
             base(IncludeDistributedTxId(distributedTxId) ?
-                string.Format(SR.DistributedTxIDInTransactionException, SR.TransactionAborted, distributedTxId)
+                SR.Format(SR.DistributedTxIDInTransactionException, SR.TransactionAborted, distributedTxId)
                 : SR.TransactionAborted, innerException)
         {
         }
@@ -256,7 +256,7 @@ namespace System.Transactions
         {
             string messagewithTxId = message;
             if (IncludeDistributedTxId(distributedTxId))
-                messagewithTxId = string.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
+                messagewithTxId = SR.Format(SR.DistributedTxIDInTransactionException, messagewithTxId, distributedTxId);
 
             return TransactionInDoubtException.Create(traceSource, messagewithTxId, innerException);
         }
index 43148ba..97cdd5f 100644 (file)
@@ -183,7 +183,7 @@ namespace System.Transactions
 
         internal virtual void EndCommit(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
 
             throw TransactionException.CreateTransactionStateException(tx._innerException, tx.DistributedTxId);
         }
@@ -297,7 +297,7 @@ namespace System.Transactions
 
         internal virtual void ChangeStateTransactionAborted(InternalTransaction tx, Exception e)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -309,7 +309,7 @@ namespace System.Transactions
 
         internal virtual void ChangeStateTransactionCommitted(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -321,7 +321,7 @@ namespace System.Transactions
 
         internal virtual void InDoubtFromEnlistment(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -333,7 +333,7 @@ namespace System.Transactions
 
         internal virtual void ChangeStatePromotedAborted(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -345,7 +345,7 @@ namespace System.Transactions
 
         internal virtual void ChangeStatePromotedCommitted(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -357,7 +357,7 @@ namespace System.Transactions
 
         internal virtual void InDoubtFromDtc(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -369,7 +369,7 @@ namespace System.Transactions
 
         internal virtual void ChangeStatePromotedPhase0(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -381,7 +381,7 @@ namespace System.Transactions
 
         internal virtual void ChangeStatePromotedPhase1(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -393,7 +393,7 @@ namespace System.Transactions
 
         internal virtual void ChangeStateAbortedDuringPromotion(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -409,19 +409,19 @@ namespace System.Transactions
 
         internal virtual void Phase0VolatilePrepareDone(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             throw TransactionException.CreateTransactionStateException(tx._innerException, tx.DistributedTxId);
         }
 
         internal virtual void Phase1VolatilePrepareDone(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             throw TransactionException.CreateTransactionStateException(tx._innerException, tx.DistributedTxId);
         }
 
         internal virtual void RestartCommitIfNeeded(InternalTransaction tx)
         {
-            Debug.Assert(false, string.Format(null, "Invalid Event for State; Current State: {0}", GetType()));
+            Debug.Fail($"Invalid Event for State; Current State: {GetType()}");
             TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
             if (etwLog.IsEnabled())
             {
@@ -4300,8 +4300,8 @@ namespace System.Transactions
 
 
                 distributedTx = TransactionStatePSPEOperation.PSPEPromote(tx);
-                Debug.Assert((distributedTx == null), string.Format(null, "PSPEPromote for non-MSDTC promotion returned a distributed transaction."));
-                Debug.Assert((tx.promotedToken != null), string.Format(null, "PSPEPromote for non-MSDTC promotion did not set InternalTransaction.PromotedToken."));
+                Debug.Assert((distributedTx == null), "PSPEPromote for non-MSDTC promotion returned a distributed transaction.");
+                Debug.Assert((tx.promotedToken != null), "PSPEPromote for non-MSDTC promotion did not set InternalTransaction.PromotedToken.");
             }
             catch (TransactionPromotionException e)
             {
index 07e5aed..e98593a 100644 (file)
@@ -156,7 +156,7 @@ namespace System.Drawing.Printing
             if (left == null || right == null || bottom == null || top == null ||
                 !(left is int) || !(right is int) || !(bottom is int) || !(top is int))
             {
-                throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry));
+                throw new ArgumentException(SR.PropertyValueInvalidEntry);
             }
 
             return new Margins((int)left,