From 4fc5d8971dcae0c8dd67af72f7f2145ce0466200 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 23 Aug 2019 22:24:14 -0400 Subject: [PATCH] Contribute to IDE0055 (fix formatting) Commit migrated from https://github.com/dotnet/corefx/commit/b49a8a9be1d53cd9e50cb68fd8540be25c65d433 --- .../Common/src/Interop/Interop.Odbc.cs | 4 +- ...nterop.DuplicateTokenEx_SafeTokenHandle.cs | 3 +- .../src/Interop/Windows/Interop.Errors.cs | 2 +- .../Windows/Kernel32/Interop.COMMPROP.cs | 6 +- .../Kernel32/Interop.ClearCommBreak.cs | 2 +- .../Kernel32/Interop.ClearCommError.cs | 2 +- .../Kernel32/Interop.EscapeCommFunction.cs | 2 +- .../Windows/Kernel32/Interop.GetCPInfoEx.cs | 4 +- .../Kernel32/Interop.GetCommModemStatus.cs | 2 +- .../Kernel32/Interop.GetCommProperties.cs | 2 +- .../Windows/Kernel32/Interop.GetCommState.cs | 2 +- .../Kernel32/Interop.GetOverlappedResult.cs | 2 +- .../Kernel32/Interop.PeekConsoleInput.cs | 2 +- .../Windows/Kernel32/Interop.PurgeComm.cs | 2 +- .../Windows/Kernel32/Interop.SetCommBreak.cs | 2 +- .../Windows/Kernel32/Interop.SetCommMask.cs | 2 +- .../Windows/Kernel32/Interop.SetCommState.cs | 2 +- .../Kernel32/Interop.SetCommTimeouts.cs | 2 +- .../Windows/Kernel32/Interop.SetupComm.cs | 2 +- .../Windows/Kernel32/Interop.WaitCommEvent.cs | 2 +- .../Kernel32/Interop.WaitForSingleObject.cs | 2 +- .../NtDll/Interop.RTL_OSVERSIONINFOEX.cs | 2 +- .../Windows/NtDll/Interop.RtlGetVersion.cs | 2 +- .../Windows/SspiCli/SecuritySafeHandles.cs | 2 +- .../Windows/User32/Interop.CreateWindowEx.cs | 2 +- .../Windows/User32/Interop.GetClassInfo.cs | 2 +- .../User32/Interop.GetProcessWindowStation.cs | 2 +- .../Interop.GetUserObjectInformation.cs | 2 +- .../src/Interop/Windows/User32/Interop.MSG.cs | 17 +- .../Windows/User32/Interop.USEROBJECTFLAGS.cs | 3 +- .../Windows/User32/Interop.WNDCLASS.cs | 2 +- .../Data/Common/DbConnectionOptions.Common.cs | 100 +- .../ExcludeFromCodeCoverageAttribute.cs | 2 +- .../Globalization/FormatProvider.Number.cs | 4 +- .../Net/Logging/NetEventSource.Common.cs | 1 - .../src/System/Resources/ResourceWriter.cs | 9 +- .../Cryptography/Asn1Reader/AsnWriter.cs | 2 +- .../System/Security/Cryptography/DSACng.cs | 2 +- .../Cryptography/DSAKeyFormatHelper.cs | 6 +- .../Cryptography/EccKeyFormatHelper.cs | 6 +- .../Cryptography/RSAKeyFormatHelper.cs | 6 +- .../Common/src/System/Text/DBCSDecoder.cs | 6 +- .../Common/src/System/Text/OSEncoder.cs | 4 +- .../src/System/Text/OSEncoding.Windows.cs | 14 +- .../CSharp/RuntimeBinder/BinderEquivalence.cs | 4 +- .../CSharp/RuntimeBinder/BinderHelper.cs | 4 +- .../CSharpBinaryOperationBinder.cs | 2 +- .../RuntimeBinder/CSharpGetIndexBinder.cs | 2 +- .../CSharpUnaryOperationBinder.cs | 2 +- .../ExpressionTreeCallRewriter.cs | 2 - .../RuntimeBinder/Semantics/Conversion.cs | 2 +- .../Semantics/ExpressionBinder.cs | 8 +- .../Semantics/Tree/ExprOperator.cs | 2 +- .../Tree/Visitors/ExpressionTreeRewriter.cs | 8 +- .../RuntimeBinder/Semantics/WithType.cs | 2 +- .../CSharp/RuntimeBinder/SymbolTable.cs | 10 +- .../src/Sgen.cs | 4 +- .../Microsoft/CSharp/CSharpCodeGenerator.cs | 96 +- .../Microsoft/VisualBasic/VBCodeGenerator.cs | 88 +- .../Concurrent/PartitionerStatic.cs | 10 +- .../Immutable/ImmutableList_1.Builder.cs | 2 +- .../Specialized/NameObjectCollectionBase.cs | 6 +- .../Specialized/NameValueCollection.cs | 6 +- .../Specialized/OrderedDictionary.cs | 3 +- .../Generic/SortedSet.TreeSubSet.cs | 2 +- .../CollectionServices.CollectionOfObject.cs | 2 +- .../Composition/ConstraintServices.cs | 8 +- .../Hosting/AggregateExportProvider.cs | 2 +- .../Composition/Hosting/ApplicationCatalog.cs | 10 +- .../Hosting/ComposablePartExportProvider.cs | 4 +- .../Hosting/CompositionContainer.cs | 4 +- .../Composition/Hosting/CompositionOptions.cs | 6 +- .../Hosting/CompositionScopeDefinition.cs | 6 +- ...CompositionScopeDefinitionDebuggerProxy.cs | 3 +- .../Hosting/CompositionServices.cs | 6 +- .../Composition/Hosting/FilteredCatalog.cs | 6 +- .../ImportSourceImportDefinitionHelpers.cs | 2 +- .../Composition/Hosting/ScopingExtensions.cs | 2 +- .../Composition/MetadataAttributeAttribute.cs | 3 +- .../Composition/MetadataViewGenerator.cs | 14 +- .../Composition/MetadataViewProvider.cs | 6 +- .../Primitives/ComposablePartDefinition.cs | 2 +- .../Primitives/ExportedDelegate.cs | 2 +- .../Primitives/PrimitivesServices.cs | 2 +- .../ReflectionModel/ExportfactoryCreator.cs | 6 +- .../ReflectionComposablePart.cs | 2 +- .../ReflectionModelServices.cs | 2 +- .../ReflectionModel/ReflectionParameter.cs | 4 +- .../System/ComponentModel/BooleanConverter.cs | 2 +- .../Design/DesignerOptionService.cs | 2 +- .../Design/PropertyTabAttribute.cs | 2 +- .../System/ComponentModel/LicenseManager.cs | 2 +- .../ComponentModel/MarshalByValueComponent.cs | 2 +- .../System/ComponentModel/MemberDescriptor.cs | 7 +- .../ComponentModel/NullableConverter.cs | 4 +- .../ComponentModel/PropertyDescriptor.cs | 2 +- .../ComponentModel/ReferenceConverter.cs | 2 +- .../ComponentModel/ReflectEventDescriptor.cs | 18 +- .../System/ComponentModel/TypeDescriptor.cs | 4 +- .../src/System/Composition/ExportAttribute.cs | 2 +- .../TypedParts/Discovery/DiscoveredPart.cs | 2 +- .../Configuration/BaseConfigurationRecord.cs | 40 +- .../System/Configuration/ClientConfigPaths.cs | 2 +- .../Internal/InternalConfigRoot.cs | 2 +- .../ProtectedConfigurationSection.cs | 2 +- .../System.Console/src/System/Console.cs | 5 +- .../src/System/ConsolePal.Windows.cs | 2 +- .../src/System/Data/Constraint.cs | 2 +- .../src/System/Data/DataTable.cs | 2 +- .../src/System/Data/DataView.cs | 2 +- .../src/System/Data/LinqDataView.cs | 5 +- .../src/System/Data/SQLTypes/SQLBinary.cs | 2 +- .../src/System/Data/SQLTypes/SQLBoolean.cs | 2 +- .../src/System/Data/SQLTypes/SQLByte.cs | 2 +- .../src/System/Data/SQLTypes/SQLDecimal.cs | 2 +- .../src/System/Data/SQLTypes/SQLDouble.cs | 2 +- .../src/System/Data/SQLTypes/SQLInt16.cs | 2 +- .../src/System/Data/SQLTypes/SQLInt32.cs | 2 +- .../src/System/Data/SQLTypes/SQLInt64.cs | 2 +- .../src/System/Data/SQLTypes/SQLMoney.cs | 2 +- .../src/System/Data/SQLTypes/SQLSingle.cs | 2 +- .../src/System/Data/SQLTypes/SQLString.cs | 2 +- .../src/System/Data/Selection.cs | 4 +- .../src/System/Data/Odbc/Odbc32.cs | 62 +- .../System/Data/Odbc/OdbcParameterHelper.cs | 3 +- .../System/Data/Odbc/OdbcStatementHandle.cs | 6 +- .../src/OleDbParameterCollectionHelper.cs | 18 +- .../src/System/Data/Common/AdapterUtil.cs | 99 +- .../Data/SqlClient/SNI/LocalDB.Windows.cs | 2 +- .../System/Data/SqlClient/SNI/SNIPacket.cs | 2 +- .../src/System/Data/SqlClient/SqlCommand.cs | 13 +- .../Data/SqlClient/SqlDependencyListener.cs | 45 +- .../Data/SqlClient/SqlFileStream.Windows.cs | 114 +- .../src/System/Data/SqlClient/SqlParameter.cs | 2 +- .../src/System/Data/SqlClient/SqlUtil.cs | 6 +- .../SqlClient/TdsParserStateObjectNative.cs | 2 +- .../src/misc/EnvironmentHelpers.cs | 18 +- .../Diagnostics/ProcessManager.Win32.cs | 9 +- .../SymbolStore/SymLanguageType.cs | 4 +- .../SymbolStore/SymLanguageVendor.cs | 2 +- .../Diagnostics/ConsoleTraceListener.cs | 7 +- .../Diagnostics/DefaultTraceListener.cs | 2 +- .../src/System/Diagnostics/TraceInternal.cs | 2 +- .../src/System/Diagnostics/TraceListener.cs | 3 +- .../src/System/Diagnostics/TraceSource.cs | 6 +- .../AccountManagement/AD/RangeRetriever.cs | 6 +- .../AccountManagement/GlobalDebug.cs | 1 - .../Protocols/common/SearchResults.cs | 2 +- .../src/Interop/UnsafeNativeMethods.cs | 2 +- .../ActiveDirectory/ADSearcher.cs | 2 +- .../DirectoryServices/DirectorySearcher.cs | 4 +- .../src/System/Drawing/Bitmap.cs | 2 +- .../src/System/Drawing/Brushes.cs | 2 +- .../Drawing/Drawing2D/LinearGradientBrush.cs | 4 +- .../Drawing/Imaging/MetaHeader.Windows.cs | 2 +- .../src/System/Drawing/Imaging/Metafile.cs | 2 +- .../src/System/Drawing/Pen.cs | 6 +- .../src/System/Drawing/Printing/TriState.cs | 2 +- .../src/System/Drawing/Region.cs | 2 +- .../src/System/IO/Compression/BrotliStream.cs | 4 +- .../dec/BrotliStream.Decompress.cs | 2 +- .../ZipFileExtensions.ZipArchive.Extract.cs | 2 +- .../Compression/DeflateZLib/DeflateStream.cs | 2 +- .../src/System/IO/Compression/GZipStream.cs | 6 +- .../src/System/IO/Compression/ZipBlocks.cs | 2 +- .../src/System/IO/Directory.cs | 2 +- .../FileSystemEnumerableFactory.cs | 18 +- .../src/System/IO/EnumerationOptions.cs | 8 +- .../src/System/IO/FileSystemInfo.Windows.cs | 2 +- .../InternalRelationshipCollection.cs | 2 +- .../Packaging/PackUriHelper.PackUriScheme.cs | 2 +- .../src/System/IO/Packaging/PackagePart.cs | 2 +- .../src/System/IO/Packaging/ZipPackage.cs | 28 +- .../System/IO/Packaging/ZipWrappingStream.cs | 3 +- .../src/System/IO/Pipes/PipeAccessRule.cs | 10 +- .../System/IO/Ports/SerialStream.Windows.cs | 2 +- .../System.Json/src/System/Json/JsonValue.cs | 28 +- .../Expressions/Interpreter/LightCompiler.cs | 2 +- .../src/System/Linq/EnumerableQuery.cs | 2 +- .../src/System/Linq/EnumerableRewriter.cs | 2 +- .../Management/InteropClasses/WMIInterop.cs | 448 +++---- .../System/Management/ManagementBaseObject.cs | 44 +- .../src/System/Management/ManagementClass.cs | 106 +- .../System/Management/ManagementDateTime.cs | 14 +- .../System/Management/ManagementEventArgs.cs | 515 ++++---- .../Management/ManagementEventWatcher.cs | 122 +- .../ManagementNamedValueCollection.cs | 56 +- .../src/System/Management/ManagementObject.cs | 231 ++-- .../Management/ManagementObjectCollection.cs | 80 +- .../Management/ManagementObjectSearcher.cs | 54 +- .../Management/ManagementOperationWatcher.cs | 84 +- .../System/Management/ManagementOptions.cs | 217 ++-- .../src/System/Management/ManagementPath.cs | 82 +- .../src/System/Management/ManagementQuery.cs | 408 ++++--- .../src/System/Management/ManagementScope.cs | 517 ++++---- .../src/System/Management/Method.cs | 6 +- .../src/System/Management/MethodSet.cs | 14 +- .../src/System/Management/Property.cs | 124 +- .../src/System/Management/PropertySet.cs | 17 +- .../src/System/Management/Qualifier.cs | 46 +- .../src/System/Management/QualifierSet.cs | 25 +- .../src/System/Management/WMIGenerator.cs | 666 +++++----- .../src/System/Management/WmiEventSink.cs | 508 ++++---- .../src/System/Management/wmiutil.cs | 8 +- .../src/System/Net/Http/WinHttpAuthHelper.cs | 10 +- .../src/System/Net/Http/WinHttpHandler.cs | 6 +- .../System/Net/Http/WinHttpRequestState.cs | 7 +- .../Net/Http/Headers/HttpGeneralHeaders.cs | 2 +- .../src/System/Net/Http/HttpRuleParser.cs | 2 +- .../src/System/Net/Http/MultipartContent.cs | 2 +- .../System/Net/Http/NetEventSource.Http.cs | 2 - .../AuthenticationHelper.NtAuth.cs | 6 +- .../AuthenticationHelper.cs | 4 +- .../SocketsHttpHandler/CancellationHelper.cs | 2 +- .../ChunkedEncodingReadStream.cs | 6 +- .../SocketsHttpHandler/Http2Connection.cs | 4 +- .../Http/SocketsHttpHandler/Http2Stream.cs | 2 +- .../HttpAuthenticatedConnectionHandler.cs | 2 +- .../Http/SocketsHttpHandler/HttpConnection.cs | 2 +- .../HttpConnectionHandler.cs | 2 +- .../HttpConnectionPoolManager.cs | 6 +- .../SocketsHttpHandler/HttpWindowsProxy.cs | 16 +- .../src/System/Net/Cookie.cs | 84 +- .../src/System/Net/CookieCollection.cs | 14 +- .../src/System/Net/WebRequest.cs | 2 +- .../src/System/Net/WebResponse.cs | 2 +- .../Net/Security/SslStream.Implementation.cs | 2 +- .../Net/Sockets/DynamicWinsockMethods.cs | 16 +- .../System/Net/Sockets/SafeSocketHandle.cs | 2 +- .../src/System/Net/Sockets/Socket.cs | 2 +- .../src/System/Net/WebClient.cs | 14 +- .../src/System/Net/WebHeaderCollection.cs | 2 +- .../Net/WebSockets/WebSocketHandle.Managed.cs | 2 +- .../System/Numerics/Tensors/ArrayUtilities.cs | 2 +- .../System/Runtime/Serialization/Globals.cs | 2 +- .../Json/JsonCollectionDataContract.cs | 2 +- .../Serialization/Json/JsonReaderDelegator.cs | 2 +- .../Serialization/ReflectionClassWriter.cs | 2 +- .../XmlObjectSerializerReadContext.cs | 2 +- .../System.Private.Uri/src/System/Uri.cs | 4 +- .../src/System/UriParserTemplates.cs | 35 +- .../src/System/UriSyntax.cs | 20 +- .../src/System/Xml/Linq/XAttribute.cs | 42 +- .../src/System/Xml/Linq/XDocument.cs | 2 +- .../src/System/Xml/Linq/XElement.cs | 42 +- .../src/System/Xml/Linq/XLinq.cs | 2 +- .../src/System/Xml/Linq/XObject.cs | 2 +- .../src/System/Xml/Linq/XText.cs | 2 +- .../Xml/Core/XmlEncodedRawTextWriter.cs | 20 +- .../Xml/Core/XmlEncodedRawTextWriterAsync.cs | 12 +- .../src/System/Xml/Core/XmlReader.cs | 2 +- .../src/System/Xml/Core/XmlReaderSettings.cs | 4 +- .../System/Xml/Core/XmlTextReaderImplAsync.cs | 2 +- .../System/Xml/Schema/XmlSchemaDataType.cs | 2 +- .../System/Xml/Schema/XmlSchemaGroupBase.cs | 2 +- .../src/System/Xml/Serialization/Compiler.cs | 6 +- .../ReflectionXmlSerializationWriter.cs | 5 +- .../System/Xml/Serialization/SourceInfo.cs | 2 +- .../Serialization/XmlSerializationReader.cs | 20 +- .../Serialization/XmlSerializationWriter.cs | 28 +- .../src/System/Xml/Xsl/QIL/QilLiteral.cs | 10 +- .../System/Xml/Xsl/Runtime/XmlCollation.cs | 2 +- .../src/System/Xml/Xsl/XPathConvert.cs | 4 +- .../src/System/Xml/Xsl/Xslt/XsltInput.cs | 2 +- .../Reflection/DispatchProxyGenerator.cs | 2 +- .../System/Reflection/Metadata/BlobReader.cs | 2 +- .../PortableExecutable/PEHeaderBuilder.cs | 2 +- .../src/System/Reflection/DefaultBinder.cs | 10 +- .../Reflection/MetadataLoadContext.Loading.cs | 2 +- .../Ecma/EcmaCustomAttributeHelpers.cs | 2 +- .../TypeLoading/General/Utf8Constants.cs | 104 +- .../TypeLoading/Modules/Ecma/EcmaModule.cs | 2 +- .../TypeLoading/RuntimeTypeInfo.GetMember.cs | 4 +- .../TypeLoading/Types/RoArrayType.cs | 2 +- .../src/System/Reflection/TypeExtensions.cs | 2 +- .../Resources/Extensions/TypeNameComparer.cs | 2 +- .../Resources/__FastResourceComparer.cs | 2 +- .../Runtime/CompilerServices/Attributes.cs | 4 +- .../src/System/Context.cs | 2 +- .../src/System/LoaderOptimizationAttribute.cs | 2 +- .../SwitchExpressionException.cs | 4 +- .../Runtime/Versioning/VersioningHelper.cs | 3 +- .../InteropServices/ComTypes/IDataObject.cs | 3 +- .../InteropServices/ComTypes/IEnumSTATDATA.cs | 2 +- .../src/System/Numerics/BigInteger.cs | 8 +- .../src/System/Numerics/Complex.cs | 6 +- .../Formatters/Binary/BinaryUtilClasses.cs | 2 +- .../System/Windows/LayoutCycleException.cs | 2 +- .../Threading/Tasks/TaskToAsyncInfoAdapter.cs | 10 +- .../src/System/Security/AccessControl/ACL.cs | 1076 ++++++++--------- .../Security/AccessControl/ObjectSecurity.cs | 192 +-- .../System/Security/AccessControl/Rules.cs | 86 +- .../AsymmetricKeyExchangeDeformatter.cs | 4 +- .../AsymmetricKeyExchangeFormatter.cs | 4 +- .../AsymmetricSignatureDeformatter.cs | 2 +- .../AsymmetricSignatureFormatter.cs | 2 +- .../Security/Cryptography/CngKeyLite.cs | 2 +- .../RSAOAEPKeyExchangeDeformatter.cs | 2 +- .../RSAOAEPKeyExchangeFormatter.cs | 5 +- .../RSAPKCS1KeyExchangeDeformatter.cs | 5 +- .../RSAPKCS1KeyExchangeFormatter.cs | 3 +- .../System/Security/Cryptography/TripleDES.cs | 6 +- .../Security/Cryptography/ECDsaCng.Key.cs | 3 +- .../CspKeyContainerInfo.Windows.cs | 2 +- .../Cryptography/RNGCryptoServiceProvider.cs | 2 +- .../SHA512CryptoServiceProvider.cs | 2 +- .../Cryptography/AsnEncodedDataCollection.cs | 2 +- .../Cryptography/Pal/AnyOS/AsnHelpers.cs | 3 +- .../Pal/Windows/HelpersWindows.cs | 2 +- .../src/Internal/Cryptography/PkcsHelpers.cs | 2 +- .../Cryptography/Pkcs/CmsRecipient.cs | 12 +- .../Cryptography/Pkcs/Pkcs12KeyBag.cs | 2 +- .../Cryptography/Pkcs/Pkcs12SafeBag.cs | 2 +- .../Cryptography/Pkcs/Pkcs12ShroudedKeyBag.cs | 2 +- .../Security/Cryptography/CipherMode.cs | 4 +- .../Security/Cryptography/HashAlgorithm.cs | 2 +- .../Pal.Windows/CertificatePal.cs | 10 +- .../Cryptography/Pal.Windows/FindPal.cs | 18 +- .../Pal.Windows/StorePal.Export.cs | 8 +- .../Pal.Windows/StorePal.Import.cs | 6 +- .../Cryptography/Pal.Windows/StorePal.cs | 2 +- .../Pal.Windows/X509Pal.CustomExtensions.cs | 2 +- .../SubjectAlternativeNameBuilder.cs | 2 +- .../X509CertificateCollection.cs | 2 +- .../X509Certificates/X509Chain.cs | 3 +- .../Security/Cryptography/Xml/EncryptedXml.cs | 2 +- .../Cryptography/Xml/KeyInfoX509Data.cs | 2 +- .../System/Security/Cryptography/Xml/Utils.cs | 2 +- .../Syndication/Atom10FeedFormatter.cs | 2 +- .../Syndication/SyndicationFeed.cs | 4 +- .../src/System/ServiceProcess/ServiceBase.cs | 2 +- .../src/System/Text/DecoderNLS.cs | 27 +- .../src/System/Text/EncoderNLS.cs | 28 +- .../src/System/Text/EncodingNLS.cs | 48 +- .../Text/Json/Document/JsonDocumentOptions.cs | 2 +- .../Text/Json/Reader/JsonReaderException.cs | 2 +- .../Converters/EnumConverterOptions.cs | 4 +- .../Converters/JsonValueConverterEnum.cs | 2 +- .../JsonClassInfo.AddProperty.cs | 6 +- .../Text/Json/Serialization/JsonClassInfo.cs | 2 +- .../JsonSerializer.Read.HandleNull.cs | 2 +- .../Text/RegularExpressions/Regex.Cache.cs | 2 +- .../Text/RegularExpressions/RegexCode.cs | 2 +- .../Text/RegularExpressions/RegexCompiler.cs | 18 +- .../Text/RegularExpressions/RegexFCD.cs | 6 +- .../RegularExpressions/RegexReplacement.cs | 2 +- .../Text/RegularExpressions/RegexRunner.cs | 32 +- .../Transactions/CommittableTransaction.cs | 2 +- .../Transactions/TransactionException.cs | 14 +- .../src/System/Drawing/ImageConverter.cs | 2 +- .../X509Certificates/SafeX509Handles.cs | 2 +- 351 files changed, 4126 insertions(+), 4022 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Odbc.cs b/src/libraries/Common/src/Interop/Interop.Odbc.cs index c71b3cbead7..848dd10ae7c 100644 --- a/src/libraries/Common/src/Interop/Interop.Odbc.cs +++ b/src/libraries/Common/src/Interop/Interop.Odbc.cs @@ -130,7 +130,7 @@ internal static partial class Interop [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] internal static extern /*SQLRETURN*/ODBC32.RetCode SQLExecDirectW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, - /*SQLCHAR* */string StatementText, + /*SQLCHAR* */string StatementText, /*SQLINTEGER*/int TextLength); [DllImport(Interop.Libraries.Odbc32)] @@ -245,7 +245,7 @@ internal static partial class Interop [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] internal static extern /*SQLRETURN*/ODBC32.RetCode SQLPrepareW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, - /*SQLCHAR* */string StatementText, + /*SQLCHAR* */string StatementText, /*SQLINTEGER*/int TextLength); [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx_SafeTokenHandle.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx_SafeTokenHandle.cs index afb199728cf..e052c746802 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx_SafeTokenHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.DuplicateTokenEx_SafeTokenHandle.cs @@ -12,8 +12,7 @@ internal static partial class Interop internal static partial class Advapi32 { [DllImport(Interop.Libraries.Advapi32, SetLastError = true)] - internal static extern - bool DuplicateTokenEx(SafeTokenHandle ExistingTokenHandle, + internal static extern bool DuplicateTokenEx(SafeTokenHandle ExistingTokenHandle, TokenAccessLevels DesiredAccess, IntPtr TokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, diff --git a/src/libraries/Common/src/Interop/Windows/Interop.Errors.cs b/src/libraries/Common/src/Interop/Windows/Interop.Errors.cs index 7803d5d8cb5..741c7831130 100644 --- a/src/libraries/Common/src/Interop/Windows/Interop.Errors.cs +++ b/src/libraries/Common/src/Interop/Windows/Interop.Errors.cs @@ -30,7 +30,7 @@ internal partial class Interop internal const int ERROR_INVALID_PARAMETER = 0x57; internal const int ERROR_BROKEN_PIPE = 0x6D; internal const int ERROR_SEM_TIMEOUT = 0x79; - internal const int ERROR_CALL_NOT_IMPLEMENTED = 0x78; + internal const int ERROR_CALL_NOT_IMPLEMENTED = 0x78; internal const int ERROR_INSUFFICIENT_BUFFER = 0x7A; internal const int ERROR_INVALID_NAME = 0x7B; internal const int ERROR_NEGATIVE_SEEK = 0x83; diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.COMMPROP.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.COMMPROP.cs index 1a88599493d..597d2d000f4 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.COMMPROP.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.COMMPROP.cs @@ -17,8 +17,8 @@ internal partial class Interop // https://msdn.microsoft.com/en-us/library/windows/desktop/aa363189.aspx internal struct COMMPROP { - public ushort wPacketLength; - public ushort wPacketVersion; + public ushort wPacketLength; + public ushort wPacketVersion; public int dwServiceMask; public int dwReserved1; public int dwMaxTxQueue; @@ -29,7 +29,7 @@ internal partial class Interop public int dwSettableParams; public int dwSettableBaud; public ushort wSettableData; - public ushort wSettableStopParity; + public ushort wSettableStopParity; public int dwCurrentTxQueue; public int dwCurrentRxQueue; public int dwProvSpec1; diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommBreak.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommBreak.cs index f181dcb7561..4b7b730700c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommBreak.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommBreak.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool ClearCommBreak( SafeFileHandle hFile); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommError.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommError.cs index 6dc5e2d5830..0b5aa5412f8 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommError.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommError.cs @@ -10,7 +10,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool ClearCommError( SafeFileHandle hFile, ref int lpErrors, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EscapeCommFunction.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EscapeCommFunction.cs index 908a9216441..866f85cd75b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EscapeCommFunction.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EscapeCommFunction.cs @@ -17,7 +17,7 @@ internal partial class Interop internal const int CLRDTR = 6; } - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool EscapeCommFunction( SafeFileHandle hFile, int dwFunc); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs index c89849706dc..e7078e31b1c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs @@ -29,10 +29,10 @@ internal partial class Interop if (GetCPInfoExW((uint)codePage, 0, &cpInfo) != BOOL.FALSE) { // we don't care about the last 2 bytes as those are nulls - for (int i=0; i<10 && leadByteRanges[i] != 0; i+=2) + for (int i = 0; i < 10 && leadByteRanges[i] != 0; i += 2) { leadByteRanges[i] = cpInfo.LeadByte[i]; - leadByteRanges[i+1] = cpInfo.LeadByte[i+1]; + leadByteRanges[i + 1] = cpInfo.LeadByte[i + 1]; count++; } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommModemStatus.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommModemStatus.cs index e7e3148f751..a089cd3762f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommModemStatus.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommModemStatus.cs @@ -16,7 +16,7 @@ internal partial class Interop internal const int MS_RLSD_ON = 0x80; } - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool GetCommModemStatus( SafeFileHandle hFile, ref int lpModemStat); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommProperties.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommProperties.cs index 3edef5c194f..830f7de047b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommProperties.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommProperties.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool GetCommProperties( SafeFileHandle hFile, ref COMMPROP lpCommProp); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommState.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommState.cs index 800d09d4afe..c5733394508 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommState.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommState.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool GetCommState( SafeFileHandle hFile, ref DCB lpDCB); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs index f78941f4671..b31b6f6c999 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs @@ -10,7 +10,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern unsafe bool GetOverlappedResult( SafeFileHandle hFile, NativeOverlapped* lpOverlapped, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs index decaed00768..ba63f0adc76 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PeekConsoleInput.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint ="PeekConsoleInputW")] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PeekConsoleInputW")] internal static extern bool PeekConsoleInput(IntPtr hConsoleInput, out InputRecord buffer, int numInputRecords_UseOne, out int numEventsRead); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PurgeComm.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PurgeComm.cs index 8eaafbb761c..1cad74c96c8 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PurgeComm.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PurgeComm.cs @@ -17,7 +17,7 @@ internal partial class Interop internal const uint PURGE_RXCLEAR = 0x0008; // Kill the typeahead buffer if there. } - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool PurgeComm( SafeFileHandle hFile, uint dwFlags); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommBreak.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommBreak.cs index d6af43fa9f8..e57d3e0c7cb 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommBreak.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommBreak.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool SetCommBreak( SafeFileHandle hFile); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommMask.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommMask.cs index d3637e702d5..9231129ae8b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommMask.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommMask.cs @@ -16,7 +16,7 @@ internal partial class Interop internal const int ALL_EVENTS = 0x1fb; } - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool SetCommMask( SafeFileHandle hFile, int dwEvtMask diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommState.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommState.cs index 6f7ad4c7504..d1a82ea3993 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommState.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommState.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool SetCommState( SafeFileHandle hFile, ref DCB lpDCB); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommTimeouts.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommTimeouts.cs index 7d19d57c171..31097041a3d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommTimeouts.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommTimeouts.cs @@ -11,7 +11,7 @@ internal partial class Interop { internal const int MAXDWORD = -1; // This is 0xfffffff, or UInt32.MaxValue, here used as an int - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool SetCommTimeouts( SafeFileHandle hFile, ref COMMTIMEOUTS lpCommTimeouts); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetupComm.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetupComm.cs index 24f0d0b686f..1e56f8edc98 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetupComm.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetupComm.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern bool SetupComm( SafeFileHandle hFile, int dwInQueue, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitCommEvent.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitCommEvent.cs index 6966f79c09e..69ac18b3a50 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitCommEvent.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitCommEvent.cs @@ -10,7 +10,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError=true, CharSet=CharSet.Auto)] + [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] internal static extern unsafe bool WaitCommEvent( SafeFileHandle hFile, int* lpEvtMask, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs index f8c3d05b5ad..8bf2705d528 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class Kernel32 { - [DllImport(Libraries.Kernel32, ExactSpelling=true, SetLastError=true)] + [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] internal static extern int WaitForSingleObject(SafeWaitHandle handle, int timeout); } } diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RTL_OSVERSIONINFOEX.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RTL_OSVERSIONINFOEX.cs index 47a6b783564..049a68ca446 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RTL_OSVERSIONINFOEX.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RTL_OSVERSIONINFOEX.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class NtDll { - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal unsafe struct RTL_OSVERSIONINFOEX { internal uint dwOSVersionInfoSize; diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs index 4a8ecdf5895..e3e52093056 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs @@ -8,7 +8,7 @@ internal partial class Interop { internal partial class NtDll { - [DllImport(Libraries.NtDll, ExactSpelling=true)] + [DllImport(Libraries.NtDll, ExactSpelling = true)] private static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation); internal static unsafe int RtlGetVersionEx(out RTL_OSVERSIONINFOEX osvi) diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs index 1231fa397e3..8182e415279 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/SecuritySafeHandles.cs @@ -533,7 +533,7 @@ namespace System.Net.Security // private static unsafe int MustRunInitializeSecurityContext( ref SafeFreeCredentials inCredentials, - bool isContextAbsent, + bool isContextAbsent, byte* targetName, Interop.SspiCli.ContextFlags inFlags, Interop.SspiCli.Endianness endianness, diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs index c5a106c0bfc..ffb80e7236b 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class User32 { - [DllImport(Libraries.User32, CharSet=CharSet.Unicode, SetLastError=true, ExactSpelling = true)] + [DllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] public static extern IntPtr CreateWindowExW( int exStyle, string lpszClassName, diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs index 7a02b0e27cd..7fe4dc09a28 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class User32 { - [DllImport(Libraries.User32, CharSet=CharSet.Unicode, ExactSpelling = true)] + [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern bool GetClassInfoW(IntPtr hInst, string lpszClass, ref WNDCLASS wc); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetProcessWindowStation.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetProcessWindowStation.cs index 7e16cbe783f..10a3ed9e744 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetProcessWindowStation.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetProcessWindowStation.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class User32 { - [DllImport(Libraries.User32, ExactSpelling=true)] + [DllImport(Libraries.User32, ExactSpelling = true)] internal static extern IntPtr GetProcessWindowStation(); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs index 9afdf0ca6ae..85205d3570a 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class User32 { - [DllImport(Libraries.User32, SetLastError=true, CharSet = CharSet.Unicode, ExactSpelling = true)] + [DllImport(Libraries.User32, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern bool GetUserObjectInformationW(IntPtr hObj, int nIndex, ref USEROBJECTFLAGS pvBuffer, int nLength, ref int lpnLengthNeeded); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.MSG.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.MSG.cs index 871d7727236..cc424da5240 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.MSG.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.MSG.cs @@ -10,14 +10,15 @@ internal partial class Interop internal partial class User32 { [StructLayout(LayoutKind.Sequential)] - public struct MSG { - public IntPtr hwnd; - public int message; - public IntPtr wParam; - public IntPtr lParam; - public int time; - public int pt_x; - public int pt_y; + public struct MSG + { + public IntPtr hwnd; + public int message; + public IntPtr wParam; + public IntPtr lParam; + public int time; + public int pt_x; + public int pt_y; } } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.USEROBJECTFLAGS.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.USEROBJECTFLAGS.cs index f52e0cdd315..f33a5beabf2 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.USEROBJECTFLAGS.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.USEROBJECTFLAGS.cs @@ -8,7 +8,8 @@ internal partial class Interop { internal partial class User32 { - internal struct USEROBJECTFLAGS { + internal struct USEROBJECTFLAGS + { public int fInherit; public int fReserved; public int dwFlags; diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.WNDCLASS.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.WNDCLASS.cs index 72c076bda2f..9f23c761869 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.WNDCLASS.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.WNDCLASS.cs @@ -9,7 +9,7 @@ internal partial class Interop { internal partial class User32 { - [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal unsafe struct WNDCLASS { public int style; diff --git a/src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs b/src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs index 1bc6de94b08..939f62a3cc6 100644 --- a/src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs +++ b/src/libraries/Common/src/System/Data/Common/DbConnectionOptions.Common.cs @@ -26,40 +26,39 @@ namespace System.Data.Common + "))" + "[\\s;]*" ;*/ - private const string ConnectionStringPattern = // may not contain embedded null except trailing last value + private const string ConnectionStringPattern = // may not contain embedded null except trailing last value "([\\s;]*" // leading whitespace and extra semicolons + "(?![\\s;])" // key does not start with space or semicolon + "(?([^=\\s\\p{Cc}]|\\s+[^=\\s\\p{Cc}]|\\s+==|==)+)" // allow any visible character for keyname except '=' which must quoted as '==' + "\\s*=(?!=)\\s*" // the equal sign divides the key and value parts + "(?" - + "(\"([^\"\u0000]|\"\")*\")" // double quoted string, " must be quoted as "" + + "(\"([^\"\u0000]|\"\")*\")" // double quoted string, " must be quoted as "" + "|" - + "('([^'\u0000]|'')*')" // single quoted string, ' must be quoted as '' + + "('([^'\u0000]|'')*')" // single quoted string, ' must be quoted as '' + "|" - + "((?![\"'\\s])" // unquoted value must not start with " or ' or space, would also like = but too late to change - + "([^;\\s\\p{Cc}]|\\s+[^;\\s\\p{Cc}])*" // control characters must be quoted + + "((?![\"'\\s])" // unquoted value must not start with " or ' or space, would also like = but too late to change + + "([^;\\s\\p{Cc}]|\\s+[^;\\s\\p{Cc}])*" // control characters must be quoted + "(?([^=\\s\\p{Cc}]|\\s+[^=\\s\\p{Cc}])+)" // allow any visible character for keyname except '=' - + "\\s*=\\s*" // the equal sign divides the key and value parts + private const string ConnectionStringPatternOdbc = // may not contain embedded null except trailing last value + "([\\s;]*" // leading whitespace and extra semicolons + + "(?![\\s;])" // key does not start with space or semicolon + + "(?([^=\\s\\p{Cc}]|\\s+[^=\\s\\p{Cc}])+)" // allow any visible character for keyname except '=' + + "\\s*=\\s*" // the equal sign divides the key and value parts + "(?" + "(\\{([^\\}\u0000]|\\}\\})*\\})" // quoted string, starts with { and ends with } + "|" + "((?![\\{\\s])" // unquoted value must not start with { or space, would also like = but too late to change - + "([^;\\s\\p{Cc}]|\\s+[^;\\s\\p{Cc}])*" // control characters must be quoted + + "([^;\\s\\p{Cc}]|\\s+[^;\\s\\p{Cc}])*" // control characters must be quoted - + ")" // although the spec does not allow {} - // embedded within a value, the retail code does. + + ")" // although the spec does not allow {} embedded within a value, the retail code does. + ")(\\s*)(;|[\u0000\\s]*$)" // whitespace after value up to semicolon or end-of-line - + ")*" // repeat the key-value pair - + "[\\s;]*[\u0000\\s]*" // traling whitespace/semicolons (DataSourceLocator), embedded nulls are allowed only in the end + + ")*" // repeat the key-value pair + + "[\\s;]*[\u0000\\s]*" // traling whitespace/semicolons (DataSourceLocator), embedded nulls are allowed only in the end ; private static readonly Regex s_connectionStringRegex = new Regex(ConnectionStringPattern, RegexOptions.ExplicitCapture | RegexOptions.Compiled); @@ -548,47 +547,48 @@ namespace System.Data.Common try { #endif - int nextStartPosition = 0; - int endPosition = connectionString.Length; - while (nextStartPosition < endPosition) - { - int startPosition = nextStartPosition; - - string keyname, keyvalue; - nextStartPosition = GetKeyValuePair(connectionString, startPosition, buffer, firstKey, out keyname, out keyvalue); - if (string.IsNullOrEmpty(keyname)) + int nextStartPosition = 0; + int endPosition = connectionString.Length; + while (nextStartPosition < endPosition) { - // if (nextStartPosition != endPosition) { throw; } - break; - } + int startPosition = nextStartPosition; + + string keyname, keyvalue; + nextStartPosition = GetKeyValuePair(connectionString, startPosition, buffer, firstKey, out keyname, out keyvalue); + if (string.IsNullOrEmpty(keyname)) + { + break; + } #if DEBUG DebugTraceKeyValuePair(keyname, keyvalue, synonyms); Debug.Assert(IsKeyNameValid(keyname), "ParseFailure, invalid keyname"); Debug.Assert(IsValueValidInternal(keyvalue), "parse failure, invalid keyvalue"); #endif - string synonym; - string realkeyname = null != synonyms ? - (synonyms.TryGetValue(keyname, out synonym) ? synonym : null) : - keyname; - if (!IsKeyNameValid(realkeyname)) - { - throw ADP.KeywordNotSupported(keyname); - } - if (!firstKey || !parsetable.ContainsKey(realkeyname)) - { - parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first) - } + string synonym; + string realkeyname = null != synonyms ? + (synonyms.TryGetValue(keyname, out synonym) ? synonym : null) : + keyname; - if (null != localKeychain) - { - localKeychain = localKeychain.Next = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition); + if (!IsKeyNameValid(realkeyname)) + { + throw ADP.KeywordNotSupported(keyname); + } + if (!firstKey || !parsetable.ContainsKey(realkeyname)) + { + parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first) + } + + if (null != localKeychain) + { + localKeychain = localKeychain.Next = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition); + } + else if (buildChain) + { + // first time only - don't contain modified chain from UDL file + keychain = localKeychain = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition); + } } - else if (buildChain) - { // first time only - don't contain modified chain from UDL file - keychain = localKeychain = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition); - } - } #if DEBUG } catch (ArgumentException e) diff --git a/src/libraries/Common/src/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs b/src/libraries/Common/src/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs index 01759b3877a..5cc12b43ed5 100644 --- a/src/libraries/Common/src/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs +++ b/src/libraries/Common/src/System/Diagnostics/CodeAnalysis/ExcludeFromCodeCoverageAttribute.cs @@ -10,7 +10,7 @@ namespace System.Diagnostics.CodeAnalysis #else internal #endif - sealed class ExcludeFromCodeCoverageAttribute: Attribute + sealed class ExcludeFromCodeCoverageAttribute : Attribute { public ExcludeFromCodeCoverageAttribute() { } diff --git a/src/libraries/Common/src/System/Globalization/FormatProvider.Number.cs b/src/libraries/Common/src/System/Globalization/FormatProvider.Number.cs index 646b9504079..2d4f90654aa 100644 --- a/src/libraries/Common/src/System/Globalization/FormatProvider.Number.cs +++ b/src/libraries/Common/src/System/Globalization/FormatProvider.Number.cs @@ -1600,12 +1600,12 @@ namespace System.Globalization // Handles E0, which should format the same as E-0 i++; } - else if (src+1 < format.Length && pFormat[src] == '+' && pFormat[src + 1] == '0') + else if (src + 1 < format.Length && pFormat[src] == '+' && pFormat[src + 1] == '0') { // Handles E+0 positiveSign = true; } - else if (src+1 < format.Length && pFormat[src] == '-' && pFormat[src + 1] == '0') + else if (src + 1 < format.Length && pFormat[src] == '-' && pFormat[src + 1] == '0') { // Handles E-0 // Do nothing, this is just a place holder s.t. we don't break out of the loop. diff --git a/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs b/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs index ee7da84d59b..bd2ca6a7e6a 100644 --- a/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs +++ b/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs @@ -411,7 +411,6 @@ namespace System.Net public static new bool IsEnabled => Log.IsEnabled(); - //true; // uncomment for debugging only [NonEvent] public static string IdOf(object value) => value != null ? value.GetType().Name + "#" + GetHashCode(value) : NullInstance; diff --git a/src/libraries/Common/src/System/Resources/ResourceWriter.cs b/src/libraries/Common/src/System/Resources/ResourceWriter.cs index 969b38b7cad..dfab31a78a3 100644 --- a/src/libraries/Common/src/System/Resources/ResourceWriter.cs +++ b/src/libraries/Common/src/System/Resources/ResourceWriter.cs @@ -488,9 +488,11 @@ namespace System.Resources // This is a user type, or a precanned resource. Find type // table index. If not there, add new element. string typeName; - if (type == typeof(PrecannedResource)) { + if (type == typeof(PrecannedResource)) + { typeName = ((PrecannedResource)value).TypeName; - if (typeName.StartsWith("ResourceTypeCode.", StringComparison.Ordinal)) { + if (typeName.StartsWith("ResourceTypeCode.", StringComparison.Ordinal)) + { typeName = typeName.Substring(17); // Remove through '.' ResourceTypeCode typeCode = (ResourceTypeCode)Enum.Parse(typeof(ResourceTypeCode), typeName); return typeCode; @@ -503,7 +505,8 @@ namespace System.Resources } int typeIndex = types.IndexOf(typeName); - if (typeIndex == -1) { + if (typeIndex == -1) + { typeIndex = types.Count; types.Add(typeName); } diff --git a/src/libraries/Common/src/System/Security/Cryptography/Asn1Reader/AsnWriter.cs b/src/libraries/Common/src/System/Security/Cryptography/Asn1Reader/AsnWriter.cs index 26ef55f6ce5..a8ee1dcd124 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/Asn1Reader/AsnWriter.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/Asn1Reader/AsnWriter.cs @@ -421,7 +421,7 @@ namespace System.Security.Cryptography.Asn1 WriteLength(-1); } - private void PopTag(Asn1Tag tag, UniversalTagNumber tagType, bool sortContents=false) + private void PopTag(Asn1Tag tag, UniversalTagNumber tagType, bool sortContents = false) { CheckDisposed(); diff --git a/src/libraries/Common/src/System/Security/Cryptography/DSACng.cs b/src/libraries/Common/src/System/Security/Cryptography/DSACng.cs index 77ea091e83b..f9e716ab952 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/DSACng.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/DSACng.cs @@ -45,7 +45,7 @@ namespace System.Security.Cryptography } public override string SignatureAlgorithm => "DSA"; - public override string KeyExchangeAlgorithm => null; + public override string KeyExchangeAlgorithm => null; // Need to override since base methods throw a "override me" exception: makes SignData/VerifyData function. protected override byte[] HashData(byte[] data, int offset, int count, HashAlgorithmName hashAlgorithm) => diff --git a/src/libraries/Common/src/System/Security/Cryptography/DSAKeyFormatHelper.cs b/src/libraries/Common/src/System/Security/Cryptography/DSAKeyFormatHelper.cs index a4450e12f12..12a128e1dc0 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/DSAKeyFormatHelper.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/DSAKeyFormatHelper.cs @@ -88,9 +88,9 @@ namespace System.Security.Cryptography out key); } - internal static ReadOnlyMemory ReadSubjectPublicKeyInfo( - ReadOnlyMemory source, - out int bytesRead) + internal static ReadOnlyMemory ReadSubjectPublicKeyInfo( + ReadOnlyMemory source, + out int bytesRead) { return KeyFormatHelper.ReadSubjectPublicKeyInfo( s_validOids, diff --git a/src/libraries/Common/src/System/Security/Cryptography/EccKeyFormatHelper.cs b/src/libraries/Common/src/System/Security/Cryptography/EccKeyFormatHelper.cs index 0ec6169843e..dd68722d788 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/EccKeyFormatHelper.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/EccKeyFormatHelper.cs @@ -31,9 +31,9 @@ namespace System.Security.Cryptography out key); } - internal static ReadOnlyMemory ReadSubjectPublicKeyInfo( - ReadOnlyMemory source, - out int bytesRead) + internal static ReadOnlyMemory ReadSubjectPublicKeyInfo( + ReadOnlyMemory source, + out int bytesRead) { return KeyFormatHelper.ReadSubjectPublicKeyInfo( s_validOids, diff --git a/src/libraries/Common/src/System/Security/Cryptography/RSAKeyFormatHelper.cs b/src/libraries/Common/src/System/Security/Cryptography/RSAKeyFormatHelper.cs index db0b438b71e..926cf94ee6b 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/RSAKeyFormatHelper.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/RSAKeyFormatHelper.cs @@ -85,9 +85,9 @@ namespace System.Security.Cryptography out key); } - internal static ReadOnlyMemory ReadSubjectPublicKeyInfo( - ReadOnlyMemory source, - out int bytesRead) + internal static ReadOnlyMemory ReadSubjectPublicKeyInfo( + ReadOnlyMemory source, + out int bytesRead) { return KeyFormatHelper.ReadSubjectPublicKeyInfo( s_validOids, diff --git a/src/libraries/Common/src/System/Text/DBCSDecoder.cs b/src/libraries/Common/src/System/Text/DBCSDecoder.cs index 1d67fcee09d..01268b84a55 100644 --- a/src/libraries/Common/src/System/Text/DBCSDecoder.cs +++ b/src/libraries/Common/src/System/Text/DBCSDecoder.cs @@ -83,7 +83,7 @@ namespace System.Text index++; } - int result = OSEncoding.MultiByteToWideChar(_encoding.CodePage, pTempBuffer, index+1, chars, charCount); + int result = OSEncoding.MultiByteToWideChar(_encoding.CodePage, pTempBuffer, index + 1, chars, charCount); if (count - index > 0) result += OSEncoding.MultiByteToWideChar( @@ -170,7 +170,7 @@ namespace System.Text if (charCount == 0) return 0; - byte lastByte = byteCount > 0 && !flush && IsLastByteALeadByte(bytes, byteCount) ? bytes[byteCount - 1] : (byte) 0; + byte lastByte = byteCount > 0 && !flush && IsLastByteALeadByte(bytes, byteCount) ? bytes[byteCount - 1] : (byte)0; if (lastByte != 0) byteCount--; @@ -183,7 +183,7 @@ namespace System.Text return 0; } - int result = OSEncoding.MultiByteToWideChar(_encoding.CodePage, bytes, byteCount, chars, charCount); + int result = OSEncoding.MultiByteToWideChar(_encoding.CodePage, bytes, byteCount, chars, charCount); _leftOverLeadByte = lastByte; return result; } diff --git a/src/libraries/Common/src/System/Text/OSEncoder.cs b/src/libraries/Common/src/System/Text/OSEncoder.cs index 092e99d29fe..4a56ccb0781 100644 --- a/src/libraries/Common/src/System/Text/OSEncoder.cs +++ b/src/libraries/Common/src/System/Text/OSEncoder.cs @@ -62,7 +62,7 @@ namespace System.Text index++; } - int result = OSEncoding.WideCharToMultiByte(_encoding.CodePage, pTempBuffer, index+1, bytes, byteCount); + int result = OSEncoding.WideCharToMultiByte(_encoding.CodePage, pTempBuffer, index + 1, bytes, byteCount); if (count - index > 0) result += OSEncoding.WideCharToMultiByte( @@ -157,7 +157,7 @@ namespace System.Text return 0; } - int result = OSEncoding.WideCharToMultiByte(_encoding.CodePage, chars, charCount, bytes, byteCount); + int result = OSEncoding.WideCharToMultiByte(_encoding.CodePage, chars, charCount, bytes, byteCount); _charLeftOver = lastChar; return result; } diff --git a/src/libraries/Common/src/System/Text/OSEncoding.Windows.cs b/src/libraries/Common/src/System/Text/OSEncoding.Windows.cs index 38b5da5695e..c7815f68bbf 100644 --- a/src/libraries/Common/src/System/Text/OSEncoding.Windows.cs +++ b/src/libraries/Common/src/System/Text/OSEncoding.Windows.cs @@ -34,7 +34,7 @@ namespace System.Text fixed (char* pChar = chars) { - return WideCharToMultiByte(_codePage, pChar+index, count, null, 0); + return WideCharToMultiByte(_codePage, pChar + index, count, null, 0); } } @@ -76,9 +76,9 @@ namespace System.Text } fixed (char* pChars = s) - fixed (byte *pBytes = &bytes[0]) + fixed (byte* pBytes = &bytes[0]) { - return WideCharToMultiByte(_codePage, pChars+charIndex, charCount, pBytes+byteIndex, bytes.Length - byteIndex); + return WideCharToMultiByte(_codePage, pChars + charIndex, charCount, pBytes + byteIndex, bytes.Length - byteIndex); } } @@ -105,9 +105,9 @@ namespace System.Text } fixed (char* pChars = chars) - fixed (byte *pBytes = &bytes[0]) + fixed (byte* pBytes = &bytes[0]) { - return WideCharToMultiByte(_codePage, pChars+charIndex, charCount, pBytes+byteIndex, bytes.Length - byteIndex); + return WideCharToMultiByte(_codePage, pChars + charIndex, charCount, pBytes + byteIndex, bytes.Length - byteIndex); } } @@ -127,7 +127,7 @@ namespace System.Text fixed (byte* pBytes = bytes) { - return MultiByteToWideChar(_codePage, pBytes+index, count, null, 0); + return MultiByteToWideChar(_codePage, pBytes + index, count, null, 0); } } @@ -154,7 +154,7 @@ namespace System.Text fixed (byte* pBytes = bytes) fixed (char* pChars = &chars[0]) { - return MultiByteToWideChar(_codePage, pBytes+byteIndex, byteCount, pChars+charIndex, chars.Length - charIndex); + return MultiByteToWideChar(_codePage, pBytes + byteIndex, byteCount, pChars + charIndex, chars.Length - charIndex); } } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderEquivalence.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderEquivalence.cs index a67dcc38ecd..3ea5f16f0a8 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderEquivalence.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderEquivalence.cs @@ -31,10 +31,10 @@ namespace Microsoft.CSharp.RuntimeBinder // creating binders is not a very frequent operation. // typically a dynamic operation in the source will create just one binder lazily when first executed. private static readonly ConcurrentDictionary binderEquivalenceCache = - new ConcurrentDictionary(concurrencyLevel:2, capacity: 32, new BinderEqualityComparer()); + new ConcurrentDictionary(concurrencyLevel: 2, capacity: 32, new BinderEqualityComparer()); internal static T TryGetExisting(this T binder) - where T: ICSharpBinder + where T : ICSharpBinder { var fromCache = binderEquivalenceCache.GetOrAdd(binder, binder); if (fromCache == (object)binder) diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs index 924d73c8dc6..67c7a439fe0 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs @@ -112,7 +112,7 @@ namespace Microsoft.CSharp.RuntimeBinder DynamicMetaObject arg0 = args[0]; expression = Expression.Block( - new[] {tempForIncrement}, + new[] { tempForIncrement }, Expression.Assign(tempForIncrement, Expression.Convert(arg0.Expression, arg0.Value.GetType())), expression, Expression.Assign(arg0.Expression, Expression.Convert(tempForIncrement, arg0.Expression.Type))); @@ -367,7 +367,7 @@ namespace Microsoft.CSharp.RuntimeBinder return array; } - return new[] {sourceHead, sourceLast}; + return new[] { sourceHead, sourceLast }; } ///////////////////////////////////////////////////////////////////////////////// diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpBinaryOperationBinder.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpBinaryOperationBinder.cs index f1d9b2ed602..1fa96251868 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpBinaryOperationBinder.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpBinaryOperationBinder.cs @@ -127,7 +127,7 @@ namespace Microsoft.CSharp.RuntimeBinder { BinderHelper.ValidateBindArgument(target, nameof(target)); BinderHelper.ValidateBindArgument(arg, nameof(arg)); - return BinderHelper.Bind(this, _binder, new[] {target, arg}, _argumentInfo, errorSuggestion); + return BinderHelper.Bind(this, _binder, new[] { target, arg }, _argumentInfo, errorSuggestion); } } } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpGetIndexBinder.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpGetIndexBinder.cs index c49eb07f013..d0d69c7f42d 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpGetIndexBinder.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpGetIndexBinder.cs @@ -15,7 +15,7 @@ namespace Microsoft.CSharp.RuntimeBinder /// internal sealed class CSharpGetIndexBinder : GetIndexBinder, ICSharpBinder { - public string Name => SpecialNames.Indexer; + public string Name => SpecialNames.Indexer; public BindingFlag BindingFlags => BindingFlag.BIND_RVALUEREQUIRED; diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpUnaryOperationBinder.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpUnaryOperationBinder.cs index 9020efb505c..c2c2bfae3a1 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpUnaryOperationBinder.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/CSharpUnaryOperationBinder.cs @@ -110,7 +110,7 @@ namespace Microsoft.CSharp.RuntimeBinder public override DynamicMetaObject FallbackUnaryOperation(DynamicMetaObject target, DynamicMetaObject errorSuggestion) { BinderHelper.ValidateBindArgument(target, nameof(target)); - return BinderHelper.Bind(this, _binder, new[] {target}, _argumentInfo, errorSuggestion); + return BinderHelper.Bind(this, _binder, new[] { target }, _argumentInfo, errorSuggestion); } } } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ExpressionTreeCallRewriter.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ExpressionTreeCallRewriter.cs index df73f1e096b..2e110c73af1 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ExpressionTreeCallRewriter.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ExpressionTreeCallRewriter.cs @@ -775,13 +775,11 @@ namespace Microsoft.CSharp.RuntimeBinder return GenerateConvert(call); case PREDEFMETH.PM_EXPRESSION_NEWARRAYINIT: - { ExprList list = (ExprList)call.OptionalArguments; return Expression.NewArrayInit( ((ExprTypeOf)list.OptionalElement).SourceType.AssociatedSystemType, GetArgumentsFromArrayInit((ExprArrayInit)list.OptionalNextListNode)); - } case PREDEFMETH.PM_EXPRESSION_ARRAYINDEX: case PREDEFMETH.PM_EXPRESSION_ARRAYINDEX2: diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs index 4941f162095..3817e0bd226 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Conversion.cs @@ -1135,7 +1135,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics pexprDest = ExprFactory.CreateConstant(typeDest, cv); return ConstCastResult.Success; } - valueInt = (long)(constSrc.UInt64Value& 0xFFFFFFFFFFFFFFFF); + valueInt = (long)(constSrc.UInt64Value & 0xFFFFFFFFFFFFFFFF); } else { diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs index c179ee40d84..443912bb010 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs @@ -722,10 +722,10 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics // invocation. private GroupToArgsBinderResult BindMethodGroupToArgumentsCore(BindingFlag bindFlags, ExprMemberGroup grp, Expr args, int carg, NamedArgumentsKind namedArgumentsKind) { - ArgInfos pargInfo = new ArgInfos {carg = carg}; + ArgInfos pargInfo = new ArgInfos { carg = carg }; FillInArgInfoFromArgList(pargInfo, args); - ArgInfos pOriginalArgInfo = new ArgInfos {carg = carg}; + ArgInfos pOriginalArgInfo = new ArgInfos { carg = carg }; FillInArgInfoFromArgList(pOriginalArgInfo, args); GroupToArgsBinder binder = new GroupToArgsBinder(this, bindFlags, grp, pargInfo, pOriginalArgInfo, namedArgumentsKind); @@ -1069,7 +1069,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics [Conditional("DEBUG")] private static void AssertObjectIsLvalue(Expr pObject) { - Debug.Assert ( + Debug.Assert( pObject == null || // statics are always lvalues (((pObject.Flags & EXPRFLAG.EXF_LVALUE) != 0) && (pObject.Kind != ExpressionKind.Property)) || // things marked as lvalues have props/fields which are lvalues, with one exception: props of structs @@ -1319,7 +1319,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics return type; - NEXTI: + NEXTI: ; } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs index 4f338cc3dc4..6ebb848f791 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/ExprOperator.cs @@ -15,7 +15,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics } protected ExprOperator(ExpressionKind kind, CType type, Expr call, MethPropWithInst userDefinedMethod) - : this (kind, type) + : this(kind, type) { OptionalUserDefinedCall = call; UserDefinedCallMethod = userDefinedMethod; diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs index f8d67be962f..3b9f6c1da9f 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/Tree/Visitors/ExpressionTreeRewriter.cs @@ -34,7 +34,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics Expr lhs; if (assignment.LHS is ExprProperty prop) { - if (prop.OptionalArguments== null) + if (prop.OptionalArguments == null) { // Regular property. lhs = Visit(prop); @@ -113,7 +113,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics { Debug.Assert(expr != null); Expr pObject; - if (expr.OptionalObject== null) + if (expr.OptionalObject == null) { pObject = ExprFactory.CreateNull(); } @@ -244,7 +244,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics } Expr pObject; - if (expr.MethWithInst.Meth().isStatic || expr.MemberGroup.OptionalObject== null) + if (expr.MethWithInst.Meth().isStatic || expr.MemberGroup.OptionalObject == null) { pObject = ExprFactory.CreateNull(); } @@ -283,7 +283,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics { Debug.Assert(expr != null); Expr pObject; - if (expr.PropWithTypeSlot.Prop().isStatic || expr.MemberGroup.OptionalObject== null) + if (expr.PropWithTypeSlot.Prop().isStatic || expr.MemberGroup.OptionalObject == null) { pObject = ExprFactory.CreateNull(); } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/WithType.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/WithType.cs index 365094475a2..e691ba0f622 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/WithType.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/WithType.cs @@ -94,7 +94,7 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics } // The SymWithType is considered NULL iff the Symbol is NULL. - public static implicit operator bool (SymWithType swt) + public static implicit operator bool(SymWithType swt) { return swt != null; } diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs index 9765082df42..5df305f4194 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/SymbolTable.cs @@ -39,7 +39,7 @@ namespace Microsoft.CSharp.RuntimeBinder public override bool Equals(object obj) { Debug.Fail("Sub-optimal overload called. Check if this can be avoided."); - return obj is NameHashKey key && Equals(key); + return obj is NameHashKey key && Equals(key); } public override int GetHashCode() => Type.GetHashCode() ^ Name.GetHashCode(); @@ -789,10 +789,10 @@ namespace Microsoft.CSharp.RuntimeBinder { // We use "IsEquivalentTo" so that unified local types match. if (sym is AggregateSymbol agg) - if (agg.AssociatedSystemType.IsEquivalentTo(t.IsGenericType ? t.GetGenericTypeDefinition() : t)) - { - return agg; - } + if (agg.AssociatedSystemType.IsEquivalentTo(t.IsGenericType ? t.GetGenericTypeDefinition() : t)) + { + return agg; + } sym = sym.nextSameName; } diff --git a/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs b/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs index 64f1561be05..58b582f9688 100644 --- a/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs +++ b/src/libraries/Microsoft.XmlSerializer.Generator/src/Sgen.cs @@ -67,7 +67,7 @@ namespace Microsoft.XmlSerializer.Generator else if (ArgumentMatch(arg, "out") || ShortNameArgumentMatch(arg, "o")) { i++; - if (i >= args.Length || codePath != null ) + if (i >= args.Length || codePath != null) { errs.Add(SR.Format(SR.ErrInvalidArgument, arg)); } @@ -388,7 +388,7 @@ namespace Microsoft.XmlSerializer.Generator private bool ArgumentMatch(string arg, string formal) { // Full name format, eg: --assembly - if (arg.Length < 3 || arg[0] != '-' || arg[1] != '-' ) + if (arg.Length < 3 || arg[0] != '-' || arg[1] != '-') { return false; } diff --git a/src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs b/src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs index b778e6c0ced..8643d1a86cc 100644 --- a/src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs +++ b/src/libraries/System.CodeDom/src/Microsoft/CSharp/CSharpCodeGenerator.cs @@ -2741,60 +2741,60 @@ namespace Microsoft.CSharp } } - // replace + with . for nested classes. - // - var sb = new StringBuilder(s.Length + 10); - if ((typeRef.Options & CodeTypeReferenceOptions.GlobalReference) != 0) - { - sb.Append("global::"); - } + // replace + with . for nested classes. + // + var sb = new StringBuilder(s.Length + 10); + if ((typeRef.Options & CodeTypeReferenceOptions.GlobalReference) != 0) + { + sb.Append("global::"); + } - string baseType = typeRef.BaseType; + string baseType = typeRef.BaseType; - int lastIndex = 0; - int currentTypeArgStart = 0; - for (int i = 0; i < baseType.Length; i++) - { - switch (baseType[i]) + int lastIndex = 0; + int currentTypeArgStart = 0; + for (int i = 0; i < baseType.Length; i++) + { + switch (baseType[i]) + { + case '+': + case '.': + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); + sb.Append('.'); + i++; + lastIndex = i; + break; + + case '`': + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); + i++; // skip the ' + int numTypeArgs = 0; + while (i < baseType.Length && baseType[i] >= '0' && baseType[i] <= '9') { - case '+': - case '.': - sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); - sb.Append('.'); - i++; - lastIndex = i; - break; - - case '`': - sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); - i++; // skip the ' - int numTypeArgs = 0; - while (i < baseType.Length && baseType[i] >= '0' && baseType[i] <= '9') - { - numTypeArgs = numTypeArgs * 10 + (baseType[i] - '0'); - i++; - } - - GetTypeArgumentsOutput(typeRef.TypeArguments, currentTypeArgStart, numTypeArgs, sb); - currentTypeArgStart += numTypeArgs; - - // Arity can be in the middle of a nested type name, so we might have a . or + after it. - // Skip it if so. - if (i < baseType.Length && (baseType[i] == '+' || baseType[i] == '.')) - { - sb.Append('.'); - i++; - } - - lastIndex = i; - break; + numTypeArgs = numTypeArgs * 10 + (baseType[i] - '0'); + i++; } - } - if (lastIndex < baseType.Length) - sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex))); + GetTypeArgumentsOutput(typeRef.TypeArguments, currentTypeArgStart, numTypeArgs, sb); + currentTypeArgStart += numTypeArgs; - return sb.ToString(); + // Arity can be in the middle of a nested type name, so we might have a . or + after it. + // Skip it if so. + if (i < baseType.Length && (baseType[i] == '+' || baseType[i] == '.')) + { + sb.Append('.'); + i++; + } + + lastIndex = i; + break; + } + } + + if (lastIndex < baseType.Length) + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex))); + + return sb.ToString(); } private string GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArguments) diff --git a/src/libraries/System.CodeDom/src/Microsoft/VisualBasic/VBCodeGenerator.cs b/src/libraries/System.CodeDom/src/Microsoft/VisualBasic/VBCodeGenerator.cs index cee045d606c..4eeaa42f367 100644 --- a/src/libraries/System.CodeDom/src/Microsoft/VisualBasic/VBCodeGenerator.cs +++ b/src/libraries/System.CodeDom/src/Microsoft/VisualBasic/VBCodeGenerator.cs @@ -2450,58 +2450,58 @@ namespace Microsoft.VisualBasic } } - var sb = new StringBuilder(baseType.Length + 10); - if ((typeRef.Options & CodeTypeReferenceOptions.GlobalReference) != 0) - { - sb.Append("Global."); - } + var sb = new StringBuilder(baseType.Length + 10); + if ((typeRef.Options & CodeTypeReferenceOptions.GlobalReference) != 0) + { + sb.Append("Global."); + } - int lastIndex = 0; - int currentTypeArgStart = 0; - for (int i = 0; i < baseType.Length; i++) + int lastIndex = 0; + int currentTypeArgStart = 0; + for (int i = 0; i < baseType.Length; i++) + { + switch (baseType[i]) { - switch (baseType[i]) - { - case '+': - case '.': - sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); + case '+': + case '.': + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); + sb.Append('.'); + i++; + lastIndex = i; + break; + + case '`': + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); + i++; // skip the ' + int numTypeArgs = 0; + while (i < baseType.Length && baseType[i] >= '0' && baseType[i] <= '9') + { + numTypeArgs = numTypeArgs * 10 + (baseType[i] - '0'); + i++; + } + + GetTypeArgumentsOutput(typeRef.TypeArguments, currentTypeArgStart, numTypeArgs, sb); + currentTypeArgStart += numTypeArgs; + + // Arity can be in the middle of a nested type name, so we might have a . or + after it. + // Skip it if so. + if (i < baseType.Length && (baseType[i] == '+' || baseType[i] == '.')) + { sb.Append('.'); i++; - lastIndex = i; - break; + } - case '`': - sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); - i++; // skip the ' - int numTypeArgs = 0; - while (i < baseType.Length && baseType[i] >= '0' && baseType[i] <= '9') - { - numTypeArgs = numTypeArgs * 10 + (baseType[i] - '0'); - i++; - } - - GetTypeArgumentsOutput(typeRef.TypeArguments, currentTypeArgStart, numTypeArgs, sb); - currentTypeArgStart += numTypeArgs; - - // Arity can be in the middle of a nested type name, so we might have a . or + after it. - // Skip it if so. - if (i < baseType.Length && (baseType[i] == '+' || baseType[i] == '.')) - { - sb.Append('.'); - i++; - } - - lastIndex = i; - break; - } + lastIndex = i; + break; } + } - if (lastIndex < baseType.Length) - { - sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex))); - } + if (lastIndex < baseType.Length) + { + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex))); + } - return sb.ToString(); + return sb.ToString(); } private string GetTypeOutputWithoutArrayPostFix(CodeTypeReference typeRef) diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs index e6d73f3b76c..ef1095ea357 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs @@ -555,11 +555,11 @@ namespace System.Collections.Concurrent private readonly IEnumerator _sharedReader; private readonly SharedLong _sharedIndex; //initial value -1 - private volatile KeyValuePair[]? _fillBuffer; // intermediate buffer to reduce locking - private volatile int _fillBufferSize; // actual number of elements in _FillBuffer. Will start - // at _FillBuffer.Length, and might be reduced during the last refill - private volatile int _fillBufferCurrentPosition; //shared value to be accessed by Interlock.Increment only - private volatile int _activeCopiers; //number of active copiers + private volatile KeyValuePair[]? _fillBuffer; // intermediate buffer to reduce locking + private volatile int _fillBufferSize; // actual number of elements in _FillBuffer. Will start + // at _FillBuffer.Length, and might be reduced during the last refill + private volatile int _fillBufferCurrentPosition; //shared value to be accessed by Interlock.Increment only + private volatile int _activeCopiers; //number of active copiers //fields shared by all partitions that this Enumerable owns, their allocation is deferred private readonly SharedBool _hasNoElementsLeft; // no elements left at all. diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Builder.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Builder.cs index c0c35479d6f..cc8ac354aa0 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Builder.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.Builder.cs @@ -169,7 +169,7 @@ namespace System.Collections.Immutable { return ref this.Root.ItemRef(index); } - #endif +#endif #endregion diff --git a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs index ab228d4d6cc..f809126e7c4 100644 --- a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs +++ b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameObjectCollectionBase.cs @@ -53,13 +53,15 @@ namespace System.Collections.Specialized } [Obsolete("Please use NameObjectCollectionBase(IEqualityComparer) instead.")] - protected NameObjectCollectionBase(IHashCodeProvider hashProvider, IComparer comparer) { + protected NameObjectCollectionBase(IHashCodeProvider hashProvider, IComparer comparer) + { _keyComparer = new CompatibleComparer(hashProvider, comparer); Reset(); } [Obsolete("Please use NameObjectCollectionBase(Int32, IEqualityComparer) instead.")] - protected NameObjectCollectionBase(int capacity, IHashCodeProvider hashProvider, IComparer comparer) { + protected NameObjectCollectionBase(int capacity, IHashCodeProvider hashProvider, IComparer comparer) + { _keyComparer = new CompatibleComparer(hashProvider, comparer); Reset(capacity); } diff --git a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs index cff5546b152..38c88138396 100644 --- a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs +++ b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/NameValueCollection.cs @@ -48,7 +48,8 @@ namespace System.Collections.Specialized [Obsolete("Please use NameValueCollection(IEqualityComparer) instead.")] public NameValueCollection(IHashCodeProvider hashProvider, IComparer comparer) - : base(hashProvider, comparer) { + : base(hashProvider, comparer) + { } /// @@ -89,7 +90,8 @@ namespace System.Collections.Specialized [Obsolete("Please use NameValueCollection(Int32, IEqualityComparer) instead.")] public NameValueCollection(int capacity, IHashCodeProvider hashProvider, IComparer comparer) - : base(capacity, hashProvider, comparer) { + : base(capacity, hashProvider, comparer) + { } protected NameValueCollection(SerializationInfo info, StreamingContext context) : base(info, context) diff --git a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs index 2e782d0fad9..30c9b9613c2 100644 --- a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs +++ b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs @@ -422,7 +422,8 @@ namespace System.Collections.Specialized #endregion #region IDeserializationCallback implementation - void IDeserializationCallback.OnDeserialization(object sender) { + void IDeserializationCallback.OnDeserialization(object sender) + { OnDeserialization(sender); } diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.TreeSubSet.cs b/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.TreeSubSet.cs index 8c766020f8a..9ac4f7433aa 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.TreeSubSet.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.TreeSubSet.cs @@ -177,7 +177,7 @@ namespace System.Collections.Generic } return result; - } + } } internal override bool InOrderTreeWalk(TreeWalkPredicate action) diff --git a/src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Collections/CollectionServices.CollectionOfObject.cs b/src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Collections/CollectionServices.CollectionOfObject.cs index 0abaf274258..82dc72392dc 100644 --- a/src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Collections/CollectionServices.CollectionOfObject.cs +++ b/src/libraries/System.ComponentModel.Composition/src/Microsoft/Internal/Collections/CollectionServices.CollectionOfObject.cs @@ -108,7 +108,7 @@ namespace Microsoft.Internal.Collections public void Add(object item) { - _collectionOfT.Add((T) item); + _collectionOfT.Add((T)item); } public void Clear() diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ConstraintServices.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ConstraintServices.cs index 303eda8782a..3ee2140a5c0 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ConstraintServices.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ConstraintServices.cs @@ -108,7 +108,7 @@ namespace System.ComponentModel.Composition // CreationPolicy.Any.Equals(definition.Metadata[CompositionConstants.PartCreationPolicyMetadataName]) || // policy.Equals(definition.Metadata[CompositionConstants.PartCreationPolicyMetadataName]); - return Expression.MakeBinary(ExpressionType.OrElse, + return Expression.MakeBinary(ExpressionType.OrElse, Expression.MakeBinary(ExpressionType.OrElse, Expression.Not(CreateMetadataContainsKeyExpression(parameter, CompositionConstants.PartCreationPolicyMetadataName)), CreateMetadataValueEqualsExpression(parameter, CreationPolicy.Any, CompositionConstants.PartCreationPolicyMetadataName)), @@ -130,7 +130,7 @@ namespace System.ComponentModel.Composition // definition.Metadata.ContainsKey(CompositionServices.ExportTypeIdentity) && // requiredTypeIdentity.Equals(definition.Metadata[CompositionConstants.ExportTypeIdentityMetadataName]); - return Expression.MakeBinary(ExpressionType.AndAlso, + return Expression.MakeBinary(ExpressionType.AndAlso, CreateMetadataContainsKeyExpression(parameter, CompositionConstants.ExportTypeIdentityMetadataName), CreateMetadataValueEqualsExpression(parameter, requiredTypeIdentity, CompositionConstants.ExportTypeIdentityMetadataName)); } @@ -148,7 +148,7 @@ namespace System.ComponentModel.Composition } // definition.Metadata.ContainsKey(constantKey) - return Expression.Call( + return Expression.Call( Expression.Property(parameter, ConstraintServices._exportDefinitionMetadataProperty), ConstraintServices._metadataContainsKeyMethod, Expression.Constant(constantKey)); @@ -195,7 +195,7 @@ namespace System.ComponentModel.Composition } // constantValue.Equals(definition.Metadata[CompositionServices.PartCreationPolicyMetadataName]) - return Expression.Call( + return Expression.Call( Expression.Constant(constantValue), ConstraintServices._metadataEqualsMethod, Expression.Call( diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs index 15bfb4dd581..0e70ea9b3d1 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/AggregateExportProvider.cs @@ -81,7 +81,7 @@ namespace System.ComponentModel.Composition.Hosting /// /// public AggregateExportProvider(IEnumerable providers) - : this((providers!= null) ? providers.AsArray() : null) + : this((providers != null) ? providers.AsArray() : null) { } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs index 1ed182e8fab..ed3e532a190 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ApplicationCatalog.cs @@ -21,7 +21,7 @@ namespace System.ComponentModel.Composition.Hosting private readonly ICompositionElement _definitionOrigin = null; private readonly ReflectionContext _reflectionContext = null; - public ApplicationCatalog() {} + public ApplicationCatalog() { } public ApplicationCatalog(ICompositionElement definitionOrigin) { @@ -59,9 +59,9 @@ namespace System.ComponentModel.Composition.Hosting : new DirectoryCatalog(location, pattern); } -// Note: -// Creating a catalog does not cause change notifications to propagate, For some reason the DeploymentCatalog did, but that is a bug. -// InnerCatalog is delay evaluated, from data supplied at construction time and so does not propagate change notifications + // Note: + // Creating a catalog does not cause change notifications to propagate, For some reason the DeploymentCatalog did, but that is a bug. + // InnerCatalog is delay evaluated, from data supplied at construction time and so does not propagate change notifications private AggregateCatalog InnerCatalog { get @@ -85,7 +85,7 @@ namespace System.ComponentModel.Composition.Hosting string relativeSearchPath = AppDomain.CurrentDomain.RelativeSearchPath; if (!string.IsNullOrEmpty(relativeSearchPath)) { - string[] probingPaths = relativeSearchPath.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries); + string[] probingPaths = relativeSearchPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (var probingPath in probingPaths) { var path = Path.Combine(location, probingPath); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs index bf6218441b3..35ddb1452d6 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ComposablePartExportProvider.cs @@ -32,7 +32,7 @@ namespace System.ComponentModel.Composition.Hosting } public ComposablePartExportProvider(bool isThreadSafe) - :this(isThreadSafe ? CompositionOptions.IsThreadSafe : CompositionOptions.Default) + : this(isThreadSafe ? CompositionOptions.IsThreadSafe : CompositionOptions.Default) { } @@ -180,7 +180,7 @@ namespace System.ComponentModel.Composition.Hosting } } -/// + /// /// Returns all exports that match the conditions of the specified import. /// /// The that defines the conditions of the diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs index 57da31eb88c..b37bf6b7a35 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionContainer.cs @@ -90,7 +90,7 @@ namespace System.ComponentModel.Composition.Hosting /// /// contains an element that is . /// - public CompositionContainer(ComposablePartCatalog catalog, params ExportProvider[] providers): + public CompositionContainer(ComposablePartCatalog catalog, params ExportProvider[] providers) : this(catalog, false, providers) { } @@ -212,7 +212,7 @@ namespace System.ComponentModel.Composition.Hosting _disposableRootProvider = _rootProvider as IDisposable; } -//Insert Composition Service + //Insert Composition Service if (compositionOptions.HasFlag(CompositionOptions.ExportCompositionService)) { this.ComposeExportedValue(new CompositionServiceShim(this)); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionOptions.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionOptions.cs index 3a5d19054c7..c25ef887c88 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionOptions.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionOptions.cs @@ -10,9 +10,9 @@ namespace System.ComponentModel.Composition.Hosting [Flags] public enum CompositionOptions { - Default = 0x0000, - DisableSilentRejection = 0x0001, - IsThreadSafe = 0x0002, + Default = 0x0000, + DisableSilentRejection = 0x0001, + IsThreadSafe = 0x0002, ExportCompositionService = 0x0004 } } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs index ffbe6b8b82c..e4cef2e85c7 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinition.cs @@ -37,7 +37,7 @@ namespace System.ComponentModel.Composition.Hosting InitializeCompositionScopeDefinition(catalog, children, null); } -/// + /// /// Initializes a new instance of the class. /// /// The catalog. @@ -52,7 +52,7 @@ namespace System.ComponentModel.Composition.Hosting InitializeCompositionScopeDefinition(catalog, children, publicSurface); } -/// + /// /// Initializes a new instance of the class. /// /// The catalog. @@ -137,7 +137,7 @@ namespace System.ComponentModel.Composition.Hosting ThrowIfDisposed(); if (_publicSurface == null) { - return this.SelectMany( (p) => p.ExportDefinitions ); + return this.SelectMany((p) => p.ExportDefinitions); } return _publicSurface; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinitionDebuggerProxy.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinitionDebuggerProxy.cs index 08e6a9d3083..b87db9126be 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinitionDebuggerProxy.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionScopeDefinitionDebuggerProxy.cs @@ -43,6 +43,5 @@ namespace System.ComponentModel.Composition.Hosting return _compositionScopeDefinition.Children.ToReadOnlyCollection(); } } - -} + } } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs index 38a03920c41..93cf9ace32b 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/CompositionServices.cs @@ -115,7 +115,7 @@ namespace System.ComponentModel.Composition.Hosting } } -internal static string GetTypeIdentityFromExport(this MemberInfo member, Type typeIdentityType) + internal static string GetTypeIdentityFromExport(this MemberInfo member, Type typeIdentityType) { if (typeIdentityType != null) { @@ -154,7 +154,7 @@ internal static string GetTypeIdentityFromExport(this MemberInfo member, Type ty return string.IsNullOrEmpty(export.ContractName); } -internal static Type GetContractTypeFromImport(this IAttributedImport import, ImportType importType) + internal static Type GetContractTypeFromImport(this IAttributedImport import, ImportType importType) { if (import.ContractType != null) { @@ -224,7 +224,7 @@ internal static Type GetContractTypeFromImport(this IAttributedImport import, Im bool hasConstraints = false; object[] genericParameterConstraints = new object[genericArguments.Length]; GenericParameterAttributes[] genericParameterAttributes = new GenericParameterAttributes[genericArguments.Length]; - for (int i=0; i< genericArguments.Length; i++) + for (int i = 0; i < genericArguments.Length; i++) { Type genericArgument = genericArguments[i]; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.cs index 0cef10d003b..1270460d380 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.cs @@ -47,7 +47,7 @@ namespace System.ComponentModel.Composition.Hosting } } -/// + /// /// Releases unmanaged and - optionally - managed resources /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. @@ -173,12 +173,12 @@ namespace System.ComponentModel.Composition.Hosting /// public event EventHandler Changed; -/// + /// /// Notify when the contents of the Catalog is changing. /// public event EventHandler Changing; -/// + /// /// Raises the event. /// /// The instance containing the event data. diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ImportSourceImportDefinitionHelpers.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ImportSourceImportDefinitionHelpers.cs index 61d05b748bf..ed0c221051f 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ImportSourceImportDefinitionHelpers.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ImportSourceImportDefinitionHelpers.cs @@ -53,7 +53,7 @@ namespace System.ComponentModel.Composition.Hosting var reply = _metadata; if (reply == null) { - reply = new Dictionary (_sourceDefinition.Metadata); + reply = new Dictionary(_sourceDefinition.Metadata); reply.Remove(CompositionConstants.ImportSourceMetadataName); _metadata = reply; } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ScopingExtensions.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ScopingExtensions.cs index 3c9416ea5ab..57f8d8c3dca 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ScopingExtensions.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/ScopingExtensions.cs @@ -81,7 +81,7 @@ namespace System.ComponentModel.Composition.Hosting return false; } -/// + /// /// Determines whether the part contains a metadata entry with the specified key. /// /// The part. diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataAttributeAttribute.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataAttributeAttribute.cs index b08f97e98ed..0bcd1071e2f 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataAttributeAttribute.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataAttributeAttribute.cs @@ -8,8 +8,7 @@ namespace System.ComponentModel.Composition /// Specifies that an attribute can be used to provide metadata for a type, property, field, /// or method marked with the . /// - [AttributeUsage(AttributeTargets.Class, - AllowMultiple=false, Inherited=true)] + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] public sealed class MetadataAttributeAttribute : Attribute { /// diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewGenerator.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewGenerator.cs index e19456d7c24..84853dd3351 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewGenerator.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewGenerator.cs @@ -59,17 +59,17 @@ namespace System.ComponentModel.Composition { public delegate object MetadataViewFactory(IDictionary metadata); - public const string MetadataViewType = "MetadataViewType"; - public const string MetadataItemKey = "MetadataItemKey"; - public const string MetadataItemTargetType = "MetadataItemTargetType"; - public const string MetadataItemSourceType = "MetadataItemSourceType"; - public const string MetadataItemValue = "MetadataItemValue"; - public const string MetadataViewFactoryName= "Create"; + public const string MetadataViewType = "MetadataViewType"; + public const string MetadataItemKey = "MetadataItemKey"; + public const string MetadataItemTargetType = "MetadataItemTargetType"; + public const string MetadataItemSourceType = "MetadataItemSourceType"; + public const string MetadataItemValue = "MetadataItemValue"; + public const string MetadataViewFactoryName = "Create"; private static readonly Lock _lock = new Lock(); private static readonly Dictionary _metadataViewFactories = new Dictionary(); private static readonly AssemblyName ProxyAssemblyName = new AssemblyName(string.Format(CultureInfo.InvariantCulture, "MetadataViewProxies_{0}", Guid.NewGuid())); - private static ModuleBuilder transparentProxyModuleBuilder; + private static ModuleBuilder transparentProxyModuleBuilder; private static readonly Type[] CtorArgumentTypes = new Type[] { typeof(IDictionary) }; private static readonly MethodInfo _mdvDictionaryTryGet = CtorArgumentTypes[0].GetMethod("TryGetValue"); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewProvider.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewProvider.cs index 509c5bd9ca4..31c82c4ddf5 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewProvider.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/MetadataViewProvider.cs @@ -135,9 +135,9 @@ namespace System.ComponentModel.Composition } // If the Metadata dictionary is cast compatible with the passed in type - if (ExportServices.IsDefaultMetadataViewType(metadataViewType) - || metadataViewType.IsInterface - || ExportServices.IsDictionaryConstructorViewType(metadataViewType)) + if (ExportServices.IsDefaultMetadataViewType(metadataViewType) || + metadataViewType.IsInterface || + ExportServices.IsDictionaryConstructorViewType(metadataViewType)) { return true; } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartDefinition.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartDefinition.cs index 997beb0c2f5..565858b8a35 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartDefinition.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ComposablePartDefinition.cs @@ -32,7 +32,7 @@ namespace System.ComponentModel.Composition.Primitives /// . /// /// - /// + /// /// Overrides of this property should never return . /// If the objects created by the /// do not provide exported values, return diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ExportedDelegate.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ExportedDelegate.cs index 0ceadf0f21f..f37d88b7abd 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ExportedDelegate.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/ExportedDelegate.cs @@ -51,7 +51,7 @@ namespace System.ComponentModel.Composition.Primitives // This array should contains a lit of all argument types, and the last one is the return type (could be void) Type[] parameterTypes = new Type[parameters.Length + 1]; parameterTypes[parameters.Length] = _method.ReturnType; - for (int i = 0; i < parameters.Length; i++ ) + for (int i = 0; i < parameters.Length; i++) { parameterTypes[i] = parameters[i].ParameterType; } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/PrimitivesServices.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/PrimitivesServices.cs index 6213a5822c2..1085c176c62 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/PrimitivesServices.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Primitives/PrimitivesServices.cs @@ -51,7 +51,7 @@ namespace System.ComponentModel.Composition.Primitives } } -internal static bool IsImportDependentOnPart(this ImportDefinition import, ComposablePartDefinition part, ExportDefinition export, bool expandGenerics) + internal static bool IsImportDependentOnPart(this ImportDefinition import, ComposablePartDefinition part, ExportDefinition export, bool expandGenerics) { import = import.GetProductImportDefinition(); if (expandGenerics) diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportfactoryCreator.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportfactoryCreator.cs index 3dd2fecad9f..450c29b7ffa 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportfactoryCreator.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportfactoryCreator.cs @@ -12,7 +12,7 @@ namespace System.ComponentModel.Composition.ReflectionModel private static readonly MethodInfo _createStronglyTypedExportFactoryOfT = typeof(ExportFactoryCreator).GetMethod("CreateStronglyTypedExportFactoryOfT", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); private static readonly MethodInfo _createStronglyTypedExportFactoryOfTM = typeof(ExportFactoryCreator).GetMethod("CreateStronglyTypedExportFactoryOfTM", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); - private readonly Type _exportFactoryType; + private readonly Type _exportFactoryType; public ExportFactoryCreator(Type exportFactoryType) { @@ -29,7 +29,7 @@ namespace System.ComponentModel.Composition.ReflectionModel MethodInfo genericMethod = null; if (metadataViewType == null) { - genericMethod = _createStronglyTypedExportFactoryOfT.MakeGenericMethod(exportType); + genericMethod = _createStronglyTypedExportFactoryOfT.MakeGenericMethod(exportType); } else { @@ -71,7 +71,7 @@ namespace System.ComponentModel.Composition.ReflectionModel var metadataView = AttributedModelServices.GetMetadataView(export.Metadata); object[] args = { exportLifetimeContextCreator, metadataView }; - var instance = Activator.CreateInstance(constructed, args); + var instance = Activator.CreateInstance(constructed, args); return instance; } diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs index 5ec6e9b77b3..292eeba259e 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionComposablePart.cs @@ -187,7 +187,7 @@ namespace System.ComponentModel.Composition.ReflectionModel { RequiresRunning(); Requires.NotNull(definition, nameof(definition)); - Requires.NotNull(exports, nameof(exports));; + Requires.NotNull(exports, nameof(exports)); ImportingItem item = GetImportingItemFromDefinition(definition); if (item == null) diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServices.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServices.cs index 0f576c38e76..474615bc357 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServices.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionModelServices.cs @@ -322,7 +322,7 @@ namespace System.ComponentModel.Composition.ReflectionModel } } -internal class ReflectionPartCreationInfo : IReflectionPartCreationInfo + internal class ReflectionPartCreationInfo : IReflectionPartCreationInfo { private readonly Lazy _partType; private readonly Lazy> _imports; diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionParameter.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionParameter.cs index 57d543725e4..190bb7f1100 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionParameter.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ReflectionParameter.cs @@ -14,8 +14,8 @@ namespace System.ComponentModel.Composition.ReflectionModel public ReflectionParameter(ParameterInfo parameter) { - if (parameter == null) - { + if (parameter == null) + { throw new ArgumentNullException(nameof(parameter)); } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BooleanConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BooleanConverter.cs index b54faa40ed2..d89bb6a7f81 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BooleanConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/BooleanConverter.cs @@ -48,7 +48,7 @@ namespace System.ComponentModel /// public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { - return s_values ?? (s_values = new StandardValuesCollection(new object[] {true, false})); + return s_values ?? (s_values = new StandardValuesCollection(new object[] { true, false })); } /// diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerOptionService.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerOptionService.cs index 7e38a7f4ee2..599153fe031 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerOptionService.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerOptionService.cs @@ -14,7 +14,7 @@ namespace System.ComponentModel.Design public abstract class DesignerOptionService : IDesignerOptionService { private DesignerOptionCollection _options; - private static readonly char[] s_slash = {'\\'}; + private static readonly char[] s_slash = { '\\' }; /// /// Returns the options collection for this service. There is diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs index a7b19a48284..a85b08a76d2 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/PropertyTabAttribute.cs @@ -122,7 +122,7 @@ namespace System.ComponentModel } } - protected string[] TabClassNames => (string[]) _tabClassNames?.Clone(); + protected string[] TabClassNames => (string[])_tabClassNames?.Clone(); /// /// Gets the scopes of tabs for this System.ComponentModel.Design.PropertyTabAttribute, from System.ComponentModel.Design.PropertyTabScope. diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs index d6941fd8af2..0d6b7a4d816 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/LicenseManager.cs @@ -179,7 +179,7 @@ namespace System.ComponentModel private static LicenseProvider GetCachedProviderInstance(Type providerType) { Debug.Assert(providerType != null, "Type cannot ever be null"); - return (LicenseProvider) s_providerInstances?[providerType]; + return (LicenseProvider)s_providerInstances?[providerType]; } /// diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MarshalByValueComponent.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MarshalByValueComponent.cs index 2f9340cb5be..5149b75f0ef 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MarshalByValueComponent.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MarshalByValueComponent.cs @@ -131,7 +131,7 @@ namespace System.ComponentModel lock (this) { _site?.Container?.Remove(this); - ((EventHandler) _events?[s_eventDisposed])?.Invoke(this, EventArgs.Empty); + ((EventHandler)_events?[s_eventDisposed])?.Invoke(this, EventArgs.Empty); } } } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MemberDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MemberDescriptor.cs index 93118413f4a..2198db25054 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MemberDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/MemberDescriptor.cs @@ -173,13 +173,13 @@ namespace System.ComponentModel /// Gets the name of the category that the member belongs to, as specified /// in the . /// - public virtual string Category => _category ?? (_category = ((CategoryAttribute) Attributes[typeof(CategoryAttribute)]).Category); + public virtual string Category => _category ?? (_category = ((CategoryAttribute)Attributes[typeof(CategoryAttribute)]).Category); /// /// Gets the description of the member as specified in the . /// public virtual string Description => _description ?? - (_description = ((DescriptionAttribute) Attributes[typeof(DescriptionAttribute)]).Description); + (_description = ((DescriptionAttribute)Attributes[typeof(DescriptionAttribute)]).Description); /// /// Gets a value indicating whether the member is browsable as specified in the @@ -455,7 +455,8 @@ namespace System.ComponentModel protected static ISite GetSite(object component) => (component as IComponent)?.Site; [Obsolete("This method has been deprecated. Use GetInvocationTarget instead. https://go.microsoft.com/fwlink/?linkid=14202")] - protected static object GetInvokee(Type componentClass, object component) { + protected static object GetInvokee(Type componentClass, object component) + { if (componentClass == null) { diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs index 8b6705afb2a..72f0d9375a0 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs @@ -107,9 +107,9 @@ namespace System.ComponentModel } else if (destinationType == typeof(InstanceDescriptor)) { - ConstructorInfo ci = NullableType.GetConstructor(new Type[] {UnderlyingType}); + ConstructorInfo ci = NullableType.GetConstructor(new Type[] { UnderlyingType }); Debug.Assert(ci != null, "Couldn't find constructor"); - return new InstanceDescriptor(ci, new object[] {value}, true); + return new InstanceDescriptor(ci, new object[] { value }, true); } else if (value == null) { diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs index 14c3c38631f..68d24a25aaf 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs @@ -383,7 +383,7 @@ namespace System.ComponentModel { if (component != null) { - ((EventHandler) _valueChangedHandlers?[component])?.Invoke(component, e); + ((EventHandler)_valueChangedHandlers?[component])?.Invoke(component, e); } } diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReferenceConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReferenceConverter.cs index 601dcd4d5f9..ff855a0eb93 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReferenceConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReferenceConverter.cs @@ -94,7 +94,7 @@ namespace System.ComponentModel if (value != null) { // Try the reference service first. - IReferenceService refSvc = (IReferenceService) context?.GetService(typeof(IReferenceService)); + IReferenceService refSvc = (IReferenceService)context?.GetService(typeof(IReferenceService)); if (refSvc != null) { string name = refSvc.GetName(value); diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs index 245777f6cc8..100d0638d9e 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectEventDescriptor.cs @@ -153,11 +153,14 @@ namespace System.ComponentModel if (changeService != null) { - try { + try + { changeService.OnComponentChanging(component, this); } - catch (CheckoutException coEx) { - if (coEx == CheckoutException.Canceled) { + catch (CheckoutException coEx) + { + if (coEx == CheckoutException.Canceled) + { return; } throw; @@ -424,11 +427,14 @@ namespace System.ComponentModel if (changeService != null) { - try { + try + { changeService.OnComponentChanging(component, this); } - catch (CheckoutException coEx) { - if (coEx == CheckoutException.Canceled) { + catch (CheckoutException coEx) + { + if (coEx == CheckoutException.Canceled) + { return; } throw; diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs index 46ee18c4d78..23edb7f9d53 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs @@ -565,7 +565,7 @@ namespace System.ComponentModel { // Check our association table for a match. Hashtable assocTable = AssociationTable; - IList associations = (IList) assocTable?[primary]; + IList associations = (IList)assocTable?[primary]; if (associations != null) { lock (associations) @@ -2401,7 +2401,7 @@ namespace System.ComponentModel } Hashtable assocTable = AssociationTable; - IList associations = (IList) assocTable?[primary]; + IList associations = (IList)assocTable?[primary]; if (associations != null) { lock (associations) diff --git a/src/libraries/System.Composition.AttributedModel/src/System/Composition/ExportAttribute.cs b/src/libraries/System.Composition.AttributedModel/src/System/Composition/ExportAttribute.cs index 960fa2fb2b4..7a6602b17c1 100644 --- a/src/libraries/System.Composition.AttributedModel/src/System/Composition/ExportAttribute.cs +++ b/src/libraries/System.Composition.AttributedModel/src/System/Composition/ExportAttribute.cs @@ -76,7 +76,7 @@ namespace System.Composition /// A containing the contract name to export the type or member /// marked with this attribute, under. The default value is an empty string (""). /// - public string ContractName { get; } + public string ContractName { get; } /// /// Get the contract type that is exported by the member that this attribute is attached to. diff --git a/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/DiscoveredPart.cs b/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/DiscoveredPart.cs index 54da7dfd548..7f2de397334 100644 --- a/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/DiscoveredPart.cs +++ b/src/libraries/System.Composition.TypedParts/src/System/Composition/TypedParts/Discovery/DiscoveredPart.cs @@ -238,7 +238,7 @@ namespace System.Composition.TypedParts.Discovery public int GetHashCode(ParameterInfo obj) { - return HashHelpers.Combine(obj.Position.GetHashCode(), obj.Member.GetHashCode()); + return HashHelpers.Combine(obj.Position.GetHashCode(), obj.Member.GetHashCode()); } public bool Equals(ParameterInfo x, ParameterInfo y) diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs index 0283dc316de..4a4013be1b2 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/BaseConfigurationRecord.cs @@ -31,37 +31,37 @@ namespace System.Configuration protected const string ConfigSectionsTag = "configSections"; protected const string SectionTag = "section"; - protected const string SectionNameAttribute = "name"; - protected const string SectionTypeAttribute = "type"; - protected const string SectionAllowLocationAttribute = "allowLocation"; - protected const string SectionAllowDefinitionAttribute = "allowDefinition"; - protected const string AllowDefinitionEverywhere = "Everywhere"; - protected const string AllowDefinitionMachineOnly = "MachineOnly"; - protected const string AllowDefinitionMachineToApplication = "MachineToApplication"; - protected const string AllowDefinitionMachineToWebRoot = "MachineToWebRoot"; - protected const string SectionAllowExeDefinitionAttribute = "allowExeDefinition"; - protected const string AllowExeDefinitionMachineToRoaming = "MachineToRoamingUser"; - protected const string AllowExeDefinitionMachineToLocal = "MachineToLocalUser"; - protected const string SectionRestartonExternalChangesAttribute = "restartOnExternalChanges"; - protected const string SectionRequirePermissionAttribute = "requirePermission"; - internal const string SectionOverrideModeDefaultAttribute = "overrideModeDefault"; + protected const string SectionNameAttribute = "name"; + protected const string SectionTypeAttribute = "type"; + protected const string SectionAllowLocationAttribute = "allowLocation"; + protected const string SectionAllowDefinitionAttribute = "allowDefinition"; + protected const string AllowDefinitionEverywhere = "Everywhere"; + protected const string AllowDefinitionMachineOnly = "MachineOnly"; + protected const string AllowDefinitionMachineToApplication = "MachineToApplication"; + protected const string AllowDefinitionMachineToWebRoot = "MachineToWebRoot"; + protected const string SectionAllowExeDefinitionAttribute = "allowExeDefinition"; + protected const string AllowExeDefinitionMachineToRoaming = "MachineToRoamingUser"; + protected const string AllowExeDefinitionMachineToLocal = "MachineToLocalUser"; + protected const string SectionRestartonExternalChangesAttribute = "restartOnExternalChanges"; + protected const string SectionRequirePermissionAttribute = "requirePermission"; + internal const string SectionOverrideModeDefaultAttribute = "overrideModeDefault"; internal const string OverrideModeInherit = "Inherit"; internal const string OverrideModeAllow = "Allow"; internal const string OverrideModeDeny = "Deny"; protected const string SectionGroupTag = "sectionGroup"; - protected const string SectionGroupNameAttribute = "name"; - protected const string SectionGroupTypeAttribute = "type"; + protected const string SectionGroupNameAttribute = "name"; + protected const string SectionGroupTypeAttribute = "type"; protected const string RemoveTag = "remove"; protected const string ClearTag = "clear"; protected const string LocationTag = "location"; - protected const string LocationPathAttribute = "path"; - internal const string LocationAllowOverrideAttribute = "allowOverride"; - internal const string LocationOverrideModeAttribute = "overrideMode"; - protected const string LocationInheritInChildApplicationsAttribute = "inheritInChildApplications"; + protected const string LocationPathAttribute = "path"; + internal const string LocationAllowOverrideAttribute = "allowOverride"; + internal const string LocationOverrideModeAttribute = "overrideMode"; + protected const string LocationInheritInChildApplicationsAttribute = "inheritInChildApplications"; protected const string ConfigSourceAttribute = "configSource"; internal const string ProtectionProviderAttibute = "configProtectionProvider"; diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigPaths.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigPaths.cs index 02dfec7f4d3..f2b9289655f 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigPaths.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigPaths.cs @@ -70,7 +70,7 @@ namespace System.Configuration } else { - ApplicationUri = Uri.EscapeDataString(configBasePath); + ApplicationUri = Uri.EscapeDataString(configBasePath); } } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/InternalConfigRoot.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/InternalConfigRoot.cs index 5ce74339311..5938dea9938 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/InternalConfigRoot.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Internal/InternalConfigRoot.cs @@ -142,7 +142,7 @@ namespace System.Configuration.Internal childRecord = _isDesignTime ? MgmtConfigurationRecord.Create(this, currentRecord, currentConfigPath, null) - : (BaseConfigurationRecord) RuntimeConfigurationRecord.Create(this, currentRecord, currentConfigPath); + : (BaseConfigurationRecord)RuntimeConfigurationRecord.Create(this, currentRecord, currentConfigPath); currentRecord.HlAddChild(configName, childRecord); diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ProtectedConfigurationSection.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ProtectedConfigurationSection.cs index 76ae5b46379..dfc7533e0ec 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ProtectedConfigurationSection.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ProtectedConfigurationSection.cs @@ -28,7 +28,7 @@ namespace System.Configuration private static readonly ConfigurationPropertyCollection s_properties = new ConfigurationPropertyCollection { s_propProviders, s_propDefaultProvider }; - public ProtectedConfigurationSection(){} + public ProtectedConfigurationSection() { } protected internal override ConfigurationPropertyCollection Properties => s_properties; diff --git a/src/libraries/System.Console/src/System/Console.cs b/src/libraries/System.Console/src/System/Console.cs index faf949041ba..365f03ecff0 100644 --- a/src/libraries/System.Console/src/System/Console.cs +++ b/src/libraries/System.Console/src/System/Console.cs @@ -130,7 +130,10 @@ namespace System stream: outputStream, encoding: OutputEncoding.RemovePreamble(), // This ensures no prefix is written to the stream. bufferSize: WriteBufferSize, - leaveOpen: true) { AutoFlush = true }); + leaveOpen: true) + { + AutoFlush = true + }); } private static StrongBox _isStdInRedirected; diff --git a/src/libraries/System.Console/src/System/ConsolePal.Windows.cs b/src/libraries/System.Console/src/System/ConsolePal.Windows.cs index 7bf08b77a11..8e1586775cd 100644 --- a/src/libraries/System.Console/src/System/ConsolePal.Windows.cs +++ b/src/libraries/System.Console/src/System/ConsolePal.Windows.cs @@ -1030,7 +1030,7 @@ namespace System } // Try to give a better error message here - Interop.Kernel32.COORD bounds = Interop.Kernel32.GetLargestConsoleWindowSize(OutputHandle); + Interop.Kernel32.COORD bounds = Interop.Kernel32.GetLargestConsoleWindowSize(OutputHandle); if (width > bounds.X) throw new ArgumentOutOfRangeException(nameof(width), width, SR.Format(SR.ArgumentOutOfRange_ConsoleWindowSize_Size, bounds.X)); if (height > bounds.Y) diff --git a/src/libraries/System.Data.Common/src/System/Data/Constraint.cs b/src/libraries/System.Data.Common/src/System/Data/Constraint.cs index 7fc5cdad328..01a30b75b28 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Constraint.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Constraint.cs @@ -20,7 +20,7 @@ namespace System.Data internal string _name = string.Empty; internal PropertyCollection _extendedProperties = null; - internal Constraint() {} + internal Constraint() { } /// /// The name of this constraint within the . diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index 3cd42b5130e..3c3bbedcb8c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -4775,7 +4775,7 @@ namespace System.Data } DataRow dataRow = LoadRow(values, loadOption, indextoUse); // if indextoUse == null, it means we dont have PK, - // so LoadRow will take care of just adding the row to end + // so LoadRow will take care of just adding the row to end return dataRow; } diff --git a/src/libraries/System.Data.Common/src/System/Data/DataView.cs b/src/libraries/System.Data.Common/src/System/Data/DataView.cs index 523ea6d4064..f06ef1ad0fd 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataView.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataView.cs @@ -757,7 +757,7 @@ namespace System.Data } /// This method exists for LinqDataView to keep a level of abstraction away from the RBTree - internal Range FindRecords(Index.ComparisonBySelector comparison, TKey key) where TRow:DataRow + internal Range FindRecords(Index.ComparisonBySelector comparison, TKey key) where TRow : DataRow { return _index.FindRecords(comparison, key); } diff --git a/src/libraries/System.Data.Common/src/System/Data/LinqDataView.cs b/src/libraries/System.Data.Common/src/System/Data/LinqDataView.cs index 0609213578e..de4432c20b5 100644 --- a/src/libraries/System.Data.Common/src/System/Data/LinqDataView.cs +++ b/src/libraries/System.Data.Common/src/System/Data/LinqDataView.cs @@ -122,7 +122,7 @@ namespace System.Data } else // find for expression based sort { - if (sortExpressionBuilder.Count !=1) + if (sortExpressionBuilder.Count != 1) throw DataSetUtil.InvalidOperation(SR.Format(SR.LDV_InvalidNumOfKeys, sortExpressionBuilder.Count)); Index.ComparisonBySelector compareDelg = @@ -217,8 +217,7 @@ namespace System.Data internal override void SetIndex(string newSort, DataViewRowState newRowStates, IFilter newRowFilter) { // Throw only if expressions (filter or sort) are used and rowstate is not current rows - if ( (base.SortComparison != null || base.RowPredicate != null) - && newRowStates != DataViewRowState.CurrentRows) + if ((base.SortComparison != null || base.RowPredicate != null) && newRowStates != DataViewRowState.CurrentRows) { throw DataSetUtil.Argument(SR.LDVRowStateError); } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs index 962f61e4c17..4154dd09c6b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs @@ -114,7 +114,7 @@ namespace System.Data.SqlTypes /// /// Converts a to a binary object. /// - public static explicit operator byte[] (SqlBinary x) => x.Value; + public static explicit operator byte[](SqlBinary x) => x.Value; /// /// Returns a string describing a object. diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs index 206831d3757..e2ff7ce92c1 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs @@ -106,7 +106,7 @@ namespace System.Data.SqlTypes /// /// Converts a to a boolean. /// - public static explicit operator bool (SqlBoolean x) + public static explicit operator bool(SqlBoolean x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs index 6c695896eda..29093fb3bac 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs @@ -64,7 +64,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlByte to byte. Throw exception if x is Null. - public static explicit operator byte (SqlByte x) + public static explicit operator byte(SqlByte x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs index 0dd2400f061..d9718390df5 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs @@ -1167,7 +1167,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlDecimal to Decimal. Throw exception if x is Null. - public static explicit operator decimal (SqlDecimal x) + public static explicit operator decimal(SqlDecimal x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs index adae6d2b18f..32781b76ef4 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs @@ -70,7 +70,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlDouble to double. Throw exception if x is Null. - public static explicit operator double (SqlDouble x) + public static explicit operator double(SqlDouble x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs index 6d2a5a05cd1..3c005a9225a 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs @@ -63,7 +63,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlInt16 to short. Throw exception if x is Null. - public static explicit operator short (SqlInt16 x) + public static explicit operator short(SqlInt16 x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs index 9c2ad073abb..f0f8673af0c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs @@ -64,7 +64,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlInt32 to int. Throw exception if x is Null. - public static explicit operator int (SqlInt32 x) + public static explicit operator int(SqlInt32 x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs index a86bea4b227..0ad4d97ecbf 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs @@ -65,7 +65,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlInt64 to long. Throw exception if x is Null. - public static explicit operator long (SqlInt64 x) + public static explicit operator long(SqlInt64 x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs index b3d7057c02f..ebef7c49996 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs @@ -200,7 +200,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlMoney to Decimal. Throw exception if x is Null. - public static explicit operator decimal (SqlMoney x) + public static explicit operator decimal(SqlMoney x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs index ce7cc65a535..efae1f98cba 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs @@ -71,7 +71,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlSingle to float. Throw exception if x is Null. - public static explicit operator float (SqlSingle x) + public static explicit operator float(SqlSingle x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs index 3aa30c896c6..835e199d5b9 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs @@ -297,7 +297,7 @@ namespace System.Data.SqlTypes } // Explicit conversion from SqlString to String. Throw exception if x is Null. - public static explicit operator string (SqlString x) + public static explicit operator string(SqlString x) { return x.Value; } diff --git a/src/libraries/System.Data.Common/src/System/Data/Selection.cs b/src/libraries/System.Data.Common/src/System/Data/Selection.cs index 63dc79f1554..71588849bf9 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Selection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Selection.cs @@ -621,10 +621,10 @@ namespace System.Data return x; } - internal delegate int ComparisonBySelector(TKey key, TRow row) where TRow:DataRow; + internal delegate int ComparisonBySelector(TKey key, TRow row) where TRow : DataRow; /// This method exists for LinqDataView to keep a level of abstraction away from the RBTree - internal Range FindRecords(ComparisonBySelector comparison, TKey key) where TRow:DataRow + internal Range FindRecords(ComparisonBySelector comparison, TKey key) where TRow : DataRow { int x = _records.root; while (IndexTree.NIL != x) diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs index a1ba2f3b18f..58d8ba8bab4 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs @@ -688,57 +688,43 @@ namespace System.Data.Odbc // Column set for SQLPrimaryKeys internal enum SQL_PRIMARYKEYS : short { -/* - CATALOGNAME = 1, // TABLE_CAT - SCHEMANAME = 2, // TABLE_SCHEM - TABLENAME = 3, // TABLE_NAME -*/ + // CATALOGNAME = 1, // TABLE_CAT + // SCHEMANAME = 2, // TABLE_SCHEM + // TABLENAME = 3, // TABLE_NAME COLUMNNAME = 4, // COLUMN_NAME -/* - KEY_SEQ = 5, // KEY_SEQ - PKNAME = 6, // PK_NAME -*/ + // KEY_SEQ = 5, // KEY_SEQ + // PKNAME = 6, // PK_NAME } // Column set for SQLStatistics internal enum SQL_STATISTICS : short { -/* - CATALOGNAME = 1, // TABLE_CAT - SCHEMANAME = 2, // TABLE_SCHEM - TABLENAME = 3, // TABLE_NAME - NONUNIQUE = 4, // NON_UNIQUE - INDEXQUALIFIER = 5, // INDEX_QUALIFIER -*/ + // CATALOGNAME = 1, // TABLE_CAT + // SCHEMANAME = 2, // TABLE_SCHEM + // TABLENAME = 3, // TABLE_NAME + // NONUNIQUE = 4, // NON_UNIQUE + // INDEXQUALIFIER = 5, // INDEX_QUALIFIER INDEXNAME = 6, // INDEX_NAME -/* - TYPE = 7, // TYPE -*/ - ORDINAL_POSITION = 8, // ORDINAL_POSITION - COLUMN_NAME = 9, // COLUMN_NAME -/* - ASC_OR_DESC = 10, // ASC_OR_DESC - CARDINALITY = 11, // CARDINALITY - PAGES = 12, // PAGES - FILTER_CONDITION = 13, // FILTER_CONDITION -*/ + // TYPE = 7, // TYPE + ORDINAL_POSITION = 8, // ORDINAL_POSITION + COLUMN_NAME = 9, // COLUMN_NAME + // ASC_OR_DESC = 10, // ASC_OR_DESC + // CARDINALITY = 11, // CARDINALITY + // PAGES = 12, // PAGES + // FILTER_CONDITION = 13, // FILTER_CONDITION } // Column set for SQLSpecialColumns internal enum SQL_SPECIALCOLUMNSET : short { -/* - SCOPE = 1, // SCOPE -*/ + // SCOPE = 1, // SCOPE COLUMN_NAME = 2, // COLUMN_NAME -/* - DATA_TYPE = 3, // DATA_TYPE - TYPE_NAME = 4, // TYPE_NAME - COLUMN_SIZE = 5, // COLUMN_SIZE - BUFFER_LENGTH = 6, // BUFFER_LENGTH - DECIMAL_DIGITS = 7, // DECIMAL_DIGITS - PSEUDO_COLUMN = 8, // PSEUDO_COLUMN -*/ + // DATA_TYPE = 3, // DATA_TYPE + // TYPE_NAME = 4, // TYPE_NAME + // COLUMN_SIZE = 5, // COLUMN_SIZE + // BUFFER_LENGTH = 6, // BUFFER_LENGTH + // DECIMAL_DIGITS = 7, // DECIMAL_DIGITS + // PSEUDO_COLUMN = 8, // PSEUDO_COLUMN } internal const short SQL_DIAG_SQLSTATE = 4; diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameterHelper.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameterHelper.cs index 361b4792fbc..6c29aa1f2f1 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameterHelper.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameterHelper.cs @@ -23,7 +23,8 @@ namespace System.Data.Odbc private object _coercedValue; - private OdbcParameter(OdbcParameter source) : this() { // V1.2.3300, Clone + private OdbcParameter(OdbcParameter source) : this() // V1.2.3300, Clone + { ADP.CheckArgumentNull(source, nameof(source)); source.CloneHelper(this); diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcStatementHandle.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcStatementHandle.cs index 0a306c3cc52..2599fa2fea0 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcStatementHandle.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcStatementHandle.cs @@ -40,8 +40,8 @@ namespace System.Data.Odbc return new SQLLEN(value); } - public static unsafe implicit operator int (SQLLEN value) - { // + public static unsafe implicit operator int(SQLLEN value) + { #if WIN32 return (int)value._value.ToInt32(); #else @@ -50,7 +50,7 @@ namespace System.Data.Odbc #endif } - public static unsafe explicit operator long (SQLLEN value) + public static unsafe explicit operator long(SQLLEN value) { return value._value.ToInt64(); } diff --git a/src/libraries/System.Data.OleDb/src/OleDbParameterCollectionHelper.cs b/src/libraries/System.Data.OleDb/src/OleDbParameterCollectionHelper.cs index 11bfb766fca..319dd4c612f 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbParameterCollectionHelper.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbParameterCollectionHelper.cs @@ -37,20 +37,26 @@ namespace System.Data.OleDb } } - public override bool IsFixedSize { - get { + public override bool IsFixedSize + { + get + { return ((System.Collections.IList)InnerList).IsFixedSize; } } - public override bool IsReadOnly { - get { + public override bool IsReadOnly + { + get + { return ((System.Collections.IList)InnerList).IsReadOnly; } } - public override bool IsSynchronized { - get { + public override bool IsSynchronized + { + get + { return ((System.Collections.ICollection)InnerList).IsSynchronized; } } diff --git a/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs b/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs index a7565478ad9..7730558ebad 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs @@ -261,12 +261,13 @@ namespace System.Data.Common internal static ArgumentOutOfRangeException InvalidCommandType(CommandType value) { #if DEBUG - switch (value) { - case CommandType.Text: - case CommandType.StoredProcedure: - case CommandType.TableDirect: - Debug.Assert(false, "valid CommandType " + value.ToString()); - break; + switch (value) + { + case CommandType.Text: + case CommandType.StoredProcedure: + case CommandType.TableDirect: + Debug.Assert(false, "valid CommandType " + value.ToString()); + break; } #endif return InvalidEnumerationValue(typeof(CommandType), (int)value); @@ -276,13 +277,14 @@ namespace System.Data.Common internal static ArgumentOutOfRangeException InvalidDataRowVersion(DataRowVersion value) { #if DEBUG - switch (value) { - case DataRowVersion.Default: - case DataRowVersion.Current: - case DataRowVersion.Original: - case DataRowVersion.Proposed: - Debug.Assert(false, "valid DataRowVersion " + value.ToString()); - break; + switch (value) + { + case DataRowVersion.Default: + case DataRowVersion.Current: + case DataRowVersion.Original: + case DataRowVersion.Proposed: + Debug.Assert(false, "valid DataRowVersion " + value.ToString()); + break; } #endif return InvalidEnumerationValue(typeof(DataRowVersion), (int)value); @@ -292,16 +294,17 @@ namespace System.Data.Common internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value) { #if DEBUG - switch (value) { - case IsolationLevel.Unspecified: - case IsolationLevel.Chaos: - case IsolationLevel.ReadUncommitted: - case IsolationLevel.ReadCommitted: - case IsolationLevel.RepeatableRead: - case IsolationLevel.Serializable: - case IsolationLevel.Snapshot: - Debug.Assert(false, "valid IsolationLevel " + value.ToString()); - break; + switch (value) + { + case IsolationLevel.Unspecified: + case IsolationLevel.Chaos: + case IsolationLevel.ReadUncommitted: + case IsolationLevel.ReadCommitted: + case IsolationLevel.RepeatableRead: + case IsolationLevel.Serializable: + case IsolationLevel.Snapshot: + Debug.Assert(false, "valid IsolationLevel " + value.ToString()); + break; } #endif return InvalidEnumerationValue(typeof(IsolationLevel), (int)value); @@ -311,13 +314,14 @@ namespace System.Data.Common internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value) { #if DEBUG - switch (value) { - case ParameterDirection.Input: - case ParameterDirection.Output: - case ParameterDirection.InputOutput: - case ParameterDirection.ReturnValue: - Debug.Assert(false, "valid ParameterDirection " + value.ToString()); - break; + switch (value) + { + case ParameterDirection.Input: + case ParameterDirection.Output: + case ParameterDirection.InputOutput: + case ParameterDirection.ReturnValue: + Debug.Assert(false, "valid ParameterDirection " + value.ToString()); + break; } #endif return InvalidEnumerationValue(typeof(ParameterDirection), (int)value); @@ -327,13 +331,14 @@ namespace System.Data.Common internal static ArgumentOutOfRangeException InvalidUpdateRowSource(UpdateRowSource value) { #if DEBUG - switch (value) { - case UpdateRowSource.None: - case UpdateRowSource.OutputParameters: - case UpdateRowSource.FirstReturnedRecord: - case UpdateRowSource.Both: - Debug.Assert(false, "valid UpdateRowSource " + value.ToString()); - break; + switch (value) + { + case UpdateRowSource.None: + case UpdateRowSource.OutputParameters: + case UpdateRowSource.FirstReturnedRecord: + case UpdateRowSource.Both: + Debug.Assert(false, "valid UpdateRowSource " + value.ToString()); + break; } #endif return InvalidEnumerationValue(typeof(UpdateRowSource), (int)value); @@ -1293,15 +1298,17 @@ namespace System.Data.Common return (condition == (condition & value.Direction)); } #if DEBUG - private static void IsDirectionValid(ParameterDirection value) { - switch (value) { // @perfnote: Enum.IsDefined - case ParameterDirection.Input: - case ParameterDirection.Output: - case ParameterDirection.InputOutput: - case ParameterDirection.ReturnValue: - break; - default: - throw ADP.InvalidParameterDirection(value); + private static void IsDirectionValid(ParameterDirection value) + { + switch (value) + { // @perfnote: Enum.IsDefined + case ParameterDirection.Input: + case ParameterDirection.Output: + case ParameterDirection.InputOutput: + case ParameterDirection.ReturnValue: + break; + default: + throw ADP.InvalidParameterDirection(value); } } #endif diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SNI/LocalDB.Windows.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SNI/LocalDB.Windows.cs index 6f2a1415aca..367e1a3c7aa 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SNI/LocalDB.Windows.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SNI/LocalDB.Windows.cs @@ -82,7 +82,7 @@ namespace System.Data.SqlClient.SNI lock (this) { - if (_sqlUserInstanceLibraryHandle !=null) + if (_sqlUserInstanceLibraryHandle != null) { return true; } diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SNI/SNIPacket.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SNI/SNIPacket.cs index b2a54916d4d..c806f39c0ac 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SNI/SNIPacket.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SNI/SNIPacket.cs @@ -16,7 +16,7 @@ namespace System.Data.SqlClient.SNI private int _dataCapacity; // the total capacity requested, if the array is rented this may be less than the _data.Length, does not include smux header length private int _dataOffset; // the start point of the data in the data segment, advanced by Take-ing data private int _headerLength; // the amount of space at the start of the array reserved for the smux header, this is zeroed in SetHeader - // _headerOffset is not needed because it is always 0 + // _headerOffset is not needed because it is always 0 private byte[] _data; private SNIAsyncCallback _completionCallback; diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs index 1f9736e8dff..5ac2f13476b 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs @@ -924,7 +924,8 @@ namespace System.Data.SqlClient { AsyncHelper.ContinueTaskWithState(execNQ, completion, state: Tuple.Create(this, completion), - onSuccess: state => { + onSuccess: state => + { var parameters = (Tuple>)state; parameters.Item1.BeginExecuteNonQueryInternalReadStage(parameters.Item2); } @@ -1284,7 +1285,8 @@ namespace System.Data.SqlClient { AsyncHelper.ContinueTaskWithState(writeTask, completion, state: Tuple.Create(this, completion), - onSuccess: state => { + onSuccess: state => + { var parameters = (Tuple>)state; parameters.Item1.BeginExecuteXmlReaderInternalReadStage(parameters.Item2); } @@ -1573,7 +1575,8 @@ namespace System.Data.SqlClient { AsyncHelper.ContinueTaskWithState(writeTask, completion, state: Tuple.Create(this, completion), - onSuccess: state => { + onSuccess: state => + { var parameters = (Tuple>)state; parameters.Item1.BeginExecuteReaderInternalReadStage(parameters.Item2); } @@ -2584,7 +2587,7 @@ namespace System.Data.SqlClient Debug.Assert(!IsPrepared, "Batch RPC should not be prepared!"); Debug.Assert(!IsDirty, "Batch RPC should not be marked as dirty!"); Debug.Assert(_SqlRPCBatchArray != null, "RunExecuteReader rpc array not provided"); - writeTask = _stateObj.Parser.TdsExecuteRPC( _SqlRPCBatchArray, timeout, inSchema, this.Notification, _stateObj, CommandType.StoredProcedure == CommandType, sync: !asyncWrite); + writeTask = _stateObj.Parser.TdsExecuteRPC(_SqlRPCBatchArray, timeout, inSchema, this.Notification, _stateObj, CommandType.StoredProcedure == CommandType, sync: !asyncWrite); } else if ((System.Data.CommandType.Text == this.CommandType) && (0 == GetParameterCount(_parameters))) { @@ -3328,7 +3331,7 @@ namespace System.Data.SqlClient if (parameter.IsDerivedParameterTypeName) { string[] parts = MultipartIdentifier.ParseMultipartIdentifier(parameter.TypeName, "[\"", "]\"", SR.SQL_TDSParserTableName, false); - if (parts != null && parts.Length==4) // will always return int[4] right justified + if (parts != null && parts.Length == 4) // will always return int[4] right justified { if ( parts[3] != null && // name must not be null diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs index 9abf9275b06..4786513239d 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs @@ -1430,12 +1430,12 @@ internal class SqlDependencyProcessDispatcher : MarshalByRefObject string appDomainKey, out bool appDomainStop) { - Debug.Assert(this == s_staticInstance, "Instance method called on non _staticInstance instance!"); - server = null; // Reset out param. - identity = null; - user = null; - database = null; - appDomainStop = false; + Debug.Assert(this == s_staticInstance, "Instance method called on non _staticInstance instance!"); + server = null; // Reset out param. + identity = null; + user = null; + database = null; + appDomainStop = false; SqlConnectionContainerHashHelper hashHelper = GetHashHelper(connectionString, out SqlConnectionStringBuilder connectionStringBuilder, @@ -1445,23 +1445,24 @@ internal class SqlDependencyProcessDispatcher : MarshalByRefObject bool stopped = false; - lock (_connectionContainers) - { - if (_connectionContainers.ContainsKey(hashHelper)) - { - SqlConnectionContainer container = _connectionContainers[hashHelper]; - server = container.Server; // Return server, database, and queue info for use by calling SqlDependency. - database = container.Database; - queueService = container.Queue; + lock (_connectionContainers) + { + if (_connectionContainers.ContainsKey(hashHelper)) + { + SqlConnectionContainer container = _connectionContainers[hashHelper]; + server = container.Server; // Return server, database, and queue info for use by calling SqlDependency. + database = container.Database; + queueService = container.Queue; - if (container.Stop(appDomainKey, out appDomainStop)) - { // Stop can be blocking if refCount == 0 on container. - stopped = true; - _connectionContainers.Remove(hashHelper); // Remove from collection. - } - } - } + if (container.Stop(appDomainKey, out appDomainStop)) + { + // Stop can be blocking if refCount == 0 on container. + stopped = true; + _connectionContainers.Remove(hashHelper); // Remove from collection. + } + } + } - return stopped; + return stopped; } } diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlFileStream.Windows.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlFileStream.Windows.cs index c147356bf1c..2afff435dd3 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlFileStream.Windows.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlFileStream.Windows.cs @@ -570,71 +570,71 @@ namespace System.Data.SqlTypes } switch (retval) - { - case 0: - break; + { + case 0: + break; - case Interop.Errors.ERROR_SHARING_VIOLATION: - throw ADP.InvalidOperation(SR.GetString(SR.SqlFileStream_FileAlreadyInTransaction)); + case Interop.Errors.ERROR_SHARING_VIOLATION: + throw ADP.InvalidOperation(SR.GetString(SR.SqlFileStream_FileAlreadyInTransaction)); - case Interop.Errors.ERROR_INVALID_PARAMETER: - throw ADP.Argument(SR.GetString(SR.SqlFileStream_InvalidParameter)); + case Interop.Errors.ERROR_INVALID_PARAMETER: + throw ADP.Argument(SR.GetString(SR.SqlFileStream_InvalidParameter)); - case Interop.Errors.ERROR_FILE_NOT_FOUND: - { - System.IO.DirectoryNotFoundException e = new System.IO.DirectoryNotFoundException(); - ADP.TraceExceptionAsReturnValue(e); - throw e; - } - default: - { - uint error = Interop.NtDll.RtlNtStatusToDosError(retval); - if (error == ERROR_MR_MID_NOT_FOUND) - { - // status code could not be mapped to a Win32 error code - error = (uint)retval; - } - - System.ComponentModel.Win32Exception e = new System.ComponentModel.Win32Exception(unchecked((int)error)); - ADP.TraceExceptionAsReturnValue(e); - throw e; - } - } - - if (hFile.IsInvalid) - { - System.ComponentModel.Win32Exception e = new System.ComponentModel.Win32Exception(Interop.Errors.ERROR_INVALID_HANDLE); - ADP.TraceExceptionAsReturnValue(e); - throw e; - } - - if (Interop.Kernel32.GetFileType(hFile) != Interop.Kernel32.FileTypes.FILE_TYPE_DISK) - { - hFile.Dispose(); - throw ADP.Argument(SR.GetString(SR.SqlFileStream_PathNotValidDiskResource)); - } - - // if the user is opening the SQL FileStream in read/write mode, we assume that they want to scan - // through current data and then append new data to the end, so we need to tell SQL Server to preserve - // the existing file contents. - if (access == System.IO.FileAccess.ReadWrite) - { - uint ioControlCode = Interop.Kernel32.CTL_CODE(FILE_DEVICE_FILE_SYSTEM, - IoControlCodeFunctionCode, (byte)Interop.Kernel32.IoControlTransferType.METHOD_BUFFERED, - (byte)Interop.Kernel32.IoControlCodeAccess.FILE_ANY_ACCESS); - - if (!Interop.Kernel32.DeviceIoControl(hFile, ioControlCode, IntPtr.Zero, 0, IntPtr.Zero, 0, out uint cbBytesReturned, IntPtr.Zero)) + case Interop.Errors.ERROR_FILE_NOT_FOUND: { - System.ComponentModel.Win32Exception e = new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); + System.IO.DirectoryNotFoundException e = new System.IO.DirectoryNotFoundException(); ADP.TraceExceptionAsReturnValue(e); throw e; } - } + default: + { + uint error = Interop.NtDll.RtlNtStatusToDosError(retval); + if (error == ERROR_MR_MID_NOT_FOUND) + { + // status code could not be mapped to a Win32 error code + error = (uint)retval; + } - // now that we've successfully opened a handle on the path and verified that it is a file, - // use the SafeFileHandle to initialize our internal System.IO.FileStream instance - System.Diagnostics.Debug.Assert(_m_fs == null); - _m_fs = new System.IO.FileStream(hFile, access, DefaultBufferSize, ((options & System.IO.FileOptions.Asynchronous) != 0)); + System.ComponentModel.Win32Exception e = new System.ComponentModel.Win32Exception(unchecked((int)error)); + ADP.TraceExceptionAsReturnValue(e); + throw e; + } + } + + if (hFile.IsInvalid) + { + System.ComponentModel.Win32Exception e = new System.ComponentModel.Win32Exception(Interop.Errors.ERROR_INVALID_HANDLE); + ADP.TraceExceptionAsReturnValue(e); + throw e; + } + + if (Interop.Kernel32.GetFileType(hFile) != Interop.Kernel32.FileTypes.FILE_TYPE_DISK) + { + hFile.Dispose(); + throw ADP.Argument(SR.GetString(SR.SqlFileStream_PathNotValidDiskResource)); + } + + // if the user is opening the SQL FileStream in read/write mode, we assume that they want to scan + // through current data and then append new data to the end, so we need to tell SQL Server to preserve + // the existing file contents. + if (access == System.IO.FileAccess.ReadWrite) + { + uint ioControlCode = Interop.Kernel32.CTL_CODE(FILE_DEVICE_FILE_SYSTEM, + IoControlCodeFunctionCode, (byte)Interop.Kernel32.IoControlTransferType.METHOD_BUFFERED, + (byte)Interop.Kernel32.IoControlCodeAccess.FILE_ANY_ACCESS); + + if (!Interop.Kernel32.DeviceIoControl(hFile, ioControlCode, IntPtr.Zero, 0, IntPtr.Zero, 0, out uint cbBytesReturned, IntPtr.Zero)) + { + System.ComponentModel.Win32Exception e = new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); + ADP.TraceExceptionAsReturnValue(e); + throw e; + } + } + + // now that we've successfully opened a handle on the path and verified that it is a file, + // use the SafeFileHandle to initialize our internal System.IO.FileStream instance + System.Diagnostics.Debug.Assert(_m_fs == null); + _m_fs = new System.IO.FileStream(hFile, access, DefaultBufferSize, ((options & System.IO.FileOptions.Asynchronous) != 0)); } catch { diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlParameter.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlParameter.cs index 81b4f2e2a55..6ffe50256cc 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlParameter.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlParameter.cs @@ -835,7 +835,7 @@ namespace System.Data.SqlClient // NOTE: Udts can change their value any time if (_internalMetaType.SqlDbType == Data.SqlDbType.Udt) { - Set(SqlParameterFlags.IsNull, ((_value == null) || (_value == DBNull.Value) || (( _flags.HasFlag(SqlParameterFlags.IsSqlParameterSqlType)) && (_valueAsINullable.IsNull)))); + Set(SqlParameterFlags.IsNull, ((_value == null) || (_value == DBNull.Value) || ((_flags.HasFlag(SqlParameterFlags.IsSqlParameterSqlType)) && (_valueAsINullable.IsNull)))); } return _flags.HasFlag(SqlParameterFlags.IsNull); } diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlUtil.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlUtil.cs index 91c558e6668..5ceecca9be2 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlUtil.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlUtil.cs @@ -29,7 +29,8 @@ namespace System.Data.SqlClient TaskCompletionSource completion = new TaskCompletionSource(); ContinueTaskWithState(task, completion, state: Tuple.Create(onSuccess, onFailure, completion), - onSuccess: (state) => { + onSuccess: (state) => + { var parameters = (Tuple, TaskCompletionSource>)state; Action success = parameters.Item1; TaskCompletionSource taskCompletionSource = parameters.Item3; @@ -58,7 +59,8 @@ namespace System.Data.SqlClient { var completion = new TaskCompletionSource(); ContinueTaskWithState(task, completion, state, - onSuccess: (continueState) => { + onSuccess: (continueState) => + { onSuccess(continueState); completion.SetResult(null); }, diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObjectNative.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObjectNative.cs index 10e7ee34d05..898d53124d1 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObjectNative.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParserStateObjectNative.cs @@ -246,7 +246,7 @@ namespace System.Data.SqlClient internal override bool IsValidPacket(PacketHandle packetPointer) { - Debug.Assert(packetPointer.Type == PacketHandle.NativePointerType || packetPointer.Type==PacketHandle.NativePacketType, "unexpected packet type when requiring NativePointer"); + Debug.Assert(packetPointer.Type == PacketHandle.NativePointerType || packetPointer.Type == PacketHandle.NativePacketType, "unexpected packet type when requiring NativePointer"); return ( (packetPointer.Type == PacketHandle.NativePointerType && packetPointer.NativePointer != IntPtr.Zero) || diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/misc/EnvironmentHelpers.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/misc/EnvironmentHelpers.cs index 868187b7459..8cee3484acc 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/misc/EnvironmentHelpers.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/misc/EnvironmentHelpers.cs @@ -19,15 +19,15 @@ namespace System { if (!s_isAppContainerProcessInitalized) { - if (Environment.OSVersion.Version.Major < 6 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor <= 1)) - { - // Windows 7 or older. - s_isAppContainerProcess = false; - } - else - { - s_isAppContainerProcess = HasAppContainerToken(); - } + if (Environment.OSVersion.Version.Major < 6 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor <= 1)) + { + // Windows 7 or older. + s_isAppContainerProcess = false; + } + else + { + s_isAppContainerProcess = HasAppContainerToken(); + } s_isAppContainerProcessInitalized = true; } diff --git a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs index 3080a20e05f..b2a1775fd01 100644 --- a/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs +++ b/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Win32.cs @@ -46,12 +46,15 @@ namespace System.Diagnostics return true; } - private bool EnumWindowsCallback(IntPtr handle, IntPtr extraParameter) { + private bool EnumWindowsCallback(IntPtr handle, IntPtr extraParameter) + { int processId; Interop.User32.GetWindowThreadProcessId(handle, out processId); - if (processId == _processId) { - if (IsMainWindow(handle)) { + if (processId == _processId) + { + if (IsMainWindow(handle)) + { _bestHandle = handle; return false; } diff --git a/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/SymbolStore/SymLanguageType.cs b/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/SymbolStore/SymLanguageType.cs index fc83ae3665f..7a84281a8a6 100644 --- a/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/SymbolStore/SymLanguageType.cs +++ b/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/SymbolStore/SymLanguageType.cs @@ -6,7 +6,7 @@ namespace System.Diagnostics.SymbolStore { public class SymLanguageType { - public static readonly Guid C = new Guid(0x63a08714, unchecked((short) 0xfc37), 0x11d2, 0x90, 0x4c, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); + public static readonly Guid C = new Guid(0x63a08714, unchecked((short)0xfc37), 0x11d2, 0x90, 0x4c, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); public static readonly Guid CPlusPlus = new Guid(0x3a12d0b7, unchecked((short)0xc26c), 0x11d0, 0xb4, 0x42, 0x0, 0xa0, 0x24, 0x4a, 0x1d, 0xd2); public static readonly Guid CSharp = new Guid(0x3f5162f8, unchecked((short)0x07c6), 0x11d3, 0x90, 0x53, 0x0, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); @@ -17,7 +17,7 @@ namespace System.Diagnostics.SymbolStore public static readonly Guid Cobol = new Guid(unchecked((int)0xaf046cd1), unchecked((short)0xd0e1), 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); - public static readonly Guid Pascal = new Guid(unchecked((int)0xaf046cd2), unchecked((short) 0xd0e1), 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); + public static readonly Guid Pascal = new Guid(unchecked((int)0xaf046cd2), unchecked((short)0xd0e1), 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); public static readonly Guid ILAssembly = new Guid(unchecked((int)0xaf046cd3), unchecked((short)0xd0e1), 0x11d2, 0x97, 0x7c, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc); diff --git a/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/SymbolStore/SymLanguageVendor.cs b/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/SymbolStore/SymLanguageVendor.cs index 97e04727609..73ae1e09d63 100644 --- a/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/SymbolStore/SymLanguageVendor.cs +++ b/src/libraries/System.Diagnostics.StackTrace/src/System/Diagnostics/SymbolStore/SymLanguageVendor.cs @@ -6,6 +6,6 @@ namespace System.Diagnostics.SymbolStore { public class SymLanguageVendor { - public static readonly Guid Microsoft = new Guid(unchecked((int)0x994b45c4), unchecked((short) 0xe6e9), 0x11d2, 0x90, 0x3f, 0x00, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); + public static readonly Guid Microsoft = new Guid(unchecked((int)0x994b45c4), unchecked((short)0xe6e9), 0x11d2, 0x90, 0x3f, 0x00, 0xc0, 0x4f, 0xa3, 0x02, 0xa1); } } diff --git a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/ConsoleTraceListener.cs b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/ConsoleTraceListener.cs index c01eda876f7..856a8e14895 100644 --- a/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/ConsoleTraceListener.cs +++ b/src/libraries/System.Diagnostics.TextWriterTraceListener/src/System/Diagnostics/ConsoleTraceListener.cs @@ -4,14 +4,15 @@ namespace System.Diagnostics { - public class ConsoleTraceListener : TextWriterTraceListener { + public class ConsoleTraceListener : TextWriterTraceListener + { public ConsoleTraceListener() - : base (Console.Out) + : base(Console.Out) { } public ConsoleTraceListener(bool useErrorStream) - : base (useErrorStream ? Console.Error : Console.Out) + : base(useErrorStream ? Console.Error : Console.Out) { } diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/DefaultTraceListener.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/DefaultTraceListener.cs index 2397c10e213..19e863284a3 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/DefaultTraceListener.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/DefaultTraceListener.cs @@ -83,7 +83,7 @@ namespace System.Diagnostics string stackTrace; try { - stackTrace = new StackTrace(fNeedFileInfo:true).ToString(); + stackTrace = new StackTrace(fNeedFileInfo: true).ToString(); } catch { diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs index a6a4abb0be1..c7571e29738 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceInternal.cs @@ -145,7 +145,7 @@ namespace System.Diagnostics public static void Indent() { - Debug.IndentLevel++; + Debug.IndentLevel++; } public static void Unindent() diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs index 5dd48403e6d..7b48cb89ab7 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceListener.cs @@ -44,7 +44,8 @@ namespace System.Diagnostics public StringDictionary Attributes { - get { + get + { if (_attributes == null) _attributes = new StringDictionary(); return _attributes; diff --git a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceSource.cs b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceSource.cs index 967c0f726b7..801c721e8c5 100644 --- a/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceSource.cs +++ b/src/libraries/System.Diagnostics.TraceSource/src/System/Diagnostics/TraceSource.cs @@ -468,8 +468,10 @@ namespace System.Diagnostics } } - public StringDictionary Attributes { - get { + public StringDictionary Attributes + { + get + { // Ensure that config is loaded Initialize(); diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs index 9cfaf8508a4..5e43e105cf8 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/RangeRetriever.cs @@ -229,13 +229,13 @@ namespace System.DirectoryServices.AccountManagement } private bool _disposed = false; // keeps track of whether this object was disposed or not. - private readonly bool _disposeDirEntry = false; // If set to true then the RangeRetriever object will own the directory entry + private readonly bool _disposeDirEntry = false; // If set to true then the RangeRetriever object will own the directory entry // supplied to it in the constructor and will be responsible for disposing this entry // when Dispose() is called on this object. private bool _cacheValues = false; // If set to true then the attribute values will be cached in the InnerList // By default caching is turned off. - private readonly DirectoryEntry _de; // the DirectoryEntry whose property we're retrieving the values of - private readonly string _propertyName; // the property we're retrieving the values of + private readonly DirectoryEntry _de; // the DirectoryEntry whose property we're retrieving the values of + private readonly string _propertyName; // the property we're retrieving the values of private bool _endReached = false; // if true, all property values (from all chunks) have been retrieved diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/GlobalDebug.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/GlobalDebug.cs index ae7718d348c..ad56e0be83a 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/GlobalDebug.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/GlobalDebug.cs @@ -21,7 +21,6 @@ namespace System.DirectoryServices.AccountManagement static GlobalDebug() { GlobalDebug.s_debugLevel = GlobalConfig.DebugLevel; -//#if DEBUG #if SUPPORTDEBUGLOGFILE // not defined string debugLogFile = GlobalConfig.DebugLogFile; diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/SearchResults.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/SearchResults.cs index 673104cfd94..ff6b1108292 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/SearchResults.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/SearchResults.cs @@ -72,7 +72,7 @@ namespace System.DirectoryServices.Protocols { private readonly DirectoryControl[] _resultControls = null; - internal SearchResultEntry(string dn) : this(dn, new SearchResultAttributeCollection()) {} + internal SearchResultEntry(string dn) : this(dn, new SearchResultAttributeCollection()) { } internal SearchResultEntry(string dn, SearchResultAttributeCollection attrs) { diff --git a/src/libraries/System.DirectoryServices/src/Interop/UnsafeNativeMethods.cs b/src/libraries/System.DirectoryServices/src/Interop/UnsafeNativeMethods.cs index 2a40927ffed..62004ce1b16 100644 --- a/src/libraries/System.DirectoryServices/src/Interop/UnsafeNativeMethods.cs +++ b/src/libraries/System.DirectoryServices/src/Interop/UnsafeNativeMethods.cs @@ -284,7 +284,7 @@ namespace System.DirectoryServices.Interop set; } - object Values { get; set; } + object Values { get; set; } } [ComImport, Guid("C6F602B6-8F69-11D0-8528-00C04FD8D503")] diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADSearcher.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADSearcher.cs index 79d8e47c31f..f61535cfbff 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADSearcher.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ADSearcher.cs @@ -38,7 +38,7 @@ namespace System.DirectoryServices.ActiveDirectory _searcher.ServerPageTimeLimit = s_defaultTimeSpan; } - _searcher.CacheResults = cacheResults; + _searcher.CacheResults = cacheResults; } public SearchResult FindOne() => _searcher.FindOne(); diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs index 0d62e36d7bf..65dd71873a7 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs @@ -410,8 +410,8 @@ namespace System.DirectoryServices /// [ DefaultValue(""), - // CoreFXPort - Remove design support - // TypeConverter("System.Diagnostics.Design.StringValueConverter, " + AssemblyRef.SystemDesign) + // CoreFXPort - Remove design support + // TypeConverter("System.Diagnostics.Design.StringValueConverter, " + AssemblyRef.SystemDesign) ] public string AttributeScopeQuery { diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs index 36895d0c3a0..e6e3fe12202 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs @@ -21,7 +21,7 @@ namespace System.Drawing internal Bitmap(IntPtr ptr) => SetNativeImage(ptr); - public Bitmap(string filename) : this (filename, useIcm: false) { } + public Bitmap(string filename) : this(filename, useIcm: false) { } public Bitmap(string filename, bool useIcm) { diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Brushes.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Brushes.cs index eeb37eb3f59..6c53ac95532 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Brushes.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Brushes.cs @@ -247,7 +247,7 @@ namespace System.Drawing public static Brush MediumOrchid => GetBrush(s_mediumOrchidKey, Color.MediumOrchid); public static Brush MediumPurple => GetBrush(s_mediumPurpleKey, Color.MediumPurple); public static Brush MediumSeaGreen => GetBrush(s_mediumSeaGreenKey, Color.MediumSeaGreen); - public static Brush MediumSlateBlue => GetBrush(s_mediumSlateBlueKey, Color.MediumSlateBlue); + public static Brush MediumSlateBlue => GetBrush(s_mediumSlateBlueKey, Color.MediumSlateBlue); public static Brush MediumSpringGreen => GetBrush(s_mediumSpringGreenKey, Color.MediumSpringGreen); public static Brush MediumTurquoise => GetBrush(s_mediumTurquoiseKey, Color.MediumTurquoise); public static Brush MediumVioletRed => GetBrush(s_mediumVioletRedKey, Color.MediumVioletRed); diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs index d243838027c..65c6afa2990 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs @@ -238,7 +238,7 @@ namespace System.Drawing.Drawing2D if (count == 0 || value.Positions.Length == 0) throw new ArgumentException(SR.BlendObjectMustHaveTwoElements); - if (count >=2 && count != value.Positions.Length) + if (count >= 2 && count != value.Positions.Length) throw new ArgumentOutOfRangeException(); if (count >= 2 && value.Positions[0] != 0.0F) throw new ArgumentException(SR.BlendObjectFirstElementInvalid); @@ -505,7 +505,7 @@ namespace System.Drawing.Drawing2D public void ScaleTransform(float sx, float sy, MatrixOrder order) { - Gdip.CheckStatus( Gdip.GdipScaleLineTransform( + Gdip.CheckStatus(Gdip.GdipScaleLineTransform( new HandleRef(this, NativeBrush), sx, sy, order)); } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetaHeader.Windows.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetaHeader.Windows.cs index 1da8d18551e..478bfdf3461 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetaHeader.Windows.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetaHeader.Windows.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace System.Drawing.Imaging { diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Metafile.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Metafile.cs index db91a2a0afe..7f0de6bfc13 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Metafile.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Metafile.cs @@ -166,7 +166,7 @@ namespace System.Drawing.Imaging /// /// Initializes a new instance of the class with the specified filename. /// - public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) : + public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) : this(fileName, referenceHdc, frameRect, frameUnit, type, null) { } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs index 80ea8417130..39253b59b88 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs @@ -41,7 +41,7 @@ namespace System.Drawing /// private Pen(IntPtr nativePen) => SetNativePen(nativePen); - internal Pen(Color color, bool immutable) : this(color) => _immutable = immutable; + internal Pen(Color color, bool immutable) : this(color) => _immutable = immutable; /// /// Initializes a new instance of the Pen class with the specified . @@ -217,7 +217,7 @@ namespace System.Drawing int status = Gdip.GdipSetPenLineCap197819(new HandleRef(this, NativePen), unchecked((int)startCap), unchecked((int)endCap), unchecked((int)dashCap)); - Gdip.CheckStatus(status); + Gdip.CheckStatus(status); } /// @@ -660,7 +660,7 @@ namespace System.Drawing { IntPtr nativeBrush = IntPtr.Zero; int status = Gdip.GdipGetPenBrushFill(new HandleRef(this, NativePen), out nativeBrush); - Gdip.CheckStatus(status); + Gdip.CheckStatus(status); return nativeBrush; } diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs index 0c8a7d66a03..0ad9933eda0 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs @@ -63,7 +63,7 @@ namespace System.Drawing.Printing return (value) ? True : False; } - public static explicit operator bool (TriState value) + public static explicit operator bool(TriState value) { if (value.IsDefault) throw new InvalidCastException(SR.TriStateCompareError); diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Region.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Region.cs index db8f7912c72..8a73061b3f8 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/Region.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/Region.cs @@ -385,7 +385,7 @@ namespace System.Drawing Gdip.CheckStatus(Gdip.GdipIsVisibleRegionPointI( new HandleRef(this, NativeRegion), point.X, point.Y, - new HandleRef(g, g?.NativeGraphics ?? IntPtr.Zero), + new HandleRef(g, g?.NativeGraphics ?? IntPtr.Zero), out int isVisible)); return isVisible != 0; diff --git a/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/BrotliStream.cs b/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/BrotliStream.cs index b87820454aa..6943b694068 100644 --- a/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/BrotliStream.cs +++ b/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/BrotliStream.cs @@ -129,8 +129,8 @@ namespace System.IO.Compression } public Stream BaseStream => _stream; - public override bool CanRead => _mode == CompressionMode.Decompress && _stream != null && _stream.CanRead; - public override bool CanWrite => _mode == CompressionMode.Compress && _stream != null && _stream.CanWrite; + public override bool CanRead => _mode == CompressionMode.Decompress && _stream != null && _stream.CanRead; + public override bool CanWrite => _mode == CompressionMode.Compress && _stream != null && _stream.CanWrite; public override bool CanSeek => false; public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException(); public override long Length => throw new NotSupportedException(); diff --git a/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs b/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs index 58d84b6c9a8..a74cd3bfd8a 100644 --- a/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs +++ b/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs @@ -111,7 +111,7 @@ namespace System.IO.Compression { return new ValueTask(Task.FromCanceled(cancellationToken)); } - return FinishReadAsyncMemory(buffer, cancellationToken); + return FinishReadAsyncMemory(buffer, cancellationToken); } private async ValueTask FinishReadAsyncMemory(Memory buffer, CancellationToken cancellationToken) diff --git a/src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchive.Extract.cs b/src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchive.Extract.cs index 21ae421950b..e0824f6ac00 100644 --- a/src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchive.Extract.cs +++ b/src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchive.Extract.cs @@ -76,7 +76,7 @@ namespace System.IO.Compression foreach (ZipArchiveEntry entry in source.Entries) { - entry.ExtractRelativeToDirectory(destinationDirectoryName, overwriteFiles); + entry.ExtractRelativeToDirectory(destinationDirectoryName, overwriteFiles); } } } diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/DeflateStream.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/DeflateStream.cs index a433df3bbd3..c905c28d3e6 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/DeflateStream.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/DeflateZLib/DeflateStream.cs @@ -295,7 +295,7 @@ namespace System.IO.Compression throw new InvalidDataException(SR.GenericInvalidData); } - _inflater.SetInput(_buffer, 0, bytes); + _inflater.SetInput(_buffer, 0, bytes); } } diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/GZipStream.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/GZipStream.cs index 84ba93c8d0c..e938bbd72fd 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/GZipStream.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/GZipStream.cs @@ -12,17 +12,17 @@ namespace System.IO.Compression { private DeflateStream _deflateStream; - public GZipStream(Stream stream, CompressionMode mode): this(stream, mode, leaveOpen: false) + public GZipStream(Stream stream, CompressionMode mode) : this(stream, mode, leaveOpen: false) { } public GZipStream(Stream stream, CompressionMode mode, bool leaveOpen) { - _deflateStream = new DeflateStream(stream, mode, leaveOpen, ZLibNative.GZip_DefaultWindowBits); + _deflateStream = new DeflateStream(stream, mode, leaveOpen, ZLibNative.GZip_DefaultWindowBits); } // Implies mode = Compress - public GZipStream(Stream stream, CompressionLevel compressionLevel): this(stream, compressionLevel, leaveOpen: false) + public GZipStream(Stream stream, CompressionLevel compressionLevel) : this(stream, compressionLevel, leaveOpen: false) { } diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs index 82e0cbdf287..9f40670f922 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs @@ -517,7 +517,7 @@ namespace System.IO.Compression compressedSize = reader.ReadInt32(); uncompressedSize = reader.ReadInt32(); } - reader.BaseStream.Seek( -seekSize - entry.CompressedLength - 4, SeekOrigin.Current); // Seek back to the beginning of compressed stream + reader.BaseStream.Seek(-seekSize - entry.CompressedLength - 4, SeekOrigin.Current); // Seek back to the beginning of compressed stream } if (entry.CompressedLength != compressedSize) diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/Directory.cs b/src/libraries/System.IO.FileSystem/src/System/IO/Directory.cs index acb0e74dd93..35b2a593f96 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/Directory.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/Directory.cs @@ -219,7 +219,7 @@ namespace System.IO => EnumerateFileSystemEntries(path, searchPattern, EnumerationOptions.FromSearchOption(searchOption)); public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, EnumerationOptions enumerationOptions) - => InternalEnumeratePaths(path, searchPattern, SearchTarget.Both, enumerationOptions); + => InternalEnumeratePaths(path, searchPattern, SearchTarget.Both, enumerationOptions); public static string GetDirectoryRoot(string path) { diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs index 373419a6045..c0a66f50014 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerableFactory.cs @@ -166,15 +166,15 @@ namespace System.IO.Enumeration EnumerationOptions options, bool isNormalized) { - return new FileSystemEnumerable( - directory, - (ref FileSystemEntry entry) => (FileInfo)entry.ToFileSystemInfo(), - options, - isNormalized) - { - ShouldIncludePredicate = (ref FileSystemEntry entry) => - !entry.IsDirectory && MatchesPattern(expression, entry.FileName, options) - }; + return new FileSystemEnumerable( + directory, + (ref FileSystemEntry entry) => (FileInfo)entry.ToFileSystemInfo(), + options, + isNormalized) + { + ShouldIncludePredicate = (ref FileSystemEntry entry) => + !entry.IsDirectory && MatchesPattern(expression, entry.FileName, options) + }; } internal static IEnumerable DirectoryInfos( diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/EnumerationOptions.cs b/src/libraries/System.IO.FileSystem/src/System/IO/EnumerationOptions.cs index 1acdcee65b7..3c136618c5b 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/EnumerationOptions.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/EnumerationOptions.cs @@ -17,11 +17,11 @@ namespace System.IO /// For internal use. These are the options we want to use if calling the existing Directory/File APIs where you don't /// explicitly specify EnumerationOptions. /// - internal static EnumerationOptions Compatible { get; } = new EnumerationOptions - { MatchType = MatchType.Win32, AttributesToSkip = 0, IgnoreInaccessible = false }; + internal static EnumerationOptions Compatible { get; } = + new EnumerationOptions { MatchType = MatchType.Win32, AttributesToSkip = 0, IgnoreInaccessible = false }; - private static EnumerationOptions CompatibleRecursive { get; } = new EnumerationOptions - { RecurseSubdirectories = true, MatchType = MatchType.Win32, AttributesToSkip = 0, IgnoreInaccessible = false }; + private static EnumerationOptions CompatibleRecursive { get; } = + new EnumerationOptions { RecurseSubdirectories = true, MatchType = MatchType.Win32, AttributesToSkip = 0, IgnoreInaccessible = false }; /// /// Internal singleton for default options. diff --git a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Windows.cs b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Windows.cs index c86be39506c..ca9d0150c67 100644 --- a/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Windows.cs +++ b/src/libraries/System.IO.FileSystem/src/System/IO/FileSystemInfo.Windows.cs @@ -34,7 +34,7 @@ namespace System.IO internal static unsafe FileSystemInfo Create(string fullPath, ref FileSystemEntry findData) { FileSystemInfo info = findData.IsDirectory - ? (FileSystemInfo) new DirectoryInfo(fullPath, fileName: findData.FileName.ToString(), isNormalized: true) + ? (FileSystemInfo)new DirectoryInfo(fullPath, fileName: findData.FileName.ToString(), isNormalized: true) : new FileInfo(fullPath, fileName: findData.FileName.ToString(), isNormalized: true); Debug.Assert(!PathInternal.IsPartiallyQualified(fullPath.AsSpan()), $"'{fullPath}' should be fully qualified when constructed from directory enumeration"); diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs index cfe7710c737..09413c8a384 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/InternalRelationshipCollection.cs @@ -31,7 +31,7 @@ namespace System.IO.Packaging // .NET Framework will parse this as relative. This will break internal relationships // in packaging. For more information, see // http://www.mono-project.com/docs/faq/known-issues/urikind-relativeorabsolute/ - private static readonly UriKind DotNetRelativeOrAbsolute = Type.GetType ("Mono.Runtime") == null ? UriKind.RelativeOrAbsolute : (UriKind)300; + private static readonly UriKind DotNetRelativeOrAbsolute = Type.GetType("Mono.Runtime") == null ? UriKind.RelativeOrAbsolute : (UriKind)300; #region IEnumerable /// diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackUriHelper.PackUriScheme.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackUriHelper.PackUriScheme.cs index 5c181f10dba..4b6925e4c87 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackUriHelper.PackUriScheme.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackUriHelper.PackUriScheme.cs @@ -45,7 +45,7 @@ namespace System.IO.Packaging /// This parameter can be null in which case we will create a valid pack uri /// that references the entire package /// A Uri with the "pack://" scheme - /// If packageUri parameter is null + /// If packageUri parameter is null /// If packageUri parameter is not an absolute Uri /// If partUri parameter does not conform to the valid partUri syntax public static Uri Create(Uri packageUri, Uri partUri) diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackagePart.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackagePart.cs index fdcaa036421..d8fbe07d85d 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackagePart.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/PackagePart.cs @@ -786,7 +786,7 @@ namespace System.IO.Packaging //has been closed. private bool IsStreamClosed(Stream s) { - return !s.CanRead && !s.CanSeek && !s.CanWrite; + return !s.CanRead && !s.CanSeek && !s.CanWrite; } #endregion Private Methods diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs index f26f7dc73c3..0dacf42da39 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipPackage.cs @@ -784,21 +784,21 @@ namespace System.IO.Packaging { ProcessDefaultTagAttributes(reader); } + else if (reader.NodeType == XmlNodeType.Element + && reader.Depth == 1 + && (string.CompareOrdinal(reader.NamespaceURI, TypesNamespaceUri) == 0) + && (string.CompareOrdinal(reader.Name, OverrideTagName) == 0)) + { + ProcessOverrideTagAttributes(reader); + } + else if (reader.NodeType == XmlNodeType.EndElement && reader.Depth == 0 && string.CompareOrdinal(reader.Name, TypesTagName) == 0) + { + continue; + } else - if (reader.NodeType == XmlNodeType.Element - && reader.Depth == 1 - && (string.CompareOrdinal(reader.NamespaceURI, TypesNamespaceUri) == 0) - && (string.CompareOrdinal(reader.Name, OverrideTagName) == 0)) - { - ProcessOverrideTagAttributes(reader); - } - else - if (reader.NodeType == XmlNodeType.EndElement && reader.Depth == 0 && string.CompareOrdinal(reader.Name, TypesTagName) == 0) - continue; - else - { - throw new XmlException(SR.TypesXmlDoesNotMatchSchema, null, ((IXmlLineInfo)reader).LineNumber, ((IXmlLineInfo)reader).LinePosition); - } + { + throw new XmlException(SR.TypesXmlDoesNotMatchSchema, null, ((IXmlLineInfo)reader).LineNumber, ((IXmlLineInfo)reader).LinePosition); + } } } else diff --git a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipWrappingStream.cs b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipWrappingStream.cs index 60c1d59d4c6..ed6ddb55ef5 100644 --- a/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipWrappingStream.cs +++ b/src/libraries/System.IO.Packaging/src/System/IO/Packaging/ZipWrappingStream.cs @@ -102,7 +102,8 @@ namespace System.IO.Packaging public override long Length { - get { + get + { // ZipArchiveEntry's read stream doesn't provide a length since it's a raw DeflateStream // Return length from the archive entry. if (_packageFileAccess == FileAccess.Read) diff --git a/src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeAccessRule.cs b/src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeAccessRule.cs index be0eda0180f..388e5c2c87a 100644 --- a/src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeAccessRule.cs +++ b/src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeAccessRule.cs @@ -12,12 +12,12 @@ namespace System.IO.Pipes // // Constructor for creating access rules for pipe objects // - public PipeAccessRule( string identity, PipeAccessRights rights, AccessControlType type) - : this( new NTAccount(identity), AccessMaskFromRights(rights, type), false, type) + public PipeAccessRule(string identity, PipeAccessRights rights, AccessControlType type) + : this(new NTAccount(identity), AccessMaskFromRights(rights, type), false, type) { } - public PipeAccessRule( IdentityReference identity, PipeAccessRights rights, AccessControlType type) + public PipeAccessRule(IdentityReference identity, PipeAccessRights rights, AccessControlType type) : this(identity, AccessMaskFromRights(rights, type), false, type) { } @@ -26,8 +26,8 @@ namespace System.IO.Pipes // Internal constructor to be called by public constructors // and the access rights factory methods // - internal PipeAccessRule( IdentityReference identity, int accessMask, bool isInherited, AccessControlType type) - : base( identity, accessMask, isInherited, InheritanceFlags.None, PropagationFlags.None, type) + internal PipeAccessRule(IdentityReference identity, int accessMask, bool isInherited, AccessControlType type) + : base(identity, accessMask, isInherited, InheritanceFlags.None, PropagationFlags.None, type) { } diff --git a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs index 6ede7c00e61..2affb90bc4e 100644 --- a/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs +++ b/src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs @@ -558,7 +558,7 @@ namespace System.IO.Ports { if (portName == null) { - throw new ArgumentNullException(nameof(portName)); + throw new ArgumentNullException(nameof(portName)); } if (!portName.StartsWith("COM", StringComparison.OrdinalIgnoreCase) || diff --git a/src/libraries/System.Json/src/System/Json/JsonValue.cs b/src/libraries/System.Json/src/System/Json/JsonValue.cs index 50897ed84ae..87db42f7de2 100644 --- a/src/libraries/System.Json/src/System/Json/JsonValue.cs +++ b/src/libraries/System.Json/src/System/Json/JsonValue.cs @@ -343,7 +343,7 @@ namespace System.Json // JsonValue -> CLI - public static implicit operator bool (JsonValue value) + public static implicit operator bool(JsonValue value) { if (value == null) { @@ -353,7 +353,7 @@ namespace System.Json return Convert.ToBoolean(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator byte (JsonValue value) + public static implicit operator byte(JsonValue value) { if (value == null) { @@ -363,7 +363,7 @@ namespace System.Json return Convert.ToByte(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator char (JsonValue value) + public static implicit operator char(JsonValue value) { if (value == null) { @@ -373,7 +373,7 @@ namespace System.Json return Convert.ToChar(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator decimal (JsonValue value) + public static implicit operator decimal(JsonValue value) { if (value == null) { @@ -383,14 +383,14 @@ namespace System.Json return Convert.ToDecimal(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator double (JsonValue value) + public static implicit operator double(JsonValue value) { if (value == null) throw new ArgumentNullException(nameof(value)); return Convert.ToDouble(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator float (JsonValue value) + public static implicit operator float(JsonValue value) { if (value == null) { @@ -400,7 +400,7 @@ namespace System.Json return Convert.ToSingle(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator int (JsonValue value) + public static implicit operator int(JsonValue value) { if (value == null) { @@ -410,7 +410,7 @@ namespace System.Json return Convert.ToInt32(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator long (JsonValue value) + public static implicit operator long(JsonValue value) { if (value == null) { @@ -421,7 +421,7 @@ namespace System.Json } [CLSCompliant(false)] - public static implicit operator sbyte (JsonValue value) + public static implicit operator sbyte(JsonValue value) { if (value == null) { @@ -431,7 +431,7 @@ namespace System.Json return Convert.ToSByte(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator short (JsonValue value) + public static implicit operator short(JsonValue value) { if (value == null) { @@ -441,7 +441,7 @@ namespace System.Json return Convert.ToInt16(((JsonPrimitive)value).Value, CultureInfo.InvariantCulture); } - public static implicit operator string (JsonValue value) + public static implicit operator string(JsonValue value) { return value != null ? (string)((JsonPrimitive)value).Value : @@ -449,7 +449,7 @@ namespace System.Json } [CLSCompliant(false)] - public static implicit operator uint (JsonValue value) + public static implicit operator uint(JsonValue value) { if (value == null) { @@ -460,7 +460,7 @@ namespace System.Json } [CLSCompliant(false)] - public static implicit operator ulong (JsonValue value) + public static implicit operator ulong(JsonValue value) { if (value == null) { @@ -471,7 +471,7 @@ namespace System.Json } [CLSCompliant(false)] - public static implicit operator ushort (JsonValue value) + public static implicit operator ushort(JsonValue value) { if (value == null) { diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs index 14933579288..53422451711 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/LightCompiler.cs @@ -1090,7 +1090,7 @@ namespace System.Linq.Expressions.Interpreter } else { - _instructions.EmitByRefCall(method, parameters, new[] {updater}); + _instructions.EmitByRefCall(method, parameters, new[] { updater }); updater.UndefineTemps(_instructions, _locals); } diff --git a/src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableQuery.cs b/src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableQuery.cs index 369c71c7505..81494cae197 100644 --- a/src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableQuery.cs +++ b/src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableQuery.cs @@ -13,7 +13,7 @@ namespace System.Linq internal abstract Expression Expression { get; } internal abstract IEnumerable Enumerable { get; } - internal EnumerableQuery() {} + internal EnumerableQuery() { } internal static IQueryable Create(Type elementType, IEnumerable sequence) { diff --git a/src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableRewriter.cs b/src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableRewriter.cs index ec433c254d5..774b1151829 100644 --- a/src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableRewriter.cs +++ b/src/libraries/System.Linq.Queryable/src/System/Linq/EnumerableRewriter.cs @@ -168,7 +168,7 @@ namespace System.Linq var interfacesWithInfo = pubType.GetInterfaces().Select(IntrospectionExtensions.GetTypeInfo).ToArray(); var singleTypeGenInterfacesWithGetType = interfacesWithInfo .Where(i => i.IsGenericType && i.GenericTypeArguments.Length == 1) - .Select(i => new {Info = i, GenType = i.GetGenericTypeDefinition() }) + .Select(i => new { Info = i, GenType = i.GetGenericTypeDefinition() }) .ToArray(); Type typeArg = singleTypeGenInterfacesWithGetType .Where(i => i.GenType == typeof(IOrderedQueryable<>) || i.GenType == typeof(IOrderedEnumerable<>)) diff --git a/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs b/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs index 583b85c6f81..21b647a28c2 100644 --- a/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs +++ b/src/libraries/System.Management/src/System/Management/InteropClasses/WMIInterop.cs @@ -10,8 +10,8 @@ using System.Threading; using System.Runtime.Versioning; using System.Text; -namespace WbemClient_v1 {} -namespace WbemUtilities_v1 {} +namespace WbemClient_v1 { } +namespace WbemUtilities_v1 { } namespace System.Management { @@ -60,7 +60,7 @@ namespace System.Management Dispose_(false); } - private void Dispose_ ( bool finalization ) + private void Dispose_(bool finalization) { if (pWbemClassObject != IntPtr.Zero) { @@ -75,7 +75,7 @@ namespace System.Management Dispose_(true); } - private void DeserializeFromBlob(byte [] rg) + private void DeserializeFromBlob(byte[] rg) { IntPtr hGlobal = IntPtr.Zero; System.Runtime.InteropServices.ComTypes.IStream stream = null; @@ -100,7 +100,7 @@ namespace System.Management private byte[] SerializeToBlob() { - byte [] rg = null; + byte[] rg = null; System.Runtime.InteropServices.ComTypes.IStream stream = null; IntPtr pData = IntPtr.Zero; try @@ -343,7 +343,7 @@ namespace System.Management { if (pWbemClassObject == IntPtr.Zero) throw new ObjectDisposedException(name); - int res = WmiNetUtilsHelper.BeginMethodEnumeration_f(22, pWbemClassObject, lEnumFlags); + int res = WmiNetUtilsHelper.BeginMethodEnumeration_f(22, pWbemClassObject, lEnumFlags); GC.KeepAlive(this); return res; } @@ -400,24 +400,24 @@ namespace System.Management private enum STATFLAG { - STATFLAG_DEFAULT = 0, - STATFLAG_NONAME = 1 + STATFLAG_DEFAULT = 0, + STATFLAG_NONAME = 1 } private enum MSHCTX { - MSHCTX_LOCAL = 0, - MSHCTX_NOSHAREDMEM = 1, - MSHCTX_DIFFERENTMACHINE = 2, - MSHCTX_INPROC = 3 + MSHCTX_LOCAL = 0, + MSHCTX_NOSHAREDMEM = 1, + MSHCTX_DIFFERENTMACHINE = 2, + MSHCTX_INPROC = 3 } private enum MSHLFLAGS { - MSHLFLAGS_NORMAL = 0, - MSHLFLAGS_TABLESTRONG = 1, - MSHLFLAGS_TABLEWEAK = 2, - MSHLFLAGS_NOPING = 3 + MSHLFLAGS_NORMAL = 0, + MSHLFLAGS_TABLESTRONG = 1, + MSHLFLAGS_TABLEWEAK = 2, + MSHLFLAGS_NOPING = 3 } } @@ -438,14 +438,14 @@ namespace System.Management Dispose_(false); } - private void Dispose_( bool finalization ) + private void Dispose_(bool finalization) { if (pWbemQualifierSet != IntPtr.Zero) { Marshal.Release(pWbemQualifierSet); pWbemQualifierSet = IntPtr.Zero; } - if ( finalization == false ) + if (finalization == false) { GC.KeepAlive(this); } @@ -471,7 +471,7 @@ namespace System.Management { if (pWbemQualifierSet == IntPtr.Zero) throw new ObjectDisposedException(name); - int res = WmiNetUtilsHelper.QualifierPut_f(4, pWbemQualifierSet, wszName, ref pVal, lFlavor); + int res = WmiNetUtilsHelper.QualifierPut_f(4, pWbemQualifierSet, wszName, ref pVal, lFlavor); GC.KeepAlive(this); return res; } @@ -562,30 +562,30 @@ namespace System.Management [ComImport] internal interface IWbemClassObject_DoNotMarshal { - [PreserveSig] int GetQualifierSet_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); - [PreserveSig] int Get_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); - [PreserveSig] int Put_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] ref object pVal, [In] int Type); - [PreserveSig] int Delete_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); - [PreserveSig] int GetNames_([In][MarshalAs(UnmanagedType.LPWStr)] string wszQualifierName, [In] int lFlags, [In] ref object pQualifierVal, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)] out string[] pNames); + [PreserveSig] int GetQualifierSet_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); + [PreserveSig] int Get_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); + [PreserveSig] int Put_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] ref object pVal, [In] int Type); + [PreserveSig] int Delete_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); + [PreserveSig] int GetNames_([In][MarshalAs(UnmanagedType.LPWStr)] string wszQualifierName, [In] int lFlags, [In] ref object pQualifierVal, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pNames); [PreserveSig] int BeginEnumeration_([In] int lEnumFlags); - [PreserveSig] int Next_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string strName, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); + [PreserveSig] int Next_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string strName, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); [PreserveSig] int EndEnumeration_(); - [PreserveSig] int GetPropertyQualifierSet_([In][MarshalAs(UnmanagedType.LPWStr)] string wszProperty, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); - [PreserveSig] int Clone_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppCopy); - [PreserveSig] int GetObjectText_([In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrObjectText); - [PreserveSig] int SpawnDerivedClass_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppNewClass); - [PreserveSig] int SpawnInstance_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppNewInstance); - [PreserveSig] int CompareTo_([In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pCompareTo); - [PreserveSig] int GetPropertyOrigin_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); - [PreserveSig] int InheritsFrom_([In][MarshalAs(UnmanagedType.LPWStr)] string strAncestor); - [PreserveSig] int GetMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppInSignature, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppOutSignature); - [PreserveSig] int PutMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInSignature, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pOutSignature); - [PreserveSig] int DeleteMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); + [PreserveSig] int GetPropertyQualifierSet_([In][MarshalAs(UnmanagedType.LPWStr)] string wszProperty, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); + [PreserveSig] int Clone_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppCopy); + [PreserveSig] int GetObjectText_([In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrObjectText); + [PreserveSig] int SpawnDerivedClass_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppNewClass); + [PreserveSig] int SpawnInstance_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppNewInstance); + [PreserveSig] int CompareTo_([In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pCompareTo); + [PreserveSig] int GetPropertyOrigin_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); + [PreserveSig] int InheritsFrom_([In][MarshalAs(UnmanagedType.LPWStr)] string strAncestor); + [PreserveSig] int GetMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppInSignature, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppOutSignature); + [PreserveSig] int PutMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInSignature, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pOutSignature); + [PreserveSig] int DeleteMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); [PreserveSig] int BeginMethodEnumeration_([In] int lEnumFlags); - [PreserveSig] int NextMethod_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string pstrName, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppInSignature, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppOutSignature); + [PreserveSig] int NextMethod_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string pstrName, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppInSignature, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppOutSignature); [PreserveSig] int EndMethodEnumeration_(); - [PreserveSig] int GetMethodQualifierSet_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMethod, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); - [PreserveSig] int GetMethodOrigin_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMethodName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); + [PreserveSig] int GetMethodQualifierSet_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMethod, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); + [PreserveSig] int GetMethodOrigin_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMethodName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); } [InterfaceTypeAttribute(0x0001)] @@ -594,12 +594,12 @@ namespace System.Management [ComImport] internal interface IWbemQualifierSet_DoNotMarshal { - [PreserveSig] int Get_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int plFlavor); - [PreserveSig] int Put_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] ref object pVal, [In] int lFlavor); - [PreserveSig] int Delete_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); - [PreserveSig] int GetNames_([In] int lFlags, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)] out string[] pNames); + [PreserveSig] int Get_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int plFlavor); + [PreserveSig] int Put_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] ref object pVal, [In] int lFlavor); + [PreserveSig] int Delete_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); + [PreserveSig] int GetNames_([In] int lFlags, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pNames); [PreserveSig] int BeginEnumeration_([In] int lFlags); - [PreserveSig] int Next_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string pstrName, [In][Out] ref object pVal, [In][Out] ref int plFlavor); + [PreserveSig] int Next_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string pstrName, [In][Out] ref object pVal, [In][Out] ref int plFlavor); [PreserveSig] int EndEnumeration_(); } @@ -609,7 +609,7 @@ namespace System.Management [ComImport] internal interface IWbemLocator { - [PreserveSig] int ConnectServer_([In][MarshalAs(UnmanagedType.BStr)] string strNetworkResource, [In][MarshalAs(UnmanagedType.BStr)] string strUser, [In]IntPtr strPassword, [In][MarshalAs(UnmanagedType.BStr)] string strLocale, [In] int lSecurityFlags, [In][MarshalAs(UnmanagedType.BStr)] string strAuthority, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemServices ppNamespace); + [PreserveSig] int ConnectServer_([In][MarshalAs(UnmanagedType.BStr)] string strNetworkResource, [In][MarshalAs(UnmanagedType.BStr)] string strUser, [In]IntPtr strPassword, [In][MarshalAs(UnmanagedType.BStr)] string strLocale, [In] int lSecurityFlags, [In][MarshalAs(UnmanagedType.BStr)] string strAuthority, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemServices ppNamespace); } [GuidAttribute("44ACA674-E8FC-11D0-A07C-00C04FB68820")] @@ -618,14 +618,14 @@ namespace System.Management [ComImport] internal interface IWbemContext { - [PreserveSig] int Clone_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemContext ppNewCopy); - [PreserveSig] int GetNames_([In] int lFlags, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)] out string[] pNames); + [PreserveSig] int Clone_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemContext ppNewCopy); + [PreserveSig] int GetNames_([In] int lFlags, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pNames); [PreserveSig] int BeginEnumeration_([In] int lFlags); - [PreserveSig] int Next_([In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrName, [Out] out object pValue); + [PreserveSig] int Next_([In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrName, [Out] out object pValue); [PreserveSig] int EndEnumeration_(); - [PreserveSig] int SetValue_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] ref object pValue); - [PreserveSig] int GetValue_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [Out] out object pValue); - [PreserveSig] int DeleteValue_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags); + [PreserveSig] int SetValue_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] ref object pValue); + [PreserveSig] int GetValue_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [Out] out object pValue); + [PreserveSig] int DeleteValue_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags); [PreserveSig] int DeleteAll_(); } @@ -635,29 +635,29 @@ namespace System.Management [ComImport] internal interface IWbemServices { - [PreserveSig] int OpenNamespace_([In][MarshalAs(UnmanagedType.BStr)] string strNamespace, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemServices ppWorkingNamespace, [In] IntPtr ppCallResult); - [PreserveSig] int CancelAsyncCall_([In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pSink); - [PreserveSig] int QueryObjectSink_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemObjectSink ppResponseHandler); - [PreserveSig] int GetObject_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(MarshalWbemObject))] out IWbemClassObjectFreeThreaded ppObject, [In] IntPtr ppCallResult); - [PreserveSig] int GetObjectAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int PutClass_([In] IntPtr pObject, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); - [PreserveSig] int PutClassAsync_([In] IntPtr pObject, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int DeleteClass_([In][MarshalAs(UnmanagedType.BStr)] string strClass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); - [PreserveSig] int DeleteClassAsync_([In][MarshalAs(UnmanagedType.BStr)] string strClass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int CreateClassEnum_([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); - [PreserveSig] int CreateClassEnumAsync_([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int PutInstance_([In] IntPtr pInst, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); - [PreserveSig] int PutInstanceAsync_([In] IntPtr pInst, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int DeleteInstance_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); - [PreserveSig] int DeleteInstanceAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int CreateInstanceEnum_([In][MarshalAs(UnmanagedType.BStr)] string strFilter, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); - [PreserveSig] int CreateInstanceEnumAsync_([In][MarshalAs(UnmanagedType.BStr)] string strFilter, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int ExecQuery_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); - [PreserveSig] int ExecQueryAsync_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int ExecNotificationQuery_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); - [PreserveSig] int ExecNotificationQueryAsync_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int ExecMethod_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In][MarshalAs(UnmanagedType.BStr)] string strMethodName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr pInParams, [Out][MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(MarshalWbemObject))] out IWbemClassObjectFreeThreaded ppOutParams, [In] IntPtr ppCallResult); - [PreserveSig] int ExecMethodAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In][MarshalAs(UnmanagedType.BStr)] string strMethodName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr pInParams, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int OpenNamespace_([In][MarshalAs(UnmanagedType.BStr)] string strNamespace, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemServices ppWorkingNamespace, [In] IntPtr ppCallResult); + [PreserveSig] int CancelAsyncCall_([In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pSink); + [PreserveSig] int QueryObjectSink_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemObjectSink ppResponseHandler); + [PreserveSig] int GetObject_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MarshalWbemObject))] out IWbemClassObjectFreeThreaded ppObject, [In] IntPtr ppCallResult); + [PreserveSig] int GetObjectAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int PutClass_([In] IntPtr pObject, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); + [PreserveSig] int PutClassAsync_([In] IntPtr pObject, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int DeleteClass_([In][MarshalAs(UnmanagedType.BStr)] string strClass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); + [PreserveSig] int DeleteClassAsync_([In][MarshalAs(UnmanagedType.BStr)] string strClass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int CreateClassEnum_([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int CreateClassEnumAsync_([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int PutInstance_([In] IntPtr pInst, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); + [PreserveSig] int PutInstanceAsync_([In] IntPtr pInst, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int DeleteInstance_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); + [PreserveSig] int DeleteInstanceAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int CreateInstanceEnum_([In][MarshalAs(UnmanagedType.BStr)] string strFilter, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int CreateInstanceEnumAsync_([In][MarshalAs(UnmanagedType.BStr)] string strFilter, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int ExecQuery_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int ExecQueryAsync_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int ExecNotificationQuery_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int ExecNotificationQueryAsync_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int ExecMethod_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In][MarshalAs(UnmanagedType.BStr)] string strMethodName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr pInParams, [Out][MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MarshalWbemObject))] out IWbemClassObjectFreeThreaded ppOutParams, [In] IntPtr ppCallResult); + [PreserveSig] int ExecMethodAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In][MarshalAs(UnmanagedType.BStr)] string strMethodName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr pInParams, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); } [InterfaceTypeAttribute(0x0001)] @@ -666,29 +666,29 @@ namespace System.Management [ComImport] internal interface IWbemServices_Old { - [PreserveSig] int OpenNamespace_([In][MarshalAs(UnmanagedType.BStr)] string strNamespace, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemServices ppWorkingNamespace, [In] IntPtr ppCallResult); - [PreserveSig] int CancelAsyncCall_([In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pSink); - [PreserveSig] int QueryObjectSink_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemObjectSink ppResponseHandler); - [PreserveSig] int GetObject_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppObject, [In] IntPtr ppCallResult); - [PreserveSig] int GetObjectAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int PutClass_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pObject, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); - [PreserveSig] int PutClassAsync_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pObject, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int DeleteClass_([In][MarshalAs(UnmanagedType.BStr)] string strClass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); - [PreserveSig] int DeleteClassAsync_([In][MarshalAs(UnmanagedType.BStr)] string strClass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int CreateClassEnum_([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); - [PreserveSig] int CreateClassEnumAsync_([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int PutInstance_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInst, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); - [PreserveSig] int PutInstanceAsync_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInst, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int DeleteInstance_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); - [PreserveSig] int DeleteInstanceAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int CreateInstanceEnum_([In][MarshalAs(UnmanagedType.BStr)] string strFilter, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); - [PreserveSig] int CreateInstanceEnumAsync_([In][MarshalAs(UnmanagedType.BStr)] string strFilter, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int ExecQuery_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); - [PreserveSig] int ExecQueryAsync_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int ExecNotificationQuery_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); - [PreserveSig] int ExecNotificationQueryAsync_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); - [PreserveSig] int ExecMethod_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In][MarshalAs(UnmanagedType.BStr)] string strMethodName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInParams, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppOutParams, [In] IntPtr ppCallResult); - [PreserveSig] int ExecMethodAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In][MarshalAs(UnmanagedType.BStr)] string strMethodName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInParams, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int OpenNamespace_([In][MarshalAs(UnmanagedType.BStr)] string strNamespace, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemServices ppWorkingNamespace, [In] IntPtr ppCallResult); + [PreserveSig] int CancelAsyncCall_([In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pSink); + [PreserveSig] int QueryObjectSink_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemObjectSink ppResponseHandler); + [PreserveSig] int GetObject_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppObject, [In] IntPtr ppCallResult); + [PreserveSig] int GetObjectAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int PutClass_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pObject, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); + [PreserveSig] int PutClassAsync_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pObject, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int DeleteClass_([In][MarshalAs(UnmanagedType.BStr)] string strClass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); + [PreserveSig] int DeleteClassAsync_([In][MarshalAs(UnmanagedType.BStr)] string strClass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int CreateClassEnum_([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int CreateClassEnumAsync_([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int PutInstance_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInst, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); + [PreserveSig] int PutInstanceAsync_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInst, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int DeleteInstance_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult); + [PreserveSig] int DeleteInstanceAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int CreateInstanceEnum_([In][MarshalAs(UnmanagedType.BStr)] string strFilter, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int CreateInstanceEnumAsync_([In][MarshalAs(UnmanagedType.BStr)] string strFilter, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int ExecQuery_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int ExecQueryAsync_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int ExecNotificationQuery_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int ExecNotificationQueryAsync_([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); + [PreserveSig] int ExecMethod_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In][MarshalAs(UnmanagedType.BStr)] string strMethodName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInParams, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppOutParams, [In] IntPtr ppCallResult); + [PreserveSig] int ExecMethodAsync_([In][MarshalAs(UnmanagedType.BStr)] string strObjectPath, [In][MarshalAs(UnmanagedType.BStr)] string strMethodName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInParams, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pResponseHandler); } [GuidAttribute("44ACA675-E8FC-11D0-A07C-00C04FB68820")] @@ -697,9 +697,9 @@ namespace System.Management [ComImport] internal interface IWbemCallResult { - [PreserveSig] int GetResultObject_([In] int lTimeout, [Out][MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(MarshalWbemObject))] out IWbemClassObjectFreeThreaded ppResultObject); - [PreserveSig] int GetResultString_([In] int lTimeout, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrResultString); - [PreserveSig] int GetResultServices_([In] int lTimeout, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemServices ppServices); + [PreserveSig] int GetResultObject_([In] int lTimeout, [Out][MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MarshalWbemObject))] out IWbemClassObjectFreeThreaded ppResultObject); + [PreserveSig] int GetResultString_([In] int lTimeout, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrResultString); + [PreserveSig] int GetResultServices_([In] int lTimeout, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemServices ppServices); [PreserveSig] int GetCallStatus_([In] int lTimeout, [Out] out int plStatus); } @@ -710,7 +710,7 @@ namespace System.Management internal interface IWbemObjectSink { [PreserveSig] int Indicate_([In] int lObjectCount, [In][MarshalAs(UnmanagedType.LPArray)] IntPtr[] apObjArray); - [PreserveSig] int SetStatus_([In] int lFlags, [In][MarshalAs(UnmanagedType.Error)] int hResult, [In][MarshalAs(UnmanagedType.BStr)] string strParam, [In] IntPtr pObjParam); + [PreserveSig] int SetStatus_([In] int lFlags, [In][MarshalAs(UnmanagedType.Error)] int hResult, [In][MarshalAs(UnmanagedType.BStr)] string strParam, [In] IntPtr pObjParam); } [InterfaceTypeAttribute(0x0001)] @@ -721,8 +721,8 @@ namespace System.Management { [PreserveSig] int Reset_(); [PreserveSig] int Next_([In] int lTimeout, [In] uint uCount, [In][Out][MarshalAs(UnmanagedType.LPArray)] IWbemClassObject_DoNotMarshal[] apObjects, [Out] out uint puReturned); - [PreserveSig] int NextAsync_([In] uint uCount, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pSink); - [PreserveSig] int Clone_([Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); + [PreserveSig] int NextAsync_([In] uint uCount, [In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pSink); + [PreserveSig] int Clone_([Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum); [PreserveSig] int Skip_([In] int lTimeout, [In] uint nCount); } @@ -731,7 +731,7 @@ namespace System.Management [ComImport] internal interface IWbemShutdown { - [PreserveSig] int Shutdown_([In] int uReason, [In] uint uMaxMilliseconds, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx); + [PreserveSig] int Shutdown_([In] int uReason, [In] uint uMaxMilliseconds, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx); } [InterfaceTypeAttribute(0x0001)] @@ -740,8 +740,8 @@ namespace System.Management [ComImport] internal interface IWbemObjectTextSrc { - [PreserveSig] int GetText_([In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pObj, [In] uint uObjTextFormat, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.BStr)] out string strText); - [PreserveSig] int CreateFromText_([In] int lFlags, [In][MarshalAs(UnmanagedType.BStr)] string strText, [In] uint uObjTextFormat, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal pNewObj); + [PreserveSig] int GetText_([In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pObj, [In] uint uObjTextFormat, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.BStr)] out string strText); + [PreserveSig] int CreateFromText_([In] int lFlags, [In][MarshalAs(UnmanagedType.BStr)] string strText, [In] uint uObjTextFormat, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal pNewObj); } [GuidAttribute("49353C9A-516B-11D1-AEA6-00C04FB68820")] @@ -750,38 +750,38 @@ namespace System.Management [ComImport] internal interface IWbemObjectAccess { - [PreserveSig] int GetQualifierSet_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); - [PreserveSig] int Get_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); - [PreserveSig] int Put_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] ref object pVal, [In] int Type); - [PreserveSig] int Delete_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); - [PreserveSig] int GetNames_([In][MarshalAs(UnmanagedType.LPWStr)] string wszQualifierName, [In] int lFlags, [In] ref object pQualifierVal, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)] out string[] pNames); + [PreserveSig] int GetQualifierSet_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); + [PreserveSig] int Get_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); + [PreserveSig] int Put_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] ref object pVal, [In] int Type); + [PreserveSig] int Delete_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); + [PreserveSig] int GetNames_([In][MarshalAs(UnmanagedType.LPWStr)] string wszQualifierName, [In] int lFlags, [In] ref object pQualifierVal, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pNames); [PreserveSig] int BeginEnumeration_([In] int lEnumFlags); - [PreserveSig] int Next_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string strName, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); + [PreserveSig] int Next_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string strName, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); [PreserveSig] int EndEnumeration_(); - [PreserveSig] int GetPropertyQualifierSet_([In][MarshalAs(UnmanagedType.LPWStr)] string wszProperty, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); - [PreserveSig] int Clone_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppCopy); - [PreserveSig] int GetObjectText_([In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrObjectText); - [PreserveSig] int SpawnDerivedClass_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppNewClass); - [PreserveSig] int SpawnInstance_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppNewInstance); - [PreserveSig] int CompareTo_([In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pCompareTo); - [PreserveSig] int GetPropertyOrigin_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); - [PreserveSig] int InheritsFrom_([In][MarshalAs(UnmanagedType.LPWStr)] string strAncestor); - [PreserveSig] int GetMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppInSignature, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppOutSignature); - [PreserveSig] int PutMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInSignature, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pOutSignature); - [PreserveSig] int DeleteMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); + [PreserveSig] int GetPropertyQualifierSet_([In][MarshalAs(UnmanagedType.LPWStr)] string wszProperty, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); + [PreserveSig] int Clone_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppCopy); + [PreserveSig] int GetObjectText_([In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrObjectText); + [PreserveSig] int SpawnDerivedClass_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppNewClass); + [PreserveSig] int SpawnInstance_([In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppNewInstance); + [PreserveSig] int CompareTo_([In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pCompareTo); + [PreserveSig] int GetPropertyOrigin_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); + [PreserveSig] int InheritsFrom_([In][MarshalAs(UnmanagedType.LPWStr)] string strAncestor); + [PreserveSig] int GetMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppInSignature, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemClassObject_DoNotMarshal ppOutSignature); + [PreserveSig] int PutMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pInSignature, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pOutSignature); + [PreserveSig] int DeleteMethod_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName); [PreserveSig] int BeginMethodEnumeration_([In] int lEnumFlags); - [PreserveSig] int NextMethod_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string pstrName, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppInSignature, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppOutSignature); + [PreserveSig] int NextMethod_([In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string pstrName, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppInSignature, [In][Out][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal ppOutSignature); [PreserveSig] int EndMethodEnumeration_(); - [PreserveSig] int GetMethodQualifierSet_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMethod, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); - [PreserveSig] int GetMethodOrigin_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMethodName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); - [PreserveSig] int GetPropertyHandle_([In][MarshalAs(UnmanagedType.LPWStr)] string wszPropertyName, [Out] out int pType, [Out] out int plHandle); + [PreserveSig] int GetMethodQualifierSet_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMethod, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemQualifierSet_DoNotMarshal ppQualSet); + [PreserveSig] int GetMethodOrigin_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMethodName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); + [PreserveSig] int GetPropertyHandle_([In][MarshalAs(UnmanagedType.LPWStr)] string wszPropertyName, [Out] out int pType, [Out] out int plHandle); [PreserveSig] int WritePropertyValue_([In] int lHandle, [In] int lNumBytes, [In] ref byte aData); [PreserveSig] int ReadPropertyValue_([In] int lHandle, [In] int lBufferSize, [Out] out int plNumBytes, [Out] out byte aData); [PreserveSig] int ReadDWORD_([In] int lHandle, [Out] out uint pdw); [PreserveSig] int WriteDWORD_([In] int lHandle, [In] uint dw); [PreserveSig] int ReadQWORD_([In] int lHandle, [Out] out ulong pqw); [PreserveSig] int WriteQWORD_([In] int lHandle, [In] ulong pw); - [PreserveSig] int GetPropertyInfoByHandle_([In] int lHandle, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrName, [Out] out int pType); + [PreserveSig] int GetPropertyInfoByHandle_([In] int lHandle, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrName, [Out] out int pType); [PreserveSig] int Lock_([In] int lFlags); [PreserveSig] int Unlock_([In] int lFlags); } @@ -792,7 +792,7 @@ namespace System.Management [ComImport] internal interface IUnsecuredApartment { - [PreserveSig] int CreateObjectStub_([In][MarshalAs(UnmanagedType.IUnknown)] object pObject, [Out][MarshalAs(UnmanagedType.IUnknown)] out object ppStub); + [PreserveSig] int CreateObjectStub_([In][MarshalAs(UnmanagedType.IUnknown)] object pObject, [Out][MarshalAs(UnmanagedType.IUnknown)] out object ppStub); } [GuidAttribute("EB87E1BC-3233-11D2-AEC9-00C04FB68820")] @@ -800,8 +800,8 @@ namespace System.Management [ComImport] internal interface IWbemStatusCodeText { - [PreserveSig] int GetErrorCodeText_([In][MarshalAs(UnmanagedType.Error)] int hRes, [In] uint LocaleId, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string MessageText); - [PreserveSig] int GetFacilityCodeText_([In][MarshalAs(UnmanagedType.Error)] int hRes, [In] uint LocaleId, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string MessageText); + [PreserveSig] int GetErrorCodeText_([In][MarshalAs(UnmanagedType.Error)] int hRes, [In] uint LocaleId, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string MessageText); + [PreserveSig] int GetFacilityCodeText_([In][MarshalAs(UnmanagedType.Error)] int hRes, [In] uint LocaleId, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string MessageText); } [InterfaceTypeAttribute(0x0001)] @@ -810,7 +810,7 @@ namespace System.Management [ComImport] internal interface IWbemUnboundObjectSink { - [PreserveSig] int IndicateToConsumer_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pLogicalConsumer, [In] int lNumObjects, [In][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal apObjects); + [PreserveSig] int IndicateToConsumer_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pLogicalConsumer, [In] int lNumObjects, [In][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal apObjects); } [InterfaceTypeAttribute(0x0001)] @@ -819,8 +819,8 @@ namespace System.Management [ComImport] internal interface IWbemPropertyProvider { - [PreserveSig] int GetProperty_([In] int lFlags, [In][MarshalAs(UnmanagedType.BStr)] string strLocale, [In][MarshalAs(UnmanagedType.BStr)] string strClassMapping, [In][MarshalAs(UnmanagedType.BStr)] string strInstMapping, [In][MarshalAs(UnmanagedType.BStr)] string strPropMapping, [Out] out object pvValue); - [PreserveSig] int PutProperty_([In] int lFlags, [In][MarshalAs(UnmanagedType.BStr)] string strLocale, [In][MarshalAs(UnmanagedType.BStr)] string strClassMapping, [In][MarshalAs(UnmanagedType.BStr)] string strInstMapping, [In][MarshalAs(UnmanagedType.BStr)] string strPropMapping, [In] ref object pvValue); + [PreserveSig] int GetProperty_([In] int lFlags, [In][MarshalAs(UnmanagedType.BStr)] string strLocale, [In][MarshalAs(UnmanagedType.BStr)] string strClassMapping, [In][MarshalAs(UnmanagedType.BStr)] string strInstMapping, [In][MarshalAs(UnmanagedType.BStr)] string strPropMapping, [Out] out object pvValue); + [PreserveSig] int PutProperty_([In] int lFlags, [In][MarshalAs(UnmanagedType.BStr)] string strLocale, [In][MarshalAs(UnmanagedType.BStr)] string strClassMapping, [In][MarshalAs(UnmanagedType.BStr)] string strInstMapping, [In][MarshalAs(UnmanagedType.BStr)] string strPropMapping, [In] ref object pvValue); } [InterfaceTypeAttribute(0x0001)] @@ -829,7 +829,7 @@ namespace System.Management [ComImport] internal interface IWbemEventProvider { - [PreserveSig] int ProvideEvents_([In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pSink, [In] int lFlags); + [PreserveSig] int ProvideEvents_([In][MarshalAs(UnmanagedType.Interface)] IWbemObjectSink pSink, [In] int lFlags); } [GuidAttribute("580ACAF8-FA1C-11D0-AD72-00C04FD8FDFF")] @@ -838,7 +838,7 @@ namespace System.Management [ComImport] internal interface IWbemEventProviderQuerySink { - [PreserveSig] int NewQuery_([In] uint dwId, [In][MarshalAs(UnmanagedType.LPWStr)] string wszQueryLanguage, [In][MarshalAs(UnmanagedType.LPWStr)] string wszQuery); + [PreserveSig] int NewQuery_([In] uint dwId, [In][MarshalAs(UnmanagedType.LPWStr)] string wszQueryLanguage, [In][MarshalAs(UnmanagedType.LPWStr)] string wszQuery); [PreserveSig] int CancelQuery_([In] uint dwId); } @@ -848,7 +848,7 @@ namespace System.Management [ComImport] internal interface IWbemEventProviderSecurity { - [PreserveSig] int AccessCheck_([In][MarshalAs(UnmanagedType.LPWStr)] string wszQueryLanguage, [In][MarshalAs(UnmanagedType.LPWStr)] string wszQuery, [In] int lSidLength, [In] ref byte pSid); + [PreserveSig] int AccessCheck_([In][MarshalAs(UnmanagedType.LPWStr)] string wszQueryLanguage, [In][MarshalAs(UnmanagedType.LPWStr)] string wszQuery, [In] int lSidLength, [In] ref byte pSid); } [GuidAttribute("631F7D97-D993-11D2-B339-00105A1F4AAF")] @@ -857,7 +857,7 @@ namespace System.Management [ComImport] internal interface IWbemProviderIdentity { - [PreserveSig] int SetRegistrationObject_([In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pProvReg); + [PreserveSig] int SetRegistrationObject_([In] int lFlags, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pProvReg); } [InterfaceTypeAttribute(0x0001)] @@ -866,7 +866,7 @@ namespace System.Management [ComImport] internal interface IWbemEventConsumerProvider { - [PreserveSig] int FindConsumer_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pLogicalConsumer, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemUnboundObjectSink ppConsumer); + [PreserveSig] int FindConsumer_([In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pLogicalConsumer, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemUnboundObjectSink ppConsumer); } [GuidAttribute("1BE41571-91DD-11D1-AEB2-00C04FB68820")] @@ -882,7 +882,7 @@ namespace System.Management [ComImport] internal interface IWbemProviderInit { - [PreserveSig] int Initialize_([In][MarshalAs(UnmanagedType.LPWStr)] string wszUser, [In] int lFlags, [In][MarshalAs(UnmanagedType.LPWStr)] string wszNamespace, [In][MarshalAs(UnmanagedType.LPWStr)] string wszLocale, [In][MarshalAs(UnmanagedType.Interface)] IWbemServices pNamespace, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemProviderInitSink pInitSink); + [PreserveSig] int Initialize_([In][MarshalAs(UnmanagedType.LPWStr)] string wszUser, [In] int lFlags, [In][MarshalAs(UnmanagedType.LPWStr)] string wszNamespace, [In][MarshalAs(UnmanagedType.LPWStr)] string wszLocale, [In][MarshalAs(UnmanagedType.Interface)] IWbemServices pNamespace, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In][MarshalAs(UnmanagedType.Interface)] IWbemProviderInitSink pInitSink); } [InterfaceTypeAttribute(0x0001)] @@ -890,7 +890,7 @@ namespace System.Management [ComImport] internal interface IWbemDecoupledRegistrar { - [PreserveSig] int Register_([In] int flags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext context, [In][MarshalAs(UnmanagedType.LPWStr)] string user, [In][MarshalAs(UnmanagedType.LPWStr)] string locale, [In][MarshalAs(UnmanagedType.LPWStr)] string scope, [In][MarshalAs(UnmanagedType.LPWStr)] string registration, [In][MarshalAs(UnmanagedType.IUnknown)] object unknown); + [PreserveSig] int Register_([In] int flags, [In][MarshalAs(UnmanagedType.Interface)] IWbemContext context, [In][MarshalAs(UnmanagedType.LPWStr)] string user, [In][MarshalAs(UnmanagedType.LPWStr)] string locale, [In][MarshalAs(UnmanagedType.LPWStr)] string scope, [In][MarshalAs(UnmanagedType.LPWStr)] string registration, [In][MarshalAs(UnmanagedType.IUnknown)] object unknown); [PreserveSig] int UnRegister_(); } @@ -900,12 +900,12 @@ namespace System.Management [ComImport] internal interface IWbemEventSink { - [PreserveSig] int Indicate_([In] int lObjectCount, [In][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal apObjArray); - [PreserveSig] int SetStatus_([In] int lFlags, [In][MarshalAs(UnmanagedType.Error)] int hResult, [In][MarshalAs(UnmanagedType.BStr)] string strParam, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pObjParam); - [PreserveSig] int IndicateWithSD_([In] int lNumObjects, [In][MarshalAs(UnmanagedType.IUnknown)] ref object apObjects, [In] int lSDLength, [In] ref byte pSD); + [PreserveSig] int Indicate_([In] int lObjectCount, [In][MarshalAs(UnmanagedType.Interface)] ref IWbemClassObject_DoNotMarshal apObjArray); + [PreserveSig] int SetStatus_([In] int lFlags, [In][MarshalAs(UnmanagedType.Error)] int hResult, [In][MarshalAs(UnmanagedType.BStr)] string strParam, [In][MarshalAs(UnmanagedType.Interface)] IWbemClassObject_DoNotMarshal pObjParam); + [PreserveSig] int IndicateWithSD_([In] int lNumObjects, [In][MarshalAs(UnmanagedType.IUnknown)] ref object apObjects, [In] int lSDLength, [In] ref byte pSD); [PreserveSig] int SetSinkSecurity_([In] int lSDLength, [In] ref byte pSD); [PreserveSig] int IsActive_(); - [PreserveSig] int GetRestrictedSink_([In] int lNumQueries, [In][MarshalAs(UnmanagedType.LPWStr)] ref string awszQueries, [In][MarshalAs(UnmanagedType.IUnknown)] object pCallback, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemEventSink ppSink); + [PreserveSig] int GetRestrictedSink_([In] int lNumQueries, [In][MarshalAs(UnmanagedType.LPWStr)] ref string awszQueries, [In][MarshalAs(UnmanagedType.IUnknown)] object pCallback, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemEventSink ppSink); [PreserveSig] int SetBatchingParameters_([In] int lFlags, [In] uint dwMaxBufferSize, [In] uint dwMaxSendLatency); } @@ -916,15 +916,15 @@ namespace System.Management internal interface IWbemPathKeyList { [PreserveSig] int GetCount_([Out] out uint puKeyCount); - [PreserveSig] int SetKey_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] uint uFlags, [In] uint uCimType, [In] IntPtr pKeyVal); - [PreserveSig] int SetKey2_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] uint uFlags, [In] uint uCimType, [In] ref object pKeyVal); - [PreserveSig] int GetKey_([In] uint uKeyIx, [In] uint uFlags, [In][Out] ref uint puNameBufSize, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 2)] char[] pszKeyName, [In][Out] ref uint puKeyValBufSize, [In][Out] IntPtr pKeyVal, [Out] out uint puApparentCimType); - [PreserveSig] int GetKey2_([In] uint uKeyIx, [In] uint uFlags, [In][Out] ref uint puNameBufSize, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 2)] char[] pszKeyName, [In][Out] ref object pKeyValue, [Out] out uint puApparentCimType); - [PreserveSig] int RemoveKey_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] uint uFlags); + [PreserveSig] int SetKey_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] uint uFlags, [In] uint uCimType, [In] IntPtr pKeyVal); + [PreserveSig] int SetKey2_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] uint uFlags, [In] uint uCimType, [In] ref object pKeyVal); + [PreserveSig] int GetKey_([In] uint uKeyIx, [In] uint uFlags, [In][Out] ref uint puNameBufSize, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 2)] char[] pszKeyName, [In][Out] ref uint puKeyValBufSize, [In][Out] IntPtr pKeyVal, [Out] out uint puApparentCimType); + [PreserveSig] int GetKey2_([In] uint uKeyIx, [In] uint uFlags, [In][Out] ref uint puNameBufSize, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 2)] char[] pszKeyName, [In][Out] ref object pKeyValue, [Out] out uint puApparentCimType); + [PreserveSig] int RemoveKey_([In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] uint uFlags); [PreserveSig] int RemoveAllKeys_([In] uint uFlags); [PreserveSig] int MakeSingleton_([In] sbyte bSet); [PreserveSig] int GetInfo_([In] uint uRequestedInfo, [Out] out ulong puResponse); - [PreserveSig] int GetText_([In] int lFlags, [In][Out] ref uint puBuffLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pszText); + [PreserveSig] int GetText_([In] int lFlags, [In][Out] ref uint puBuffLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pszText); } [GuidAttribute("3BC15AF2-736C-477E-9E51-238AF8667DCC")] @@ -932,32 +932,32 @@ namespace System.Management [ComImport] internal interface IWbemPath { - [PreserveSig] int SetText_([In] uint uMode, [In][MarshalAs(UnmanagedType.LPWStr)] string pszPath); - [PreserveSig] int GetText_([In] int lFlags, [In][Out] ref uint puBuffLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pszText); + [PreserveSig] int SetText_([In] uint uMode, [In][MarshalAs(UnmanagedType.LPWStr)] string pszPath); + [PreserveSig] int GetText_([In] int lFlags, [In][Out] ref uint puBuffLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pszText); [PreserveSig] int GetInfo_([In] uint uRequestedInfo, [Out] out ulong puResponse); - [PreserveSig] int SetServer_([In][MarshalAs(UnmanagedType.LPWStr)] string Name); - [PreserveSig] int GetServer_([In][Out] ref uint puNameBufLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 0)] char[] pName); + [PreserveSig] int SetServer_([In][MarshalAs(UnmanagedType.LPWStr)] string Name); + [PreserveSig] int GetServer_([In][Out] ref uint puNameBufLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 0)] char[] pName); [PreserveSig] int GetNamespaceCount_([Out] out uint puCount); - [PreserveSig] int SetNamespaceAt_([In] uint uIndex, [In][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 0)] char[] pszName); - [PreserveSig] int GetNamespaceAt_([In] uint uIndex, [In][Out] ref uint puNameBufLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pName); + [PreserveSig] int SetNamespaceAt_([In] uint uIndex, [In][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 0)] char[] pszName); + [PreserveSig] int GetNamespaceAt_([In] uint uIndex, [In][Out] ref uint puNameBufLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pName); [PreserveSig] int RemoveNamespaceAt_([In] uint uIndex); [PreserveSig] int RemoveAllNamespaces_(); [PreserveSig] int GetScopeCount_([Out] out uint puCount); - [PreserveSig] int SetScope_([In] uint uIndex, [In][MarshalAs(UnmanagedType.LPWStr)] string pszClass); - [PreserveSig] int SetScopeFromText_([In] uint uIndex, [In][MarshalAs(UnmanagedType.LPWStr)] string pszText); - [PreserveSig] int GetScope_([In] uint uIndex, [In][Out] ref uint puClassNameBufSize, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pszClass, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemPathKeyList pKeyList); - [PreserveSig] int GetScopeAsText_([In] uint uIndex, [In][Out] ref uint puTextBufSize, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pszText); + [PreserveSig] int SetScope_([In] uint uIndex, [In][MarshalAs(UnmanagedType.LPWStr)] string pszClass); + [PreserveSig] int SetScopeFromText_([In] uint uIndex, [In][MarshalAs(UnmanagedType.LPWStr)] string pszText); + [PreserveSig] int GetScope_([In] uint uIndex, [In][Out] ref uint puClassNameBufSize, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pszClass, [Out][MarshalAs(UnmanagedType.Interface)] out IWbemPathKeyList pKeyList); + [PreserveSig] int GetScopeAsText_([In] uint uIndex, [In][Out] ref uint puTextBufSize, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 1)] char[] pszText); [PreserveSig] int RemoveScope_([In] uint uIndex); [PreserveSig] int RemoveAllScopes_(); - [PreserveSig] int SetClassName_([In][MarshalAs(UnmanagedType.LPWStr)] string Name); - [PreserveSig] int GetClassName_([In][Out] ref uint puBuffLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 0)] char[] pszName); - [PreserveSig] int GetKeyList_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemPathKeyList pOut); - [PreserveSig] int CreateClassPart_([In] int lFlags, [In][MarshalAs(UnmanagedType.LPWStr)] string Name); + [PreserveSig] int SetClassName_([In][MarshalAs(UnmanagedType.LPWStr)] string Name); + [PreserveSig] int GetClassName_([In][Out] ref uint puBuffLength, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U2, SizeParamIndex = 0)] char[] pszName); + [PreserveSig] int GetKeyList_([Out][MarshalAs(UnmanagedType.Interface)] out IWbemPathKeyList pOut); + [PreserveSig] int CreateClassPart_([In] int lFlags, [In][MarshalAs(UnmanagedType.LPWStr)] string Name); [PreserveSig] int DeleteClassPart_([In] int lFlags); - [PreserveSig] int IsRelative_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMachine, [In][MarshalAs(UnmanagedType.LPWStr)] string wszNamespace); - [PreserveSig] int IsRelativeOrChild_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMachine, [In][MarshalAs(UnmanagedType.LPWStr)] string wszNamespace, [In] int lFlags); - [PreserveSig] int IsLocal_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMachine); - [PreserveSig] int IsSameClassName_([In][MarshalAs(UnmanagedType.LPWStr)] string wszClass); + [PreserveSig] int IsRelative_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMachine, [In][MarshalAs(UnmanagedType.LPWStr)] string wszNamespace); + [PreserveSig] int IsRelativeOrChild_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMachine, [In][MarshalAs(UnmanagedType.LPWStr)] string wszNamespace, [In] int lFlags); + [PreserveSig] int IsLocal_([In][MarshalAs(UnmanagedType.LPWStr)] string wszMachine); + [PreserveSig] int IsSameClassName_([In][MarshalAs(UnmanagedType.LPWStr)] string wszClass); } #endregion @@ -1487,7 +1487,7 @@ namespace System.Management ndx = reqList.Add(myReq); - if ( evtGo.Set() == false ) + if (evtGo.Set() == false) { reqList.RemoveAt(ndx); throw new ManagementException(SR.WorkerThreadWakeupFailed); @@ -1566,7 +1566,7 @@ namespace System.Management public static bool IsNoContextMTA() { // If the runtime says we are not an MTA thread, we'll trust it and return false - if (Thread.CurrentThread.GetApartmentState() != ApartmentState.MTA) + if (Thread.CurrentThread.GetApartmentState() != ApartmentState.MTA) return false; // We know that 'ApartmentState' says we are MTA @@ -1619,7 +1619,7 @@ namespace System.Management // If we are on Win2k or above, we are OK // - Platform == Win32NT and OS version >= 5.0.0.0 OperatingSystem os = Environment.OSVersion; - if (os.Platform==PlatformID.Win32NT && os.Version >= new Version(5, 0)) + if (os.Platform == PlatformID.Win32NT && os.Version >= new Version(5, 0)) return true; return false; } @@ -1648,16 +1648,16 @@ namespace System.Management internal class ThreadDispatch { #region Private fields - private Thread thread; - private Exception exception; // Exception thrown from worker method (if any). Exposed as property. - private ThreadWorkerMethodWithReturn threadWorkerMethodWithReturn; // Delegate to be called for worker method with return value - private ThreadWorkerMethodWithReturnAndParam threadWorkerMethodWithReturnAndParam; // Delegate to be called for worker method with return value and parameter - private ThreadWorkerMethod threadWorkerMethod; // Delegate to be called for worker method - private ThreadWorkerMethodWithParam threadWorkerMethodWithParam; // Delegate to be called for worker method with parameter - private object threadReturn; // Return data from worker method. - private object threadParams; // Parameters to be passed to worker method - private bool backgroundThread; // Is this a background thread? - private ApartmentState apartmentType; // Apartment type of thread + private Thread thread; + private Exception exception; // Exception thrown from worker method (if any). Exposed as property. + private ThreadWorkerMethodWithReturn threadWorkerMethodWithReturn; // Delegate to be called for worker method with return value + private ThreadWorkerMethodWithReturnAndParam threadWorkerMethodWithReturnAndParam; // Delegate to be called for worker method with return value and parameter + private ThreadWorkerMethod threadWorkerMethod; // Delegate to be called for worker method + private ThreadWorkerMethodWithParam threadWorkerMethodWithParam; // Delegate to be called for worker method with parameter + private object threadReturn; // Return data from worker method. + private object threadParams; // Parameters to be passed to worker method + private bool backgroundThread; // Is this a background thread? + private ApartmentState apartmentType; // Apartment type of thread #endregion #region Properties @@ -1735,22 +1735,22 @@ namespace System.Management /// /// Delegate declaration representing signature of worker method with return value. /// - public delegate object ThreadWorkerMethodWithReturn ( ); + public delegate object ThreadWorkerMethodWithReturn(); /// /// Delegate declaration representing signature of worker method with return value and parameter. /// - public delegate object ThreadWorkerMethodWithReturnAndParam ( object param ); + public delegate object ThreadWorkerMethodWithReturnAndParam(object param); /// /// Delegate declaration representing signature of worker method with no return value and no parameter /// - public delegate void ThreadWorkerMethod ( ); + public delegate void ThreadWorkerMethod(); /// /// Delegate declaration representing signature of worker method with parameter. /// - public delegate void ThreadWorkerMethodWithParam ( object param ); + public delegate void ThreadWorkerMethodWithParam(object param); #endregion #region Public methods @@ -1762,9 +1762,9 @@ namespace System.Management /// 3. Background thread status will be false /// /// Delegate to be called to perform the work - public ThreadDispatch ( ThreadWorkerMethodWithReturn workerMethod ) : this ( ) + public ThreadDispatch(ThreadWorkerMethodWithReturn workerMethod) : this() { - InitializeThreadState ( null, workerMethod, ApartmentState.MTA, false ); + InitializeThreadState(null, workerMethod, ApartmentState.MTA, false); } /// @@ -1775,9 +1775,9 @@ namespace System.Management /// 3. Background thread status will be false /// /// Delegate to be called to perform the work - public ThreadDispatch ( ThreadWorkerMethodWithReturnAndParam workerMethod ) : this ( ) + public ThreadDispatch(ThreadWorkerMethodWithReturnAndParam workerMethod) : this() { - InitializeThreadState ( null, workerMethod, ApartmentState.MTA, false ); + InitializeThreadState(null, workerMethod, ApartmentState.MTA, false); } /// @@ -1788,9 +1788,9 @@ namespace System.Management /// 3. Background thread status will be false /// /// Delegate to be called to perform the work - public ThreadDispatch ( ThreadWorkerMethodWithParam workerMethod ) : this ( ) + public ThreadDispatch(ThreadWorkerMethodWithParam workerMethod) : this() { - InitializeThreadState ( null, workerMethod, ApartmentState.MTA, false ); + InitializeThreadState(null, workerMethod, ApartmentState.MTA, false); } /// @@ -1801,20 +1801,20 @@ namespace System.Management /// 3. Background thread status will be false /// /// Delegate to be called to perform the work - public ThreadDispatch ( ThreadWorkerMethod workerMethod ) : this ( ) + public ThreadDispatch(ThreadWorkerMethod workerMethod) : this() { - InitializeThreadState ( null, workerMethod, ApartmentState.MTA, false ); + InitializeThreadState(null, workerMethod, ApartmentState.MTA, false); } /// /// Starts the thread execution and waits for thread to finish. If an exception occurs in the worker method /// this method rethrows the exception. /// - public void Start ( ) + public void Start() { this.exception = null; DispatchThread(); - if ( this.Exception != null ) + if (this.Exception != null) { throw this.Exception; } @@ -1826,18 +1826,18 @@ namespace System.Management /// Initializes the ThreadDispatch instance with initial values. Note that this constructor is private to avoid /// declaring instances without specifying at least a worker delegate instance. /// - private ThreadDispatch ( ) + private ThreadDispatch() { - this.thread = null; - this.exception = null; - this.threadParams = null; - this.threadWorkerMethodWithReturn = null; + this.thread = null; + this.exception = null; + this.threadParams = null; + this.threadWorkerMethodWithReturn = null; this.threadWorkerMethodWithReturnAndParam = null; - this.threadWorkerMethod = null; - this.threadWorkerMethodWithParam = null; - this.threadReturn = null; - this.backgroundThread = false; - this.apartmentType = ApartmentState.MTA; + this.threadWorkerMethod = null; + this.threadWorkerMethodWithParam = null; + this.threadReturn = null; + this.backgroundThread = false; + this.apartmentType = ApartmentState.MTA; } /// @@ -1847,11 +1847,11 @@ namespace System.Management /// The delegate to be called from thread /// The apartment of the thread created /// Thread is created as a background or not - private void InitializeThreadState ( object threadParams, ThreadWorkerMethodWithReturn workerMethod, ApartmentState aptState, bool background ) + private void InitializeThreadState(object threadParams, ThreadWorkerMethodWithReturn workerMethod, ApartmentState aptState, bool background) { this.threadParams = threadParams; - this.threadWorkerMethodWithReturn = workerMethod; - this.thread = new Thread ( new ThreadStart ( ThreadEntryPointMethodWithReturn ) ); + this.threadWorkerMethodWithReturn = workerMethod; + this.thread = new Thread(new ThreadStart(ThreadEntryPointMethodWithReturn)); this.thread.SetApartmentState(aptState); this.backgroundThread = background; } @@ -1863,11 +1863,11 @@ namespace System.Management /// The delegate to be called from thread /// The apartment of the thread created /// Thread is created as a background or not - private void InitializeThreadState ( object threadParams, ThreadWorkerMethodWithReturnAndParam workerMethod, ApartmentState aptState, bool background ) + private void InitializeThreadState(object threadParams, ThreadWorkerMethodWithReturnAndParam workerMethod, ApartmentState aptState, bool background) { this.threadParams = threadParams; this.threadWorkerMethodWithReturnAndParam = workerMethod; - this.thread = new Thread ( new ThreadStart ( ThreadEntryPointMethodWithReturnAndParam ) ); + this.thread = new Thread(new ThreadStart(ThreadEntryPointMethodWithReturnAndParam)); this.thread.SetApartmentState(aptState); this.backgroundThread = background; } @@ -1879,12 +1879,12 @@ namespace System.Management /// The delegate to be called from thread /// The apartment of the thread created /// Thread is created as a background or not - private void InitializeThreadState ( object threadParams, ThreadWorkerMethod workerMethod, ApartmentState aptState, bool background ) + private void InitializeThreadState(object threadParams, ThreadWorkerMethod workerMethod, ApartmentState aptState, bool background) { this.threadParams = threadParams; - this.threadWorkerMethod = workerMethod; - this.thread = new Thread ( new ThreadStart ( ThreadEntryPoint ) ); - this.thread.SetApartmentState(aptState ); + this.threadWorkerMethod = workerMethod; + this.thread = new Thread(new ThreadStart(ThreadEntryPoint)); + this.thread.SetApartmentState(aptState); this.backgroundThread = background; } @@ -1895,12 +1895,12 @@ namespace System.Management /// The delegate to be called from thread /// The apartment of the thread created /// Thread is created as a background or not - private void InitializeThreadState ( object threadParams, ThreadWorkerMethodWithParam workerMethod, ApartmentState aptState, bool background ) + private void InitializeThreadState(object threadParams, ThreadWorkerMethodWithParam workerMethod, ApartmentState aptState, bool background) { this.threadParams = threadParams; this.threadWorkerMethodWithParam = workerMethod; - this.thread = new Thread ( new ThreadStart ( ThreadEntryPointMethodWithParam ) ); - this.thread.SetApartmentState( aptState ); + this.thread = new Thread(new ThreadStart(ThreadEntryPointMethodWithParam)); + this.thread.SetApartmentState(aptState); this.backgroundThread = background; } @@ -1908,7 +1908,7 @@ namespace System.Management /// /// Starts the execution of the thread and waits until the threadFinished event is signaled before continuing /// - private void DispatchThread ( ) + private void DispatchThread() { this.thread.Start(); this.thread.Join(); @@ -1919,7 +1919,7 @@ namespace System.Management /// exceptions thrown from the worker method and re-throws the exception. /// The worker method for this thread entry point has no parameter and no return value. /// - private void ThreadEntryPoint ( ) + private void ThreadEntryPoint() { try { @@ -1937,11 +1937,11 @@ namespace System.Management /// The worker method for this thread entry point takes a parameter and no return value. /// - private void ThreadEntryPointMethodWithParam ( ) + private void ThreadEntryPointMethodWithParam() { try { - this.threadWorkerMethodWithParam ( this.threadParams ); + this.threadWorkerMethodWithParam(this.threadParams); } catch (Exception e) { @@ -1955,7 +1955,7 @@ namespace System.Management /// The worker method for this thread entry point has no parameter but does return a value. /// - private void ThreadEntryPointMethodWithReturn ( ) + private void ThreadEntryPointMethodWithReturn() { try { @@ -1973,7 +1973,7 @@ namespace System.Management /// The worker method for this thread entry point has a parameter and return value. /// - private void ThreadEntryPointMethodWithReturnAndParam ( ) + private void ThreadEntryPointMethodWithReturnAndParam() { try { diff --git a/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs b/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs index 24b1530b593..ca5bd064367 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementBaseObject.cs @@ -323,7 +323,7 @@ namespace System.Management return new ManagementBaseObject(theClone); } - internal virtual void Initialize ( bool getObject ) {} + internal virtual void Initialize(bool getObject) { } // //Properties @@ -342,7 +342,7 @@ namespace System.Management { get { - Initialize ( true ); + Initialize(true); if (properties == null) properties = new PropertyDataCollection(this, false); @@ -364,7 +364,7 @@ namespace System.Management { get { - Initialize ( false ); + Initialize(false); if (systemProperties == null) systemProperties = new PropertyDataCollection(this, true); @@ -387,7 +387,7 @@ namespace System.Management { get { - Initialize ( true ); + Initialize(true); if (qualifiers == null) qualifiers = new QualifierDataCollection(this); @@ -479,10 +479,10 @@ namespace System.Management get { return GetPropertyValue(propertyName); } set { - Initialize ( true ); + Initialize(true); try { - SetPropertyValue (propertyName, value); + SetPropertyValue(propertyName, value); } catch (COMException e) { @@ -504,10 +504,10 @@ namespace System.Management public object GetPropertyValue(string propertyName) { if (null == propertyName) - throw new ArgumentNullException (nameof(propertyName)); + throw new ArgumentNullException(nameof(propertyName)); // Check for system properties - if (propertyName.StartsWith ("__", StringComparison.Ordinal)) + if (propertyName.StartsWith("__", StringComparison.Ordinal)) return SystemProperties[propertyName].Value; else return Properties[propertyName].Value; @@ -525,7 +525,7 @@ namespace System.Management /// public object GetQualifierValue(string qualifierName) { - return Qualifiers [qualifierName].Value; + return Qualifiers[qualifierName].Value; } //****************************************************** @@ -538,7 +538,7 @@ namespace System.Management /// The value to set. public void SetQualifierValue(string qualifierName, object qualifierValue) { - Qualifiers [qualifierName].Value = qualifierValue; + Qualifiers[qualifierName].Value = qualifierValue; } @@ -595,7 +595,7 @@ namespace System.Management // switch (format) { - case TextFormat.Mof : + case TextFormat.Mof: status = wbemObject.GetObjectText_(0, out objText); @@ -609,8 +609,8 @@ namespace System.Management return objText; - case TextFormat.CimDtd20 : - case TextFormat.WmiDtd20 : + case TextFormat.CimDtd20: + case TextFormat.WmiDtd20: //This may throw on non-XP platforms... - should we catch ? IWbemObjectTextSrc wbemTextSrc = (IWbemObjectTextSrc)new WbemObjectTextSrc(); @@ -660,7 +660,7 @@ namespace System.Management { if (obj is ManagementBaseObject) { - result = CompareTo ((ManagementBaseObject)obj, ComparisonSettings.IncludeAll); + result = CompareTo((ManagementBaseObject)obj, ComparisonSettings.IncludeAll); } else { @@ -741,15 +741,15 @@ namespace System.Management public bool CompareTo(ManagementBaseObject otherObject, ComparisonSettings settings) { if (null == otherObject) - throw new ArgumentNullException (nameof(otherObject)); + throw new ArgumentNullException(nameof(otherObject)); bool result = false; if (null != wbemObject) { - int status = (int) ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; - status = wbemObject.CompareTo_((int) settings, otherObject.wbemObject); + status = wbemObject.CompareTo_((int)settings, otherObject.wbemObject); if ((int)ManagementStatus.Different == status) result = false; @@ -772,7 +772,7 @@ namespace System.Management int dummy1 = 0, dummy2 = 0; int status = (int)ManagementStatus.NoError; - status = wbemObject.Get_ ("__CLASS", 0, ref val, ref dummy1, ref dummy2); + status = wbemObject.Get_("__CLASS", 0, ref val, ref dummy1, ref dummy2); if (status < 0) { @@ -785,7 +785,7 @@ namespace System.Management if (val is System.DBNull) return string.Empty; else - return ((string) val); + return ((string)val); } } @@ -820,15 +820,15 @@ namespace System.Management /// /// The name of the property to be changed. /// The new value for this property. - public void SetPropertyValue ( + public void SetPropertyValue( string propertyName, object propertyValue) { if (null == propertyName) - throw new ArgumentNullException (nameof(propertyName)); + throw new ArgumentNullException(nameof(propertyName)); // Check for system properties - if (propertyName.StartsWith ("__", StringComparison.Ordinal)) + if (propertyName.StartsWith("__", StringComparison.Ordinal)) SystemProperties[propertyName].Value = propertyValue; else Properties[propertyName].Value = propertyValue; diff --git a/src/libraries/System.Management/src/System/Management/ManagementClass.cs b/src/libraries/System.Management/src/System/Management/ManagementClass.cs index 5380fad4939..523121bd4ae 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementClass.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementClass.cs @@ -141,7 +141,7 @@ namespace System.Management /// Dim c As New ManagementClass() /// /// - public ManagementClass() : this ((ManagementScope)null, (ManagementPath)null, null) {} + public ManagementClass() : this((ManagementScope)null, (ManagementPath)null, null) { } //parameterized constructors /// @@ -161,7 +161,7 @@ namespace System.Management /// New ManagementPath("Win32_LogicalDisk")) /// /// - public ManagementClass(ManagementPath path) : this(null, path, null) {} + public ManagementClass(ManagementPath path) : this(null, path, null) { } /// /// Initializes a new instance of the class initialized to the given path. @@ -174,7 +174,7 @@ namespace System.Management /// Dim c As New ManagementClass("Win32_LogicalDisk") /// /// - public ManagementClass(string path) : this(null, new ManagementPath(path), null) {} + public ManagementClass(string path) : this(null, new ManagementPath(path), null) { } /// /// Initializes a new instance of the class initialized to the @@ -194,7 +194,7 @@ namespace System.Management /// Dim c As New ManagementClass(p,o) /// /// - public ManagementClass(ManagementPath path, ObjectGetOptions options) : this(null, path, options) {} + public ManagementClass(ManagementPath path, ObjectGetOptions options) : this(null, path, options) { } /// /// Initializes a new instance of the class initialized to the given WMI class path @@ -213,7 +213,7 @@ namespace System.Management /// /// public ManagementClass(string path, ObjectGetOptions options) - : this(null, new ManagementPath(path), options) {} + : this(null, new ManagementPath(path), options) { } /// /// Initializes a new instance of the class for the specified @@ -240,7 +240,7 @@ namespace System.Management /// /// public ManagementClass(ManagementScope scope, ManagementPath path, ObjectGetOptions options) - : base (scope, path, options) {} + : base(scope, path, options) { } /// /// Initializes a new instance of the class for the specified WMI class, in the @@ -265,7 +265,7 @@ namespace System.Management /// /// public ManagementClass(string scope, string path, ObjectGetOptions options) - : base (new ManagementScope(scope), new ManagementPath(path), options) {} + : base(new ManagementScope(scope), new ManagementPath(path), options) { } protected ManagementClass(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -353,7 +353,7 @@ namespace System.Management } if (null != val) - result.AddRange((string [])val); + result.AddRange((string[])val); return result; } @@ -382,7 +382,7 @@ namespace System.Management { get { - Initialize ( true ); + Initialize(true); if (methods == null) methods = new MethodDataCollection(this); @@ -458,7 +458,7 @@ namespace System.Management if ((null == Path) || (null == Path.Path) || (0 == Path.Path.Length)) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); IEnumWbemClassObject enumWbem = null; EnumerationOptions o = (null == options) ? new EnumerationOptions() : (EnumerationOptions)options.Clone(); @@ -467,16 +467,13 @@ namespace System.Management o.EnsureLocatable = false; o.PrototypeOnly = false; SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { securityHandler = Scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices() ).CreateInstanceEnum_(ClassName, - o.Flags, - o.GetContext(), - ref enumWbem - ); + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).CreateInstanceEnum_( + ClassName, o.Flags, o.GetContext(), ref enumWbem); } finally { @@ -585,7 +582,7 @@ namespace System.Management if ((null == Path) || (null == Path.Path) || (0 == Path.Path.Length)) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); EnumerationOptions o = (null == options) ? new EnumerationOptions() : (EnumerationOptions)options.Clone(); @@ -603,19 +600,16 @@ namespace System.Management WmiEventSink sink = watcher.GetNewSink(Scope, o.Context); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = Scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices() ).CreateInstanceEnumAsync_( - ClassName, - o.Flags, - o.GetContext(), - sink.Stub ); + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).CreateInstanceEnumAsync_( + ClassName, o.Flags, o.GetContext(), sink.Stub); if (securityHandler != null) - securityHandler.Reset(); + securityHandler.Reset(); if (status < 0) { @@ -682,7 +676,7 @@ namespace System.Management if (null == Path) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); IEnumWbemClassObject enumWbem = null; EnumerationOptions o = (null == options) ? new EnumerationOptions() : (EnumerationOptions)options.Clone(); @@ -691,15 +685,13 @@ namespace System.Management o.EnsureLocatable = false; o.PrototypeOnly = false; SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { securityHandler = Scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler( Scope.GetIWbemServices() ).CreateClassEnum_(ClassName, - o.Flags, - o.GetContext(), - ref enumWbem); + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).CreateClassEnum_( + ClassName, o.Flags, o.GetContext(), ref enumWbem); } finally { @@ -743,7 +735,7 @@ namespace System.Management if (null == Path) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); EnumerationOptions o = (null == options) ? new EnumerationOptions() : (EnumerationOptions)options.Clone(); @@ -762,14 +754,12 @@ namespace System.Management WmiEventSink sink = watcher.GetNewSink(Scope, o.Context); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = Scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices() ).CreateClassEnumAsync_(ClassName, - o.Flags, - o.GetContext(), - sink.Stub); + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).CreateClassEnumAsync_( + ClassName, o.Flags, o.GetContext(), sink.Stub); if (securityHandler != null) @@ -1032,7 +1022,7 @@ namespace System.Management if ((null == Path) || (null == Path.Path) || (0 == Path.Path.Length)) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); IEnumWbemClassObject enumWbem = null; @@ -1040,7 +1030,7 @@ namespace System.Management //Ensure EnumerateDeep flag bit is turned off as it's invalid for queries o.EnumerateDeep = true; - RelatedObjectQuery q = new RelatedObjectQuery(true, Path.Path, + RelatedObjectQuery q = new RelatedObjectQuery(true, Path.Path, relatedClass, relationshipClass, relatedQualifier, @@ -1048,12 +1038,12 @@ namespace System.Management relatedRole, thisRole); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { securityHandler = Scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices() ).ExecQuery_( + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).ExecQuery_( q.QueryLanguage, q.QueryString, o.Flags, @@ -1130,7 +1120,7 @@ namespace System.Management if ((null == Path) || (null == Path.Path) || (0 == Path.Path.Length)) throw new InvalidOperationException(); - Initialize ( true ); + Initialize(true); if (null == watcher) throw new ArgumentNullException(nameof(watcher)); @@ -1159,16 +1149,12 @@ namespace System.Management relatedRole, thisRole); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = Scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices() ).ExecQueryAsync_( - q.QueryLanguage, - q.QueryString, - o.Flags, - o.GetContext(), - sink.Stub); + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).ExecQueryAsync_( + q.QueryLanguage, q.QueryString, o.Flags, o.GetContext(), sink.Stub); if (securityHandler != null) @@ -1241,7 +1227,7 @@ namespace System.Management if ((null == Path) || (null == Path.Path) || (0 == Path.Path.Length)) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); IEnumWbemClassObject enumWbem = null; @@ -1254,18 +1240,14 @@ namespace System.Management relationshipQualifier, thisRole); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; //Execute WMI query try { securityHandler = Scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices() ).ExecQuery_( - q.QueryLanguage, - q.QueryString, - o.Flags, - o.GetContext(), - ref enumWbem); + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).ExecQuery_( + q.QueryLanguage, q.QueryString, o.Flags, o.GetContext(), ref enumWbem); } finally @@ -1334,7 +1316,7 @@ namespace System.Management throw new ArgumentNullException(nameof(watcher)); else { - Initialize ( true ); + Initialize(true); EnumerationOptions o = (null != options) ? (EnumerationOptions)options.Clone() : new EnumerationOptions(); @@ -1355,16 +1337,12 @@ namespace System.Management relationshipQualifier, thisRole); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = Scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).ExecQueryAsync_( - q.QueryLanguage, - q.QueryString, - o.Flags, - o.GetContext(), - sink.Stub); + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).ExecQueryAsync_( + q.QueryLanguage, q.QueryString, o.Flags, o.GetContext(), sink.Stub); if (securityHandler != null) diff --git a/src/libraries/System.Management/src/System/Management/ManagementDateTime.cs b/src/libraries/System.Management/src/System/Management/ManagementDateTime.cs index c857012fe5c..04802486e8a 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementDateTime.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementDateTime.cs @@ -175,7 +175,7 @@ namespace System.Management tempString = dmtf.Substring(15, 6); if (("******" != tempString)) { - ticks = (long.Parse(tempString, (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(long)))) * (TimeSpan.TicksPerMillisecond/1000); + ticks = (long.Parse(tempString, (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(long)))) * (TimeSpan.TicksPerMillisecond / 1000); } tempString = dmtf.Substring(22, 3); if (("***" != tempString)) @@ -184,7 +184,7 @@ namespace System.Management utcOffset = int.Parse(tempString, frmInt32); } - if ( year < 0 || month < 0 || day < 0 || hour < 0 || minute < 0 || second < 0 || ticks < 0) + if (year < 0 || month < 0 || day < 0 || hour < 0 || minute < 0 || second < 0 || ticks < 0) { throw new ArgumentOutOfRangeException(nameof(dmtfDate)); } @@ -256,7 +256,7 @@ namespace System.Management else { string strTemp = OffsetMins.ToString(frmInt32); - UtcString = "-" + strTemp.Substring(1, strTemp.Length-1).PadLeft(3, '0'); + UtcString = "-" + strTemp.Substring(1, strTemp.Length - 1).PadLeft(3, '0'); } string dmtfDateTime = date.Year.ToString(frmInt32).PadLeft(4, '0'); @@ -271,7 +271,7 @@ namespace System.Management // Construct a DateTime with the precision to Second as same as the passed DateTime and so get // the ticks difference so that the microseconds can be calculated DateTime dtTemp = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, 0); - long microsec = ((date.Ticks-dtTemp.Ticks) * 1000) / System.TimeSpan.TicksPerMillisecond; + long microsec = ((date.Ticks - dtTemp.Ticks) * 1000) / System.TimeSpan.TicksPerMillisecond; // fill the microseconds field string strMicrosec = microsec.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(long))); @@ -354,7 +354,7 @@ namespace System.Management seconds = int.Parse(tempString, frmInt32); tempString = dmtfts.Substring(15, 6); - ticks = (long.Parse(tempString, (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(long)))) * (System.TimeSpan.TicksPerMillisecond/1000); + ticks = (long.Parse(tempString, (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(long)))) * (System.TimeSpan.TicksPerMillisecond / 1000); } catch @@ -362,7 +362,7 @@ namespace System.Management throw new System.ArgumentOutOfRangeException(nameof(dmtfTimespan)); } - if ( days < 0 || hours < 0 || minutes < 0 || seconds < 0 || ticks < 0 ) + if (days < 0 || hours < 0 || minutes < 0 || seconds < 0 || ticks < 0) { throw new System.ArgumentOutOfRangeException(nameof(dmtfTimespan)); } @@ -426,7 +426,7 @@ namespace System.Management // Construct a DateTime with the precision to Second as same as the passed DateTime and so get // the ticks difference so that the microseconds can be calculated TimeSpan tsTemp = new TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes, timespan.Seconds, 0); - long microsec = ((timespan.Ticks-tsTemp.Ticks) * 1000) / System.TimeSpan.TicksPerMillisecond; + long microsec = ((timespan.Ticks - tsTemp.Ticks) * 1000) / System.TimeSpan.TicksPerMillisecond; // fill the microseconds field string strMicrosec = microsec.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(long))); diff --git a/src/libraries/System.Management/src/System/Management/ManagementEventArgs.cs b/src/libraries/System.Management/src/System/Management/ManagementEventArgs.cs index f8cd3d836c4..6745dc409b7 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementEventArgs.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementEventArgs.cs @@ -5,315 +5,308 @@ namespace System.Management { -internal class IdentifierChangedEventArgs : EventArgs -{ - internal IdentifierChangedEventArgs () {} -} - -internal class InternalObjectPutEventArgs : EventArgs -{ - private readonly ManagementPath path; - - internal InternalObjectPutEventArgs (ManagementPath path) + internal class IdentifierChangedEventArgs : EventArgs { - this.path = path.Clone(); + internal IdentifierChangedEventArgs() { } } - internal ManagementPath Path { - get { return path; } + internal class InternalObjectPutEventArgs : EventArgs + { + private readonly ManagementPath path; + + internal InternalObjectPutEventArgs(ManagementPath path) + { + this.path = path.Clone(); + } + + internal ManagementPath Path + { + get { return path; } + } } -} /// /// Represents the virtual base class to hold event data for WMI events. /// -public abstract class ManagementEventArgs : EventArgs -{ - private readonly object context; - - /// - /// Constructor. This is not callable directly by applications. - /// - /// The operation context which is echoed back - /// from the operation which trigerred the event. - internal ManagementEventArgs (object context) { - this.context = context; - } - - /// - /// Gets the operation context echoed back - /// from the operation that triggered the event. - /// - /// - /// A WMI context object containing - /// context information provided by the operation that triggered the event. - /// - public object Context { get { return context; } - } -} - -/// -/// Holds event data for the event. -/// -public class ObjectReadyEventArgs : ManagementEventArgs -{ - private readonly ManagementBaseObject wmiObject; - - /// - /// Constructor. - /// - /// The operation context which is echoed back - /// from the operation which triggerred the event. - /// The newly arrived WmiObject. - internal ObjectReadyEventArgs ( - object context, - ManagementBaseObject wmiObject - ) : base (context) + public abstract class ManagementEventArgs : EventArgs { - this.wmiObject = wmiObject; - } + private readonly object context; - /// - /// Gets the newly-returned object. - /// - /// - /// A representing the - /// newly-returned object. - /// - public ManagementBaseObject NewObject - { - get { - return wmiObject; + /// + /// Constructor. This is not callable directly by applications. + /// + /// The operation context which is echoed back + /// from the operation which trigerred the event. + internal ManagementEventArgs(object context) + { + this.context = context; } - } -} -/// -/// Holds event data for the event. -/// -public class CompletedEventArgs : ManagementEventArgs -{ - private readonly int status; - private readonly ManagementBaseObject wmiObject; - - /// - /// Constructor. - /// - /// The operation context which is echoed back - /// from the operation which trigerred the event. - /// The completion status of the operation. - /// Additional status information - /// encapsulated within a WmiObject. This may be null. - internal CompletedEventArgs ( - object context, - int status, - ManagementBaseObject wmiStatusObject - ) : base (context) - { - wmiObject = wmiStatusObject; - this.status = status; - } - - /// - /// Gets or sets additional status information - /// within a WMI object. This may be null. - /// - /// - /// if an error did not occur. Otherwise, may be non-null if the provider - /// supports extended error information. - /// - public ManagementBaseObject StatusObject - { - get { - return wmiObject; + /// + /// Gets the operation context echoed back + /// from the operation that triggered the event. + /// + /// + /// A WMI context object containing + /// context information provided by the operation that triggered the event. + /// + public object Context + { + get { return context; } } } /// - /// Gets the completion status of the operation. + /// Holds event data for the event. /// - /// - /// A value - /// indicating the return code of the operation. - /// - public ManagementStatus Status + public class ObjectReadyEventArgs : ManagementEventArgs { - get { - return (ManagementStatus) status; + private readonly ManagementBaseObject wmiObject; + + /// + /// Constructor. + /// + /// The operation context which is echoed back + /// from the operation which triggerred the event. + /// The newly arrived WmiObject. + internal ObjectReadyEventArgs(object context, ManagementBaseObject wmiObject) : base(context) + { + this.wmiObject = wmiObject; } - } -} -/// -/// Holds event data for the event. -/// -public class ObjectPutEventArgs : ManagementEventArgs -{ - private readonly ManagementPath wmiPath; - - /// - /// Constructor - /// - /// The operation context which is echoed back - /// from the operation which trigerred the event. - /// The WmiPath representing the identity of the - /// object that has been put. - internal ObjectPutEventArgs ( - object context, - ManagementPath path - ) : base (context) - { - wmiPath = path; - } - - /// - /// Gets the identity of the - /// object that has been put. - /// - /// - /// A containing the path of the object that has - /// been put. - /// - public ManagementPath Path - { - get { - return wmiPath; - } - } -} - -/// -/// Holds event data for the event. -/// -public class ProgressEventArgs : ManagementEventArgs -{ - private readonly int upperBound; - private readonly int current; - private readonly string message; - - /// - /// Constructor - /// - /// The operation context which is echoed back - /// from the operation which trigerred the event. - /// A quantity representing the total - /// amount of work required to be done by the operation. - /// A quantity representing the current - /// amount of work required to be done by the operation. This is - /// always less than or equal to upperBound. - /// Optional additional information regarding - /// operation progress. - internal ProgressEventArgs ( - object context, - int upperBound, - int current, - string message - ) : base (context) - { - this.upperBound = upperBound; - this.current = current; - this.message = message; - } - - /// - /// Gets the total - /// amount of work required to be done by the operation. - /// - /// - /// An integer representing the total - /// amount of work for the operation. - /// - public int UpperBound - { - get { - return upperBound; + /// + /// Gets the newly-returned object. + /// + /// + /// A representing the + /// newly-returned object. + /// + public ManagementBaseObject NewObject + { + get + { + return wmiObject; + } } } /// - /// Gets the current amount of work - /// done by the operation. This is always less than or equal to . + /// Holds event data for the event. /// - /// - /// An integer representing the current amount of work - /// already completed by the operation. - /// - public int Current + public class CompletedEventArgs : ManagementEventArgs { - get { - return current; + private readonly int status; + private readonly ManagementBaseObject wmiObject; + + /// + /// Constructor. + /// + /// The operation context which is echoed back + /// from the operation which trigerred the event. + /// The completion status of the operation. + /// Additional status information + /// encapsulated within a WmiObject. This may be null. + internal CompletedEventArgs(object context, int status, ManagementBaseObject wmiStatusObject) : base(context) + { + wmiObject = wmiStatusObject; + this.status = status; + } + + /// + /// Gets or sets additional status information + /// within a WMI object. This may be null. + /// + /// + /// if an error did not occur. Otherwise, may be non-null if the provider + /// supports extended error information. + /// + public ManagementBaseObject StatusObject + { + get + { + return wmiObject; + } + } + + /// + /// Gets the completion status of the operation. + /// + /// + /// A value + /// indicating the return code of the operation. + /// + public ManagementStatus Status + { + get + { + return (ManagementStatus)status; + } } } /// - /// Gets or sets optional additional information regarding the operation's progress. + /// Holds event data for the event. /// - /// - /// A string containing additional - /// information regarding the operation's progress. - /// - public string Message + public class ObjectPutEventArgs : ManagementEventArgs { - get { - return (null != message) ? message : string.Empty; + private readonly ManagementPath wmiPath; + + /// + /// Constructor + /// + /// The operation context which is echoed back + /// from the operation which trigerred the event. + /// The WmiPath representing the identity of the + /// object that has been put. + internal ObjectPutEventArgs(object context, ManagementPath path) : base(context) + { + wmiPath = path; } - } -} -/// -/// Holds event data for the event. -/// -public class EventArrivedEventArgs : ManagementEventArgs -{ - private readonly ManagementBaseObject eventObject; - - internal EventArrivedEventArgs ( - object context, - ManagementBaseObject eventObject) : base (context) - { - this.eventObject = eventObject; + /// + /// Gets the identity of the + /// object that has been put. + /// + /// + /// A containing the path of the object that has + /// been put. + /// + public ManagementPath Path + { + get + { + return wmiPath; + } + } } /// - /// Gets the WMI event that was delivered. + /// Holds event data for the event. /// - /// - /// The object representing the WMI event. - /// - public ManagementBaseObject NewEvent + public class ProgressEventArgs : ManagementEventArgs { - get { return this.eventObject; } - } -} + private readonly int upperBound; + private readonly int current; + private readonly string message; -/// -/// Holds event data for the event. -/// -public class StoppedEventArgs : ManagementEventArgs -{ - private readonly int status; + /// + /// Constructor + /// + /// The operation context which is echoed back + /// from the operation which trigerred the event. + /// A quantity representing the total + /// amount of work required to be done by the operation. + /// A quantity representing the current + /// amount of work required to be done by the operation. This is + /// always less than or equal to upperBound. + /// Optional additional information regarding + /// operation progress. + internal ProgressEventArgs(object context, int upperBound, int current, string message) : base(context) + { + this.upperBound = upperBound; + this.current = current; + this.message = message; + } - internal StoppedEventArgs ( - object context, - int status) : base (context) - { - this.status = status; + /// + /// Gets the total + /// amount of work required to be done by the operation. + /// + /// + /// An integer representing the total + /// amount of work for the operation. + /// + public int UpperBound + { + get + { + return upperBound; + } + } + + /// + /// Gets the current amount of work + /// done by the operation. This is always less than or equal to . + /// + /// + /// An integer representing the current amount of work + /// already completed by the operation. + /// + public int Current + { + get + { + return current; + } + } + + /// + /// Gets or sets optional additional information regarding the operation's progress. + /// + /// + /// A string containing additional + /// information regarding the operation's progress. + /// + public string Message + { + get + { + return (null != message) ? message : string.Empty; + } + } } /// - /// Gets the completion status of the operation. + /// Holds event data for the event. /// - /// - /// A value representing the status of the - /// operation. - /// - public ManagementStatus Status + public class EventArrivedEventArgs : ManagementEventArgs { - get { - return (ManagementStatus) status; + private readonly ManagementBaseObject eventObject; + + internal EventArrivedEventArgs(object context, ManagementBaseObject eventObject) : base(context) + { + this.eventObject = eventObject; + } + + /// + /// Gets the WMI event that was delivered. + /// + /// + /// The object representing the WMI event. + /// + public ManagementBaseObject NewEvent + { + get { return this.eventObject; } + } + } + + /// + /// Holds event data for the event. + /// + public class StoppedEventArgs : ManagementEventArgs + { + private readonly int status; + + internal StoppedEventArgs(object context, int status) : base(context) + { + this.status = status; + } + + /// + /// Gets the completion status of the operation. + /// + /// + /// A value representing the status of the + /// operation. + /// + public ManagementStatus Status + { + get + { + return (ManagementStatus)status; + } } } -} } diff --git a/src/libraries/System.Management/src/System/Management/ManagementEventWatcher.cs b/src/libraries/System.Management/src/System/Management/ManagementEventWatcher.cs index 3c5618f77f5..793f1b6fef0 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementEventWatcher.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementEventWatcher.cs @@ -16,7 +16,7 @@ namespace System.Management /// /// Represents the method that will handle the event. /// - public delegate void StoppedEventHandler (object sender, StoppedEventArgs e); + public delegate void StoppedEventHandler(object sender, StoppedEventArgs e); //CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC// /// @@ -114,15 +114,15 @@ namespace System.Management public class ManagementEventWatcher : Component { //fields - private ManagementScope scope; - private EventQuery query; - private EventWatcherOptions options; - private IEnumWbemClassObject enumWbem; - private IWbemClassObjectFreeThreaded[] cachedObjects; //points to objects currently available in cache - private uint cachedCount; //says how many objects are in the cache (when using BlockSize option) - private uint cacheIndex; //used to walk the cache - private SinkForEventQuery sink; // the sink implementation for event queries - private readonly WmiDelegateInvoker delegateInvoker; + private ManagementScope scope; + private EventQuery query; + private EventWatcherOptions options; + private IEnumWbemClassObject enumWbem; + private IWbemClassObjectFreeThreaded[] cachedObjects; //points to objects currently available in cache + private uint cachedCount; //says how many objects are in the cache (when using BlockSize option) + private uint cacheIndex; //used to walk the cache + private SinkForEventQuery sink; // the sink implementation for event queries + private readonly WmiDelegateInvoker delegateInvoker; //Called when IdentifierChanged() event fires private void HandleIdentifierChange(object sender, @@ -140,7 +140,7 @@ namespace System.Management /// Initializes a new instance of the class. For further /// initialization, set the properties on the object. This is the default constructor. /// - public ManagementEventWatcher() : this((ManagementScope)null, null, null) {} + public ManagementEventWatcher() : this((ManagementScope)null, null, null) { } //parameterized constructors /// @@ -151,8 +151,8 @@ namespace System.Management /// The namespace in which the watcher will be listening for /// events is the default namespace that is currently set. /// - public ManagementEventWatcher ( - EventQuery query) : this(null, query, null) {} + public ManagementEventWatcher( + EventQuery query) : this(null, query, null) { } /// /// Initializes a new instance of the class when given a WMI event query in the @@ -163,8 +163,8 @@ namespace System.Management /// The namespace in which the watcher will be listening for /// events is the default namespace that is currently set. /// - public ManagementEventWatcher ( - string query) : this(null, new EventQuery(query), null) {} + public ManagementEventWatcher( + string query) : this(null, new EventQuery(query), null) { } /// /// Initializes a new instance of the @@ -174,7 +174,7 @@ namespace System.Management /// An object representing a WMI event query, which determines the events for which the watcher will listen. public ManagementEventWatcher( ManagementScope scope, - EventQuery query) : this(scope, query, null) {} + EventQuery query) : this(scope, query, null) { } /// /// Initializes a new instance of the @@ -185,7 +185,7 @@ namespace System.Management /// The query that defines the events for which the watcher will listen. public ManagementEventWatcher( string scope, - string query) : this(new ManagementScope(scope), new EventQuery(query), null) {} + string query) : this(new ManagementScope(scope), new EventQuery(query), null) { } /// /// Initializes a new instance of the class that listens for @@ -199,7 +199,7 @@ namespace System.Management public ManagementEventWatcher( string scope, string query, - EventWatcherOptions options) : this(new ManagementScope(scope), new EventQuery(query), options) {} + EventWatcherOptions options) : this(new ManagementScope(scope), new EventQuery(query), options) { } /// /// Initializes a new instance of the class @@ -236,25 +236,25 @@ namespace System.Management cachedCount = 0; cacheIndex = 0; sink = null; - delegateInvoker = new WmiDelegateInvoker (this); + delegateInvoker = new WmiDelegateInvoker(this); } /// /// Ensures that outstanding calls are cleared. This is the destructor for the object. /// - ~ManagementEventWatcher () + ~ManagementEventWatcher() { // Ensure any outstanding calls are cleared - Stop (); + Stop(); if (null != scope) - scope.IdentifierChanged -= new IdentifierChangedEventHandler (HandleIdentifierChange); + scope.IdentifierChanged -= new IdentifierChangedEventHandler(HandleIdentifierChange); if (null != options) - options.IdentifierChanged -= new IdentifierChangedEventHandler (HandleIdentifierChange); + options.IdentifierChanged -= new IdentifierChangedEventHandler(HandleIdentifierChange); if (null != query) - query.IdentifierChanged -= new IdentifierChangedEventHandler (HandleIdentifierChange); + query.IdentifierChanged -= new IdentifierChangedEventHandler(HandleIdentifierChange); } // @@ -264,12 +264,12 @@ namespace System.Management /// /// Occurs when a new event arrives. /// - public event EventArrivedEventHandler EventArrived; + public event EventArrivedEventHandler EventArrived; /// /// Occurs when a subscription is canceled. /// - public event StoppedEventHandler Stopped; + public event StoppedEventHandler Stopped; // //Public Properties @@ -292,7 +292,7 @@ namespace System.Management if (null != value) { ManagementScope oldScope = scope; - scope = (ManagementScope)value.Clone (); + scope = (ManagementScope)value.Clone(); // Unregister ourselves from the previous scope object if (null != oldScope) @@ -325,7 +325,7 @@ namespace System.Management if (null != value) { ManagementQuery oldQuery = query; - query = (EventQuery)value.Clone (); + query = (EventQuery)value.Clone(); // Unregister ourselves from the previous query object if (null != oldQuery) @@ -358,7 +358,7 @@ namespace System.Management if (null != value) { EventWatcherOptions oldOptions = options; - options = (EventWatcherOptions)value.Clone (); + options = (EventWatcherOptions)value.Clone(); // Unregister ourselves from the previous scope object if (null != oldOptions) @@ -392,7 +392,7 @@ namespace System.Management { ManagementBaseObject obj = null; - Initialize (); + Initialize(); #pragma warning disable CA2002 lock (this) @@ -407,11 +407,11 @@ namespace System.Management if (null == enumWbem) //don't have an enumerator yet - get it { //Execute the query - status = scope.GetSecuredIWbemServicesHandler( Scope.GetIWbemServices() ).ExecNotificationQuery_( + status = scope.GetSecuredIWbemServicesHandler(Scope.GetIWbemServices()).ExecNotificationQuery_( query.QueryLanguage, query.QueryString, options.Flags, - options.GetContext (), + options.GetContext(), ref enumWbem); } @@ -425,8 +425,8 @@ namespace System.Management IWbemClassObject_DoNotMarshal[] tempArray = new IWbemClassObject_DoNotMarshal[options.BlockSize]; int timeout = (ManagementOptions.InfiniteTimeout == options.Timeout) - ? (int) tag_WBEM_TIMEOUT_TYPE.WBEM_INFINITE : - (int) options.Timeout.TotalMilliseconds; + ? (int)tag_WBEM_TIMEOUT_TYPE.WBEM_INFINITE : + (int)options.Timeout.TotalMilliseconds; status = scope.GetSecuredIEnumWbemClassObjectHandler(enumWbem).Next_(timeout, (uint)options.BlockSize, tempArray, ref cachedCount); cacheIndex = 0; @@ -478,10 +478,10 @@ namespace System.Management /// public void Start() { - Initialize (); + Initialize(); // Cancel any current event query - Stop (); + Stop(); // Submit a new query SecurityHandler securityHandler = Scope.GetSecurityHandler(); @@ -539,26 +539,26 @@ namespace System.Management { Marshal.ReleaseComObject(enumWbem); enumWbem = null; - FireStopped (new StoppedEventArgs (options.Context, (int)ManagementStatus.OperationCanceled)); + FireStopped(new StoppedEventArgs(options.Context, (int)ManagementStatus.OperationCanceled)); } // In async mode cancel the call to the sink - this will // unwind the operation and cause a Stopped message if (null != sink) { - sink.Cancel (); + sink.Cancel(); sink = null; } } - private void Initialize () + private void Initialize() { //If the query is not set yet we can't do it if (null == query) throw new InvalidOperationException(); if (null == options) - Options = new EventWatcherOptions (); + Options = new EventWatcherOptions(); //If we're not connected yet, this is the time to do it... #pragma warning disable CA2002 @@ -566,7 +566,7 @@ namespace System.Management #pragma warning restore CA2002 { if (null == scope) - Scope = new ManagementScope (); + Scope = new ManagementScope(); if (null == cachedObjects) cachedObjects = new IWbemClassObjectFreeThreaded[options.BlockSize]; @@ -574,27 +574,27 @@ namespace System.Management lock (scope) { - scope.Initialize (); + scope.Initialize(); } } - internal void FireStopped (StoppedEventArgs args) + internal void FireStopped(StoppedEventArgs args) { try { - delegateInvoker.FireEventToDelegates (Stopped, args); + delegateInvoker.FireEventToDelegates(Stopped, args); } catch { } } - internal void FireEventArrived (EventArrivedEventArgs args) + internal void FireEventArrived(EventArrivedEventArgs args) { try { - delegateInvoker.FireEventToDelegates (EventArrived, args); + delegateInvoker.FireEventToDelegates(EventArrived, args); } catch { @@ -607,16 +607,16 @@ namespace System.Management internal class SinkForEventQuery : IWmiEventSource { - private readonly ManagementEventWatcher eventWatcher; - private readonly object context; - private readonly IWbemServices services; + private readonly ManagementEventWatcher eventWatcher; + private readonly object context; + private readonly IWbemServices services; private IWbemObjectSink stub; // The secured IWbemObjectSink private int status; private readonly bool isLocal; - public int Status {get {return status; } set {status=value; }} + public int Status { get { return status; } set { status = value; } } - public SinkForEventQuery (ManagementEventWatcher eventWatcher, + public SinkForEventQuery(ManagementEventWatcher eventWatcher, object context, IWbemServices services) { @@ -627,8 +627,8 @@ namespace System.Management this.isLocal = false; // determine if the server is local, and if so don't create a real stub using unsecap - if ((0==string.Compare(eventWatcher.Scope.Path.Server, ".", StringComparison.OrdinalIgnoreCase)) || - (0==string.Compare(eventWatcher.Scope.Path.Server, System.Environment.MachineName, StringComparison.OrdinalIgnoreCase))) + if ((0 == string.Compare(eventWatcher.Scope.Path.Server, ".", StringComparison.OrdinalIgnoreCase)) || + (0 == string.Compare(eventWatcher.Scope.Path.Server, System.Environment.MachineName, StringComparison.OrdinalIgnoreCase))) { this.isLocal = true; } @@ -640,19 +640,19 @@ namespace System.Management // // Ensure we are able to trap exceptions from worker thread. // - ThreadDispatch disp = new ThreadDispatch ( new ThreadDispatch.ThreadWorkerMethodWithParam ( HackToCreateStubInMTA ) ); + ThreadDispatch disp = new ThreadDispatch(new ThreadDispatch.ThreadWorkerMethodWithParam(HackToCreateStubInMTA)); disp.Parameter = this; - disp.Start ( ); + disp.Start(); } } private void HackToCreateStubInMTA(object param) { - SinkForEventQuery obj = (SinkForEventQuery) param; + SinkForEventQuery obj = (SinkForEventQuery)param; object dmuxStub = null; - obj.Status = WmiNetUtilsHelper.GetDemultiplexedStub_f (obj, obj.isLocal, out dmuxStub); - obj.stub = (IWbemObjectSink) dmuxStub; + obj.Status = WmiNetUtilsHelper.GetDemultiplexedStub_f(obj, obj.isLocal, out dmuxStub); + obj.stub = (IWbemObjectSink)dmuxStub; } internal IWbemObjectSink Stub @@ -676,7 +676,7 @@ namespace System.Management } } - public void SetStatus ( + public void SetStatus( int flags, int hResult, string message, @@ -717,7 +717,7 @@ namespace System.Management } } - internal void Cancel () + internal void Cancel() { if (null != stub) { @@ -745,7 +745,7 @@ namespace System.Management } } - internal void ReleaseStub () + internal void ReleaseStub() { if (null != stub) { diff --git a/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs b/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs index c591ea29e2e..2717cf0519e 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementNamedValueCollection.cs @@ -46,7 +46,7 @@ namespace System.Management /// and . /// /// The to populate with data. - /// The destination (see ) for this serialization. + /// The destination (see ) for this serialization. protected ManagementNamedValueCollection(SerializationInfo info, StreamingContext context) : base(info, context) { throw new PlatformNotSupportedException(); @@ -65,19 +65,21 @@ namespace System.Management { int status = (int)ManagementStatus.NoError; - try { - wbemContext = (IWbemContext) new WbemContext (); + try + { + wbemContext = (IWbemContext)new WbemContext(); foreach (string name in this) { object val = base.BaseGet(name); - status = wbemContext.SetValue_ (name, 0, ref val); + status = wbemContext.SetValue_(name, 0, ref val); if ((status & 0x80000000) != 0) { break; } } - } catch {} + } + catch { } } return wbemContext; @@ -88,16 +90,17 @@ namespace System.Management /// /// The name of the new value. /// The value to be associated with the name. - public void Add (string name, object value) + public void Add(string name, object value) { // Remove any old entry try { - base.BaseRemove (name); - } catch {} + base.BaseRemove(name); + } + catch { } - base.BaseAdd (name, value); - FireIdentifierChanged (); + base.BaseAdd(name, value); + FireIdentifierChanged(); } /// @@ -107,19 +110,19 @@ namespace System.Management /// exception is thrown. /// /// The name of the value to be removed. - public void Remove (string name) + public void Remove(string name) { - base.BaseRemove (name); - FireIdentifierChanged (); + base.BaseRemove(name); + FireIdentifierChanged(); } /// /// Removes all entries from the collection. /// - public void RemoveAll () + public void RemoveAll() { - base.BaseClear (); - FireIdentifierChanged (); + base.BaseClear(); + FireIdentifierChanged(); } /// @@ -130,38 +133,40 @@ namespace System.Management /// /// The new copy of the collection. /// - public ManagementNamedValueCollection Clone () + public ManagementNamedValueCollection Clone() { ManagementNamedValueCollection nvc = new ManagementNamedValueCollection(); foreach (string name in this) { // If we can clone the value, do so. Otherwise throw. - object val = base.BaseGet (name); + object val = base.BaseGet(name); if (null != val) { - Type valueType = val.GetType (); + Type valueType = val.GetType(); if (valueType.IsByRef) { try { - object clonedValue = ((ICloneable)val).Clone (); - nvc.Add (name, clonedValue); + object clonedValue = ((ICloneable)val).Clone(); + nvc.Add(name, clonedValue); } catch { - throw new NotSupportedException (); + throw new NotSupportedException(); } } else { - nvc.Add (name, val); + nvc.Add(name, val); } } else - nvc.Add (name, null); + { + nvc.Add(name, null); + } } return nvc; @@ -177,7 +182,8 @@ namespace System.Management /// public object this[string name] { - get { + get + { return base.BaseGet(name); } } diff --git a/src/libraries/System.Management/src/System/Management/ManagementObject.cs b/src/libraries/System.Management/src/System/Management/ManagementObject.cs index adf603dc0d4..6b4db0291c9 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementObject.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementObject.cs @@ -69,10 +69,10 @@ namespace System.Management //Fields - private IWbemClassObjectFreeThreaded wmiClass; - internal ManagementScope scope; - internal ManagementPath path; - internal ObjectGetOptions options; + private IWbemClassObjectFreeThreaded wmiClass; + internal ManagementScope scope; + internal ManagementPath path; + internal ObjectGetOptions options; //Used to represent whether this managementObject is currently bound to a wbemObject //or not - whenever an "identifying" property is changed (Path, Scope...) the object @@ -227,7 +227,7 @@ namespace System.Management /// Console.WriteLine(o("FreeSpace")) /// /// - public ManagementObject() : this ((ManagementScope)null, null, null) {} + public ManagementObject() : this((ManagementScope)null, null, null) { } //parameterized constructors /// @@ -243,7 +243,7 @@ namespace System.Management /// Dim o As New ManagementObject(p) /// /// - public ManagementObject(ManagementPath path) : this(null, path, null) {} + public ManagementObject(ManagementPath path) : this(null, path, null) { } /// /// Initializes a new instance of the class for the specified WMI object path. The path @@ -271,7 +271,7 @@ namespace System.Management /// Dim o As New ManagementObject("\\\\MyServer\\root\\MyApp:MyClass.Key=""abc"""); /// /// - public ManagementObject(string path) : this(null, new ManagementPath(path), null) {} + public ManagementObject(string path) : this(null, new ManagementPath(path), null) { } /// /// Initializes a new instance of the class bound to the specified @@ -301,7 +301,7 @@ namespace System.Management /// Console.WriteLine(o.GetQualifierValue("Description")); /// /// - public ManagementObject(ManagementPath path, ObjectGetOptions options) : this(null, path, options) {} + public ManagementObject(ManagementPath path, ObjectGetOptions options) : this(null, path, options) { } /// /// Initializes a new instance of the class bound to the specified WMI path, including the @@ -329,7 +329,8 @@ namespace System.Management /// /// public ManagementObject(string path, ObjectGetOptions options) : - this(new ManagementPath(path), options) {} + this(new ManagementPath(path), options) + { } /// /// Initializes a new instance of the @@ -370,7 +371,7 @@ namespace System.Management /// /// public ManagementObject(ManagementScope scope, ManagementPath path, ObjectGetOptions options) - : base (null) + : base(null) { ManagementObjectCTOR(scope, path, options); } @@ -393,7 +394,7 @@ namespace System.Management // we don't have a scope nsPath = path.GetNamespacePath((int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY); - if ((null != scope) && (scope.Path.NamespacePath.Length>0)) + if ((null != scope) && (scope.Path.NamespacePath.Length > 0)) { // If the scope has a path too, the namespace portion of // scope.path takes precedence over what is specified in path @@ -418,7 +419,7 @@ namespace System.Management else { // Use the path if possible, otherwise let it default - if (nsPath.Length>0) + if (nsPath.Length > 0) { this.scope = new ManagementScope(nsPath); this.scope.IdentifierChanged += new IdentifierChangedEventHandler(HandleIdentifierChange); @@ -455,13 +456,13 @@ namespace System.Management /// /// public ManagementObject(string scopeString, string pathString, ObjectGetOptions options) - : this(new ManagementScope(scopeString), new ManagementPath(pathString), options) {} + : this(new ManagementScope(scopeString), new ManagementPath(pathString), options) { } /// /// Initializes a new instance of the class that is serializable. /// /// The to populate with data. - /// The destination (see ) for this serialization. + /// The destination (see ) for this serialization. protected ManagementObject(SerializationInfo info, StreamingContext context) : base(info, context) { ManagementObjectCTOR(null, null, null); @@ -579,7 +580,7 @@ namespace System.Management newPath.IsEmpty) { if (null != path) - path.IdentifierChanged -= new IdentifierChangedEventHandler(HandleIdentifierChange); + path.IdentifierChanged -= new IdentifierChangedEventHandler(HandleIdentifierChange); path = ManagementPath._Clone((ManagementPath)value, new IdentifierChangedEventHandler(HandleIdentifierChange)); @@ -772,9 +773,9 @@ namespace System.Management { IWbemClassObjectFreeThreaded tempObj = null; - Initialize ( false ); // this may throw + Initialize(false); // this may throw - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); else { @@ -782,17 +783,17 @@ namespace System.Management (null == options) ? new ObjectGetOptions() : options; SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { securityHandler = scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler( scope.GetIWbemServices() ).GetObject_(path.RelativePath, + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).GetObject_(path.RelativePath, gOptions.Flags, gOptions.GetContext(), ref tempObj, - IntPtr.Zero ); + IntPtr.Zero); if (status < 0) { @@ -894,9 +895,9 @@ namespace System.Management /// public void Get(ManagementOperationObserver watcher) { - Initialize ( false ); + Initialize(false); - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); else if (null == watcher) throw new ArgumentNullException(nameof(watcher)); @@ -916,7 +917,7 @@ namespace System.Management o.SendStatus = true; SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = scope.GetSecurityHandler(); @@ -1032,10 +1033,10 @@ namespace System.Management bool classDefinitionsOnly, EnumerationOptions options) { - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); IEnumWbemClassObject enumWbem = null; EnumerationOptions o = (null != options) ? options : new EnumerationOptions(); @@ -1052,13 +1053,13 @@ namespace System.Management o.EnumerateDeep = true; //note this turns the FLAG to 0 !! SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { securityHandler = scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices() ).ExecQuery_( + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).ExecQuery_( q.QueryLanguage, q.QueryString, o.Flags, @@ -1149,10 +1150,10 @@ namespace System.Management bool classDefinitionsOnly, EnumerationOptions options) { - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); - Initialize ( true ); + Initialize(true); if (null == watcher) throw new ArgumentNullException(nameof(watcher)); @@ -1180,12 +1181,12 @@ namespace System.Management //Make sure the EnumerateDeep flag bit is turned off because it's invalid for queries o.EnumerateDeep = true; //note this turns the FLAG to 0 !! - SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + SecurityHandler securityHandler = null; + int status = (int)ManagementStatus.NoError; securityHandler = scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler( scope.GetIWbemServices() ).ExecQueryAsync_( + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).ExecQueryAsync_( q.QueryLanguage, q.QueryString, o.Flags, @@ -1270,10 +1271,10 @@ namespace System.Management bool classDefinitionsOnly, EnumerationOptions options) { - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); IEnumWbemClassObject enumWbem = null; EnumerationOptions o = @@ -1286,7 +1287,7 @@ namespace System.Management o.EnumerateDeep = true; //note this turns the FLAG to 0 !! SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { @@ -1297,7 +1298,7 @@ namespace System.Management q.QueryString, o.Flags, o.GetContext(), - ref enumWbem ); + ref enumWbem); if (status < 0) @@ -1378,13 +1379,13 @@ namespace System.Management bool classDefinitionsOnly, EnumerationOptions options) { - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); if (null == watcher) throw new ArgumentNullException(nameof(watcher)); else { - Initialize ( false ); + Initialize(false); // Ensure we switch off ReturnImmediately as this is invalid for async calls EnumerationOptions o = @@ -1406,16 +1407,16 @@ namespace System.Management o.EnumerateDeep = true; //note this turns the FLAG to 0 !! SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = scope.GetSecurityHandler(); - status = scope.GetSecuredIWbemServicesHandler( scope.GetIWbemServices() ).ExecQueryAsync_( + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).ExecQueryAsync_( q.QueryLanguage, q.QueryString, o.Flags, o.GetContext(), - sink.Stub ); + sink.Stub); if (securityHandler != null) @@ -1447,7 +1448,7 @@ namespace System.Management /// public ManagementPath Put() { - return Put((PutOptions) null); + return Put((PutOptions)null); } @@ -1464,7 +1465,7 @@ namespace System.Management public ManagementPath Put(PutOptions options) { ManagementPath newPath = null; - Initialize ( true ); + Initialize(true); PutOptions o = (null != options) ? options : new PutOptions(); IWbemServices wbemServices = scope.GetIWbemServices(); @@ -1474,11 +1475,11 @@ namespace System.Management // has been redefined to be an IntPtr. Due to the fact that it wasn't possible to // pass NULL for the optional argument. // - IntPtr ppwbemCallResult = IntPtr.Zero; - IntPtr pwbemCallResult = IntPtr.Zero; - IWbemCallResult wbemCallResult = null; - SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + IntPtr ppwbemCallResult = IntPtr.Zero; + IntPtr pwbemCallResult = IntPtr.Zero; + IWbemCallResult wbemCallResult = null; + SecurityHandler securityHandler = null; + int status = (int)ManagementStatus.NoError; try { @@ -1489,10 +1490,10 @@ namespace System.Management if (IsClass) { - status = scope.GetSecuredIWbemServicesHandler(wbemServices).PutClass_( wbemObject, + status = scope.GetSecuredIWbemServicesHandler(wbemServices).PutClass_(wbemObject, o.Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_RETURN_IMMEDIATELY, o.GetContext(), - ppwbemCallResult ); + ppwbemCallResult); } else { @@ -1597,8 +1598,8 @@ namespace System.Management } catch - { - } + { + } if (newPath == null) newPath = new ManagementPath(); @@ -1627,7 +1628,7 @@ namespace System.Management throw new ArgumentNullException(nameof(watcher)); else { - Initialize ( false ); + Initialize(false); PutOptions o = (null == options) ? new PutOptions() : (PutOptions)options.Clone(); @@ -1644,16 +1645,16 @@ namespace System.Management sink.InternalObjectPut += new InternalObjectPutEventHandler(this.HandleObjectPut); - SecurityHandler securityHandler = null; + SecurityHandler securityHandler = null; // Assign to error initially to insure internal event handler cleanup // on non-management exception. - int status = (int)ManagementStatus.Failed; + int status = (int)ManagementStatus.Failed; securityHandler = scope.GetSecurityHandler(); if (IsClass) { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).PutClassAsync_( + status = scope.GetSecuredIWbemServicesHandler(wbemServices).PutClassAsync_( wbemObject, o.Flags, o.GetContext(), @@ -1661,7 +1662,7 @@ namespace System.Management } else { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).PutInstanceAsync_( + status = scope.GetSecuredIWbemServicesHandler(wbemServices).PutInstanceAsync_( wbemObject, o.Flags, o.GetContext(), @@ -1753,7 +1754,7 @@ namespace System.Management /// public ManagementPath CopyTo(ManagementPath path, PutOptions options) { - Initialize ( false ); + Initialize(false); ManagementScope destinationScope = null; @@ -1772,11 +1773,11 @@ namespace System.Management // has been redefined to be an IntPtr. Due to the fact that it wasn't possible to // pass NULL for the optional argument. // - IntPtr ppwbemCallResult = IntPtr.Zero; - IntPtr pwbemCallResult = IntPtr.Zero; - IWbemCallResult wbemCallResult = null; - SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + IntPtr ppwbemCallResult = IntPtr.Zero; + IntPtr pwbemCallResult = IntPtr.Zero; + IWbemCallResult wbemCallResult = null; + SecurityHandler securityHandler = null; + int status = (int)ManagementStatus.NoError; try { @@ -1787,7 +1788,7 @@ namespace System.Management if (IsClass) { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).PutClass_( + status = scope.GetSecuredIWbemServicesHandler(wbemServices).PutClass_( wbemObject, o.Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_RETURN_IMMEDIATELY, o.GetContext(), @@ -1795,7 +1796,7 @@ namespace System.Management } else { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).PutInstance_( + status = scope.GetSecuredIWbemServicesHandler(wbemServices).PutInstance_( wbemObject, o.Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_RETURN_IMMEDIATELY, o.GetContext(), @@ -1888,13 +1889,13 @@ namespace System.Management throw new ArgumentNullException(nameof(watcher)); else { - Initialize ( false ); + Initialize(false); ManagementScope destinationScope = null; destinationScope = new ManagementScope(path, scope); destinationScope.Initialize(); - PutOptions o = (null != options) ? (PutOptions) options.Clone() : new PutOptions(); + PutOptions o = (null != options) ? (PutOptions)options.Clone() : new PutOptions(); // If someone has registered for progress, make sure we flag it if (watcher.HaveListenersForProgress) @@ -1905,13 +1906,13 @@ namespace System.Management IWbemServices destWbemServices = destinationScope.GetIWbemServices(); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = destinationScope.GetSecurityHandler(); if (IsClass) { - status = destinationScope.GetSecuredIWbemServicesHandler( destWbemServices ).PutClassAsync_( + status = destinationScope.GetSecuredIWbemServicesHandler(destWbemServices).PutClassAsync_( wbemObject, o.Flags, o.GetContext(), @@ -1920,7 +1921,7 @@ namespace System.Management } else { - status = destinationScope.GetSecuredIWbemServicesHandler( destWbemServices ).PutInstanceAsync_( + status = destinationScope.GetSecuredIWbemServicesHandler(destWbemServices).PutInstanceAsync_( wbemObject, o.Flags, o.GetContext(), @@ -1953,7 +1954,7 @@ namespace System.Management /// public void Delete() { - Delete((DeleteOptions) null); + Delete((DeleteOptions)null); } /// @@ -1962,15 +1963,15 @@ namespace System.Management /// The options for how to delete the object. public void Delete(DeleteOptions options) { - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); - Initialize ( false ); + Initialize(false); DeleteOptions o = (null != options) ? options : new DeleteOptions(); IWbemServices wbemServices = scope.GetIWbemServices(); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { @@ -1978,7 +1979,7 @@ namespace System.Management if (IsClass) { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).DeleteClass_( + status = scope.GetSecuredIWbemServicesHandler(wbemServices).DeleteClass_( path.RelativePath, o.Flags, o.GetContext(), @@ -1986,7 +1987,7 @@ namespace System.Management } else { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).DeleteInstance_( + status = scope.GetSecuredIWbemServicesHandler(wbemServices).DeleteInstance_( path.RelativePath, o.Flags, o.GetContext(), @@ -2026,14 +2027,14 @@ namespace System.Management /// The options for how to delete the object. public void Delete(ManagementOperationObserver watcher, DeleteOptions options) { - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); else if (null == watcher) throw new ArgumentNullException(nameof(watcher)); else { - Initialize ( false ); - DeleteOptions o = (null != options) ? (DeleteOptions) options.Clone() : new DeleteOptions(); + Initialize(false); + DeleteOptions o = (null != options) ? (DeleteOptions)options.Clone() : new DeleteOptions(); // If someone has registered for progress, make sure we flag it if (watcher.HaveListenersForProgress) @@ -2043,20 +2044,20 @@ namespace System.Management WmiEventSink sink = watcher.GetNewSink(scope, o.Context); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = scope.GetSecurityHandler(); if (IsClass) { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).DeleteClassAsync_(path.RelativePath, + status = scope.GetSecuredIWbemServicesHandler(wbemServices).DeleteClassAsync_(path.RelativePath, o.Flags, o.GetContext(), sink.Stub); } else { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).DeleteInstanceAsync_(path.RelativePath, + status = scope.GetSecuredIWbemServicesHandler(wbemServices).DeleteInstanceAsync_(path.RelativePath, o.Flags, o.GetContext(), sink.Stub); @@ -2150,13 +2151,13 @@ namespace System.Management { object result = null; - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); else if (null == methodName) throw new ArgumentNullException(nameof(methodName)); else { - Initialize ( false ); + Initialize(false); // Map args into a inparams structure ManagementBaseObject inParameters; @@ -2195,7 +2196,7 @@ namespace System.Management string methodName, object[] args) { - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); else if (null == watcher) throw new ArgumentNullException(nameof(watcher)); @@ -2203,13 +2204,13 @@ namespace System.Management throw new ArgumentNullException(nameof(methodName)); else { - Initialize ( false ); + Initialize(false); // Map args into a inparams structure ManagementBaseObject inParameters; IWbemClassObjectFreeThreaded inParametersClass, outParametersClass; GetMethodParameters(methodName, out inParameters, - out inParametersClass, out outParametersClass); + out inParametersClass, out outParametersClass); MapInParameters(args, inParameters, inParametersClass); @@ -2296,18 +2297,18 @@ namespace System.Management { ManagementBaseObject outParameters = null; - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); else if (null == methodName) throw new ArgumentNullException(nameof(methodName)); else { - Initialize ( false ); + Initialize(false); InvokeMethodOptions o = (null != options) ? options : new InvokeMethodOptions(); IWbemServices wbemServices = scope.GetIWbemServices(); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { @@ -2316,7 +2317,7 @@ namespace System.Management IWbemClassObjectFreeThreaded inParams = (null == inParameters) ? null : inParameters.wbemObject; IWbemClassObjectFreeThreaded outParams = null; - status = scope.GetSecuredIWbemServicesHandler( scope.GetIWbemServices() ).ExecMethod_( + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).ExecMethod_( path.RelativePath, methodName, o.Flags, @@ -2364,7 +2365,7 @@ namespace System.Management ManagementBaseObject inParameters, InvokeMethodOptions options) { - if ((null == path) || (path.Path.Length==0)) + if ((null == path) || (path.Path.Length == 0)) throw new InvalidOperationException(); else if (null == watcher) throw new ArgumentNullException(nameof(watcher)); @@ -2372,9 +2373,9 @@ namespace System.Management throw new ArgumentNullException(nameof(methodName)); else { - Initialize ( false ); + Initialize(false); InvokeMethodOptions o = (null != options) ? - (InvokeMethodOptions) options.Clone() : new InvokeMethodOptions(); + (InvokeMethodOptions)options.Clone() : new InvokeMethodOptions(); // If someone has registered for progress, make sure we flag it if (watcher.HaveListenersForProgress) @@ -2383,7 +2384,7 @@ namespace System.Management WmiEventSink sink = watcher.GetNewSink(scope, o.Context); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; securityHandler = scope.GetSecurityHandler(); @@ -2392,13 +2393,13 @@ namespace System.Management if (null != inParameters) inParams = inParameters.wbemObject; - status = scope.GetSecuredIWbemServicesHandler( scope.GetIWbemServices() ).ExecMethodAsync_( + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).ExecMethodAsync_( path.RelativePath, methodName, o.Flags, o.GetContext(), inParams, - sink.Stub ); + sink.Stub); if (securityHandler != null) securityHandler.Reset(); @@ -2454,7 +2455,7 @@ namespace System.Management throw new ArgumentNullException(nameof(methodName)); else { - Initialize ( false ); + Initialize(false); // Do we have the class? if (null == wmiClass) @@ -2559,7 +2560,7 @@ namespace System.Management // The prototype of Initialize has been changed to accept a bool, indicating whether or not // the caller wants to bind to the underlying WMI object in the Initialize call or not. // - internal override void Initialize( bool getObject ) + internal override void Initialize(bool getObject) { bool needToGetObject = false; @@ -2580,7 +2581,7 @@ namespace System.Management } //Have we already got this object - if (!IsBound && ( getObject == true ) ) + if (!IsBound && (getObject == true)) needToGetObject = true; if (null == scope) @@ -2620,7 +2621,7 @@ namespace System.Management scope.Initialize(); // If we have just connected, make sure we get the object - if ( getObject == true ) + if (getObject == true) { needToGetObject = true; } @@ -2642,7 +2643,7 @@ namespace System.Management IWbemServices wbemServices = scope.GetIWbemServices(); SecurityHandler securityHandler = null; - int status = (int)ManagementStatus.NoError; + int status = (int)ManagementStatus.NoError; try { @@ -2651,9 +2652,9 @@ namespace System.Management string objectPath = null; string curPath = path.RelativePath; - if (curPath.Length>0) + if (curPath.Length > 0) objectPath = curPath; - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).GetObject_(objectPath, options.Flags, options.GetContext(), ref tempObj, IntPtr.Zero); + status = scope.GetSecuredIWbemServicesHandler(wbemServices).GetObject_(objectPath, options.Flags, options.GetContext(), ref tempObj, IntPtr.Zero); if (status >= 0) { @@ -2674,7 +2675,7 @@ namespace System.Management if (status >= 0) { - path = (System.DBNull.Value != val) ? (new ManagementPath((string)val)) : (new ManagementPath ()); + path = (System.DBNull.Value != val) ? (new ManagementPath((string)val)) : (new ManagementPath()); path.IdentifierChanged += new IdentifierChangedEventHandler(HandleIdentifierChange); } } @@ -2699,7 +2700,7 @@ namespace System.Management private static void MapInParameters( - object [] args, + object[] args, ManagementBaseObject inParams, IWbemClassObjectFreeThreaded inParamsClass) { @@ -2727,9 +2728,9 @@ namespace System.Management { while (true) { - object val = null; - int dummy = 0; - string propertyName = null; + object val = null; + int dummy = 0; + string propertyName = null; IWbemQualifierSetFreeThreaded qualifierSet = null; status = inParamsClass.Next_(0, ref propertyName, ref val, ref dummy, ref dummy); @@ -2751,7 +2752,7 @@ namespace System.Management // If the id is in range, map the value into the args array int idIndex = (int)id; if ((0 <= idIndex) && (topId >= idIndex)) - inParams[propertyName] = args [minIndex + idIndex]; + inParams[propertyName] = args[minIndex + idIndex]; } finally { @@ -2780,7 +2781,7 @@ namespace System.Management } private static object MapOutParameters( - object [] args, + object[] args, ManagementBaseObject outParams, IWbemClassObjectFreeThreaded outParamsClass) { @@ -2811,9 +2812,9 @@ namespace System.Management { while (true) { - object val = null; - int dummy = 0; - string propertyName = null; + object val = null; + int dummy = 0; + string propertyName = null; IWbemQualifierSetFreeThreaded qualifierSet = null; status = outParamsClass.Next_(0, ref propertyName, ref val, ref dummy, ref dummy); @@ -2842,7 +2843,7 @@ namespace System.Management // If the id is in range, map the value into the args array int idIndex = (int)id; if ((0 <= idIndex) && (topId >= idIndex)) - args [minIndex + idIndex] = outParams[propertyName]; + args[minIndex + idIndex] = outParams[propertyName]; } finally { diff --git a/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs b/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs index b6a5967dddc..047f7284675 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementObjectCollection.cs @@ -73,12 +73,12 @@ namespace System.Management IEnumWbemClassObject enumWbem) { if (null != options) - this.options = (EnumerationOptions) options.Clone(); + this.options = (EnumerationOptions)options.Clone(); else - this.options = new EnumerationOptions (); + this.options = new EnumerationOptions(); if (null != scope) - this.scope = (ManagementScope)scope.Clone (); + this.scope = (ManagementScope)scope.Clone(); else this.scope = ManagementScope._Clone(null); @@ -88,9 +88,9 @@ namespace System.Management /// /// Disposes of resources the object is holding. This is the destructor for the object. /// - ~ManagementObjectCollection () + ~ManagementObjectCollection() { - Dispose ( false ); + Dispose(false); } /// @@ -98,22 +98,22 @@ namespace System.Management /// method has been called, an attempt to use this object will /// result in an ObjectDisposedException being thrown. /// - public void Dispose () + public void Dispose() { if (!isDisposed) { - Dispose ( true ); + Dispose(true); } } - private void Dispose ( bool disposing ) + private void Dispose(bool disposing) { - if ( disposing ) + if (disposing) { - GC.SuppressFinalize (this); + GC.SuppressFinalize(this); isDisposed = true; } - Marshal.ReleaseComObject (enumWbem); + Marshal.ReleaseComObject(enumWbem); } @@ -145,8 +145,8 @@ namespace System.Management // int count = 0; - IEnumerator enumCol = this.GetEnumerator ( ); - while ( enumCol.MoveNext() == true ) + IEnumerator enumCol = this.GetEnumerator(); + while (enumCol.MoveNext() == true) { count++; } @@ -197,16 +197,16 @@ namespace System.Management /// /// An array to copy to. /// The index to start from. - public void CopyTo (Array array, int index) + public void CopyTo(Array array, int index) { if (isDisposed) throw new ObjectDisposedException(name); if (null == array) - throw new ArgumentNullException (nameof(array)); + throw new ArgumentNullException(nameof(array)); - if ((index < array.GetLowerBound (0)) || (index > array.GetUpperBound(0))) - throw new ArgumentOutOfRangeException (nameof(index)); + if ((index < array.GetLowerBound(0)) || (index > array.GetUpperBound(0))) + throw new ArgumentOutOfRangeException(nameof(index)); // Since we don't know the size until we've enumerated // we'll have to dump the objects in a list first then @@ -214,7 +214,7 @@ namespace System.Management int capacity = array.Length - index; int numObjects = 0; - ArrayList arrList = new ArrayList (); + ArrayList arrList = new ArrayList(); ManagementObjectEnumerator en = this.GetEnumerator(); ManagementBaseObject obj; @@ -227,11 +227,11 @@ namespace System.Management numObjects++; if (numObjects > capacity) - throw new ArgumentException (null, nameof(index)); + throw new ArgumentException(null, nameof(index)); } // If we get here we are OK. Now copy the list to the array - arrList.CopyTo (array, index); + arrList.CopyTo(array, index); return; } @@ -242,9 +242,9 @@ namespace System.Management /// /// The target array. /// The index to start from. - public void CopyTo (ManagementBaseObject[] objectCollection, int index) + public void CopyTo(ManagementBaseObject[] objectCollection, int index) { - CopyTo ((Array)objectCollection, index); + CopyTo((Array)objectCollection, index); } // @@ -288,25 +288,25 @@ namespace System.Management // Unless this is the first enumerator, we have // to clone. This may throw if we are non-rewindable. - if ( this.options.Rewindable == true ) + if (this.options.Rewindable == true) { IEnumWbemClassObject enumWbemClone = null; int status = (int)ManagementStatus.NoError; try { - status = scope.GetSecuredIEnumWbemClassObjectHandler(enumWbem ).Clone_( ref enumWbemClone); + status = scope.GetSecuredIEnumWbemClassObjectHandler(enumWbem).Clone_(ref enumWbemClone); if ((status & 0x80000000) == 0) { //since the original enumerator might not be reset, we need //to reset the new one. - status = scope.GetSecuredIEnumWbemClassObjectHandler(enumWbemClone ).Reset_( ); + status = scope.GetSecuredIEnumWbemClassObjectHandler(enumWbemClone).Reset_(); } } catch (COMException e) { - ManagementException.ThrowWithExtendedInfo (e); + ManagementException.ThrowWithExtendedInfo(e); } if ((status & 0xfffff000) == 0x80041000) @@ -317,7 +317,7 @@ namespace System.Management { Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f()); } - return new ManagementObjectEnumerator (this, enumWbemClone); + return new ManagementObjectEnumerator(this, enumWbemClone); } else { @@ -342,7 +342,7 @@ namespace System.Management /// IEnumerator IEnumerable.GetEnumerator() { - return GetEnumerator (); + return GetEnumerator(); } @@ -426,9 +426,9 @@ namespace System.Management /// /// Disposes of resources the object is holding. This is the destructor for the object. /// - ~ManagementObjectEnumerator () + ~ManagementObjectEnumerator() { - Dispose (); + Dispose(); } @@ -437,13 +437,13 @@ namespace System.Management /// method has been called, an attempt to use this object will /// result in an ObjectDisposedException being thrown. /// - public void Dispose () + public void Dispose() { if (!isDisposed) { if (null != enumWbem) { - Marshal.ReleaseComObject (enumWbem); + Marshal.ReleaseComObject(enumWbem); enumWbem = null; } @@ -457,7 +457,7 @@ namespace System.Management isDisposed = true; - GC.SuppressFinalize (this); + GC.SuppressFinalize(this); } } @@ -479,7 +479,7 @@ namespace System.Management if (cacheIndex < 0) throw new InvalidOperationException(); - return ManagementBaseObject.GetBaseObject (cachedObjects[cacheIndex], + return ManagementBaseObject.GetBaseObject(cachedObjects[cacheIndex], collectionObject.scope); } } @@ -511,7 +511,7 @@ namespace System.Management /// successfully advanced to the next element; if the enumerator has /// passed the end of the collection. /// - public bool MoveNext () + public bool MoveNext() { if (isDisposed) throw new ObjectDisposedException(name); @@ -538,7 +538,7 @@ namespace System.Management //counterparts afterwards. IWbemClassObject_DoNotMarshal[] tempArray = new IWbemClassObject_DoNotMarshal[collectionObject.options.BlockSize]; - int status = collectionObject.scope.GetSecuredIEnumWbemClassObjectHandler(enumWbem ).Next_(timeout, (uint)collectionObject.options.BlockSize, tempArray, ref cachedCount); + int status = collectionObject.scope.GetSecuredIEnumWbemClassObjectHandler(enumWbem).Next_(timeout, (uint)collectionObject.options.BlockSize, tempArray, ref cachedCount); securityHandler.Reset(); @@ -596,7 +596,7 @@ namespace System.Management /// /// Resets the enumerator to the beginning of the collection. /// - public void Reset () + public void Reset() { if (isDisposed) throw new ObjectDisposedException(name); @@ -616,11 +616,11 @@ namespace System.Management } catch (COMException e) { - ManagementException.ThrowWithExtendedInfo (e); + ManagementException.ThrowWithExtendedInfo(e); } finally { - securityHandler.Reset (); + securityHandler.Reset(); } if ((status & 0xfffff000) == 0x80041000) @@ -633,7 +633,7 @@ namespace System.Management } //Flush the current enumeration cache - for (int i=(cacheIndex >= 0 ? cacheIndex : 0); i= 0 ? cacheIndex : 0); i < cachedCount; i++) Marshal.ReleaseComObject((IWbemClassObject_DoNotMarshal)(Marshal.GetObjectForIUnknown(cachedObjects[i]))); cachedCount = 0; diff --git a/src/libraries/System.Management/src/System/Management/ManagementObjectSearcher.cs b/src/libraries/System.Management/src/System/Management/ManagementObjectSearcher.cs index 201a4f2de2e..f0576e7e7eb 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementObjectSearcher.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementObjectSearcher.cs @@ -84,7 +84,7 @@ namespace System.Management /// Dim s As New ManagementObjectSearcher() /// /// - public ManagementObjectSearcher() : this((ManagementScope)null, null, null) {} + public ManagementObjectSearcher() : this((ManagementScope)null, null, null) { } //parameterized constructors /// @@ -99,7 +99,7 @@ namespace System.Management /// Dim s As New ManagementObjectSearcher("SELECT * FROM Win32_Service") /// /// - public ManagementObjectSearcher(string queryString) : this(null, new ObjectQuery(queryString), null) {} + public ManagementObjectSearcher(string queryString) : this(null, new ObjectQuery(queryString), null) { } /// /// Initializes a new instance of the class used to invoke the @@ -114,7 +114,7 @@ namespace System.Management /// Dim s As New ManagementObjectSearcher(q) /// /// - public ManagementObjectSearcher(ObjectQuery query) : this (null, query, null) {} + public ManagementObjectSearcher(ObjectQuery query) : this(null, query, null) { } /// /// Initializes a new instance of the class used to invoke the @@ -136,7 +136,8 @@ namespace System.Management /// /// public ManagementObjectSearcher(string scope, string queryString) : - this(new ManagementScope(scope), new ObjectQuery(queryString), null) {} + this(new ManagementScope(scope), new ObjectQuery(queryString), null) + { } /// /// Initializes a new instance of the class used to invoke the @@ -158,7 +159,7 @@ namespace System.Management /// Dim s As New ManagementObjectSearcher(myScope,q) /// /// - public ManagementObjectSearcher(ManagementScope scope, ObjectQuery query) : this(scope, query, null) {} + public ManagementObjectSearcher(ManagementScope scope, ObjectQuery query) : this(scope, query, null) { } /// /// Initializes a new instance of the class used to invoke the specified @@ -180,7 +181,8 @@ namespace System.Management /// /// public ManagementObjectSearcher(string scope, string queryString, EnumerationOptions options) : - this(new ManagementScope(scope), new ObjectQuery(queryString), options) {} + this(new ManagementScope(scope), new ObjectQuery(queryString), options) + { } /// /// Initializes a new instance of the class to be /// used to invoke the specified query in the specified scope, with the specified @@ -250,9 +252,9 @@ namespace System.Management set { if (null != value) - scope = (ManagementScope) value.Clone (); + scope = (ManagementScope)value.Clone(); else - throw new ArgumentNullException (nameof(value)); + throw new ArgumentNullException(nameof(value)); } } @@ -276,9 +278,9 @@ namespace System.Management set { if (null != value) - query = (ObjectQuery)value.Clone (); + query = (ObjectQuery)value.Clone(); else - throw new ArgumentNullException (nameof(value)); + throw new ArgumentNullException(nameof(value)); } } @@ -297,7 +299,7 @@ namespace System.Management set { if (null != value) - options = (EnumerationOptions) value.Clone (); + options = (EnumerationOptions)value.Clone(); else throw new ArgumentNullException(nameof(value)); } @@ -319,7 +321,7 @@ namespace System.Management /// public ManagementObjectCollection Get() { - Initialize (); + Initialize(); IEnumWbemClassObject ew = null; SecurityHandler securityHandler = scope.GetSecurityHandler(); EnumerationOptions enumOptions = (EnumerationOptions)options.Clone(); @@ -342,7 +344,7 @@ namespace System.Management if (((SelectQuery)query).IsSchemaQuery == false) //deep instance enumeration { - status = scope.GetSecuredIWbemServicesHandler( scope.GetIWbemServices() ).CreateInstanceEnum_( + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).CreateInstanceEnum_( ((SelectQuery)query).ClassName, enumOptions.Flags, enumOptions.GetContext(), @@ -350,22 +352,22 @@ namespace System.Management } else //deep class enumeration { - status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices() ).CreateClassEnum_(((SelectQuery)query).ClassName, + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).CreateClassEnum_(((SelectQuery)query).ClassName, enumOptions.Flags, enumOptions.GetContext(), - ref ew ); + ref ew); } } else //we can use ExecQuery { //Make sure the EnumerateDeep flag bit is turned off because it's invalid for queries enumOptions.EnumerateDeep = true; - status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices() ).ExecQuery_( + status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).ExecQuery_( query.QueryLanguage, query.QueryString, enumOptions.Flags, enumOptions.GetContext(), - ref ew ); + ref ew); } } catch (COMException e) @@ -402,10 +404,10 @@ namespace System.Management public void Get(ManagementOperationObserver watcher) { if (null == watcher) - throw new ArgumentNullException (nameof(watcher)); + throw new ArgumentNullException(nameof(watcher)); - Initialize (); - IWbemServices wbemServices = scope.GetIWbemServices (); + Initialize(); + IWbemServices wbemServices = scope.GetIWbemServices(); EnumerationOptions enumOptions = (EnumerationOptions)options.Clone(); // Ensure we switch off ReturnImmediately as this is invalid for async calls @@ -414,7 +416,7 @@ namespace System.Management if (watcher.HaveListenersForProgress) enumOptions.SendStatus = true; - WmiEventSink sink = watcher.GetNewSink (scope, enumOptions.Context); + WmiEventSink sink = watcher.GetNewSink(scope, enumOptions.Context); SecurityHandler securityHandler = scope.GetSecurityHandler(); int status = (int)ManagementStatus.NoError; @@ -435,14 +437,14 @@ namespace System.Management if (((SelectQuery)query).IsSchemaQuery == false) //deep instance enumeration { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).CreateInstanceEnumAsync_(((SelectQuery)query).ClassName, + status = scope.GetSecuredIWbemServicesHandler(wbemServices).CreateInstanceEnumAsync_(((SelectQuery)query).ClassName, enumOptions.Flags, enumOptions.GetContext(), sink.Stub); } else { - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).CreateClassEnumAsync_(((SelectQuery)query).ClassName, + status = scope.GetSecuredIWbemServicesHandler(wbemServices).CreateClassEnumAsync_(((SelectQuery)query).ClassName, enumOptions.Flags, enumOptions.GetContext(), sink.Stub); @@ -452,7 +454,7 @@ namespace System.Management { //Make sure the EnumerateDeep flag bit is turned off because it's invalid for queries enumOptions.EnumerateDeep = true; - status = scope.GetSecuredIWbemServicesHandler( wbemServices ).ExecQueryAsync_( + status = scope.GetSecuredIWbemServicesHandler(wbemServices).ExecQueryAsync_( query.QueryLanguage, query.QueryString, enumOptions.Flags, @@ -463,8 +465,8 @@ namespace System.Management } catch (COMException e) { - watcher.RemoveSink (sink); - ManagementException.ThrowWithExtendedInfo (e); + watcher.RemoveSink(sink); + ManagementException.ThrowWithExtendedInfo(e); } finally { diff --git a/src/libraries/System.Management/src/System/Management/ManagementOperationWatcher.cs b/src/libraries/System.Management/src/System/Management/ManagementOperationWatcher.cs index 29992788dc7..1a423bca888 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementOperationWatcher.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementOperationWatcher.cs @@ -16,12 +16,12 @@ namespace System.Management /// /// Represents the method that will handle the event. /// - public delegate void CompletedEventHandler (object sender, CompletedEventArgs e); + public delegate void CompletedEventHandler(object sender, CompletedEventArgs e); /// /// Represents the method that will handle the event. /// - public delegate void ProgressEventHandler (object sender, ProgressEventArgs e); + public delegate void ProgressEventHandler(object sender, ProgressEventArgs e); /// /// Represents the method that will handle the event. @@ -131,41 +131,41 @@ namespace System.Management /// /// Occurs when a new object is available. /// - public event ObjectReadyEventHandler ObjectReady; + public event ObjectReadyEventHandler ObjectReady; /// /// Occurs when an operation has completed. /// - public event CompletedEventHandler Completed; + public event CompletedEventHandler Completed; /// /// Occurs to indicate the progress of an ongoing operation. /// - public event ProgressEventHandler Progress; + public event ProgressEventHandler Progress; /// /// Occurs when an object has been successfully committed. /// - public event ObjectPutEventHandler ObjectPut; + public event ObjectPutEventHandler ObjectPut; /// /// Initializes a new instance of the class. This is the default constructor. /// - public ManagementOperationObserver () + public ManagementOperationObserver() { // We make our sink collection synchronized - m_sinkCollection = new Hashtable (); - delegateInvoker = new WmiDelegateInvoker (this); + m_sinkCollection = new Hashtable(); + delegateInvoker = new WmiDelegateInvoker(this); } /// /// Cancels all outstanding operations. /// - public void Cancel () + public void Cancel() { // Cancel all the sinks we have - make a copy to avoid things // changing under our feet - Hashtable copiedSinkTable = new Hashtable (); + Hashtable copiedSinkTable = new Hashtable(); lock (m_sinkCollection) { @@ -173,12 +173,12 @@ namespace System.Management try { - sinkEnum.Reset (); + sinkEnum.Reset(); - while (sinkEnum.MoveNext ()) + while (sinkEnum.MoveNext()) { - DictionaryEntry entry = (DictionaryEntry) sinkEnum.Current; - copiedSinkTable.Add (entry.Key, entry.Value); + DictionaryEntry entry = (DictionaryEntry)sinkEnum.Current; + copiedSinkTable.Add(entry.Key, entry.Value); } } catch @@ -190,16 +190,16 @@ namespace System.Management try { IDictionaryEnumerator copiedSinkEnum = copiedSinkTable.GetEnumerator(); - copiedSinkEnum.Reset (); + copiedSinkEnum.Reset(); - while (copiedSinkEnum.MoveNext ()) + while (copiedSinkEnum.MoveNext()) { - DictionaryEntry entry = (DictionaryEntry) copiedSinkEnum.Current; - WmiEventSink eventSink = (WmiEventSink) entry.Value; + DictionaryEntry entry = (DictionaryEntry)copiedSinkEnum.Current; + WmiEventSink eventSink = (WmiEventSink)entry.Value; try { - eventSink.Cancel (); + eventSink.Cancel(); } catch { @@ -211,7 +211,7 @@ namespace System.Management } } - internal WmiEventSink GetNewSink ( + internal WmiEventSink GetNewSink( ManagementScope scope, object context) { @@ -222,7 +222,7 @@ namespace System.Management // Add it to our collection lock (m_sinkCollection) { - m_sinkCollection.Add (eventSink.GetHashCode(), eventSink); + m_sinkCollection.Add(eventSink.GetHashCode(), eventSink); } return eventSink; @@ -242,7 +242,7 @@ namespace System.Management try { if (Progress != null) - result = ((Progress.GetInvocationList ()).Length > 0); + result = ((Progress.GetInvocationList()).Length > 0); } catch { @@ -251,7 +251,7 @@ namespace System.Management return result; } } - internal WmiEventSink GetNewPutSink ( + internal WmiEventSink GetNewPutSink( ManagementScope scope, object context, string path, @@ -264,7 +264,7 @@ namespace System.Management // Add it to our collection lock (m_sinkCollection) { - m_sinkCollection.Add (eventSink.GetHashCode(), eventSink); + m_sinkCollection.Add(eventSink.GetHashCode(), eventSink); } return eventSink; @@ -275,7 +275,7 @@ namespace System.Management } } - internal WmiGetEventSink GetNewGetSink ( + internal WmiGetEventSink GetNewGetSink( ManagementScope scope, object context, ManagementObject managementObject) @@ -288,7 +288,7 @@ namespace System.Management // Add it to our collection lock (m_sinkCollection) { - m_sinkCollection.Add (eventSink.GetHashCode(), eventSink); + m_sinkCollection.Add(eventSink.GetHashCode(), eventSink); } return eventSink; @@ -299,17 +299,17 @@ namespace System.Management } } - internal void RemoveSink (WmiEventSink eventSink) + internal void RemoveSink(WmiEventSink eventSink) { try { lock (m_sinkCollection) { - m_sinkCollection.Remove (eventSink.GetHashCode ()); + m_sinkCollection.Remove(eventSink.GetHashCode()); } // Release the stub as we are now disconnected - eventSink.ReleaseStub (); + eventSink.ReleaseStub(); } catch { @@ -320,44 +320,44 @@ namespace System.Management /// Fires the ObjectReady event to whomsoever is listening /// /// - internal void FireObjectReady (ObjectReadyEventArgs args) + internal void FireObjectReady(ObjectReadyEventArgs args) { try { - delegateInvoker.FireEventToDelegates (ObjectReady, args); + delegateInvoker.FireEventToDelegates(ObjectReady, args); } catch { } } - internal void FireCompleted (CompletedEventArgs args) + internal void FireCompleted(CompletedEventArgs args) { try { - delegateInvoker.FireEventToDelegates (Completed, args); + delegateInvoker.FireEventToDelegates(Completed, args); } catch { } } - internal void FireProgress (ProgressEventArgs args) + internal void FireProgress(ProgressEventArgs args) { try { - delegateInvoker.FireEventToDelegates (Progress, args); + delegateInvoker.FireEventToDelegates(Progress, args); } catch { } } - internal void FireObjectPut (ObjectPutEventArgs args) + internal void FireObjectPut(ObjectPutEventArgs args) { try { - delegateInvoker.FireEventToDelegates (ObjectPut, args); + delegateInvoker.FireEventToDelegates(ObjectPut, args); } catch { @@ -371,7 +371,7 @@ namespace System.Management private readonly ManagementEventArgs args; private readonly AutoResetEvent h; - internal WmiEventState (Delegate d, ManagementEventArgs args, AutoResetEvent h) + internal WmiEventState(Delegate d, ManagementEventArgs args, AutoResetEvent h) { this.d = d; this.args = args; @@ -407,7 +407,7 @@ namespace System.Management { internal object sender; - internal WmiDelegateInvoker (object sender) + internal WmiDelegateInvoker(object sender) { this.sender = sender; } @@ -419,7 +419,7 @@ namespace System.Management /// The MulticastDelegate representing the collection /// of targets for the event /// The accompanying event arguments - internal void FireEventToDelegates (MulticastDelegate md, ManagementEventArgs args) + internal void FireEventToDelegates(MulticastDelegate md, ManagementEventArgs args) { try { @@ -429,7 +429,7 @@ namespace System.Management { try { - d.DynamicInvoke (new object [] {this.sender, args}); + d.DynamicInvoke(new object[] { this.sender, args }); } catch { diff --git a/src/libraries/System.Management/src/System/Management/ManagementOptions.cs b/src/libraries/System.Management/src/System/Management/ManagementOptions.cs index 834cad17fdd..16012dee594 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementOptions.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementOptions.cs @@ -15,35 +15,35 @@ namespace System.Management /// /// The default COM authentication level. WMI uses the default Windows Authentication setting. /// - Default=0, + Default = 0, /// /// No COM authentication. /// - None=1, + None = 1, /// /// Connect-level COM authentication. /// - Connect=2, + Connect = 2, /// /// Call-level COM authentication. /// - Call=3, + Call = 3, /// /// Packet-level COM authentication. /// - Packet=4, + Packet = 4, /// /// Packet Integrity-level COM authentication. /// - PacketIntegrity=5, + PacketIntegrity = 5, /// /// Packet Privacy-level COM authentication. /// - PacketPrivacy=6, + PacketPrivacy = 6, /// /// The default COM authentication level. WMI uses the default Windows Authentication setting. /// - Unchanged=-1 + Unchanged = -1 } /// @@ -54,31 +54,31 @@ namespace System.Management /// /// Default impersonation. /// - Default=0, + Default = 0, /// /// Anonymous COM impersonation level that hides the /// identity of the caller. Calls to WMI may fail /// with this impersonation level. /// - Anonymous=1, + Anonymous = 1, /// /// Identify-level COM impersonation level that allows objects /// to query the credentials of the caller. Calls to /// WMI may fail with this impersonation level. /// - Identify=2, + Identify = 2, /// /// Impersonate-level COM impersonation level that allows /// objects to use the credentials of the caller. This is the recommended impersonation level for WMI calls. /// - Impersonate=3, + Impersonate = 3, /// /// Delegate-level COM impersonation level that allows objects /// to permit other objects to use the credentials of the caller. This /// level, which will work with WMI calls but may constitute an unnecessary /// security risk, is supported only under Windows 2000. /// - Delegate=4 + Delegate = 4 } /// @@ -95,17 +95,17 @@ namespace System.Management /// Updates an existing object /// only; does not create a new object. /// - UpdateOnly=1, + UpdateOnly = 1, /// /// Creates an object only; /// does not update an existing object. /// - CreateOnly=2, + CreateOnly = 2, /// /// Saves the object, whether /// updating an existing object or creating a new object. /// - UpdateOrCreate=3 + UpdateOrCreate = 3 } //CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC// @@ -149,7 +149,8 @@ namespace System.Management FireIdentifierChanged(); } - internal int Flags { + internal int Flags + { get { return flags; } set { flags = value; } } @@ -177,9 +178,9 @@ namespace System.Management ManagementNamedValueCollection oldContext = context; if (null != value) - context = (ManagementNamedValueCollection) value.Clone(); + context = (ManagementNamedValueCollection)value.Clone(); else - context = new ManagementNamedValueCollection (); + context = new ManagementNamedValueCollection(); if (null != oldContext) oldContext.IdentifierChanged -= new IdentifierChangedEventHandler(HandleIdentifierChange); @@ -221,8 +222,8 @@ namespace System.Management } - internal ManagementOptions() : this(null, InfiniteTimeout) {} - internal ManagementOptions(ManagementNamedValueCollection context, TimeSpan timeout) : this(context, timeout, 0) {} + internal ManagementOptions() : this(null, InfiniteTimeout) { } + internal ManagementOptions(ManagementNamedValueCollection context, TimeSpan timeout) : this(context, timeout, 0) { } internal ManagementOptions(ManagementNamedValueCollection context, TimeSpan timeout, int flags) { this.flags = flags; @@ -234,7 +235,8 @@ namespace System.Management } - internal IWbemContext GetContext () { + internal IWbemContext GetContext() + { if (context != null) return context.GetContext(); else @@ -330,7 +332,8 @@ namespace System.Management public bool ReturnImmediately { get { return (((Flags & (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_RETURN_IMMEDIATELY) != 0) ? true : false); } - set { + set + { Flags = (value == false) ? (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_RETURN_IMMEDIATELY) : (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_RETURN_IMMEDIATELY); } @@ -347,7 +350,8 @@ namespace System.Management public int BlockSize { get { return blockSize; } - set { + set + { //Unfortunately BlockSize was defined as int, but valid values are only > 0 if (value <= 0) throw new ArgumentOutOfRangeException(nameof(value)); @@ -377,7 +381,8 @@ namespace System.Management public bool Rewindable { get { return (((Flags & (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_FORWARD_ONLY) != 0) ? false : true); } - set { + set + { Flags = (value == true) ? (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_FORWARD_ONLY) : (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_FORWARD_ONLY); } @@ -403,7 +408,8 @@ namespace System.Management public bool UseAmendedQualifiers { get { return (((Flags & (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS) != 0) ? true : false); } - set { + set + { Flags = (value == true) ? (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS) : (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS); } @@ -426,8 +432,10 @@ namespace System.Management get { return (((Flags & (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_ENSURE_LOCATABLE) != 0) ? true : false); } set - { Flags = (value == true) ? (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_ENSURE_LOCATABLE) : - (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_ENSURE_LOCATABLE); } + { + Flags = (value == true) ? (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_ENSURE_LOCATABLE) : + (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_ENSURE_LOCATABLE); + } } @@ -447,8 +455,10 @@ namespace System.Management get { return (((Flags & (int)tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_PROTOTYPE) != 0) ? true : false); } set - { Flags = (value == true) ? (Flags | (int)tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_PROTOTYPE) : - (Flags & (int)~tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_PROTOTYPE); } + { + Flags = (value == true) ? (Flags | (int)tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_PROTOTYPE) : + (Flags & (int)~tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_PROTOTYPE); + } } /// @@ -466,8 +476,10 @@ namespace System.Management get { return (((Flags & (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_DIRECT_READ) != 0) ? true : false); } set - { Flags = (value == true) ? (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_DIRECT_READ) : - (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_DIRECT_READ); } + { + Flags = (value == true) ? (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_DIRECT_READ) : + (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_DIRECT_READ); + } } @@ -487,8 +499,10 @@ namespace System.Management get { return (((Flags & (int)tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_SHALLOW) != 0) ? false : true); } set - { Flags = (value == false) ? (Flags | (int)tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_SHALLOW) : - (Flags & (int)~tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_SHALLOW); } + { + Flags = (value == false) ? (Flags | (int)tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_SHALLOW) : + (Flags & (int)~tag_WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_SHALLOW); + } } @@ -502,7 +516,7 @@ namespace System.Management /// class with default values (see the individual property descriptions /// for what the default values are). This is the default constructor. /// - public EnumerationOptions() : this (null, InfiniteTimeout, 1, true, true, false, false, false, false, false) {} + public EnumerationOptions() : this(null, InfiniteTimeout, 1, true, true, false, false, false, false, false) { } @@ -549,14 +563,14 @@ namespace System.Management /// /// The cloned object. /// - public override object Clone () + public override object Clone() { ManagementNamedValueCollection newContext = null; if (null != Context) newContext = (ManagementNamedValueCollection)Context.Clone(); - return new EnumerationOptions (newContext, Timeout, blockSize, Rewindable, + return new EnumerationOptions(newContext, Timeout, blockSize, Rewindable, ReturnImmediately, UseAmendedQualifiers, EnsureLocatable, PrototypeOnly, DirectRead, EnumerateDeep); } @@ -666,7 +680,7 @@ namespace System.Management set { blockSize = value; - FireIdentifierChanged (); + FireIdentifierChanged(); } } @@ -679,7 +693,7 @@ namespace System.Management /// This is the default constructor. /// public EventWatcherOptions() - : this (null, InfiniteTimeout, 1) {} + : this(null, InfiniteTimeout, 1) { } /// /// Initializes a new instance of the class with the given @@ -691,7 +705,7 @@ namespace System.Management public EventWatcherOptions(ManagementNamedValueCollection context, TimeSpan timeout, int blockSize) : base(context, timeout) { - Flags = (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_RETURN_IMMEDIATELY|(int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_FORWARD_ONLY; + Flags = (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_RETURN_IMMEDIATELY | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_FORWARD_ONLY; BlockSize = blockSize; } @@ -701,14 +715,14 @@ namespace System.Management /// /// The cloned object. /// - public override object Clone () + public override object Clone() { ManagementNamedValueCollection newContext = null; if (null != Context) newContext = (ManagementNamedValueCollection)Context.Clone(); - return new EventWatcherOptions (newContext, Timeout, blockSize); + return new EventWatcherOptions(newContext, Timeout, blockSize); } }//EventWatcherOptions @@ -803,7 +817,8 @@ namespace System.Management public bool UseAmendedQualifiers { get { return (((Flags & (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS) != 0) ? true : false); } - set { + set + { Flags = (value == true) ? (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS) : (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS); FireIdentifierChanged(); @@ -817,14 +832,14 @@ namespace System.Management /// Initializes a new instance of the class for getting a WMI object, using /// default values. This is the default constructor. /// - public ObjectGetOptions() : this(null, InfiniteTimeout, false) {} + public ObjectGetOptions() : this(null, InfiniteTimeout, false) { } /// /// Initializes a new instance of the class for getting a WMI object, using the /// specified provider-specific context. /// /// A provider-specific, named-value pairs context object to be passed through to the provider. - public ObjectGetOptions(ManagementNamedValueCollection context) : this(context, InfiniteTimeout, false) {} + public ObjectGetOptions(ManagementNamedValueCollection context) : this(context, InfiniteTimeout, false) { } /// /// Initializes a new instance of the class for getting a WMI object, @@ -844,14 +859,14 @@ namespace System.Management /// /// The cloned object. /// - public override object Clone () + public override object Clone() { ManagementNamedValueCollection newContext = null; if (null != Context) newContext = (ManagementNamedValueCollection)Context.Clone(); - return new ObjectGetOptions (newContext, Timeout, UseAmendedQualifiers); + return new ObjectGetOptions(newContext, Timeout, UseAmendedQualifiers); } } @@ -935,8 +950,11 @@ namespace System.Management public bool UseAmendedQualifiers { get { return (((Flags & (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS) != 0) ? true : false); } - set { Flags = (value == true) ? (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS) : - (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS); } + set + { + Flags = (value == true) ? (Flags | (int)tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS) : + (Flags & (int)~tag_WBEM_GENERIC_FLAG_TYPE.WBEM_FLAG_USE_AMENDED_QUALIFIERS); + } } /// @@ -947,11 +965,14 @@ namespace System.Management /// public PutType Type { - get { return (((Flags & (int)tag_WBEM_CHANGE_FLAG_TYPE.WBEM_FLAG_UPDATE_ONLY) != 0) ? PutType.UpdateOnly : - ((Flags & (int)tag_WBEM_CHANGE_FLAG_TYPE.WBEM_FLAG_CREATE_ONLY) != 0) ? PutType.CreateOnly : - PutType.UpdateOrCreate); + get + { + return (((Flags & (int)tag_WBEM_CHANGE_FLAG_TYPE.WBEM_FLAG_UPDATE_ONLY) != 0) ? PutType.UpdateOnly : + ((Flags & (int)tag_WBEM_CHANGE_FLAG_TYPE.WBEM_FLAG_CREATE_ONLY) != 0) ? PutType.CreateOnly : + PutType.UpdateOrCreate); } - set { + set + { Flags |= value switch { PutType.UpdateOnly => (int)tag_WBEM_CHANGE_FLAG_TYPE.WBEM_FLAG_UPDATE_ONLY, @@ -969,14 +990,14 @@ namespace System.Management /// Initializes a new instance of the class for put operations, using default values. /// This is the default constructor. /// - public PutOptions() : this(null, InfiniteTimeout, false, PutType.UpdateOrCreate) {} + public PutOptions() : this(null, InfiniteTimeout, false, PutType.UpdateOrCreate) { } /// /// Initializes a new instance of the class for committing a WMI object, using the /// specified provider-specific context. /// /// A provider-specific, named-value pairs context object to be passed through to the provider. - public PutOptions(ManagementNamedValueCollection context) : this(context, InfiniteTimeout, false, PutType.UpdateOrCreate) {} + public PutOptions(ManagementNamedValueCollection context) : this(context, InfiniteTimeout, false, PutType.UpdateOrCreate) { } /// /// Initializes a new instance of the class for committing a WMI object, using @@ -998,14 +1019,14 @@ namespace System.Management /// /// The cloned object. /// - public override object Clone () + public override object Clone() { ManagementNamedValueCollection newContext = null; if (null != Context) newContext = (ManagementNamedValueCollection)Context.Clone(); - return new PutOptions (newContext, Timeout, UseAmendedQualifiers, Type); + return new PutOptions(newContext, Timeout, UseAmendedQualifiers, Type); } } @@ -1069,7 +1090,7 @@ namespace System.Management /// Initializes a new instance of the class for the delete operation, using default values. /// This is the default constructor. /// - public DeleteOptions() : base () {} + public DeleteOptions() : base() { } /// /// Initializes a new instance of the class for a delete operation, using @@ -1077,7 +1098,7 @@ namespace System.Management /// /// A provider-specific, named-value pairs object to be passed through to the provider. /// The length of time to let the operation perform before it times out. The default value is . Setting this parameter will invoke the operation semisynchronously. - public DeleteOptions(ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout) {} + public DeleteOptions(ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout) { } /// /// Returns a copy of the object. @@ -1085,14 +1106,14 @@ namespace System.Management /// /// A cloned object. /// - public override object Clone () + public override object Clone() { ManagementNamedValueCollection newContext = null; if (null != Context) newContext = (ManagementNamedValueCollection)Context.Clone(); - return new DeleteOptions (newContext, Timeout); + return new DeleteOptions(newContext, Timeout); } } @@ -1156,7 +1177,7 @@ namespace System.Management /// Initializes a new instance of the class for the operation, using default values. /// This is the default constructor. /// - public InvokeMethodOptions() : base () {} + public InvokeMethodOptions() : base() { } /// /// Initializes a new instance of the class for an invoke operation using @@ -1164,7 +1185,7 @@ namespace System.Management /// /// A provider-specific, named-value pairs object to be passed through to the provider. /// The length of time to let the operation perform before it times out. The default value is . Setting this parameter will invoke the operation semisynchronously. - public InvokeMethodOptions(ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout) {} + public InvokeMethodOptions(ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout) { } /// /// Returns a copy of the object. @@ -1172,14 +1193,14 @@ namespace System.Management /// /// The cloned object. /// - public override object Clone () + public override object Clone() { ManagementNamedValueCollection newContext = null; if (null != Context) newContext = (ManagementNamedValueCollection)Context.Clone(); - return new InvokeMethodOptions (newContext, Timeout); + return new InvokeMethodOptions(newContext, Timeout); } } @@ -1277,7 +1298,8 @@ namespace System.Management public string Locale { get { return (null != locale) ? locale : string.Empty; } - set { + set + { if (locale != value) { locale = value; @@ -1302,7 +1324,8 @@ namespace System.Management public string Username { get { return username; } - set { + set + { if (username != value) { username = value; @@ -1324,13 +1347,14 @@ namespace System.Management /// public string Password { - set { - if ( value != null) + set + { + if (value != null) { if (securePassword == null) { securePassword = new SecureString(); - for ( int i=0; i public SecureString SecurePassword { - set{ - if ( value != null) + set + { + if (value != null) { - if ( securePassword == null) + if (securePassword == null) { securePassword = value.Copy(); } @@ -1421,7 +1446,8 @@ namespace System.Management public string Authority { get { return (null != authority) ? authority : string.Empty; } - set { + set + { if (authority != value) { authority = value; @@ -1452,7 +1478,8 @@ namespace System.Management public ImpersonationLevel Impersonation { get { return impersonation; } - set { + set + { if (impersonation != value) { impersonation = value; @@ -1482,7 +1509,8 @@ namespace System.Management public AuthenticationLevel Authentication { get { return authentication; } - set { + set + { if (authentication != value) { authentication = value; @@ -1505,7 +1533,8 @@ namespace System.Management public bool EnablePrivileges { get { return enablePrivileges; } - set { + set + { if (enablePrivileges != value) { enablePrivileges = value; @@ -1526,10 +1555,11 @@ namespace System.Management /// Initializes a new instance of the class for the connection operation, using default values. This is the /// default constructor. /// - public ConnectionOptions () : - this (DEFAULTLOCALE, null, (string)null, DEFAULTAUTHORITY, + public ConnectionOptions() : + this(DEFAULTLOCALE, null, (string)null, DEFAULTAUTHORITY, DEFAULTIMPERSONATION, DEFAULTAUTHENTICATION, - DEFAULTENABLEPRIVILEGES, null, InfiniteTimeout) {} + DEFAULTENABLEPRIVILEGES, null, InfiniteTimeout) + { } //parameterized @@ -1546,11 +1576,11 @@ namespace System.Management /// to enable special user privileges; otherwise, . This parameter should only be used when performing an operation that requires special Windows NT user privileges. /// A provider-specific, named value pairs object to be passed through to the provider. /// Reserved for future use. - public ConnectionOptions (string locale, + public ConnectionOptions(string locale, string username, string password, string authority, ImpersonationLevel impersonation, AuthenticationLevel authentication, bool enablePrivileges, - ManagementNamedValueCollection context, TimeSpan timeout) : base (context, timeout) + ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout) { if (locale != null) this.locale = locale; @@ -1561,7 +1591,7 @@ namespace System.Management if (password != null) { this.securePassword = new SecureString(); - for ( int i=0; i to enable special user privileges; otherwise, . This parameter should only be used when performing an operation that requires special Windows NT user privileges. /// A provider-specific, named value pairs object to be passed through to the provider. /// Reserved for future use. - public ConnectionOptions (string locale, + public ConnectionOptions(string locale, string username, SecureString password, string authority, ImpersonationLevel impersonation, AuthenticationLevel authentication, bool enablePrivileges, - ManagementNamedValueCollection context, TimeSpan timeout) : base (context, timeout) + ManagementNamedValueCollection context, TimeSpan timeout) : base(context, timeout) { if (locale != null) this.locale = locale; @@ -1623,13 +1653,13 @@ namespace System.Management /// /// The cloned object. /// - public override object Clone () + public override object Clone() { ManagementNamedValueCollection newContext = null; if (null != Context) newContext = (ManagementNamedValueCollection)Context.Clone(); - return new ConnectionOptions (locale, username, GetSecurePassword (), + return new ConnectionOptions(locale, username, GetSecurePassword(), authority, impersonation, authentication, enablePrivileges, newContext, Timeout); } @@ -1641,7 +1671,8 @@ namespace System.Management { if (securePassword != null) { - try{ + try + { return System.Runtime.InteropServices.Marshal.SecureStringToBSTR(securePassword); } catch (OutOfMemoryException) @@ -1652,7 +1683,7 @@ namespace System.Management else return IntPtr.Zero; } - internal SecureString GetSecurePassword() + internal SecureString GetSecurePassword() { if (securePassword != null) return securePassword.Copy(); @@ -1660,9 +1691,9 @@ namespace System.Management return null; } - internal ConnectionOptions(ManagementNamedValueCollection context, TimeSpan timeout, int flags) : base(context, timeout, flags) {} + internal ConnectionOptions(ManagementNamedValueCollection context, TimeSpan timeout, int flags) : base(context, timeout, flags) { } - internal ConnectionOptions(ManagementNamedValueCollection context) : base(context, InfiniteTimeout) {} + internal ConnectionOptions(ManagementNamedValueCollection context) : base(context, InfiniteTimeout) { } internal static ConnectionOptions _Clone(ConnectionOptions options) { diff --git a/src/libraries/System.Management/src/System/Management/ManagementPath.cs b/src/libraries/System.Management/src/System/Management/ManagementPath.cs index 42d81a1b95e..1f385e2c5d1 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementPath.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementPath.cs @@ -70,14 +70,14 @@ namespace System.Management /// End Class /// /// - [TypeConverter(typeof(ManagementPathConverter ))] + [TypeConverter(typeof(ManagementPathConverter))] public class ManagementPath : ICloneable { private static ManagementPath defaultPath = new ManagementPath("//./root/cimv2"); //Used to minimize the cases in which new wbemPath (WMI object path parser) objects need to be constructed //This is done for performance reasons. - private bool isWbemPathShared = false; + private bool isWbemPathShared = false; internal event IdentifierChangedEventHandler IdentifierChanged; @@ -95,21 +95,21 @@ namespace System.Management /// /// The WMI object whose __PATH property will /// be used to supply the returned object - internal static string GetManagementPath ( + internal static string GetManagementPath( IWbemClassObjectFreeThreaded wbemObject) { string path = null; - int status = (int)ManagementStatus.Failed; + int status = (int)ManagementStatus.Failed; if (null != wbemObject) { int dummy1 = 0, dummy2 = 0; object val = null; - status = wbemObject.Get_ ("__PATH", 0, ref val, ref dummy1, ref dummy2); + status = wbemObject.Get_("__PATH", 0, ref val, ref dummy1, ref dummy2); if ((status < 0) || (val == System.DBNull.Value)) { //try to get the relpath instead - status = wbemObject.Get_ ("__RELPATH", 0, ref val, ref dummy1, ref dummy2); + status = wbemObject.Get_("__RELPATH", 0, ref val, ref dummy1, ref dummy2); if (status < 0) { if ((status & 0xfffff000) == 0x80041000) @@ -183,7 +183,7 @@ namespace System.Management /// /// Initializes a new instance of the class that is empty. This is the default constructor. /// - public ManagementPath () : this ((string) null) {} + public ManagementPath() : this((string)null) { } /// /// Initializes a new instance of the class for the given path. @@ -203,7 +203,7 @@ namespace System.Management /// path represented by this object. This value is equivalent to the value of the /// property. /// - public override string ToString () + public override string ToString() { return this.Path; } @@ -214,9 +214,9 @@ namespace System.Management /// /// The cloned object. /// - public ManagementPath Clone () + public ManagementPath Clone() { - return new ManagementPath (Path); + return new ManagementPath(Path); } /// @@ -225,9 +225,9 @@ namespace System.Management /// /// The cloned object. /// - object ICloneable.Clone () + object ICloneable.Clone() { - return Clone (); + return Clone(); } /// @@ -245,7 +245,7 @@ namespace System.Management } //private members - private IWbemPath wmiPath; + private IWbemPath wmiPath; private IWbemPath CreateWbemPath(string path) { @@ -267,13 +267,13 @@ namespace System.Management { if (null != wbemPath) { - uint flags = (uint) tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_CREATE_ACCEPT_ALL; + uint flags = (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_CREATE_ACCEPT_ALL; //For now we have to special-case the "root" namespace - // this is because in the case of "root", the path parser cannot tell whether // this is a namespace name or a class name if (string.Equals(path, "root", StringComparison.OrdinalIgnoreCase)) - flags = flags | (uint) tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; + flags = flags | (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; int status = wbemPath.SetText_(flags, path); @@ -345,7 +345,7 @@ namespace System.Management return pathStr; } - private void ClearKeys (bool setAsSingleton) + private void ClearKeys(bool setAsSingleton) { // Test/utilize isWbemPathShared *only* on public + internal members! int status = (int)ManagementStatus.NoError; @@ -364,7 +364,7 @@ namespace System.Management { sbyte bSingleton = (setAsSingleton) ? (sbyte)(-1) : (sbyte)0; status = keyList.MakeSingleton_(bSingleton); - FireIdentifierChanged (); + FireIdentifierChanged(); } } } @@ -388,7 +388,7 @@ namespace System.Management { get { - return (Path.Length == 0 ); + return (Path.Length == 0); } } @@ -401,7 +401,7 @@ namespace System.Management /// Sets the path as a new class path. This means that the path must have /// a class name but not key values. /// - public void SetAsClass () + public void SetAsClass() { if (IsClass || IsInstance) { @@ -413,17 +413,17 @@ namespace System.Management isWbemPathShared = false; } - ClearKeys (false); + ClearKeys(false); } else - throw new ManagementException (ManagementStatus.InvalidOperation, null, null); + throw new ManagementException(ManagementStatus.InvalidOperation, null, null); } /// /// Sets the path as a new singleton object path. This means that it is a path to an instance but /// there are no key values. /// - public void SetAsSingleton () + public void SetAsSingleton() { if (IsClass || IsInstance) { @@ -435,10 +435,10 @@ namespace System.Management isWbemPathShared = false; } - ClearKeys (true); + ClearKeys(true); } else - throw new ManagementException (ManagementStatus.InvalidOperation, null, null); + throw new ManagementException(ManagementStatus.InvalidOperation, null, null); } // @@ -478,7 +478,7 @@ namespace System.Management } catch { - throw new ArgumentOutOfRangeException (nameof(value)); + throw new ArgumentOutOfRangeException(nameof(value)); } FireIdentifierChanged(); } @@ -504,7 +504,7 @@ namespace System.Management // Get the space we need to reserve uint bufLen = 0; int status = wmiPath.GetText_( - (int) tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_RELATIVE_ONLY, + (int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_RELATIVE_ONLY, ref bufLen, null); @@ -512,7 +512,7 @@ namespace System.Management { char[] pathChars = new char[(int)bufLen]; status = wmiPath.GetText_( - (int) tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_RELATIVE_ONLY, + (int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_RELATIVE_ONLY, ref bufLen, pathChars); pathStr = new string(pathChars, 0, Array.IndexOf(pathChars, '\0')); @@ -540,21 +540,21 @@ namespace System.Management { // No need for isWbemPathShared here since internal SetRelativePath // always creates a new copy. - SetRelativePath (value); + SetRelativePath(value); } catch (COMException) { - throw new ArgumentOutOfRangeException (nameof(value)); + throw new ArgumentOutOfRangeException(nameof(value)); } FireIdentifierChanged(); } } - internal void SetRelativePath (string relPath) + internal void SetRelativePath(string relPath) { // No need for isWbemPathShared here since internal SetRelativePath // always creates a new copy. - ManagementPath newPath = new ManagementPath (relPath); + ManagementPath newPath = new ManagementPath(relPath); newPath.NamespacePath = this.GetNamespacePath((int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY); newPath.Server = this.Server; wmiPath = newPath.wmiPath; @@ -571,7 +571,7 @@ namespace System.Management string newPath = string.Empty; string nsPath = this.GetNamespacePath((int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_SERVER_AND_NAMESPACE_ONLY); - if (nsPath.Length>0 ) + if (nsPath.Length > 0) newPath = string.Concat(nsPath, ":", relPath); else newPath = relPath; @@ -664,10 +664,10 @@ namespace System.Management internal string SetNamespacePath(string nsPath, out bool bChange) { - int status = (int)ManagementStatus.NoError; - string nsOrg = null; - string nsNew = null; - IWbemPath wmiPathTmp = null; + int status = (int)ManagementStatus.NoError; + string nsOrg = null; + string nsNew = null; + IWbemPath wmiPathTmp = null; bChange = false; Debug.Assert(nsPath != null); @@ -735,7 +735,7 @@ namespace System.Management // if (status >= 0 && nsPath.Length > 1 && (nsPath[0] == '\\' && nsPath[1] == '\\' || - nsPath[0] == '/' && nsPath[1] == '/')) + nsPath[0] == '/' && nsPath[1] == '/')) { uint uLen = 0; status = wmiPathTmp.GetServer_(ref uLen, null); @@ -862,7 +862,7 @@ namespace System.Management } catch (COMException) { - throw new ArgumentOutOfRangeException (nameof(value)); + throw new ArgumentOutOfRangeException(nameof(value)); } if (bChange) @@ -943,7 +943,7 @@ namespace System.Management } catch (COMException) { - throw new ArgumentOutOfRangeException (nameof(value)); + throw new ArgumentOutOfRangeException(nameof(value)); } if (status < 0) @@ -1107,10 +1107,10 @@ namespace System.Management if (value is ManagementPath && destinationType == typeof(InstanceDescriptor)) { ManagementPath obj = ((ManagementPath)(value)); - ConstructorInfo ctor = typeof(ManagementPath).GetConstructor(new Type[] {typeof(string)}); + ConstructorInfo ctor = typeof(ManagementPath).GetConstructor(new Type[] { typeof(string) }); if (ctor != null) { - return new InstanceDescriptor(ctor, new object[] {obj.Path}); + return new InstanceDescriptor(ctor, new object[] { obj.Path }); } } return base.ConvertTo(context, culture, value, destinationType); diff --git a/src/libraries/System.Management/src/System/Management/ManagementQuery.cs b/src/libraries/System.Management/src/System/Management/ManagementQuery.cs index 55b327fcdd7..9e93670a645 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementQuery.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementQuery.cs @@ -19,7 +19,7 @@ namespace System.Management /// derivatives of it are actually used in the API. /// //CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC// - [TypeConverter(typeof(ManagementQueryConverter ))] + [TypeConverter(typeof(ManagementQueryConverter))] public abstract class ManagementQuery : ICloneable { internal const string DEFAULTQUERYLANGUAGE = "WQL"; @@ -39,16 +39,16 @@ namespace System.Management private string queryLanguage; private string queryString; - internal void SetQueryString (string qString) + internal void SetQueryString(string qString) { queryString = qString; } //default constructor - internal ManagementQuery() : this(DEFAULTQUERYLANGUAGE, null) {} + internal ManagementQuery() : this(DEFAULTQUERYLANGUAGE, null) { } //parameterized constructors - internal ManagementQuery(string query) : this(DEFAULTQUERYLANGUAGE, query) {} + internal ManagementQuery(string query) : this(DEFAULTQUERYLANGUAGE, query) { } internal ManagementQuery(string language, string query) { QueryLanguage = language; @@ -59,7 +59,7 @@ namespace System.Management /// Parses the query string and sets the property values accordingly. /// /// The query string to be parsed. - protected internal virtual void ParseQuery (string query) {} + protected internal virtual void ParseQuery(string query) { } // //properties @@ -75,12 +75,14 @@ namespace System.Management /// public virtual string QueryString { - get {return (null != queryString) ? queryString : string.Empty; } - set { - if (queryString != value) { - ParseQuery (value); // this may throw + get { return (null != queryString) ? queryString : string.Empty; } + set + { + if (queryString != value) + { + ParseQuery(value); // this may throw queryString = value; - FireIdentifierChanged (); + FireIdentifierChanged(); } } } @@ -95,11 +97,13 @@ namespace System.Management /// public virtual string QueryLanguage { - get {return (null != queryLanguage) ? queryLanguage : string.Empty; } - set { - if (queryLanguage != value) { + get { return (null != queryLanguage) ? queryLanguage : string.Empty; } + set + { + if (queryLanguage != value) + { queryLanguage = value; - FireIdentifierChanged (); + FireIdentifierChanged(); } } } @@ -113,13 +117,13 @@ namespace System.Management /// public abstract object Clone(); - internal static void ParseToken (ref string q, string token, string op, ref bool bTokenFound, ref string tokenValue) + internal static void ParseToken(ref string q, string token, string op, ref bool bTokenFound, ref string tokenValue) { if (bTokenFound) - throw new ArgumentException (SR.InvalidQueryDuplicatedToken); // Invalid query - duplicate token + throw new ArgumentException(SR.InvalidQueryDuplicatedToken); // Invalid query - duplicate token bTokenFound = true; - q = q.Remove (0, token.Length).TrimStart (null); + q = q.Remove(0, token.Length).TrimStart(null); // Next character should be the operator if any if (op != null) @@ -132,25 +136,25 @@ namespace System.Management } if (0 == q.Length) - throw new ArgumentException (SR.InvalidQueryNullToken); // Invalid query - token has no value + throw new ArgumentException(SR.InvalidQueryNullToken); // Invalid query - token has no value // Next token should be the token value - look for terminating WS // or end of string int i; - if (-1 == (i = q.IndexOf (' '))) + if (-1 == (i = q.IndexOf(' '))) i = q.Length; // No WS => consume entire string - tokenValue = q.Substring (0, i); - q = q.Remove (0, tokenValue.Length).TrimStart(null); + tokenValue = q.Substring(0, i); + q = q.Remove(0, tokenValue.Length).TrimStart(null); } - internal static void ParseToken (ref string q, string token, ref bool bTokenFound) + internal static void ParseToken(ref string q, string token, ref bool bTokenFound) { if (bTokenFound) - throw new ArgumentException (SR.InvalidQueryDuplicatedToken); // Invalid query - duplicate token + throw new ArgumentException(SR.InvalidQueryDuplicatedToken); // Invalid query - duplicate token bTokenFound = true; - q = q.Remove (0, token.Length).TrimStart (null); + q = q.Remove(0, token.Length).TrimStart(null); } }//ManagementQuery @@ -216,14 +220,14 @@ namespace System.Management /// class with no initialized values. This /// is the default constructor. /// - public ObjectQuery() : base() {} + public ObjectQuery() : base() { } /// /// Initializes a new instance of the /// class /// for a specific query string. /// /// The string representation of the query. - public ObjectQuery(string query) : base(query) {} + public ObjectQuery(string query) : base(query) { } /// /// Initializes a new instance of the /// class for a specific @@ -231,7 +235,7 @@ namespace System.Management /// /// The query language in which this query is specified. /// The string representation of the query. - public ObjectQuery(string language, string query) : base(language, query) {} + public ObjectQuery(string language, string query) : base(language, query) { } //ICloneable /// @@ -240,7 +244,7 @@ namespace System.Management /// /// The cloned object. /// - public override object Clone () + public override object Clone() { return new ObjectQuery(QueryLanguage, QueryString); } @@ -429,13 +433,13 @@ namespace System.Management /// class. This is the /// default constructor. /// - public EventQuery() : base() {} + public EventQuery() : base() { } /// /// Initializes a new instance of the /// class for the specified query. /// /// A textual representation of the event query. - public EventQuery(string query) : base(query) {} + public EventQuery(string query) : base(query) { } /// /// Initializes a new instance of the /// class for the specified @@ -443,7 +447,7 @@ namespace System.Management /// /// The language in which the query string is specified. /// The string representation of the query. - public EventQuery(string language, string query) : base(language, query) {} + public EventQuery(string language, string query) : base(language, query) { } //ICloneable /// @@ -518,14 +522,14 @@ namespace System.Management /// Initializes a new instance of the class. This is the /// default constructor. /// - public WqlObjectQuery() : base(null) {} + public WqlObjectQuery() : base(null) { } /// /// Initializes a new instance of the class initialized to the /// specified query. /// /// The representation of the data query. - public WqlObjectQuery(string query) : base(query) {} + public WqlObjectQuery(string query) : base(query) { } //QueryLanguage property is read-only in this class (does this work ??) /// @@ -538,7 +542,7 @@ namespace System.Management public override string QueryLanguage { get - {return base.QueryLanguage; } + { return base.QueryLanguage; } } //ICloneable @@ -621,7 +625,7 @@ namespace System.Management /// class. This is the /// default constructor. /// - public SelectQuery() :this(null) {} + public SelectQuery() : this(null) { } //parameterized constructors //ISSUE : We have 2 possible constructors that take a single string : @@ -651,7 +655,7 @@ namespace System.Management /// public SelectQuery(string queryOrClassName) { - selectedProperties = new StringCollection (); + selectedProperties = new StringCollection(); if (null != queryOrClassName) { @@ -668,12 +672,12 @@ namespace System.Management // Do some basic sanity checking on whether it's a class name // - ManagementPath p = new ManagementPath (queryOrClassName); + ManagementPath p = new ManagementPath(queryOrClassName); - if (p.IsClass && (p.NamespacePath.Length==0)) + if (p.IsClass && (p.NamespacePath.Length == 0)) ClassName = queryOrClassName; else - throw new ArgumentException (SR.InvalidQuery, nameof(queryOrClassName)); + throw new ArgumentException(SR.InvalidQuery, nameof(queryOrClassName)); } } @@ -692,7 +696,7 @@ namespace System.Management /// Dim s As New SelectQuery("Win32_Process", "HandleID=1234") /// /// - public SelectQuery(string className, string condition) : this(className, condition, null) {} + public SelectQuery(string className, string condition) : this(className, condition, null) { } /// /// Initializes a new instance of the @@ -716,15 +720,15 @@ namespace System.Management /// properties) /// /// - public SelectQuery(string className, string condition, string[] selectedProperties) : base () + public SelectQuery(string className, string condition, string[] selectedProperties) : base() { this.isSchemaQuery = false; this.className = className; this.condition = condition; - this.selectedProperties = new StringCollection (); + this.selectedProperties = new StringCollection(); if (null != selectedProperties) - this.selectedProperties.AddRange (selectedProperties); + this.selectedProperties.AddRange(selectedProperties); BuildQuery(); } @@ -742,7 +746,7 @@ namespace System.Management /// Dim s As New SelectQuery(true, "__CLASS = ""Win32_Service""") /// /// - public SelectQuery(bool isSchemaQuery, string condition) : base () + public SelectQuery(bool isSchemaQuery, string condition) : base() { if (isSchemaQuery == false) throw new ArgumentException(SR.InvalidQuery, nameof(isSchemaQuery)); @@ -778,12 +782,15 @@ namespace System.Management /// public override string QueryString { - get { + get + { // We need to force a rebuild as we may not have detected // a change to selected properties - BuildQuery (); - return base.QueryString; } - set { + BuildQuery(); + return base.QueryString; + } + set + { base.QueryString = value; } } @@ -877,20 +884,21 @@ namespace System.Management public StringCollection SelectedProperties { get { return selectedProperties; } - set { + set + { if (null != value) { // A tad painful since StringCollection doesn't support ICloneable StringCollection src = (StringCollection)value; - StringCollection dst = new StringCollection (); + StringCollection dst = new StringCollection(); foreach (string s in src) - dst.Add (s); + dst.Add(s); selectedProperties = dst; } else - selectedProperties = new StringCollection (); + selectedProperties = new StringCollection(); BuildQuery(); FireIdentifierChanged(); @@ -909,9 +917,9 @@ namespace System.Management //If the class name is not set we can't build a query //Shouldn't throw here because the user may be in the process of filling in the properties... if (className == null) - SetQueryString (string.Empty); + SetQueryString(string.Empty); - if ((className == null) || (className.Length==0)) + if ((className == null) || (className.Length == 0)) return; //Select clause @@ -945,7 +953,7 @@ namespace System.Management //Set the queryString member to the built query (NB: note we set //by accessing the internal helper function rather than the property, //since we do not want to force a parse of a query we just built). - SetQueryString (s); + SetQueryString(s); } @@ -971,13 +979,13 @@ namespace System.Management string keyword = TokenSelect; if ((q.Length >= keyword.Length) && (string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase) == 0)) //select clause found { - ParseToken (ref q, keyword, ref bFound); + ParseToken(ref q, keyword, ref bFound); if (q[0] != '*') //we have properties { if (null != selectedProperties) - selectedProperties.Clear (); + selectedProperties.Clear(); else - selectedProperties = new StringCollection (); + selectedProperties = new StringCollection(); //get the property list while (true) @@ -985,9 +993,9 @@ namespace System.Management if ((i = q.IndexOf(',')) > 0) { tempProp = q.Substring(0, i); - q = q.Remove(0, i+1).TrimStart(null); + q = q.Remove(0, i + 1).TrimStart(null); tempProp = tempProp.Trim(); - if (tempProp.Length>0) + if (tempProp.Length > 0) selectedProperties.Add(tempProp); } else @@ -1031,34 +1039,34 @@ namespace System.Management // Should start with "select" if ((q.Length < keyword.Length) || - (0 != string.Compare (q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) - throw new ArgumentException (SR.InvalidQuery, "select"); + (0 != string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) + throw new ArgumentException(SR.InvalidQuery, "select"); - q = q.Remove (0, keyword.Length).TrimStart (null); + q = q.Remove(0, keyword.Length).TrimStart(null); // Next should be a '*' - if (0 != q.IndexOf ('*', 0)) - throw new ArgumentException (SR.InvalidQuery, "*"); + if (0 != q.IndexOf('*', 0)) + throw new ArgumentException(SR.InvalidQuery, "*"); - q = q.Remove (0, 1).TrimStart (null); + q = q.Remove(0, 1).TrimStart(null); // Next should be "from" keyword = "from"; if ((q.Length < keyword.Length) || - (0 != string.Compare (q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) - throw new ArgumentException (SR.InvalidQuery, "from"); + (0 != string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) + throw new ArgumentException(SR.InvalidQuery, "from"); - q = q.Remove (0, keyword.Length).TrimStart (null); + q = q.Remove(0, keyword.Length).TrimStart(null); // Next should be "meta_class" keyword = "meta_class"; if ((q.Length < keyword.Length) || - (0 != string.Compare (q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) - throw new ArgumentException (SR.InvalidQuery, "meta_class"); + (0 != string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) + throw new ArgumentException(SR.InvalidQuery, "meta_class"); - q = q.Remove (0, keyword.Length).TrimStart (null); + q = q.Remove(0, keyword.Length).TrimStart(null); // There may be a where clause if (0 < q.Length) @@ -1067,13 +1075,13 @@ namespace System.Management keyword = "where"; if ((q.Length < keyword.Length) || - (0 != string.Compare (q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) - throw new ArgumentException (SR.InvalidQuery, "where"); + (0 != string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) + throw new ArgumentException(SR.InvalidQuery, "where"); - q = q.Remove (0, keyword.Length); + q = q.Remove(0, keyword.Length); // Must be some white space next - if ((0 == q.Length) || !char.IsWhiteSpace (q[0])) + if ((0 == q.Length) || !char.IsWhiteSpace(q[0])) throw new ArgumentException(SR.InvalidQuery); // Invalid query q = q.TrimStart(null); // Remove the leading whitespace @@ -1095,7 +1103,7 @@ namespace System.Management /// /// The copied object. /// - public override object Clone () + public override object Clone() { string[] strArray = null; @@ -1105,8 +1113,8 @@ namespace System.Management if (0 < count) { - strArray = new string [count]; - selectedProperties.CopyTo (strArray, 0); + strArray = new string[count]; + selectedProperties.CopyTo(strArray, 0); } } @@ -1207,7 +1215,7 @@ namespace System.Management /// Initializes a new instance of the class. This is the /// default constructor. /// - public RelatedObjectQuery() :this(null) {} + public RelatedObjectQuery() : this(null) { } //parameterized constructor //ISSUE : We have 2 possible constructors that take a single string : @@ -1264,15 +1272,15 @@ namespace System.Management // Do some basic sanity checking on whether it's a class/instance name // - ManagementPath p = new ManagementPath (queryOrSourceObject); + ManagementPath p = new ManagementPath(queryOrSourceObject); - if ((p.IsClass || p.IsInstance) && (p.NamespacePath.Length==0)) + if ((p.IsClass || p.IsInstance) && (p.NamespacePath.Length == 0)) { SourceObject = queryOrSourceObject; isSchemaQuery = false; } else - throw new ArgumentException (SR.InvalidQuery, nameof(queryOrSourceObject)); + throw new ArgumentException(SR.InvalidQuery, nameof(queryOrSourceObject)); } } } @@ -1284,7 +1292,8 @@ namespace System.Management /// The path of the source object for this query. /// The related objects class. public RelatedObjectQuery(string sourceObject, string relatedClass) : this(sourceObject, relatedClass, - null, null, null, null, null, false) {} + null, null, null, null, null, false) + { } //Do we need additional variants of constructors here ?? /// @@ -1556,48 +1565,48 @@ namespace System.Management //If the source object is not set we can't build a query //Shouldn't throw here because the user may be in the process of filling in the properties... if (sourceObject == null) - SetQueryString (string.Empty); + SetQueryString(string.Empty); - if ((sourceObject == null) || (sourceObject.Length==0)) + if ((sourceObject == null) || (sourceObject.Length == 0)) return; //"associators" clause string s = TokenAssociators + " " + TokenOf + " {" + sourceObject + "}"; //If any of the other parameters are set we need a "where" clause - if (!(RelatedClass.Length==0) || - !(RelationshipClass.Length==0) || - !(RelatedQualifier.Length==0) || - !(RelationshipQualifier.Length==0) || - !(RelatedRole.Length==0) || - !(ThisRole.Length==0) || + if (!(RelatedClass.Length == 0) || + !(RelationshipClass.Length == 0) || + !(RelatedQualifier.Length == 0) || + !(RelationshipQualifier.Length == 0) || + !(RelatedRole.Length == 0) || + !(ThisRole.Length == 0) || classDefinitionsOnly || isSchemaQuery) { s = s + " " + TokenWhere; //"ResultClass" - if (!(RelatedClass.Length==0)) + if (!(RelatedClass.Length == 0)) s = s + " " + TokenResultClass + " = " + relatedClass; //"AssocClass" - if (!(RelationshipClass.Length==0)) + if (!(RelationshipClass.Length == 0)) s = s + " " + TokenAssocClass + " = " + relationshipClass; //"ResultRole" - if (!(RelatedRole.Length==0)) + if (!(RelatedRole.Length == 0)) s = s + " " + TokenResultRole + " = " + relatedRole; //"Role" - if (!(ThisRole.Length==0)) + if (!(ThisRole.Length == 0)) s = s + " " + TokenRole + " = " + thisRole; //"RequiredQualifier" - if (!(RelatedQualifier.Length==0)) + if (!(RelatedQualifier.Length == 0)) s = s + " " + TokenRequiredQualifier + " = " + relatedQualifier; //"RequiredAssocQualifier" - if (!(RelationshipQualifier.Length==0)) + if (!(RelationshipQualifier.Length == 0)) s = s + " " + TokenRequiredAssocQualifier + " = " + relationshipQualifier; //"SchemaOnly" and "ClassDefsOnly" @@ -1613,7 +1622,7 @@ namespace System.Management //Set the queryString member to the built query (NB: note we set //by accessing the internal helper function rather than the property, //since we do not want to force a parse of a query we just built). - SetQueryString (s); + SetQueryString(s); }//BuildQuery() @@ -1632,8 +1641,8 @@ namespace System.Management string tempThisRole = null; string tempRelatedQualifier = null; string tempRelationshipQualifier = null; - bool tempClassDefsOnly = false; - bool tempIsSchemaQuery = false; + bool tempClassDefsOnly = false; + bool tempIsSchemaQuery = false; //Trim whitespaces string q = query.Trim(); @@ -1647,7 +1656,7 @@ namespace System.Management q = q.Remove(0, TokenAssociators.Length); // Must be some white space next - if ((0 == q.Length) || !char.IsWhiteSpace (q[0])) + if ((0 == q.Length) || !char.IsWhiteSpace(q[0])) throw new ArgumentException(SR.InvalidQuery); // Invalid query q = q.TrimStart(null); // Remove the leading whitespace @@ -1657,7 +1666,7 @@ namespace System.Management throw new ArgumentException(SR.InvalidQuery, "of"); // Invalid query // Strip off the clause and leading WS - q = q.Remove(0, TokenOf.Length).TrimStart (null); + q = q.Remove(0, TokenOf.Length).TrimStart(null); // Next character should be "{" if (0 != q.IndexOf('{')) @@ -1671,19 +1680,19 @@ namespace System.Management throw new ArgumentException(SR.InvalidQuery); // Invalid query tempSourceObject = q.Substring(0, i).TrimEnd(null); - q = q.Remove(0, i+1).TrimStart(null); + q = q.Remove(0, i + 1).TrimStart(null); // At this point we may or may not have a "where" clause if (0 < q.Length) { // Next should be the "where" clause - if (0 != string.Compare (q, 0, TokenWhere, 0, TokenWhere.Length, StringComparison.OrdinalIgnoreCase)) + if (0 != string.Compare(q, 0, TokenWhere, 0, TokenWhere.Length, StringComparison.OrdinalIgnoreCase)) throw new ArgumentException(SR.InvalidQuery, "where"); // Invalid query - q = q.Remove (0, TokenWhere.Length); + q = q.Remove(0, TokenWhere.Length); // Must be some white space next - if ((0 == q.Length) || !char.IsWhiteSpace (q[0])) + if ((0 == q.Length) || !char.IsWhiteSpace(q[0])) throw new ArgumentException(SR.InvalidQuery); // Invalid query q = q.TrimStart(null); // Remove the leading whitespace @@ -1701,26 +1710,26 @@ namespace System.Management // Keep looking for tokens until we are done while (true) { - if ((q.Length >= TokenResultClass.Length) && (0 == string.Compare (q, 0, TokenResultClass, 0, TokenResultClass.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenResultClass, "=", ref bResultClassFound, ref tempRelatedClass); - else if ((q.Length >= TokenAssocClass.Length) && (0 == string.Compare (q, 0, TokenAssocClass, 0, TokenAssocClass.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenAssocClass, "=", ref bAssocClassFound, ref tempRelationshipClass); - else if ((q.Length >= TokenResultRole.Length) && (0 == string.Compare (q, 0, TokenResultRole, 0, TokenResultRole.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenResultRole, "=", ref bResultRoleFound, ref tempRelatedRole); - else if ((q.Length >= TokenRole.Length) && (0 == string.Compare (q, 0, TokenRole, 0, TokenRole.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenRole, "=", ref bRoleFound, ref tempThisRole); - else if ((q.Length >= TokenRequiredQualifier.Length) && (0 == string.Compare (q, 0, TokenRequiredQualifier, 0, TokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenRequiredQualifier, "=", ref bRequiredQualifierFound, ref tempRelatedQualifier); - else if ((q.Length >= TokenRequiredAssocQualifier.Length) && (0 == string.Compare (q, 0, TokenRequiredAssocQualifier, 0, TokenRequiredAssocQualifier.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenRequiredAssocQualifier, "=", ref bRequiredAssocQualifierFound, ref tempRelationshipQualifier); - else if ((q.Length >= TokenSchemaOnly.Length) && (0 == string.Compare (q, 0, TokenSchemaOnly, 0, TokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase))) + if ((q.Length >= TokenResultClass.Length) && (0 == string.Compare(q, 0, TokenResultClass, 0, TokenResultClass.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenResultClass, "=", ref bResultClassFound, ref tempRelatedClass); + else if ((q.Length >= TokenAssocClass.Length) && (0 == string.Compare(q, 0, TokenAssocClass, 0, TokenAssocClass.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenAssocClass, "=", ref bAssocClassFound, ref tempRelationshipClass); + else if ((q.Length >= TokenResultRole.Length) && (0 == string.Compare(q, 0, TokenResultRole, 0, TokenResultRole.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenResultRole, "=", ref bResultRoleFound, ref tempRelatedRole); + else if ((q.Length >= TokenRole.Length) && (0 == string.Compare(q, 0, TokenRole, 0, TokenRole.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenRole, "=", ref bRoleFound, ref tempThisRole); + else if ((q.Length >= TokenRequiredQualifier.Length) && (0 == string.Compare(q, 0, TokenRequiredQualifier, 0, TokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenRequiredQualifier, "=", ref bRequiredQualifierFound, ref tempRelatedQualifier); + else if ((q.Length >= TokenRequiredAssocQualifier.Length) && (0 == string.Compare(q, 0, TokenRequiredAssocQualifier, 0, TokenRequiredAssocQualifier.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenRequiredAssocQualifier, "=", ref bRequiredAssocQualifierFound, ref tempRelationshipQualifier); + else if ((q.Length >= TokenSchemaOnly.Length) && (0 == string.Compare(q, 0, TokenSchemaOnly, 0, TokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase))) { - ParseToken (ref q, TokenSchemaOnly, ref bSchemaOnlyFound); + ParseToken(ref q, TokenSchemaOnly, ref bSchemaOnlyFound); tempIsSchemaQuery = true; } - else if ((q.Length >= TokenClassDefsOnly.Length) && (0 == string.Compare (q, 0, TokenClassDefsOnly, 0, TokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase))) + else if ((q.Length >= TokenClassDefsOnly.Length) && (0 == string.Compare(q, 0, TokenClassDefsOnly, 0, TokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase))) { - ParseToken (ref q, TokenClassDefsOnly, ref bClassDefsOnlyFound); + ParseToken(ref q, TokenClassDefsOnly, ref bClassDefsOnlyFound); tempClassDefsOnly = true; } else if (0 == q.Length) @@ -1843,7 +1852,7 @@ namespace System.Management /// /// Initializes a new instance of the class. This is the default constructor. /// - public RelationshipQuery() :this(null) {} + public RelationshipQuery() : this(null) { } //parameterized constructor //ISSUE : We have 2 possible constructors that take a single string : @@ -1890,15 +1899,15 @@ namespace System.Management // Do some basic sanity checking on whether it's a class/instance name // - ManagementPath p = new ManagementPath (queryOrSourceObject); + ManagementPath p = new ManagementPath(queryOrSourceObject); - if ((p.IsClass || p.IsInstance) && (p.NamespacePath.Length==0)) + if ((p.IsClass || p.IsInstance) && (p.NamespacePath.Length == 0)) { SourceObject = queryOrSourceObject; isSchemaQuery = false; } else - throw new ArgumentException (SR.InvalidQuery, nameof(queryOrSourceObject)); + throw new ArgumentException(SR.InvalidQuery, nameof(queryOrSourceObject)); } } @@ -1911,7 +1920,9 @@ namespace System.Management /// The path of the source object for this query. /// The type of relationship for which to query. public RelationshipQuery(string sourceObject, string relationshipClass) : this(sourceObject, relationshipClass, - null, null, false) {} + null, null, false) + { } + //Do we need additional variants of constructors here ?? /// /// Initializes a new instance of the class for the given set of parameters. @@ -2091,31 +2102,31 @@ namespace System.Management if (sourceObject == null) SetQueryString(string.Empty); - if ((sourceObject == null) || (sourceObject.Length==0)) + if ((sourceObject == null) || (sourceObject.Length == 0)) return; //"references" clause string s = TokenReferences + " " + TokenOf + " {" + sourceObject + "}"; //If any of the other parameters are set we need a "where" clause - if (!(RelationshipClass.Length==0) || - !(RelationshipQualifier.Length==0) || - !(ThisRole.Length==0) || + if (!(RelationshipClass.Length == 0) || + !(RelationshipQualifier.Length == 0) || + !(ThisRole.Length == 0) || classDefinitionsOnly || isSchemaQuery) { s = s + " " + TokenWhere; //"ResultClass" - if (!(RelationshipClass.Length==0)) + if (!(RelationshipClass.Length == 0)) s = s + " " + TokenResultClass + " = " + relationshipClass; //"Role" - if (!(ThisRole.Length==0)) + if (!(ThisRole.Length == 0)) s = s + " " + TokenRole + " = " + thisRole; //"RequiredQualifier" - if (!(RelationshipQualifier.Length==0)) + if (!(RelationshipQualifier.Length == 0)) s = s + " " + TokenRequiredQualifier + " = " + relationshipQualifier; //"SchemaOnly" and "ClassDefsOnly" @@ -2132,7 +2143,7 @@ namespace System.Management //Set the queryString member to the built query (NB: note we set //by accessing the internal helper function rather than the property, //since we do not want to force a parse of a query we just built). - SetQueryString (s); + SetQueryString(s); } //BuildQuery() @@ -2147,8 +2158,8 @@ namespace System.Management string tempRelationshipClass = null; string tempThisRole = null; string tempRelationshipQualifier = null; - bool tempClassDefsOnly = false; - bool tempSchemaOnly = false; + bool tempClassDefsOnly = false; + bool tempSchemaOnly = false; //Trim whitespaces string q = query.Trim(); @@ -2162,7 +2173,7 @@ namespace System.Management q = q.Remove(0, TokenReferences.Length); // Must be some white space next - if ((0 == q.Length) || !char.IsWhiteSpace (q[0])) + if ((0 == q.Length) || !char.IsWhiteSpace(q[0])) throw new ArgumentException(SR.InvalidQuery); // Invalid query q = q.TrimStart(null); // Remove the leading whitespace @@ -2172,7 +2183,7 @@ namespace System.Management throw new ArgumentException(SR.InvalidQuery, "of"); // Invalid query // Strip off the clause and leading WS - q = q.Remove(0, TokenOf.Length).TrimStart (null); + q = q.Remove(0, TokenOf.Length).TrimStart(null); // Next character should be "{" if (0 != q.IndexOf('{')) @@ -2186,19 +2197,19 @@ namespace System.Management throw new ArgumentException(SR.InvalidQuery); // Invalid query tempSourceObject = q.Substring(0, i).TrimEnd(null); - q = q.Remove(0, i+1).TrimStart(null); + q = q.Remove(0, i + 1).TrimStart(null); // At this point we may or may not have a "where" clause if (0 < q.Length) { // Next should be the "where" clause - if (0 != string.Compare (q, 0, TokenWhere, 0, TokenWhere.Length, StringComparison.OrdinalIgnoreCase)) + if (0 != string.Compare(q, 0, TokenWhere, 0, TokenWhere.Length, StringComparison.OrdinalIgnoreCase)) throw new ArgumentException(SR.InvalidQuery, "where"); // Invalid query - q = q.Remove (0, TokenWhere.Length); + q = q.Remove(0, TokenWhere.Length); // Must be some white space next - if ((0 == q.Length) || !char.IsWhiteSpace (q[0])) + if ((0 == q.Length) || !char.IsWhiteSpace(q[0])) throw new ArgumentException(SR.InvalidQuery); // Invalid query q = q.TrimStart(null); // Remove the leading whitespace @@ -2213,20 +2224,20 @@ namespace System.Management // Keep looking for tokens until we are done while (true) { - if ((q.Length >= TokenResultClass.Length) && (0 == string.Compare (q, 0, TokenResultClass, 0, TokenResultClass.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenResultClass, "=", ref bResultClassFound, ref tempRelationshipClass); - else if ((q.Length >= TokenRole.Length) && (0 == string.Compare (q, 0, TokenRole, 0, TokenRole.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenRole, "=", ref bRoleFound, ref tempThisRole); - else if ((q.Length >= TokenRequiredQualifier.Length) && (0 == string.Compare (q, 0, TokenRequiredQualifier, 0, TokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase))) - ParseToken (ref q, TokenRequiredQualifier, "=", ref bRequiredQualifierFound, ref tempRelationshipQualifier); - else if ((q.Length >= TokenClassDefsOnly.Length) && (0 == string.Compare (q, 0, TokenClassDefsOnly, 0, TokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase))) + if ((q.Length >= TokenResultClass.Length) && (0 == string.Compare(q, 0, TokenResultClass, 0, TokenResultClass.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenResultClass, "=", ref bResultClassFound, ref tempRelationshipClass); + else if ((q.Length >= TokenRole.Length) && (0 == string.Compare(q, 0, TokenRole, 0, TokenRole.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenRole, "=", ref bRoleFound, ref tempThisRole); + else if ((q.Length >= TokenRequiredQualifier.Length) && (0 == string.Compare(q, 0, TokenRequiredQualifier, 0, TokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase))) + ParseToken(ref q, TokenRequiredQualifier, "=", ref bRequiredQualifierFound, ref tempRelationshipQualifier); + else if ((q.Length >= TokenClassDefsOnly.Length) && (0 == string.Compare(q, 0, TokenClassDefsOnly, 0, TokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase))) { - ParseToken (ref q, TokenClassDefsOnly, ref bClassDefsOnlyFound); + ParseToken(ref q, TokenClassDefsOnly, ref bClassDefsOnlyFound); tempClassDefsOnly = true; } - else if ((q.Length >= TokenSchemaOnly.Length) && (0 == string.Compare (q, 0, TokenSchemaOnly, 0, TokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase))) + else if ((q.Length >= TokenSchemaOnly.Length) && (0 == string.Compare(q, 0, TokenSchemaOnly, 0, TokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase))) { - ParseToken (ref q, TokenSchemaOnly, ref bSchemaOnlyFound); + ParseToken(ref q, TokenSchemaOnly, ref bSchemaOnlyFound); tempSchemaOnly = true; } else if (0 == q.Length) @@ -2432,7 +2443,7 @@ namespace System.Management /// class. This is the default /// constructor. /// - public WqlEventQuery() : this(null, TimeSpan.Zero, null, TimeSpan.Zero, null, null) {} + public WqlEventQuery() : this(null, TimeSpan.Zero, null, TimeSpan.Zero, null, null) { } //parameterized constructors //ISSUE : We have 2 possible constructors that take a single string : @@ -2476,14 +2487,14 @@ namespace System.Management { // Do some basic sanity checking on whether it's a class name // - ManagementPath p = new ManagementPath (queryOrEventClassName); + ManagementPath p = new ManagementPath(queryOrEventClassName); - if (p.IsClass && (p.NamespacePath.Length==0)) + if (p.IsClass && (p.NamespacePath.Length == 0)) { EventClassName = queryOrEventClassName; } else - throw new ArgumentException (SR.InvalidQuery, nameof(queryOrEventClassName)); + throw new ArgumentException(SR.InvalidQuery, nameof(queryOrEventClassName)); } } } @@ -2507,7 +2518,7 @@ namespace System.Management /// Dim q As New WqlEventQuery("MyEvent", "FirstProp < 20 and SecondProp = 'red'") /// /// - public WqlEventQuery(string eventClassName, string condition) : this(eventClassName, TimeSpan.Zero, condition, TimeSpan.Zero, null, null) {} + public WqlEventQuery(string eventClassName, string condition) : this(eventClassName, TimeSpan.Zero, condition, TimeSpan.Zero, null, null) { } /// /// Initializes a new instance of the @@ -2531,8 +2542,9 @@ namespace System.Management /// Dim q As New WqlEventQuery("__InstanceCreationEvent", t) /// /// - public WqlEventQuery(string eventClassName, TimeSpan withinInterval): - this(eventClassName, withinInterval, null, TimeSpan.Zero, null, null) {} + public WqlEventQuery(string eventClassName, TimeSpan withinInterval) : + this(eventClassName, withinInterval, null, TimeSpan.Zero, null, null) + { } /// /// Initializes a new instance of the /// class with the specified @@ -2563,7 +2575,8 @@ namespace System.Management /// /// public WqlEventQuery(string eventClassName, TimeSpan withinInterval, string condition) : - this(eventClassName, withinInterval, condition, TimeSpan.Zero, null, null) {} + this(eventClassName, withinInterval, condition, TimeSpan.Zero, null, null) + { } /// /// Initializes a new instance of the @@ -2594,7 +2607,8 @@ namespace System.Management /// /// public WqlEventQuery(string eventClassName, string condition, TimeSpan groupWithinInterval) : - this(eventClassName, TimeSpan.Zero, condition, groupWithinInterval, null, null) {} + this(eventClassName, TimeSpan.Zero, condition, groupWithinInterval, null, null) + { } /// /// Initializes a new instance of the @@ -2632,7 +2646,8 @@ namespace System.Management /// /// public WqlEventQuery(string eventClassName, string condition, TimeSpan groupWithinInterval, string[] groupByPropertyList) : - this(eventClassName, TimeSpan.Zero, condition, groupWithinInterval, groupByPropertyList, null) {} + this(eventClassName, TimeSpan.Zero, condition, groupWithinInterval, groupByPropertyList, null) + { } /// /// Initializes a new instance of the @@ -2678,10 +2693,10 @@ namespace System.Management this.withinInterval = withinInterval; this.condition = condition; this.groupWithinInterval = groupWithinInterval; - this.groupByPropertyList = new StringCollection (); + this.groupByPropertyList = new StringCollection(); if (null != groupByPropertyList) - this.groupByPropertyList.AddRange (groupByPropertyList); + this.groupByPropertyList.AddRange(groupByPropertyList); this.havingCondition = havingCondition; BuildQuery(); @@ -2699,7 +2714,7 @@ namespace System.Management public override string QueryLanguage { get - {return base.QueryLanguage; } + { return base.QueryLanguage; } } /// @@ -2714,7 +2729,7 @@ namespace System.Management { // We need to force a rebuild as we may not have detected // a change to selected properties - BuildQuery (); + BuildQuery(); return base.QueryString; } set @@ -2892,13 +2907,14 @@ namespace System.Management public StringCollection GroupByPropertyList { get { return groupByPropertyList; } - set { + set + { // A tad painful since StringCollection doesn't support ICloneable StringCollection src = (StringCollection)value; - StringCollection dst = new StringCollection (); + StringCollection dst = new StringCollection(); foreach (string s in src) - dst.Add (s); + dst.Add(s); groupByPropertyList = dst; BuildQuery(); @@ -2950,9 +2966,9 @@ namespace System.Management { //If the event class name is not set we can't build a query //This shouldn't throw because the user may be in the process of setting properties... - if ((eventClassName == null) || (eventClassName.Length==0)) + if ((eventClassName == null) || (eventClassName.Length == 0)) { - SetQueryString (string.Empty); + SetQueryString(string.Empty); return; } @@ -2967,7 +2983,7 @@ namespace System.Management s = s + " within " + withinInterval.TotalSeconds.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(double))); //Where clause - if (!(Condition.Length==0)) + if (!(Condition.Length == 0)) s = s + " where " + condition; //Group within clause @@ -2981,12 +2997,12 @@ namespace System.Management int count = groupByPropertyList.Count; s = s + " by "; - for (int i=0; i= keyword.Length) && (0 == string.Compare (q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) + if ((q.Length >= keyword.Length) && (0 == string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) { string intervalString = null; bFound = false; ParseToken(ref q, keyword, null, ref bFound, ref intervalString); @@ -3053,19 +3069,19 @@ namespace System.Management w = q.Substring(0, i).Trim(); q = q.Remove(0, i); - string intervalString = null; bFound=false; + string intervalString = null; bFound = false; ParseToken(ref q, keyword, null, ref bFound, ref intervalString); groupWithinInterval = TimeSpan.FromSeconds(((IConvertible)intervalString).ToDouble(null)); //Find "By" subclause keyword = "by "; - if ((q.Length >= keyword.Length) && (0 == string.Compare (q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) + if ((q.Length >= keyword.Length) && (0 == string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) { q = q.Remove(0, keyword.Length); if (null != groupByPropertyList) - groupByPropertyList.Clear (); + groupByPropertyList.Clear(); else - groupByPropertyList = new StringCollection (); + groupByPropertyList = new StringCollection(); //get the property list while (true) @@ -3073,9 +3089,9 @@ namespace System.Management if ((i = q.IndexOf(',')) > 0) { tempProp = q.Substring(0, i); - q = q.Remove(0, i+1).TrimStart(null); + q = q.Remove(0, i + 1).TrimStart(null); tempProp = tempProp.Trim(); - if (tempProp.Length>0) + if (tempProp.Length > 0) groupByPropertyList.Add(tempProp); } else @@ -3098,7 +3114,7 @@ namespace System.Management //Find "Having" subclause keyword = "having "; bFound = false; - if ((q.Length >= keyword.Length) && (0 == string.Compare (q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) + if ((q.Length >= keyword.Length) && (0 == string.Compare(q, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) { //the rest until the end is assumed to be the having condition q = q.Remove(0, keyword.Length); @@ -3114,7 +3130,7 @@ namespace System.Management //Find "where" clause keyword = "where "; - if ((w.Length >= keyword.Length) && (0 == string.Compare (w, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) //where clause exists + if ((w.Length >= keyword.Length) && (0 == string.Compare(w, 0, keyword, 0, keyword.Length, StringComparison.OrdinalIgnoreCase))) //where clause exists { condition = w.Substring(keyword.Length); } @@ -3139,8 +3155,8 @@ namespace System.Management if (0 < count) { - strArray = new string [count]; - groupByPropertyList.CopyTo (strArray, 0); + strArray = new string[count]; + groupByPropertyList.CopyTo(strArray, 0); } } @@ -3214,20 +3230,20 @@ namespace System.Management if (value is EventQuery && destinationType == typeof(InstanceDescriptor)) { EventQuery obj = ((EventQuery)(value)); - ConstructorInfo ctor = typeof(EventQuery).GetConstructor(new Type[] {typeof(string)}); + ConstructorInfo ctor = typeof(EventQuery).GetConstructor(new Type[] { typeof(string) }); if (ctor != null) { - return new InstanceDescriptor(ctor, new object[] {obj.QueryString}); + return new InstanceDescriptor(ctor, new object[] { obj.QueryString }); } } if (value is ObjectQuery && destinationType == typeof(InstanceDescriptor)) { ObjectQuery obj = ((ObjectQuery)(value)); - ConstructorInfo ctor = typeof(ObjectQuery).GetConstructor(new Type[] {typeof(string)}); + ConstructorInfo ctor = typeof(ObjectQuery).GetConstructor(new Type[] { typeof(string) }); if (ctor != null) { - return new InstanceDescriptor(ctor, new object[] {obj.QueryString}); + return new InstanceDescriptor(ctor, new object[] { obj.QueryString }); } } return base.ConvertTo(context, culture, value, destinationType); diff --git a/src/libraries/System.Management/src/System/Management/ManagementScope.cs b/src/libraries/System.Management/src/System/Management/ManagementScope.cs index bc7bcd237c7..a0710354a11 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementScope.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementScope.cs @@ -16,7 +16,7 @@ namespace System.Management internal static class CompatSwitches { internal const string DotNetVersion = "v4.0.30319"; - private const string RegKeyLocation =@"SOFTWARE\Microsoft\.NETFramework\" + DotNetVersion; + private const string RegKeyLocation = @"SOFTWARE\Microsoft\.NETFramework\" + DotNetVersion; private static readonly object s_syncLock = new object(); private static int s_allowManagementObjectQI; @@ -44,40 +44,40 @@ namespace System.Management private static bool GetSwitchValueFromRegistry() { - RegistryKey s_switchesRegKey = null; - try - { - s_switchesRegKey = Registry.LocalMachine.OpenSubKey(RegKeyLocation); + RegistryKey s_switchesRegKey = null; + try + { + s_switchesRegKey = Registry.LocalMachine.OpenSubKey(RegKeyLocation); - if (s_switchesRegKey == null) - { - return false; - } + if (s_switchesRegKey == null) + { + return false; + } - return ((int)s_switchesRegKey.GetValue(c_WMIDisableCOMSecurity, -1 /* default */) == 1); - } + return ((int)s_switchesRegKey.GetValue(c_WMIDisableCOMSecurity, -1 /* default */) == 1); + } - // ignore exceptions so that we don't crash the process if we can't read the switch value - catch (Exception e) - { - if (e is StackOverflowException || - e is OutOfMemoryException || - e is System.Threading.ThreadAbortException || - e is AccessViolationException) - throw; - } - finally - { - // dispose of the key - if (s_switchesRegKey != null) - { - s_switchesRegKey.Dispose(); - } - } + // ignore exceptions so that we don't crash the process if we can't read the switch value + catch (Exception e) + { + if (e is StackOverflowException || + e is OutOfMemoryException || + e is System.Threading.ThreadAbortException || + e is AccessViolationException) + throw; + } + finally + { + // dispose of the key + if (s_switchesRegKey != null) + { + s_switchesRegKey.Dispose(); + } + } - // if for any reason we cannot retrieve the value of the switch from the Registry, - // fallback to 'false' which is the secure behavior - return false; + // if for any reason we cannot retrieve the value of the switch from the Registry, + // fallback to 'false' which is the secure behavior + return false; } } @@ -86,140 +86,140 @@ namespace System.Management internal delegate int ResetSecurity(IntPtr hToken); internal delegate int SetSecurity([In][Out] ref bool pNeedtoReset, [In][Out] ref IntPtr pHandle); internal delegate int BlessIWbemServices([MarshalAs(UnmanagedType.Interface)] IWbemServices pIUnknown, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In][MarshalAs(UnmanagedType.BStr)] string strUser, IntPtr password, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority, int impersonationLevel, int authenticationLevel); internal delegate int BlessIWbemServicesObject([MarshalAs(UnmanagedType.IUnknown)] object pIUnknown, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In][MarshalAs(UnmanagedType.BStr)] string strUser, IntPtr password, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority, int impersonationLevel, int authenticationLevel); - internal delegate int GetPropertyHandle(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszPropertyName, [Out] out int pType, [Out] out int plHandle); - internal delegate int WritePropertyValue(int vFunc, IntPtr pWbemClassObject, [In] int lHandle, [In] int lNumBytes, [In][MarshalAs(UnmanagedType.LPWStr)] string str); - internal delegate int GetQualifierSet(int vFunc, IntPtr pWbemClassObject, [Out] out IntPtr ppQualSet); - internal delegate int Get(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); - internal delegate int Put(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] ref object pVal, [In] int Type); - internal delegate int Delete(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName); - internal delegate int GetNames(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszQualifierName, [In] int lFlags, [In] ref object pQualifierVal, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)] out string[] pNames); - internal delegate int BeginEnumeration(int vFunc, IntPtr pWbemClassObject, [In] int lEnumFlags); - internal delegate int Next(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string strName, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); - internal delegate int EndEnumeration(int vFunc, IntPtr pWbemClassObject); - internal delegate int GetPropertyQualifierSet(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszProperty, [Out] out IntPtr ppQualSet); - internal delegate int Clone(int vFunc, IntPtr pWbemClassObject, [Out] out IntPtr ppCopy); - internal delegate int GetObjectText(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrObjectText); - internal delegate int SpawnDerivedClass(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out] out IntPtr ppNewClass); - internal delegate int SpawnInstance(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out] out IntPtr ppNewInstance); - internal delegate int CompareTo(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [In] IntPtr pCompareTo); - internal delegate int GetPropertyOrigin(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); - internal delegate int InheritsFrom(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string strAncestor); - internal delegate int GetMethod(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [Out]out IntPtr ppInSignature, [Out] out IntPtr ppOutSignature); - internal delegate int PutMethod(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] IntPtr pInSignature, [In] IntPtr pOutSignature); - internal delegate int DeleteMethod(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName); - internal delegate int BeginMethodEnumeration(int vFunc, IntPtr pWbemClassObject, [In] int lEnumFlags); - internal delegate int NextMethod(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrName, [Out] out IntPtr ppInSignature, [Out] out IntPtr ppOutSignature); - internal delegate int EndMethodEnumeration(int vFunc, IntPtr pWbemClassObject); - internal delegate int GetMethodQualifierSet(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszMethod, [Out] out IntPtr ppQualSet); - internal delegate int GetMethodOrigin(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszMethodName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); - internal delegate int QualifierSet_Get(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int plFlavor); - internal delegate int QualifierSet_Put(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] ref object pVal, [In] int lFlavor); - internal delegate int QualifierSet_Delete(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName); - internal delegate int QualifierSet_GetNames(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarEnum.VT_BSTR)] out string[] pNames); - internal delegate int QualifierSet_BeginEnumeration(int vFunc, IntPtr pWbemClassObject, [In] int lFlags); - internal delegate int QualifierSet_Next(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrName, [Out] out object pVal, [Out] out int plFlavor); - internal delegate int QualifierSet_EndEnumeration(int vFunc, IntPtr pWbemClassObject); - internal delegate int GetCurrentApartmentType(int vFunc, IntPtr pComThreadingInfo, [Out] out APTTYPE aptType); - internal delegate void VerifyClientKey(); - internal delegate int GetDemultiplexedStub([In, MarshalAs(UnmanagedType.IUnknown)]object pIUnknown, [In]bool isLocal, [Out, MarshalAs(UnmanagedType.IUnknown)]out object ppIUnknown); - internal delegate int CreateInstanceEnumWmi([In][MarshalAs(UnmanagedType.BStr)] string strFilter, - [In] int lFlags, - [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, - [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, - [In] int impLevel, - [In] int authnLevel, - [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, - [In]IntPtr strPassword, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority - ); - internal delegate int CreateClassEnumWmi([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, - [In] int lFlags, - [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, - [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, - [In] int impLevel, - [In] int authnLevel, - [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, - [In]IntPtr strPassword, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority - ); - internal delegate int ExecQueryWmi([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, - [In][MarshalAs(UnmanagedType.BStr)] string strQuery, - [In] int lFlags, - [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, - [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, - [In] int impLevel, - [In] int authnLevel, - [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, - [In]IntPtr strPassword, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority - ); - internal delegate int ExecNotificationQueryWmi( [In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, - [In][MarshalAs(UnmanagedType.BStr)] string strQuery, + internal delegate int GetPropertyHandle(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszPropertyName, [Out] out int pType, [Out] out int plHandle); + internal delegate int WritePropertyValue(int vFunc, IntPtr pWbemClassObject, [In] int lHandle, [In] int lNumBytes, [In][MarshalAs(UnmanagedType.LPWStr)] string str); + internal delegate int GetQualifierSet(int vFunc, IntPtr pWbemClassObject, [Out] out IntPtr ppQualSet); + internal delegate int Get(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); + internal delegate int Put(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] ref object pVal, [In] int Type); + internal delegate int Delete(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName); + internal delegate int GetNames(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszQualifierName, [In] int lFlags, [In] ref object pQualifierVal, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pNames); + internal delegate int BeginEnumeration(int vFunc, IntPtr pWbemClassObject, [In] int lEnumFlags); + internal delegate int Next(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [In][Out][MarshalAs(UnmanagedType.BStr)] ref string strName, [In][Out] ref object pVal, [In][Out] ref int pType, [In][Out] ref int plFlavor); + internal delegate int EndEnumeration(int vFunc, IntPtr pWbemClassObject); + internal delegate int GetPropertyQualifierSet(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszProperty, [Out] out IntPtr ppQualSet); + internal delegate int Clone(int vFunc, IntPtr pWbemClassObject, [Out] out IntPtr ppCopy); + internal delegate int GetObjectText(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrObjectText); + internal delegate int SpawnDerivedClass(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out] out IntPtr ppNewClass); + internal delegate int SpawnInstance(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out] out IntPtr ppNewInstance); + internal delegate int CompareTo(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [In] IntPtr pCompareTo); + internal delegate int GetPropertyOrigin(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); + internal delegate int InheritsFrom(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string strAncestor); + internal delegate int GetMethod(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [Out]out IntPtr ppInSignature, [Out] out IntPtr ppOutSignature); + internal delegate int PutMethod(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In] IntPtr pInSignature, [In] IntPtr pOutSignature); + internal delegate int DeleteMethod(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName); + internal delegate int BeginMethodEnumeration(int vFunc, IntPtr pWbemClassObject, [In] int lEnumFlags); + internal delegate int NextMethod(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrName, [Out] out IntPtr ppInSignature, [Out] out IntPtr ppOutSignature); + internal delegate int EndMethodEnumeration(int vFunc, IntPtr pWbemClassObject); + internal delegate int GetMethodQualifierSet(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszMethod, [Out] out IntPtr ppQualSet); + internal delegate int GetMethodOrigin(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszMethodName, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrClassName); + internal delegate int QualifierSet_Get(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] int lFlags, [In][Out] ref object pVal, [In][Out] ref int plFlavor); + internal delegate int QualifierSet_Put(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName, [In] ref object pVal, [In] int lFlavor); + internal delegate int QualifierSet_Delete(int vFunc, IntPtr pWbemClassObject, [In][MarshalAs(UnmanagedType.LPWStr)] string wszName); + internal delegate int QualifierSet_GetNames(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out][MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_BSTR)] out string[] pNames); + internal delegate int QualifierSet_BeginEnumeration(int vFunc, IntPtr pWbemClassObject, [In] int lFlags); + internal delegate int QualifierSet_Next(int vFunc, IntPtr pWbemClassObject, [In] int lFlags, [Out][MarshalAs(UnmanagedType.BStr)] out string pstrName, [Out] out object pVal, [Out] out int plFlavor); + internal delegate int QualifierSet_EndEnumeration(int vFunc, IntPtr pWbemClassObject); + internal delegate int GetCurrentApartmentType(int vFunc, IntPtr pComThreadingInfo, [Out] out APTTYPE aptType); + internal delegate void VerifyClientKey(); + internal delegate int GetDemultiplexedStub([In, MarshalAs(UnmanagedType.IUnknown)]object pIUnknown, [In]bool isLocal, [Out, MarshalAs(UnmanagedType.IUnknown)]out object ppIUnknown); + internal delegate int CreateInstanceEnumWmi([In][MarshalAs(UnmanagedType.BStr)] string strFilter, + [In] int lFlags, + [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, + [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, + [In] int impLevel, + [In] int authnLevel, + [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, + [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In]IntPtr strPassword, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority + ); + internal delegate int CreateClassEnumWmi([In][MarshalAs(UnmanagedType.BStr)] string strSuperclass, + [In] int lFlags, + [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, + [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, + [In] int impLevel, + [In] int authnLevel, + [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, + [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In]IntPtr strPassword, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority + ); + internal delegate int ExecQueryWmi([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, + [In][MarshalAs(UnmanagedType.BStr)] string strQuery, + [In] int lFlags, + [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, + [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, + [In] int impLevel, + [In] int authnLevel, + [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, + [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In]IntPtr strPassword, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority + ); + internal delegate int ExecNotificationQueryWmi([In][MarshalAs(UnmanagedType.BStr)] string strQueryLanguage, + [In][MarshalAs(UnmanagedType.BStr)] string strQuery, [In] int lFlags, - [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, - [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, + [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, + [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, [In] int impLevel, [In] int authnLevel, [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, - [In]IntPtr strPassword, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority + [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In]IntPtr strPassword, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority ); internal delegate int PutInstanceWmi([In] IntPtr pInst, [In] int lFlags, - [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, + [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult, [In] int impLevel, [In] int authnLevel, [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, - [In]IntPtr strPassword, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority + [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In]IntPtr strPassword, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority ); internal delegate int PutClassWmi([In] IntPtr pObject, [In] int lFlags, - [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, + [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, [In] IntPtr ppCallResult, [In] int impLevel, [In] int authnLevel, [In] [MarshalAs(UnmanagedType.Interface)] IWbemServices pCurrentNamespace, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, - [In]IntPtr strPassword, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority + [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In]IntPtr strPassword, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority ); internal delegate int CloneEnumWbemClassObject( - [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, + [Out][MarshalAs(UnmanagedType.Interface)] out IEnumWbemClassObject ppEnum, [In] int impLevel, [In] int authnLevel, [In] [MarshalAs(UnmanagedType.Interface)] IEnumWbemClassObject pCurrentEnumWbemClassObject, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, - [In]IntPtr strPassword, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority + [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In]IntPtr strPassword, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority ); internal delegate int ConnectServerWmi( - [In][MarshalAs(UnmanagedType.BStr)] string strNetworkResource, - [In][MarshalAs(UnmanagedType.BStr)] string strUser, + [In][MarshalAs(UnmanagedType.BStr)] string strNetworkResource, + [In][MarshalAs(UnmanagedType.BStr)] string strUser, [In] IntPtr strPassword, - [In][MarshalAs(UnmanagedType.BStr)] string strLocale, + [In][MarshalAs(UnmanagedType.BStr)] string strLocale, [In] int lSecurityFlags, - [In][MarshalAs(UnmanagedType.BStr)] string strAuthority, - [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, - [Out][MarshalAs(UnmanagedType.Interface)] out IWbemServices ppNamespace, + [In][MarshalAs(UnmanagedType.BStr)] string strAuthority, + [In][MarshalAs(UnmanagedType.Interface)] IWbemContext pCtx, + [Out][MarshalAs(UnmanagedType.Interface)] out IWbemServices ppNamespace, int impersonationLevel, int authenticationLevel); @@ -231,12 +231,12 @@ namespace System.Management // 'Apartment Type' returned by IComThreadingInfo::GetCurrentApartmentType() - internal enum APTTYPE + internal enum APTTYPE { APTTYPE_CURRENT = -1, APTTYPE_STA = 0, APTTYPE_MTA = 1, - APTTYPE_NA = 2, + APTTYPE_NA = 2, APTTYPE_MAINSTA = 3 } internal static ResetSecurity ResetSecurity_f; @@ -244,7 +244,7 @@ namespace System.Management internal static BlessIWbemServices BlessIWbemServices_f; internal static BlessIWbemServicesObject BlessIWbemServicesObject_f; internal static GetPropertyHandle GetPropertyHandle_f27; - internal static WritePropertyValue WritePropertyValue_f28; + internal static WritePropertyValue WritePropertyValue_f28; internal static GetQualifierSet GetQualifierSet_f; internal static Get Get_f; internal static Put Put_f; @@ -282,7 +282,7 @@ namespace System.Management internal static GetDemultiplexedStub GetDemultiplexedStub_f; internal static CreateInstanceEnumWmi CreateInstanceEnumWmi_f; internal static CreateClassEnumWmi CreateClassEnumWmi_f; - internal static ExecQueryWmi ExecQueryWmi_f; + internal static ExecQueryWmi ExecQueryWmi_f; internal static ExecNotificationQueryWmi ExecNotificationQueryWmi_f; internal static PutInstanceWmi PutInstanceWmi_f; internal static PutClassWmi PutClassWmi_f; @@ -311,7 +311,7 @@ namespace System.Management CompatSwitches.DotNetVersion, // The same value is hard coded on Environment.Version and quirks for WMI "wminet_utils.dll"); - IntPtr hModule = Interop.Kernel32.LoadLibrary(wminet_utilsPath); + IntPtr hModule = Interop.Kernel32.LoadLibrary(wminet_utilsPath); if (hModule == IntPtr.Zero) { // This is unlikely, so having the TypeInitializationException wrapping it is fine. @@ -484,9 +484,9 @@ namespace System.Management [TypeConverter(typeof(ManagementScopeConverter))] public class ManagementScope : ICloneable { - private ManagementPath validatedPath; - private IWbemServices wbemServices; - private ConnectionOptions options; + private ManagementPath validatedPath; + private IWbemServices wbemServices; + private ConnectionOptions options; internal event IdentifierChangedEventHandler IdentifierChanged; internal bool IsDefaulted; //used to tell whether the current scope has been created from the default //scope or not - this information is used to tell whether it can be overridden @@ -536,7 +536,7 @@ namespace System.Management } } - internal IWbemServices GetIWbemServices () + internal IWbemServices GetIWbemServices() { IWbemServices localCopy = wbemServices; //IWbemServices is always created in MTA context. Only if call is made through non MTA context we need to use IWbemServices in right context. @@ -564,7 +564,7 @@ namespace System.Management // fail if we are running under a local user account. The QI has to be done by // someone who is a member of the 'Everyone' group on the target machine, or DCOM // won't let the call through. - SecurityHandler securityHandler = GetSecurityHandler (); + SecurityHandler securityHandler = GetSecurityHandler(); securityHandler.SecureIUnknown(unknown); // Now, we can QI and secure the IWbemServices @@ -602,13 +602,14 @@ namespace System.Management } //Internal constructor - internal ManagementScope (ManagementPath path, IWbemServices wbemServices, + internal ManagementScope(ManagementPath path, IWbemServices wbemServices, ConnectionOptions options) { if (null != path) this.Path = path; - if (null != options) { + if (null != options) + { this.Options = options; } @@ -617,8 +618,8 @@ namespace System.Management this.wbemServices = wbemServices; } - internal ManagementScope (ManagementPath path, ManagementScope scope) - : this (path, (null != scope) ? scope.options : null) {} + internal ManagementScope(ManagementPath path, ManagementScope scope) + : this(path, (null != scope) ? scope.options : null) { } internal static ManagementScope _Clone(ManagementScope scope) { @@ -689,8 +690,8 @@ namespace System.Management /// Dim s As New ManagementScope() /// /// - public ManagementScope () : - this (new ManagementPath (ManagementPath.DefaultPath.Path)) + public ManagementScope() : + this(new ManagementPath(ManagementPath.DefaultPath.Path)) { //Flag that this scope uses the default path IsDefaulted = true; @@ -709,7 +710,7 @@ namespace System.Management /// Dim s As New ManagementScope(p) /// /// - public ManagementScope (ManagementPath path) : this(path, (ConnectionOptions)null) {} + public ManagementScope(ManagementPath path) : this(path, (ConnectionOptions)null) { } /// /// Initializes a new instance of the class representing the specified scope @@ -722,7 +723,7 @@ namespace System.Management /// Dim s As New ManagementScope("\\MyServer\root\default") /// /// - public ManagementScope (string path) : this(new ManagementPath(path), (ConnectionOptions)null) {} + public ManagementScope(string path) : this(new ManagementPath(path), (ConnectionOptions)null) { } /// /// Initializes a new instance of the class representing the specified scope path, /// with the specified options. @@ -741,7 +742,7 @@ namespace System.Management /// Dim s As New ManagementScope("\\MyServer\root\default", opt); /// /// - public ManagementScope (string path, ConnectionOptions options) : this (new ManagementPath(path), options) {} + public ManagementScope(string path, ConnectionOptions options) : this(new ManagementPath(path), options) { } /// /// Initializes a new instance of the class representing the specified scope path, @@ -765,7 +766,7 @@ namespace System.Management /// Dim s As New ManagementScope(p, opt) /// /// - public ManagementScope (ManagementPath path, ConnectionOptions options) + public ManagementScope(ManagementPath path, ConnectionOptions options) { if (null != path) this.prvpath = ManagementPath._Clone(path, new IdentifierChangedEventHandler(HandleIdentifierChange)); @@ -827,7 +828,7 @@ namespace System.Management HandleIdentifierChange(this, null); } else - throw new ArgumentNullException (nameof(value)); + throw new ArgumentNullException(nameof(value)); } } @@ -870,7 +871,7 @@ namespace System.Management HandleIdentifierChange(this, null); } else - throw new ArgumentNullException (nameof(value)); + throw new ArgumentNullException(nameof(value)); } } @@ -924,12 +925,12 @@ namespace System.Management /// Dim o As New ManagementObject(s, "Win32_LogicalDisk=""C:""", null) /// /// - public void Connect () + public void Connect() { - Initialize (); + Initialize(); } - internal void Initialize () + internal void Initialize() { //If the path is not set yet we can't do it if (null == prvpath) @@ -957,9 +958,9 @@ namespace System.Management // // Ensure we are able to trap exceptions from worker thread. // - ThreadDispatch disp = new ThreadDispatch ( new ThreadDispatch.ThreadWorkerMethodWithParam ( InitializeGuts ) ); + ThreadDispatch disp = new ThreadDispatch(new ThreadDispatch.ThreadWorkerMethodWithParam(InitializeGuts)); disp.Parameter = this; - disp.Start ( ); + disp.Start(); } else InitializeGuts(this); @@ -970,8 +971,8 @@ namespace System.Management private void InitializeGuts(object o) { - ManagementScope threadParam = (ManagementScope) o; - IWbemLocator loc = (IWbemLocator) new WbemLocator(); + ManagementScope threadParam = (ManagementScope)o; + IWbemLocator loc = (IWbemLocator)new WbemLocator(); IntPtr punk = IntPtr.Zero; if (null == threadParam.options) @@ -999,7 +1000,7 @@ namespace System.Management if (Environment.OSVersion.Platform == PlatformID.Win32NT) { - if ( ((Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor >= 1)) || (Environment.OSVersion.Version.Major >= 6) ) + if (((Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor >= 1)) || (Environment.OSVersion.Version.Major >= 6)) { threadParam.options.Flags |= (int)tag_WBEM_CONNECT_OPTIONS.WBEM_FLAG_CONNECT_USE_MAX_WAIT; } @@ -1007,11 +1008,11 @@ namespace System.Management try { - status = GetSecuredConnectHandler().ConnectNSecureIWbemServices(nsPath, ref threadParam.wbemServices); + status = GetSecuredConnectHandler().ConnectNSecureIWbemServices(nsPath, ref threadParam.wbemServices); } catch (COMException e) { - ManagementException.ThrowWithExtendedInfo (e); + ManagementException.ThrowWithExtendedInfo(e); } if ((status & 0xfffff000) == 0x80041000) @@ -1024,19 +1025,19 @@ namespace System.Management } } - internal SecurityHandler GetSecurityHandler () + internal SecurityHandler GetSecurityHandler() { return new SecurityHandler(this); } - internal SecuredConnectHandler GetSecuredConnectHandler () + internal SecuredConnectHandler GetSecuredConnectHandler() { return new SecuredConnectHandler(this); } - internal SecuredIEnumWbemClassObjectHandler GetSecuredIEnumWbemClassObjectHandler (IEnumWbemClassObject pEnumWbemClassObject) + internal SecuredIEnumWbemClassObjectHandler GetSecuredIEnumWbemClassObjectHandler(IEnumWbemClassObject pEnumWbemClassObject) { - return new SecuredIEnumWbemClassObjectHandler (this, pEnumWbemClassObject); + return new SecuredIEnumWbemClassObjectHandler(this, pEnumWbemClassObject); } - internal SecuredIWbemServicesHandler GetSecuredIWbemServicesHandler( IWbemServices pWbemServiecs) + internal SecuredIWbemServicesHandler GetSecuredIWbemServicesHandler(IWbemServices pWbemServiecs) { return new SecuredIWbemServicesHandler(this, pWbemServiecs); } @@ -1047,7 +1048,7 @@ namespace System.Management { private readonly IEnumWbemClassObject pEnumWbemClassObjectsecurityHelper; private readonly ManagementScope scope; - internal SecuredIEnumWbemClassObjectHandler (ManagementScope theScope, IEnumWbemClassObject pEnumWbemClassObject) + internal SecuredIEnumWbemClassObjectHandler(ManagementScope theScope, IEnumWbemClassObject pEnumWbemClassObject) { this.scope = theScope; pEnumWbemClassObjectsecurityHelper = pEnumWbemClassObject; @@ -1058,22 +1059,22 @@ namespace System.Management status = pEnumWbemClassObjectsecurityHelper.Reset_(); return status; } - internal int Next_( int lTimeout, uint uCount, IWbemClassObject_DoNotMarshal[] ppOutParams, ref uint puReturned) + internal int Next_(int lTimeout, uint uCount, IWbemClassObject_DoNotMarshal[] ppOutParams, ref uint puReturned) { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pEnumWbemClassObjectsecurityHelper.Next_( lTimeout, uCount, ppOutParams, out puReturned); + status = pEnumWbemClassObjectsecurityHelper.Next_(lTimeout, uCount, ppOutParams, out puReturned); return status; } - internal int NextAsync_( uint uCount, IWbemObjectSink pSink) + internal int NextAsync_(uint uCount, IWbemObjectSink pSink) { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pEnumWbemClassObjectsecurityHelper.NextAsync_(uCount, pSink); + status = pEnumWbemClassObjectsecurityHelper.NextAsync_(uCount, pSink); return status; } - internal int Clone_(ref IEnumWbemClassObject ppEnum) + internal int Clone_(ref IEnumWbemClassObject ppEnum) { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( null != scope) + if (null != scope) { IntPtr password = scope.Options.GetPassword(); status = WmiNetUtilsHelper.CloneEnumWbemClassObject_f( @@ -1088,10 +1089,10 @@ namespace System.Management } return status; } - internal int Skip_( int lTimeout, uint nCount) + internal int Skip_(int lTimeout, uint nCount) { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pEnumWbemClassObjectsecurityHelper.Skip_(lTimeout, nCount); + status = pEnumWbemClassObjectsecurityHelper.Skip_(lTimeout, nCount); return status; } } @@ -1101,14 +1102,14 @@ namespace System.Management { private readonly ManagementScope scope; - internal SecuredConnectHandler (ManagementScope theScope) + internal SecuredConnectHandler(ManagementScope theScope) { this.scope = theScope; } - internal int ConnectNSecureIWbemServices(string path, ref IWbemServices pServices) + internal int ConnectNSecureIWbemServices(string path, ref IWbemServices pServices) { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( null != scope ) + if (null != scope) { bool needToReset = false; IntPtr handle = IntPtr.Zero; @@ -1151,7 +1152,7 @@ namespace System.Management { private readonly IWbemServices pWbemServiecsSecurityHelper; private readonly ManagementScope scope; - internal SecuredIWbemServicesHandler (ManagementScope theScope, IWbemServices pWbemServiecs) + internal SecuredIWbemServicesHandler(ManagementScope theScope, IWbemServices pWbemServiecs) { this.scope = theScope; pWbemServiecsSecurityHelper = pWbemServiecs; @@ -1163,38 +1164,38 @@ namespace System.Management return status; } - internal int CancelAsyncCall_( IWbemObjectSink pSink) + internal int CancelAsyncCall_(IWbemObjectSink pSink) { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; status = pWbemServiecsSecurityHelper.CancelAsyncCall_(pSink); return status; } - internal int QueryObjectSink_( int lFlags, ref IWbemObjectSink ppResponseHandler) + internal int QueryObjectSink_(int lFlags, ref IWbemObjectSink ppResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.QueryObjectSink_(lFlags, out ppResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.QueryObjectSink_(lFlags, out ppResponseHandler); return status; } - internal int GetObject_(string strObjectPath, int lFlags, IWbemContext pCtx, ref IWbemClassObjectFreeThreaded ppObject, IntPtr ppCallResult) + internal int GetObject_(string strObjectPath, int lFlags, IWbemContext pCtx, ref IWbemClassObjectFreeThreaded ppObject, IntPtr ppCallResult) { - //It is assumed that caller always passes ppCallResult as IntPtr.Zero. + //It is assumed that caller always passes ppCallResult as IntPtr.Zero. //If it changes let this call go through wminet_utils.dll. Check implementation of CreateInstanceEnum_ for more information. int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( !object.ReferenceEquals(ppCallResult, IntPtr.Zero) ) + if (!object.ReferenceEquals(ppCallResult, IntPtr.Zero)) status = pWbemServiecsSecurityHelper.GetObject_(strObjectPath, lFlags, pCtx, out ppObject, ppCallResult); return status; } internal int GetObjectAsync_(string strObjectPath, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.GetObjectAsync_(strObjectPath, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.GetObjectAsync_(strObjectPath, lFlags, pCtx, pResponseHandler); return status; } - internal int PutClass_(IWbemClassObjectFreeThreaded pObject, int lFlags, IWbemContext pCtx, IntPtr ppCallResult) + internal int PutClass_(IWbemClassObjectFreeThreaded pObject, int lFlags, IWbemContext pCtx, IntPtr ppCallResult) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( null != scope) + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + if (null != scope) { IntPtr password = scope.Options.GetPassword(); status = WmiNetUtilsHelper.PutClassWmi_f(pObject, @@ -1211,31 +1212,31 @@ namespace System.Management } return status; } - internal int PutClassAsync_(IWbemClassObjectFreeThreaded pObject, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) + internal int PutClassAsync_(IWbemClassObjectFreeThreaded pObject, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.PutClassAsync_(pObject, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.PutClassAsync_(pObject, lFlags, pCtx, pResponseHandler); return status; } - internal int DeleteClass_( string strClass, int lFlags, IWbemContext pCtx, IntPtr ppCallResult) - { - //It is assumed that caller always passes ppCallResult as IntPtr.Zero. + internal int DeleteClass_(string strClass, int lFlags, IWbemContext pCtx, IntPtr ppCallResult) + { + //It is assumed that caller always passes ppCallResult as IntPtr.Zero. //If it changes let this call go through wminet_utils.dll. Check implementation of CreateInstanceEnum_ for more information. int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( !object.ReferenceEquals(ppCallResult, IntPtr.Zero) ) + if (!object.ReferenceEquals(ppCallResult, IntPtr.Zero)) status = pWbemServiecsSecurityHelper.DeleteClass_(strClass, lFlags, pCtx, ppCallResult); return status; - } - internal int DeleteClassAsync_(string strClass, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) + } + internal int DeleteClassAsync_(string strClass, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.DeleteClassAsync_(strClass, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.DeleteClassAsync_(strClass, lFlags, pCtx, pResponseHandler); return status; } - internal int CreateClassEnum_(string strSuperClass, int lFlags, IWbemContext pCtx, ref IEnumWbemClassObject ppEnum) - { + internal int CreateClassEnum_(string strSuperClass, int lFlags, IWbemContext pCtx, ref IEnumWbemClassObject ppEnum) + { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( null != scope ) + if (null != scope) { IntPtr password = scope.Options.GetPassword(); status = WmiNetUtilsHelper.CreateClassEnumWmi_f(strSuperClass, @@ -1251,17 +1252,17 @@ namespace System.Management System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(password); } return status; - } - internal int CreateClassEnumAsync_(string strSuperClass, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) + } + internal int CreateClassEnumAsync_(string strSuperClass, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.CreateClassEnumAsync_(strSuperClass, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.CreateClassEnumAsync_(strSuperClass, lFlags, pCtx, pResponseHandler); return status; } - internal int PutInstance_( IWbemClassObjectFreeThreaded pInst, int lFlags, IWbemContext pCtx, IntPtr ppCallResult) - { + internal int PutInstance_(IWbemClassObjectFreeThreaded pInst, int lFlags, IWbemContext pCtx, IntPtr ppCallResult) + { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( null != scope) + if (null != scope) { IntPtr password = scope.Options.GetPassword(); status = WmiNetUtilsHelper.PutInstanceWmi_f(pInst, @@ -1277,33 +1278,33 @@ namespace System.Management System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(password); } return status; - } - internal int PutInstanceAsync_(IWbemClassObjectFreeThreaded pInst, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) + } + internal int PutInstanceAsync_(IWbemClassObjectFreeThreaded pInst, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.PutInstanceAsync_(pInst, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.PutInstanceAsync_(pInst, lFlags, pCtx, pResponseHandler); return status; } - internal int DeleteInstance_(string strObjectPath, int lFlags, IWbemContext pCtx, IntPtr ppCallResult) - { - //It is assumed that caller always passes ppCallResult as IntPtr.Zero. + internal int DeleteInstance_(string strObjectPath, int lFlags, IWbemContext pCtx, IntPtr ppCallResult) + { + //It is assumed that caller always passes ppCallResult as IntPtr.Zero. //If it changes let this call go through wminet_utils.dll. Check implementation of CreateInstanceEnum_ for more information. int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( !object.ReferenceEquals(ppCallResult, IntPtr.Zero) ) + if (!object.ReferenceEquals(ppCallResult, IntPtr.Zero)) status = pWbemServiecsSecurityHelper.DeleteInstance_(strObjectPath, lFlags, pCtx, ppCallResult); return status; - } - internal int DeleteInstanceAsync_(string strObjectPath, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) + } + internal int DeleteInstanceAsync_(string strObjectPath, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.DeleteInstanceAsync_(strObjectPath, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.DeleteInstanceAsync_(strObjectPath, lFlags, pCtx, pResponseHandler); return status; } - internal int CreateInstanceEnum_(string strFilter, int lFlags, IWbemContext pCtx, ref IEnumWbemClassObject ppEnum) - { + internal int CreateInstanceEnum_(string strFilter, int lFlags, IWbemContext pCtx, ref IEnumWbemClassObject ppEnum) + { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( null != scope) + if (null != scope) { IntPtr password = scope.Options.GetPassword(); status = WmiNetUtilsHelper.CreateInstanceEnumWmi_f(strFilter, @@ -1319,17 +1320,17 @@ namespace System.Management System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(password); } return status; - } - internal int CreateInstanceEnumAsync_(string strFilter, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) + } + internal int CreateInstanceEnumAsync_(string strFilter, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.CreateInstanceEnumAsync_(strFilter, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.CreateInstanceEnumAsync_(strFilter, lFlags, pCtx, pResponseHandler); return status; } - internal int ExecQuery_(string strQueryLanguage, string strQuery, int lFlags, IWbemContext pCtx, ref IEnumWbemClassObject ppEnum) - { + internal int ExecQuery_(string strQueryLanguage, string strQuery, int lFlags, IWbemContext pCtx, ref IEnumWbemClassObject ppEnum) + { int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( null != scope) + if (null != scope) { IntPtr password = scope.Options.GetPassword(); status = WmiNetUtilsHelper.ExecQueryWmi_f(strQueryLanguage, @@ -1346,17 +1347,17 @@ namespace System.Management System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(password); } return status; - } - internal int ExecQueryAsync_(string strQueryLanguage, string strQuery, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) + } + internal int ExecQueryAsync_(string strQueryLanguage, string strQuery, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.ExecQueryAsync_(strQueryLanguage, strQuery, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.ExecQueryAsync_(strQueryLanguage, strQuery, lFlags, pCtx, pResponseHandler); return status; } - internal int ExecNotificationQuery_(string strQueryLanguage, string strQuery, int lFlags, IWbemContext pCtx, ref IEnumWbemClassObject ppEnum) + internal int ExecNotificationQuery_(string strQueryLanguage, string strQuery, int lFlags, IWbemContext pCtx, ref IEnumWbemClassObject ppEnum) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( null != scope) + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + if (null != scope) { IntPtr password = scope.Options.GetPassword(); status = WmiNetUtilsHelper.ExecNotificationQueryWmi_f(strQueryLanguage, @@ -1374,25 +1375,25 @@ namespace System.Management } return status; } - internal int ExecNotificationQueryAsync_(string strQueryLanguage, string strQuery, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) + internal int ExecNotificationQueryAsync_(string strQueryLanguage, string strQuery, int lFlags, IWbemContext pCtx, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.ExecNotificationQueryAsync_(strQueryLanguage, strQuery, lFlags, pCtx, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.ExecNotificationQueryAsync_(strQueryLanguage, strQuery, lFlags, pCtx, pResponseHandler); return status; } - internal int ExecMethod_( string strObjectPath, string strMethodName, int lFlags, IWbemContext pCtx, IWbemClassObjectFreeThreaded pInParams, ref IWbemClassObjectFreeThreaded ppOutParams, IntPtr ppCallResult) - { + internal int ExecMethod_(string strObjectPath, string strMethodName, int lFlags, IWbemContext pCtx, IWbemClassObjectFreeThreaded pInParams, ref IWbemClassObjectFreeThreaded ppOutParams, IntPtr ppCallResult) + { //It is assumed that caller always passes ppCallResult as IntPtr.Zero. //If it changes let this call go through wminet_utils.dll. Check implementation of CreateInstanceEnum_ for more information. int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - if ( !object.ReferenceEquals(ppCallResult, IntPtr.Zero) ) + if (!object.ReferenceEquals(ppCallResult, IntPtr.Zero)) status = pWbemServiecsSecurityHelper.ExecMethod_(strObjectPath, strMethodName, lFlags, pCtx, pInParams, out ppOutParams, ppCallResult); return status; - } - internal int ExecMethodAsync_(string strObjectPath, string strMethodName, int lFlags, IWbemContext pCtx, IWbemClassObjectFreeThreaded pInParams, IWbemObjectSink pResponseHandler) + } + internal int ExecMethodAsync_(string strObjectPath, string strMethodName, int lFlags, IWbemContext pCtx, IWbemClassObjectFreeThreaded pInParams, IWbemObjectSink pResponseHandler) { - int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; - status = pWbemServiecsSecurityHelper.ExecMethodAsync_(strObjectPath, strMethodName, lFlags, pCtx, pInParams, pResponseHandler); + int status = (int)tag_WBEMSTATUS.WBEM_E_FAILED; + status = pWbemServiecsSecurityHelper.ExecMethodAsync_(strObjectPath, strMethodName, lFlags, pCtx, pInParams, pResponseHandler); return status; } } @@ -1404,7 +1405,7 @@ namespace System.Management private readonly IntPtr handle; private readonly ManagementScope scope; - internal SecurityHandler (ManagementScope theScope) + internal SecurityHandler(ManagementScope theScope) { this.scope = theScope; if (null != scope) @@ -1416,7 +1417,7 @@ namespace System.Management } } - internal void Reset () + internal void Reset() { if (needToReset) { @@ -1424,14 +1425,14 @@ namespace System.Management if (null != scope) { - WmiNetUtilsHelper.ResetSecurity_f ( handle); + WmiNetUtilsHelper.ResetSecurity_f(handle); } } } - internal void Secure (IWbemServices services) + internal void Secure(IWbemServices services) { if (null != scope) { @@ -1546,10 +1547,10 @@ namespace System.Management if (value is ManagementScope && destinationType == typeof(InstanceDescriptor)) { ManagementScope obj = ((ManagementScope)(value)); - ConstructorInfo ctor = typeof(ManagementScope).GetConstructor(new Type[] {typeof(string)}); + ConstructorInfo ctor = typeof(ManagementScope).GetConstructor(new Type[] { typeof(string) }); if (ctor != null) { - return new InstanceDescriptor(ctor, new object[] {obj.Path.Path}); + return new InstanceDescriptor(ctor, new object[] { obj.Path.Path }); } } return base.ConvertTo(context, culture, value, destinationType); diff --git a/src/libraries/System.Management/src/System/Management/Method.cs b/src/libraries/System.Management/src/System/Management/Method.cs index 4b4930aa49e..a5e63646b8d 100644 --- a/src/libraries/System.Management/src/System/Management/Method.cs +++ b/src/libraries/System.Management/src/System/Management/Method.cs @@ -170,7 +170,8 @@ namespace System.Management get { RefreshMethodInfo(); - return (null == wmiInParams) ? null : new ManagementBaseObject(wmiInParams); } + return (null == wmiInParams) ? null : new ManagementBaseObject(wmiInParams); + } } /// @@ -196,7 +197,8 @@ namespace System.Management get { RefreshMethodInfo(); - return (null == wmiOutParams) ? null : new ManagementBaseObject(wmiOutParams); } + return (null == wmiOutParams) ? null : new ManagementBaseObject(wmiOutParams); + } } /// diff --git a/src/libraries/System.Management/src/System/Management/MethodSet.cs b/src/libraries/System.Management/src/System/Management/MethodSet.cs index 15a720ac724..34cbc1594fe 100644 --- a/src/libraries/System.Management/src/System/Management/MethodSet.cs +++ b/src/libraries/System.Management/src/System/Management/MethodSet.cs @@ -125,7 +125,9 @@ namespace System.Management /// if the object is synchronized; /// otherwise, . /// - public bool IsSynchronized { get { return false; } + public bool IsSynchronized + { + get { return false; } } /// @@ -134,7 +136,9 @@ namespace System.Management /// /// The object to be used for synchronization. /// - public object SyncRoot { get { return this; } + public object SyncRoot + { + get { return this; } } /// @@ -304,7 +308,7 @@ namespace System.Management { get { - return new MethodData(parent, (string)en.Current); + return new MethodData(parent, (string)en.Current); } } @@ -312,7 +316,7 @@ namespace System.Management /// Moves to the next element in the enumeration. /// /// if the enumerator was successfully advanced to the next method; if the enumerator has passed the end of the collection. - public bool MoveNext () + public bool MoveNext() { return en.MoveNext(); } @@ -342,7 +346,7 @@ namespace System.Management get { if (null == methodName) - throw new ArgumentNullException (nameof(methodName)); + throw new ArgumentNullException(nameof(methodName)); return new MethodData(parent, methodName); } diff --git a/src/libraries/System.Management/src/System/Management/Property.cs b/src/libraries/System.Management/src/System/Management/Property.cs index cf34ccb25d8..eb8a14ae562 100644 --- a/src/libraries/System.Management/src/System/Management/Property.cs +++ b/src/libraries/System.Management/src/System/Management/Property.cs @@ -80,7 +80,7 @@ namespace System.Management public class PropertyData { private readonly ManagementBaseObject parent; //need access to IWbemClassObject pointer to be able to refresh property info - //and get property qualifiers + //and get property qualifiers private readonly string propertyName; private object propertyValue; @@ -134,13 +134,15 @@ namespace System.Management /// public object Value { - get { + get + { RefreshPropertyInfo(); return ValueTypeSafety.GetSafeObject(MapWmiValueToValue(propertyValue, (CimType)(propertyType & ~(int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY), (0 != (propertyType & (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY)))); } - set { + set + { RefreshPropertyInfo(); object newValue = MapValueToWmiValue(value, @@ -161,7 +163,7 @@ namespace System.Management // whether this property is a key or not, we just do it for any property else if (parent.GetType() == typeof(ManagementObject)) - ((ManagementObject)parent).Path.UpdateRelativePath((string)parent["__RELPATH"]); + ((ManagementObject)parent).Path.UpdateRelativePath((string)parent["__RELPATH"]); } } @@ -173,8 +175,10 @@ namespace System.Management /// A value /// representing the CIM type of the property. /// - public CimType Type { - get { + public CimType Type + { + get + { RefreshPropertyInfo(); return (CimType)(propertyType & ~(int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY); } @@ -189,9 +193,11 @@ namespace System.Management /// public bool IsLocal { - get { + get + { RefreshPropertyInfo(); - return ((propertyFlavor & (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_ORIGIN_PROPAGATED) != 0) ? false : true; } + return ((propertyFlavor & (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_ORIGIN_PROPAGATED) != 0) ? false : true; + } } /// @@ -202,9 +208,11 @@ namespace System.Management /// public bool IsArray { - get { + get + { RefreshPropertyInfo(); - return ((propertyType & (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY) != 0); } + return ((propertyType & (int)tag_CIMTYPE_ENUMERATION.CIM_FLAG_ARRAY) != 0); + } } /// @@ -216,7 +224,8 @@ namespace System.Management /// public string Origin { - get { + get + { string className = null; int status = parent.wbemObject.GetPropertyOrigin_(propertyName, out className); @@ -244,23 +253,26 @@ namespace System.Management /// public QualifierDataCollection Qualifiers { - get { + get + { if (qualifiers == null) qualifiers = new QualifierDataCollection(parent, propertyName, QualifierType.PropertyQualifier); return qualifiers; } } - internal long NullEnumValue - { - get { - return propertyNullEnumValue; - } + internal long NullEnumValue + { + get + { + return propertyNullEnumValue; + } - set { - propertyNullEnumValue = value; - } - } + set + { + propertyNullEnumValue = value; + } + } /// /// Takes a property value returned from WMI and maps it to an @@ -283,52 +295,52 @@ namespace System.Management switch (type) { case CimType.UInt16: - val = new ushort [length]; + val = new ushort[length]; for (int i = 0; i < length; i++) - ((ushort[])val) [i] = (ushort)((int)(wmiValueArray.GetValue(i))); + ((ushort[])val)[i] = (ushort)((int)(wmiValueArray.GetValue(i))); break; case CimType.UInt32: - val = new uint [length]; + val = new uint[length]; for (int i = 0; i < length; i++) ((uint[])val)[i] = (uint)((int)(wmiValueArray.GetValue(i))); break; case CimType.UInt64: - val = new ulong [length]; + val = new ulong[length]; for (int i = 0; i < length; i++) - ((ulong[])val) [i] = Convert.ToUInt64((string)(wmiValueArray.GetValue(i)), (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(ulong))); + ((ulong[])val)[i] = Convert.ToUInt64((string)(wmiValueArray.GetValue(i)), (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(ulong))); break; case CimType.SInt8: - val = new sbyte [length]; + val = new sbyte[length]; for (int i = 0; i < length; i++) - ((sbyte[])val) [i] = (sbyte)((short)(wmiValueArray.GetValue(i))); + ((sbyte[])val)[i] = (sbyte)((short)(wmiValueArray.GetValue(i))); break; case CimType.SInt64: - val = new long [length]; + val = new long[length]; for (int i = 0; i < length; i++) - ((long[])val) [i] = Convert.ToInt64((string)(wmiValueArray.GetValue(i)), (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(long))); + ((long[])val)[i] = Convert.ToInt64((string)(wmiValueArray.GetValue(i)), (IFormatProvider)CultureInfo.CurrentCulture.GetFormat(typeof(long))); break; case CimType.Char16: - val = new char [length]; + val = new char[length]; for (int i = 0; i < length; i++) - ((char[])val) [i] = (char)((short)(wmiValueArray.GetValue(i))); + ((char[])val)[i] = (char)((short)(wmiValueArray.GetValue(i))); break; case CimType.Object: - val = new ManagementBaseObject [length]; + val = new ManagementBaseObject[length]; for (int i = 0; i < length; i++) - ((ManagementBaseObject[])val) [i] = new ManagementBaseObject(new IWbemClassObjectFreeThreaded(Marshal.GetIUnknownForObject(wmiValueArray.GetValue(i)))); + ((ManagementBaseObject[])val)[i] = new ManagementBaseObject(new IWbemClassObjectFreeThreaded(Marshal.GetIUnknownForObject(wmiValueArray.GetValue(i)))); break; default: @@ -375,7 +387,7 @@ namespace System.Management switch (type) { case CimType.SInt8: - wmiValue = new short [length]; + wmiValue = new short[length]; for (int i = 0; i < length; i++) ((short[])(wmiValue))[i] = (short)Convert.ToSByte(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(sbyte))); break; @@ -385,7 +397,7 @@ namespace System.Management wmiValue = val; else { - wmiValue = new byte [length]; + wmiValue = new byte[length]; for (int i = 0; i < length; i++) ((byte[])wmiValue)[i] = Convert.ToByte(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(byte))); } @@ -396,14 +408,14 @@ namespace System.Management wmiValue = val; else { - wmiValue = new short [length]; + wmiValue = new short[length]; for (int i = 0; i < length; i++) ((short[])(wmiValue))[i] = Convert.ToInt16(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(short))); } break; case CimType.UInt16: - wmiValue = new int [length]; + wmiValue = new int[length]; for (int i = 0; i < length; i++) ((int[])(wmiValue))[i] = (int)(Convert.ToUInt16(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(ushort)))); break; @@ -413,26 +425,26 @@ namespace System.Management wmiValue = val; else { - wmiValue = new int [length]; + wmiValue = new int[length]; for (int i = 0; i < length; i++) ((int[])(wmiValue))[i] = Convert.ToInt32(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(int))); } break; case CimType.UInt32: - wmiValue = new int [length]; + wmiValue = new int[length]; for (int i = 0; i < length; i++) ((int[])(wmiValue))[i] = (int)(Convert.ToUInt32(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(uint)))); break; case CimType.SInt64: - wmiValue = new string [length]; + wmiValue = new string[length]; for (int i = 0; i < length; i++) ((string[])(wmiValue))[i] = (Convert.ToInt64(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(long)))).ToString((IFormatProvider)culInfo.GetFormat(typeof(long))); break; case CimType.UInt64: - wmiValue = new string [length]; + wmiValue = new string[length]; for (int i = 0; i < length; i++) ((string[])(wmiValue))[i] = (Convert.ToUInt64(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(ulong)))).ToString((IFormatProvider)culInfo.GetFormat(typeof(ulong))); break; @@ -442,7 +454,7 @@ namespace System.Management wmiValue = val; else { - wmiValue = new float [length]; + wmiValue = new float[length]; for (int i = 0; i < length; i++) ((float[])(wmiValue))[i] = Convert.ToSingle(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(float))); } @@ -453,14 +465,14 @@ namespace System.Management wmiValue = val; else { - wmiValue = new double [length]; + wmiValue = new double[length]; for (int i = 0; i < length; i++) ((double[])(wmiValue))[i] = Convert.ToDouble(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(double))); } break; case CimType.Char16: - wmiValue = new short [length]; + wmiValue = new short[length]; for (int i = 0; i < length; i++) ((short[])(wmiValue))[i] = (short)Convert.ToChar(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(char))); break; @@ -472,7 +484,7 @@ namespace System.Management wmiValue = val; else { - wmiValue = new string [length]; + wmiValue = new string[length]; for (int i = 0; i < length; i++) ((string[])(wmiValue))[i] = (valArray.GetValue(i)).ToString(); } @@ -483,7 +495,7 @@ namespace System.Management wmiValue = val; else { - wmiValue = new bool [length]; + wmiValue = new bool[length]; for (int i = 0; i < length; i++) ((bool[])(wmiValue))[i] = Convert.ToBoolean(valArray.GetValue(i), (IFormatProvider)culInfo.GetFormat(typeof(bool))); } @@ -564,7 +576,7 @@ namespace System.Management case CimType.Object: if (val is ManagementBaseObject) { - wmiValue = Marshal.GetObjectForIUnknown(((ManagementBaseObject) val).wbemObject); + wmiValue = Marshal.GetObjectForIUnknown(((ManagementBaseObject)val).wbemObject); } else { @@ -609,7 +621,7 @@ namespace System.Management wmiValue = new short[length]; for (int i = 0; i < length; i++) - ((short[])wmiValue) [i] = ((IConvertible)((byte)(arrayValue[i]))).ToInt16(null); + ((short[])wmiValue)[i] = ((IConvertible)((byte)(arrayValue[i]))).ToInt16(null); } else if (elementType == typeof(sbyte)) { @@ -619,7 +631,7 @@ namespace System.Management wmiValue = new short[length]; for (int i = 0; i < length; i++) - ((short[])wmiValue) [i] = ((IConvertible)((sbyte)(arrayValue[i]))).ToInt16(null); + ((short[])wmiValue)[i] = ((IConvertible)((sbyte)(arrayValue[i]))).ToInt16(null); } else if (elementType == typeof(bool)) { @@ -634,7 +646,7 @@ namespace System.Management wmiValue = new int[length]; for (int i = 0; i < length; i++) - ((int[])wmiValue) [i] = ((IConvertible)((ushort)(arrayValue[i]))).ToInt32(null); + ((int[])wmiValue)[i] = ((IConvertible)((ushort)(arrayValue[i]))).ToInt32(null); } else if (elementType == typeof(short)) { @@ -654,7 +666,7 @@ namespace System.Management wmiValue = new string[length]; for (int i = 0; i < length; i++) - ((string[])wmiValue) [i] = ((uint)(arrayValue[i])).ToString((IFormatProvider)culInfo.GetFormat(typeof(uint))); + ((string[])wmiValue)[i] = ((uint)(arrayValue[i])).ToString((IFormatProvider)culInfo.GetFormat(typeof(uint))); } else if (elementType == typeof(ulong)) { @@ -664,7 +676,7 @@ namespace System.Management wmiValue = new string[length]; for (int i = 0; i < length; i++) - ((string[])wmiValue) [i] = ((ulong)(arrayValue[i])).ToString((IFormatProvider)culInfo.GetFormat(typeof(ulong))); + ((string[])wmiValue)[i] = ((ulong)(arrayValue[i])).ToString((IFormatProvider)culInfo.GetFormat(typeof(ulong))); } else if (elementType == typeof(long)) { @@ -674,7 +686,7 @@ namespace System.Management wmiValue = new string[length]; for (int i = 0; i < length; i++) - ((string[])wmiValue) [i] = ((long)(arrayValue[i])).ToString((IFormatProvider)culInfo.GetFormat(typeof(long))); + ((string[])wmiValue)[i] = ((long)(arrayValue[i])).ToString((IFormatProvider)culInfo.GetFormat(typeof(long))); } else if (elementType == typeof(float)) { @@ -694,7 +706,7 @@ namespace System.Management wmiValue = new short[length]; for (int i = 0; i < length; i++) - ((short[])wmiValue) [i] = ((IConvertible)((char)(arrayValue[i]))).ToInt16(null); + ((short[])wmiValue)[i] = ((IConvertible)((char)(arrayValue[i]))).ToInt16(null); } } else @@ -799,7 +811,7 @@ namespace System.Management if (val is ManagementBaseObject) { type = CimType.Object; - wmiValue = Marshal.GetObjectForIUnknown(((ManagementBaseObject) val).wbemObject); + wmiValue = Marshal.GetObjectForIUnknown(((ManagementBaseObject)val).wbemObject); } } } diff --git a/src/libraries/System.Management/src/System/Management/PropertySet.cs b/src/libraries/System.Management/src/System/Management/PropertySet.cs index 5c14691c37d..d9564f07ba3 100644 --- a/src/libraries/System.Management/src/System/Management/PropertySet.cs +++ b/src/libraries/System.Management/src/System/Management/PropertySet.cs @@ -71,7 +71,8 @@ namespace System.Management /// public int Count { - get { + get + { string[] propertyNames = null; object qualVal = null; int flag; if (isSystem) @@ -102,7 +103,9 @@ namespace System.Management /// if the object is synchronized; /// otherwise, . /// - public bool IsSynchronized { get { return false; } + public bool IsSynchronized + { + get { return false; } } /// @@ -111,7 +114,9 @@ namespace System.Management /// /// The object to be used for synchronization. /// - public object SyncRoot { get { return this; } + public object SyncRoot + { + get { return this; } } /// @@ -280,7 +285,8 @@ namespace System.Management /// public PropertyData Current { - get { + get + { if ((index == -1) || (index == propertyNames.Length)) throw new InvalidOperationException(); else @@ -340,7 +346,8 @@ namespace System.Management /// public virtual PropertyData this[string propertyName] { - get { + get + { if (null == propertyName) throw new ArgumentNullException(nameof(propertyName)); diff --git a/src/libraries/System.Management/src/System/Management/Qualifier.cs b/src/libraries/System.Management/src/System/Management/Qualifier.cs index 1e6080b548d..535c37d101b 100644 --- a/src/libraries/System.Management/src/System/Management/Qualifier.cs +++ b/src/libraries/System.Management/src/System/Management/Qualifier.cs @@ -107,25 +107,25 @@ namespace System.Management if (elementType == typeof(int)) { - wmiValue = new int [length]; + wmiValue = new int[length]; for (int i = 0; i < length; i++) ((int[])(wmiValue))[i] = Convert.ToInt32(valArray.GetValue(i), (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(int))); } else if (elementType == typeof(double)) { - wmiValue = new double [length]; + wmiValue = new double[length]; for (int i = 0; i < length; i++) ((double[])(wmiValue))[i] = Convert.ToDouble(valArray.GetValue(i), (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(double))); } else if (elementType == typeof(string)) { - wmiValue = new string [length]; + wmiValue = new string[length]; for (int i = 0; i < length; i++) ((string[])(wmiValue))[i] = (valArray.GetValue(i)).ToString(); } else if (elementType == typeof(bool)) { - wmiValue = new bool [length]; + wmiValue = new bool[length]; for (int i = 0; i < length; i++) ((bool[])(wmiValue))[i] = Convert.ToBoolean(valArray.GetValue(i), (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(bool))); } @@ -168,11 +168,13 @@ namespace System.Management /// public object Value { - get { + get + { RefreshQualifierInfo(); return ValueTypeSafety.GetSafeObject(qualifierValue); } - set { + set + { int status = (int)ManagementStatus.NoError; RefreshQualifierInfo(); @@ -203,7 +205,8 @@ namespace System.Management /// public bool IsAmended { - get { + get + { RefreshQualifierInfo(); return ((int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_MASK_AMENDED == (qualifierFlavor & (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_AMENDED)); @@ -212,7 +215,7 @@ namespace System.Management { int status = (int)ManagementStatus.NoError; - RefreshQualifierInfo (); + RefreshQualifierInfo(); // Mask out origin bits int flavor = qualifierFlavor & ~(int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_MASK_ORIGIN; @@ -240,7 +243,8 @@ namespace System.Management /// public bool IsLocal { - get { + get + { RefreshQualifierInfo(); return ((int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_ORIGIN_LOCAL == (qualifierFlavor & (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_MASK_ORIGIN)); @@ -257,15 +261,17 @@ namespace System.Management /// public bool PropagatesToInstance { - get { + get + { RefreshQualifierInfo(); return ((int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE == (qualifierFlavor & (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE)); } - set { + set + { int status = (int)ManagementStatus.NoError; - RefreshQualifierInfo (); + RefreshQualifierInfo(); // Mask out origin bits int flavor = qualifierFlavor & ~(int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_MASK_ORIGIN; @@ -293,15 +299,17 @@ namespace System.Management /// public bool PropagatesToSubclass { - get { + get + { RefreshQualifierInfo(); return ((int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS == (qualifierFlavor & (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS)); } - set { + set + { int status = (int)ManagementStatus.NoError; - RefreshQualifierInfo (); + RefreshQualifierInfo(); // Mask out origin bits int flavor = qualifierFlavor & ~(int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_MASK_ORIGIN; @@ -329,15 +337,17 @@ namespace System.Management /// public bool IsOverridable { - get { + get + { RefreshQualifierInfo(); return ((int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_OVERRIDABLE == (qualifierFlavor & (int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_MASK_PERMISSIONS)); } - set { + set + { int status = (int)ManagementStatus.NoError; - RefreshQualifierInfo (); + RefreshQualifierInfo(); // Mask out origin bits int flavor = qualifierFlavor & ~(int)tag_WBEM_FLAVOR_TYPE.WBEM_FLAVOR_MASK_ORIGIN; diff --git a/src/libraries/System.Management/src/System/Management/QualifierSet.cs b/src/libraries/System.Management/src/System/Management/QualifierSet.cs index 4ebe33fc6c7..851935496cc 100644 --- a/src/libraries/System.Management/src/System/Management/QualifierSet.cs +++ b/src/libraries/System.Management/src/System/Management/QualifierSet.cs @@ -83,7 +83,7 @@ namespace System.Management /// private IWbemQualifierSetFreeThreaded GetTypeQualifierSet(QualifierType qualifierSetType) { - IWbemQualifierSetFreeThreaded qualifierSet = null; + IWbemQualifierSetFreeThreaded qualifierSet = null; int status = qualifierSetType switch { @@ -115,7 +115,8 @@ namespace System.Management /// public int Count { - get { + get + { string[] qualifierNames = null; IWbemQualifierSetFreeThreaded quals; try @@ -151,7 +152,9 @@ namespace System.Management /// if the object is synchronized; /// otherwise, . /// - public bool IsSynchronized { get { return false; } + public bool IsSynchronized + { + get { return false; } } /// @@ -160,7 +163,9 @@ namespace System.Management /// /// The object to be used for synchronization. /// - public object SyncRoot { get { return this; } + public object SyncRoot + { + get { return this; } } /// @@ -306,10 +311,10 @@ namespace System.Management internal QualifierDataEnumerator(ManagementBaseObject parent, string propertyOrMethodName, QualifierType qualifierType) { - this.parent = parent; + this.parent = parent; this.propertyOrMethodName = propertyOrMethodName; - this.qualifierType = qualifierType; - this.qualifierNames = null; + this.qualifierType = qualifierType; + this.qualifierNames = null; IWbemQualifierSetFreeThreaded qualifierSet = null; int status = (int)ManagementStatus.NoError; @@ -353,7 +358,8 @@ namespace System.Management /// public QualifierData Current { - get { + get + { if ((index == -1) || (index == qualifierNames.Length)) throw new InvalidOperationException(); else @@ -403,7 +409,8 @@ namespace System.Management /// public virtual QualifierData this[string qualifierName] { - get { + get + { if (null == qualifierName) throw new ArgumentNullException(nameof(qualifierName)); diff --git a/src/libraries/System.Management/src/System/Management/WMIGenerator.cs b/src/libraries/System.Management/src/System/Management/WMIGenerator.cs index dd0b5ce9ba7..48021528114 100644 --- a/src/libraries/System.Management/src/System/Management/WMIGenerator.cs +++ b/src/libraries/System.Management/src/System/Management/WMIGenerator.cs @@ -72,7 +72,7 @@ namespace System.Management private CodeTypeDeclaration ecc; private CodeTypeDeclaration EnumObj; private CodeNamespace cn; - private CodeMemberProperty cmp; + private CodeMemberProperty cmp; private CodeConstructor cctor; private CodeMemberField cf; private CodeObjectCreateExpression coce; @@ -90,19 +90,19 @@ namespace System.Management private CodeAttributeDeclaration cad; - private readonly ArrayList arrKeyType = new ArrayList(5); - private readonly ArrayList arrKeys = new ArrayList(5); - private readonly ArrayList BitMap = new ArrayList(5); - private ArrayList BitValues = new ArrayList(5); - private readonly ArrayList ValueMap = new ArrayList(5); - private ArrayList Values = new ArrayList(5); + private readonly ArrayList arrKeyType = new ArrayList(5); + private readonly ArrayList arrKeys = new ArrayList(5); + private readonly ArrayList BitMap = new ArrayList(5); + private ArrayList BitValues = new ArrayList(5); + private readonly ArrayList ValueMap = new ArrayList(5); + private ArrayList Values = new ArrayList(5); private SortedList PublicProperties = new SortedList(StringComparer.OrdinalIgnoreCase); - private SortedList PublicMethods = new SortedList (StringComparer.OrdinalIgnoreCase); - private SortedList PublicNamesUsed = new SortedList(StringComparer.OrdinalIgnoreCase); + private SortedList PublicMethods = new SortedList(StringComparer.OrdinalIgnoreCase); + private SortedList PublicNamesUsed = new SortedList(StringComparer.OrdinalIgnoreCase); private SortedList PrivateNamesUsed = new SortedList(StringComparer.OrdinalIgnoreCase); - private bool bHasEmbeddedProperties = false; + private bool bHasEmbeddedProperties = false; /// @@ -167,14 +167,14 @@ namespace System.Management public bool GenerateCode(CodeLanguage lang, string filePath, string netNamespace) { // check for proper arguments - if (filePath == null ) + if (filePath == null) { - throw new ArgumentOutOfRangeException (SR.NullFilePathException); + throw new ArgumentOutOfRangeException(SR.NullFilePathException); } if (filePath.Length == 0) { - throw new ArgumentOutOfRangeException (SR.EmptyFilePathException); + throw new ArgumentOutOfRangeException(SR.EmptyFilePathException); } NETNamespace = netNamespace; @@ -183,7 +183,7 @@ namespace System.Management InitializeCodeGeneration(); //Now create the filestream (output file) - tw = new StreamWriter(new FileStream (filePath, FileMode.Create), System.Text.Encoding.UTF8); + tw = new StreamWriter(new FileStream(filePath, FileMode.Create), System.Text.Encoding.UTF8); return GenerateAndWriteCode(lang); @@ -196,14 +196,14 @@ namespace System.Management { if (classobj == null) { - if (OriginalNamespace == null || ( OriginalNamespace != null && OriginalNamespace.Length == 0)) + if (OriginalNamespace == null || (OriginalNamespace != null && OriginalNamespace.Length == 0)) { - throw new ArgumentOutOfRangeException (SR.NamespaceNotInitializedException); + throw new ArgumentOutOfRangeException(SR.NamespaceNotInitializedException); } - if (OriginalClassName == null || ( OriginalClassName != null && OriginalClassName.Length == 0)) + if (OriginalClassName == null || (OriginalClassName != null && OriginalClassName.Length == 0)) { - throw new ArgumentOutOfRangeException (SR.ClassNameNotInitializedException); + throw new ArgumentOutOfRangeException(SR.ClassNameNotInitializedException); } } } @@ -239,7 +239,7 @@ namespace System.Management private CodeTypeDeclaration GetCodeTypeDeclarationForClass(bool bIncludeSystemClassinClassDef) { //Create type defination for the class - cc = new CodeTypeDeclaration (PrivateNamesUsed["GeneratedClassName"].ToString()); + cc = new CodeTypeDeclaration(PrivateNamesUsed["GeneratedClassName"].ToString()); // Adding Component as base class so as to enable drag and drop cc.BaseTypes.Add(new CodeTypeReference(PrivateNamesUsed["ComponentClass"].ToString())); @@ -346,7 +346,7 @@ namespace System.Management // Generate a property "StaticScope" to set and get the static ManagementScope for the class GeneratePublicProperty(PrivateNamesUsed["staticScope"].ToString(), PublicNamesUsed["ScopeClass"].ToString(), - new CodeVariableReferenceExpression(PrivateNamesUsed["statMgmtScope"].ToString()), true, SR.CommentStaticScopeProperty, true); + new CodeVariableReferenceExpression(PrivateNamesUsed["statMgmtScope"].ToString()), true, SR.CommentStaticScopeProperty, true); // Generate a function to check if a given class can be represented // by the generated class @@ -495,11 +495,11 @@ namespace System.Management cc.Name = cp.CreateValidIdentifier(cc.Name); //As we have finished the class definition, generate the class code NOW!!!!! - cn.Types.Add (cc); + cn.Types.Add(cc); try { - cp.GenerateCodeFromNamespace (cn, tw, new CodeGeneratorOptions()); + cp.GenerateCodeFromNamespace(cn, tw, new CodeGeneratorOptions()); } finally { @@ -542,7 +542,7 @@ namespace System.Management " results in " + thePath.Path); */ } - classobj = new ManagementClass (thePath); + classobj = new ManagementClass(thePath); } else { @@ -705,7 +705,7 @@ namespace System.Management foreach (string s in PublicNamesUsed.Values) { nIndex = IsContainedIn(s, ref PublicProperties); - if ( nIndex != -1) + if (nIndex != -1) { //We had found a collision with a public property //So we will resolve the collision by changing the property name @@ -765,10 +765,10 @@ namespace System.Management //Now we will create the CollectionClass and Enumerator Class names as they are dependent on the //generated class name and the generated class name might have changed due to collision - string strTemp = PrivateNamesUsed["GeneratedClassName"].ToString()+"Collection"; + string strTemp = PrivateNamesUsed["GeneratedClassName"].ToString() + "Collection"; PrivateNamesUsed.Add("CollectionClass", ResolveCollision(strTemp, true)); - strTemp = PrivateNamesUsed["GeneratedClassName"].ToString()+"Enumerator"; + strTemp = PrivateNamesUsed["GeneratedClassName"].ToString() + "Enumerator"; PrivateNamesUsed.Add("EnumeratorClass", ResolveCollision(strTemp, true)); } @@ -791,7 +791,7 @@ namespace System.Management if (bCheckthisFirst == false) { k++; - strTemp = strTemp + strToAdd +k.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(int))); + strTemp = strTemp + strToAdd + k.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(int))); } while (bCollision == true) @@ -820,13 +820,13 @@ namespace System.Management strToAdd = strToAdd + "_"; k = 0; } - strTemp = inString + strToAdd +k.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(int))); + strTemp = inString + strToAdd + k.ToString((IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(int))); } if (strTemp.Length > 0) { string strFirstChar = strTemp.Substring(0, 1).ToUpper(CultureInfo.InvariantCulture); - strTemp = strFirstChar + strTemp.Substring(1, strTemp.Length -1); + strTemp = strFirstChar + strTemp.Substring(1, strTemp.Length - 1); } return strTemp; @@ -845,7 +845,7 @@ namespace System.Management if (NETNamespace.Length == 0) { strNs = OriginalNamespace; - strNs = strNs.Replace ('\\', '.'); + strNs = strNs.Replace('\\', '.'); strNs = strNs.ToUpper(CultureInfo.InvariantCulture); } else @@ -863,7 +863,7 @@ namespace System.Management strNs += strClass; } //Now trim the class name without the first '_' - strClass = OriginalClassName.Substring(OriginalClassName.IndexOf('_')+1); + strClass = OriginalClassName.Substring(OriginalClassName.IndexOf('_') + 1); } else { @@ -876,21 +876,21 @@ namespace System.Management strClass = "C" + strClass; } - strClass = ResolveCollision (strClass, true); + strClass = ResolveCollision(strClass, true); // Try to get a type from any of the namespace which are used in the generated code and see if // it collides with any of the standard classes. - if (Type.GetType("System." + strClass) != null || - Type.GetType("System.ComponentModel." + strClass) != null || - Type.GetType("System.Management." + strClass) != null || - Type.GetType("System.Collections." + strClass) != null || - Type.GetType("System.Globalization." + strClass) != null ) + if (Type.GetType("System." + strClass) != null || + Type.GetType("System.ComponentModel." + strClass) != null || + Type.GetType("System.Management." + strClass) != null || + Type.GetType("System.Collections." + strClass) != null || + Type.GetType("System.Globalization." + strClass) != null) { PublicNamesUsed.Add(strClass, strClass); strClass = ResolveCollision(strClass, true); } - PrivateNamesUsed.Add ("GeneratedClassName", strClass); + PrivateNamesUsed.Add("GeneratedClassName", strClass); PrivateNamesUsed.Add("GeneratedNamespace", strNs); } @@ -900,9 +900,9 @@ namespace System.Management { //Now add the import statements cn = new CodeNamespace(PrivateNamesUsed["GeneratedNamespace"].ToString()); - cn.Imports.Add (new CodeNamespaceImport("System")); - cn.Imports.Add (new CodeNamespaceImport("System.ComponentModel")); - cn.Imports.Add (new CodeNamespaceImport("System.Management")); + cn.Imports.Add(new CodeNamespaceImport("System")); + cn.Imports.Add(new CodeNamespaceImport("System.ComponentModel")); + cn.Imports.Add(new CodeNamespaceImport("System.Management")); cn.Imports.Add(new CodeNamespaceImport("System.Collections")); cn.Imports.Add(new CodeNamespaceImport("System.Globalization")); @@ -929,7 +929,7 @@ namespace System.Management /// private void GeneratePublicReadOnlyProperty(string propName, string propType, object propValue, bool isLiteral, bool isBrowsable, string Comment) { - cmp = new CodeMemberProperty (); + cmp = new CodeMemberProperty(); cmp.Name = propName; cmp.Attributes = MemberAttributes.Public | MemberAttributes.Final; cmp.Type = new CodeTypeReference(propType); @@ -951,14 +951,14 @@ namespace System.Management if (isLiteral == true) { - cmp.GetStatements.Add (new CodeMethodReturnStatement (new CodeSnippetExpression(propValue.ToString()))); + cmp.GetStatements.Add(new CodeMethodReturnStatement(new CodeSnippetExpression(propValue.ToString()))); } else { - cmp.GetStatements.Add (new CodeMethodReturnStatement (new CodePrimitiveExpression(propValue))); + cmp.GetStatements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(propValue))); } - cc.Members.Add (cmp); - if (Comment != null && Comment.Length != 0 ) + cc.Members.Add(cmp); + if (Comment != null && Comment.Length != 0) { cmp.Comments.Add(new CodeCommentStatement(Comment)); } @@ -1085,7 +1085,7 @@ namespace System.Management private CodeTypeDeclaration GenerateSystemPropertiesClass() { CodeTypeDeclaration SysPropsClass = new CodeTypeDeclaration(PublicNamesUsed["SystemPropertiesClass"].ToString()); - SysPropsClass.TypeAttributes =TypeAttributes.NestedPublic; + SysPropsClass.TypeAttributes = TypeAttributes.NestedPublic; //First create the constructor // public ManagementSystemProperties(ManagementObject obj) @@ -1100,19 +1100,19 @@ namespace System.Management SysPropsClass.Members.Add(cctor); caa = new CodeAttributeArgument(); - caa.Value = new CodeTypeOfExpression (typeof(System.ComponentModel.ExpandableObjectConverter)); + caa.Value = new CodeTypeOfExpression(typeof(System.ComponentModel.ExpandableObjectConverter)); cad = new CodeAttributeDeclaration(); cad.Name = PublicNamesUsed["TypeConverter"].ToString(); cad.Arguments.Add(caa); SysPropsClass.CustomAttributes.Add(cad); - char [] strPropTemp; - char [] strPropName; + char[] strPropTemp; + char[] strPropName; int i = 0; foreach (PropertyData prop in classobj.SystemProperties) { - cmp = new CodeMemberProperty (); + cmp = new CodeMemberProperty(); //All properties are browsable by default. caa = new CodeAttributeArgument(); caa.Value = new CodePrimitiveExpression(true); @@ -1124,7 +1124,7 @@ namespace System.Management //Now we will have to find the occurrence of the first character and trim all the characters before that strPropTemp = prop.Name.ToCharArray(); - for (i=0; i < strPropTemp.Length; i++) + for (i = 0; i < strPropTemp.Length; i++) { if (char.IsLetterOrDigit(strPropTemp[i]) == true) { @@ -1136,7 +1136,7 @@ namespace System.Management i = 0; } strPropName = new char[strPropTemp.Length - i]; - for (int j=i; j < strPropTemp.Length; j++) + for (int j = i; j < strPropTemp.Length; j++) { strPropName[j - i] = strPropTemp[j]; } @@ -1147,9 +1147,9 @@ namespace System.Management cie = new CodeIndexerExpression( new CodeVariableReferenceExpression(PrivateNamesUsed["LateBoundObject"].ToString()), - new CodeExpression[] {new CodePrimitiveExpression(prop.Name)}); + new CodeExpression[] { new CodePrimitiveExpression(prop.Name) }); - cmp.GetStatements.Add (new CodeMethodReturnStatement (new CodeCastExpression(cmp.Type, cie))); + cmp.GetStatements.Add(new CodeMethodReturnStatement(new CodeCastExpression(cmp.Type, cie))); SysPropsClass.Members.Add(cmp); } //private WmiObject _privObject @@ -1179,7 +1179,7 @@ namespace System.Management string IsValidPropName = string.Empty; bool bDateIsTimeInterval = false; - for (int i=0; i< PublicProperties.Count; i++) + for (int i = 0; i < PublicProperties.Count; i++) { bDateIsTimeInterval = false; PropertyData prop = classobj.Properties[PublicProperties.GetKey(i).ToString()]; @@ -1187,7 +1187,7 @@ namespace System.Management bWrite = true; //All properties are writeable by default bStatic = false; //By default all properties are non static - cmp = new CodeMemberProperty (); + cmp = new CodeMemberProperty(); cmp.Name = PublicProperties[prop.Name].ToString(); cmp.Attributes = MemberAttributes.Public | MemberAttributes.Final; cmp.Type = ConvertCIMType(prop.Type, prop.IsArray); @@ -1212,7 +1212,7 @@ namespace System.Management // Method for IsNull property IsValidPropName = "Is" + PublicProperties[prop.Name].ToString() + "Null"; - cmp2 = new CodeMemberProperty (); + cmp2 = new CodeMemberProperty(); cmp2.Name = IsValidPropName; cmp2.Attributes = MemberAttributes.Public | MemberAttributes.Final; cmp2.Type = new CodeTypeReference("System.Boolean"); @@ -1245,7 +1245,7 @@ namespace System.Management cie = new CodeIndexerExpression( new CodeVariableReferenceExpression(PrivateNamesUsed["CurrentObject"].ToString()), - new CodeExpression[] {new CodePrimitiveExpression(prop.Name)}); + new CodeExpression[] { new CodePrimitiveExpression(prop.Name) }); bool bNullable = false; @@ -1277,7 +1277,7 @@ namespace System.Management if (bRead == true) { - if (IsPropertyValueType(prop.Type) && prop.IsArray == false) + if (IsPropertyValueType(prop.Type) && prop.IsArray == false) { /* @@ -1300,14 +1300,14 @@ namespace System.Management new CodePrimitiveExpression(null)); - cis.TrueStatements.Add(new CodeMethodReturnStatement (new CodePrimitiveExpression(true) )); - cis.FalseStatements.Add(new CodeMethodReturnStatement (new CodePrimitiveExpression(false) )); - cmp2.GetStatements.Add (cis); - cc.Members.Add (cmp2); + cis.TrueStatements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(true))); + cis.FalseStatements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(false))); + cmp2.GetStatements.Add(cis); + cc.Members.Add(cmp2); // Adding TypeConverter Attribute caa = new CodeAttributeArgument(); - caa.Value = new CodeTypeOfExpression (PrivateNamesUsed["ConverterClass"].ToString()); + caa.Value = new CodeTypeOfExpression(PrivateNamesUsed["ConverterClass"].ToString()); cad = new CodeAttributeDeclaration(); cad.Name = PublicNamesUsed["TypeConverter"].ToString(); cad.Arguments.Add(caa); @@ -1326,7 +1326,7 @@ namespace System.Management { if (prop.IsArray) { - cis.TrueStatements.Add(new CodeMethodReturnStatement (new CodePrimitiveExpression(null))); + cis.TrueStatements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null))); } else { @@ -1339,7 +1339,7 @@ namespace System.Management cmie.Method.TargetObject = new CodeTypeReferenceExpression("System.Convert"); cmie.Parameters.Add(new CodePrimitiveExpression(prop.NullEnumValue)); cmie.Method.MethodName = arrConvFuncName; - cis.TrueStatements.Add(new CodeMethodReturnStatement (new CodeCastExpression(cmp.Type, cmie ))); + cis.TrueStatements.Add(new CodeMethodReturnStatement(new CodeCastExpression(cmp.Type, cmie))); } } else @@ -1355,7 +1355,7 @@ namespace System.Management cmie.Method.TargetObject = new CodeTypeReferenceExpression("System.Convert"); if (prop.IsArray) { - CodeExpression [] cInit = {cmie }; + CodeExpression[] cInit = { cmie }; cis.TrueStatements.Add(new CodeMethodReturnStatement( new CodeArrayCreateExpression(cmp.Type, cInit))); @@ -1363,10 +1363,10 @@ namespace System.Management else { // return ()System.Convert.(0); - cis.TrueStatements.Add(new CodeMethodReturnStatement (cmie)); + cis.TrueStatements.Add(new CodeMethodReturnStatement(cmie)); } } - cmp.GetStatements.Add (cis); + cmp.GetStatements.Add(cis); } /* @@ -1382,7 +1382,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); cmm.Name = "ShouldSerialize" + PublicProperties[prop.Name].ToString(); - cmm.Attributes = MemberAttributes.Private | MemberAttributes.Final; + cmm.Attributes = MemberAttributes.Private | MemberAttributes.Final; cmm.ReturnType = new CodeTypeReference("System.Boolean"); CodeConditionStatement cis2 = new CodeConditionStatement(); @@ -1395,7 +1395,7 @@ namespace System.Management cmm.Statements.Add(cis2); cmm.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(false))); - cc.Members.Add (cmm); + cc.Members.Add(cmm); } if (prop.Type == CimType.Reference) @@ -1434,12 +1434,12 @@ namespace System.Management cmie.Method.TargetObject = new CodeTypeReferenceExpression("System.Convert"); cmie.Parameters.Add(cie); cmie.Method.MethodName = arrConvFuncName; - cmp.GetStatements.Add (new CodeMethodReturnStatement (new CodeCastExpression(cmp.Type, cmie ))); + cmp.GetStatements.Add(new CodeMethodReturnStatement(new CodeCastExpression(cmp.Type, cmie))); } } else { - cmp.GetStatements.Add (new CodeMethodReturnStatement (new CodeCastExpression(cmp.Type, cie))); + cmp.GetStatements.Add(new CodeMethodReturnStatement(new CodeCastExpression(cmp.Type, cie))); } } @@ -1450,9 +1450,9 @@ namespace System.Management { if (bNullable) { - cmm2 = new CodeMemberMethod (); + cmm2 = new CodeMemberMethod(); cmm2.Name = "Reset" + PublicProperties[prop.Name].ToString(); - cmm2.Attributes = MemberAttributes.Private | MemberAttributes.Final; + cmm2.Attributes = MemberAttributes.Private | MemberAttributes.Final; cmm2.Statements.Add(new CodeAssignStatement(cie, new CodePrimitiveExpression(null))); } @@ -1504,14 +1504,14 @@ namespace System.Management CodeBinaryOperatorType.ValueEquality, new CodeArrayIndexerExpression(new CodeVariableReferenceExpression("value"), new CodePrimitiveExpression(0))); - } - else - { + } + else + { ccs.Condition = new CodeBinaryOperatorExpression( new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(new CodeTypeReference(PublicProperties[prop.Name].ToString() + "Values")), "NULL_ENUM_VALUE"), CodeBinaryOperatorType.ValueEquality, new CodeSnippetExpression("value")); - } + } ccs.TrueStatements.Add(new CodeAssignStatement(cie, new CodePrimitiveExpression(null))); ccs.FalseStatements.Add(new CodeAssignStatement(cie, new CodeSnippetExpression("value"))); cmp.SetStatements.Add(ccs); @@ -1632,8 +1632,8 @@ namespace System.Management writeValue = false; } } - // check for ValueMap/Values and BitMap/BitValues pair and create - // Enum Accordingly + // check for ValueMap/Values and BitMap/BitValues pair and create + // Enum Accordingly else if (string.Equals(q.Name, "ValueMap", StringComparison.OrdinalIgnoreCase) && bMapsFailed == false) { try @@ -1644,8 +1644,8 @@ namespace System.Management { if (q.Value != null) { - string [] strArray = (string [])q.Value; - for (int i=0; i < strArray.Length; i++) + string[] strArray = (string[])q.Value; + for (int i = 0; i < strArray.Length; i++) { try { @@ -1658,13 +1658,13 @@ namespace System.Management } } } - // if the value is not a numerical, then we cannot construct a enum + // if the value is not a numerical, then we cannot construct a enum catch (System.FormatException) { bMapsFailed = true; ValueMap.Clear(); } - catch (System.InvalidCastException ) + catch (System.InvalidCastException) { // This exception may occur if the qualifier value is not an array as expected ValueMap.Clear(); @@ -1680,8 +1680,8 @@ namespace System.Management if (q.Value != null) { ArrayList arTemp = new ArrayList(5); - string [] strArray = (string[])q.Value; - for (int i=0; i < strArray.Length; i++) + string[] strArray = (string[])q.Value; + for (int i = 0; i < strArray.Length; i++) { if (strArray[i].Length == 0) { @@ -1696,7 +1696,7 @@ namespace System.Management } } } - catch (System.InvalidCastException ) + catch (System.InvalidCastException) { // This exception may occur if the qualifier value is not an array as expected Values.Clear(); @@ -1712,21 +1712,21 @@ namespace System.Management { if (q.Value != null) { - string [] strArray = (string [])q.Value; - for (int i=0; i < strArray.Length; i++) + string[] strArray = (string[])q.Value; + for (int i = 0; i < strArray.Length; i++) { BitMap.Add(ConvertBitMapValueToInt32(strArray[i])); } } } } - // if the value is not a numerical, then we cannot construct a enum + // if the value is not a numerical, then we cannot construct a enum catch (System.FormatException) { BitMap.Clear(); bMapsFailed = true; } - catch (System.InvalidCastException ) + catch (System.InvalidCastException) { // This exception may occur if the qualifier value is not an array as expected BitMap.Clear(); @@ -1742,8 +1742,8 @@ namespace System.Management if (q.Value != null) { ArrayList arTemp = new ArrayList(5); - string [] strArray = (string [])q.Value; - for (int i=0; i < strArray.Length; i++) + string[] strArray = (string[])q.Value; + for (int i = 0; i < strArray.Length; i++) { if (strArray[i].Length == 0) { @@ -1758,7 +1758,7 @@ namespace System.Management } } } - catch (System.InvalidCastException ) + catch (System.InvalidCastException) { // This exception may occur if the qualifier value is not an array as expected BitValues.Clear(); @@ -1772,9 +1772,9 @@ namespace System.Management // Property is not writeable only if "read" qualifier is present and its value is "true" // Also, for dynamic classes, absence of "write" qualifier means that the property is read-only. - if ((!bDynamicClass && !hasWrite )|| - (!bDynamicClass && hasWrite && writeValue)|| - (bDynamicClass && hasWrite && writeValue) ) + if ((!bDynamicClass && !hasWrite) || + (!bDynamicClass && hasWrite && writeValue) || + (bDynamicClass && hasWrite && writeValue)) { bWrite = true; } @@ -1838,7 +1838,7 @@ namespace System.Management { cmf.InitExpression = new CodePrimitiveExpression(ValueMap[i]); long test = System.Convert.ToInt64(ValueMap[i], (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(ulong))); - if (test > maxValue) maxValue=test; + if (test > maxValue) maxValue = test; if (bZeroFieldInEnum == false) { @@ -1854,7 +1854,7 @@ namespace System.Management else { cmf.InitExpression = new CodePrimitiveExpression(i); - if (i > maxValue) maxValue=i; + if (i > maxValue) maxValue = i; } EnumObj.Members.Add(cmf); } @@ -1862,7 +1862,7 @@ namespace System.Management // If there is no 0 valued field in enum, just add a invalid for enum // This is just to show in property browser - if ((bNullable == true) && (bZeroFieldInEnum == false)) + if ((bNullable == true) && (bZeroFieldInEnum == false)) { // use the 0 enum position for NULL cmf = new CodeMemberField(); @@ -1871,20 +1871,20 @@ namespace System.Management EnumObj.Members.Add(cmf); prop.NullEnumValue = 0; } - else if ((bNullable == true) && (bZeroFieldInEnum == true)) + else if ((bNullable == true) && (bZeroFieldInEnum == true)) { // must create an entry for NULL that is not zero and is not used // use the another unused enum position for NULL - cmf = new CodeMemberField (); + cmf = new CodeMemberField(); cmf.Name = "NULL_ENUM_VALUE"; - cmf.InitExpression = new CodePrimitiveExpression((int)(maxValue+1)); + cmf.InitExpression = new CodePrimitiveExpression((int)(maxValue + 1)); EnumObj.Members.Add(cmf); - prop.NullEnumValue = (int)(maxValue+1); + prop.NullEnumValue = (int)(maxValue + 1); } else if ((bNullable == false) && (bZeroFieldInEnum == false)) { // add an entry for 0 valued enum - cmf = new CodeMemberField (); + cmf = new CodeMemberField(); cmf.Name = "INVALID_ENUM_VALUE"; cmf.InitExpression = new CodePrimitiveExpression(0); EnumObj.Members.Add(cmf); @@ -1942,12 +1942,12 @@ namespace System.Management { cmf.InitExpression = new CodePrimitiveExpression(BitMap[i]); long test = System.Convert.ToInt64(BitMap[i], (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(ulong))); - if (test > maxBitValue) maxBitValue=test; + if (test > maxBitValue) maxBitValue = test; } else { cmf.InitExpression = new CodePrimitiveExpression(bitValue); - if (bitValue > maxBitValue) maxBitValue=bitValue; + if (bitValue > maxBitValue) maxBitValue = bitValue; // Now shift 1 more bit so that we can put it for the // next element in the enum @@ -1957,7 +1957,7 @@ namespace System.Management if (bZeroFieldInEnum == false) { - if ( (System.Convert.ToInt64(BitMap[i], (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(ulong))) == 0) ) + if ((System.Convert.ToInt64(BitMap[i], (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(ulong))) == 0)) { bZeroFieldInEnum = true; } @@ -1968,24 +1968,24 @@ namespace System.Management // If there is no 0 valued field in enum, just add a invalid for enum // This is just to show in property browser - if ((bNullable == true) && (bZeroFieldInEnum == false)) + if ((bNullable == true) && (bZeroFieldInEnum == false)) { // use the 0 enum position for NULL - cmf = new CodeMemberField (); + cmf = new CodeMemberField(); cmf.Name = "NULL_ENUM_VALUE"; cmf.InitExpression = new CodePrimitiveExpression(0); EnumObj.Members.Add(cmf); prop.NullEnumValue = 0; } - else if ((bNullable == true) && (bZeroFieldInEnum == true)) + else if ((bNullable == true) && (bZeroFieldInEnum == true)) { // must create an entry for NULL that is not zero and is not used // use the another unused enum position for NULL - cmf = new CodeMemberField (); + cmf = new CodeMemberField(); cmf.Name = "NULL_ENUM_VALUE"; if (BitValues.Count > 30) { - maxBitValue = maxBitValue + 1; + maxBitValue = maxBitValue + 1; } else { @@ -1993,14 +1993,14 @@ namespace System.Management } cmf.InitExpression = new CodePrimitiveExpression((int)(maxBitValue)); EnumObj.Members.Add(cmf); - // just add one - we won't preserve the bit shifting but this won't be used in CIM anyway. - prop.NullEnumValue = (int)(maxBitValue); + // just add one - we won't preserve the bit shifting but this won't be used in CIM anyway. + prop.NullEnumValue = (int)(maxBitValue); } else if ((bNullable == false) && (bZeroFieldInEnum == false)) { // add an entry for 0 valued enum - cmf = new CodeMemberField (); + cmf = new CodeMemberField(); cmf.Name = "INVALID_ENUM_VALUE"; cmf.InitExpression = new CodePrimitiveExpression(0); EnumObj.Members.Add(cmf); @@ -2039,11 +2039,11 @@ namespace System.Management cmm.Attributes = MemberAttributes.Private | MemberAttributes.Static | MemberAttributes.Final; cmm.ReturnType = new CodeTypeReference("System.String"); - for (int i=0; i < arrKeys.Count; i++) + for (int i = 0; i < arrKeys.Count; i++) { strType = ((CodeTypeReference)arrKeyType[i]).BaseType; cmm.Parameters.Add(new CodeParameterDeclarationExpression(strType, - "key"+arrKeys[i].ToString())); + "key" + arrKeys[i].ToString())); } string strPath = OriginalNamespace + ":" + OriginalClassName; @@ -2059,15 +2059,15 @@ namespace System.Management cmm.Statements.Add(new CodeVariableDeclarationStatement("System.String", strPathObject, new CodePrimitiveExpression(strPath))); CodeMethodInvokeExpression cmietoAdd; - for (int i=0; i < arrKeys.Count; i++) + for (int i = 0; i < arrKeys.Count; i++) { if (((CodeTypeReference)arrKeyType[i]).BaseType == "System.String") { - CodeMethodInvokeExpression cmie1 = GenerateConcatStrings(new CodeVariableReferenceExpression("key"+arrKeys[i]), new CodePrimitiveExpression("\"")); + CodeMethodInvokeExpression cmie1 = GenerateConcatStrings(new CodeVariableReferenceExpression("key" + arrKeys[i]), new CodePrimitiveExpression("\"")); CodeMethodInvokeExpression cmie2 = GenerateConcatStrings(new CodePrimitiveExpression("\""), cmie1); - CodeMethodInvokeExpression cmie3 = GenerateConcatStrings(new CodePrimitiveExpression(((i==0)?("."+arrKeys[i]+"="):(","+arrKeys[i]+"="))), cmie2); + CodeMethodInvokeExpression cmie3 = GenerateConcatStrings(new CodePrimitiveExpression(((i == 0) ? ("." + arrKeys[i] + "=") : ("," + arrKeys[i] + "="))), cmie2); cmietoAdd = GenerateConcatStrings(new CodeVariableReferenceExpression(strPathObject), cmie3); @@ -2075,10 +2075,10 @@ namespace System.Management else { cmie = new CodeMethodInvokeExpression(); - cmie.Method.TargetObject = new CodeCastExpression(new CodeTypeReference(((CodeTypeReference)arrKeyType[i]).BaseType + " "), new CodeVariableReferenceExpression("key"+arrKeys[i])); + cmie.Method.TargetObject = new CodeCastExpression(new CodeTypeReference(((CodeTypeReference)arrKeyType[i]).BaseType + " "), new CodeVariableReferenceExpression("key" + arrKeys[i])); cmie.Method.MethodName = "ToString"; - CodeMethodInvokeExpression cmie1 = GenerateConcatStrings(new CodePrimitiveExpression(((i==0)?("."+arrKeys[i]+"="):(","+arrKeys[i]+"="))), cmie); + CodeMethodInvokeExpression cmie1 = GenerateConcatStrings(new CodePrimitiveExpression(((i == 0) ? ("." + arrKeys[i] + "=") : ("," + arrKeys[i] + "="))), cmie); cmietoAdd = GenerateConcatStrings(new CodeVariableReferenceExpression(strPathObject), cmie1); @@ -2147,11 +2147,11 @@ namespace System.Management cmieInit.Method.MethodName = PrivateNamesUsed["InitialObjectFunc"].ToString(); cmieInit.Method.TargetObject = new CodeThisReferenceExpression(); - for (int i=0; i < arrKeys.Count; i++) + for (int i = 0; i < arrKeys.Count; i++) { cpde = new CodeParameterDeclarationExpression(); cpde.Type = new CodeTypeReference(((CodeTypeReference)arrKeyType[i]).BaseType); - cpde.Name = "key"+arrKeys[i].ToString(); + cpde.Name = "key" + arrKeys[i].ToString(); cctor.Parameters.Add(cpde); } @@ -2172,9 +2172,9 @@ namespace System.Management cmie.Method.TargetObject = new CodeTypeReferenceExpression(PrivateNamesUsed["GeneratedClassName"].ToString()); cmie.Method.MethodName = PublicNamesUsed["ConstructPathFunction"].ToString(); - for (int i=0; i < arrKeys.Count; i++) + for (int i = 0; i < arrKeys.Count; i++) { - cmie.Parameters.Add(new CodeVariableReferenceExpression("key"+arrKeys[i])); + cmie.Parameters.Add(new CodeVariableReferenceExpression("key" + arrKeys[i])); } coce = new CodeObjectCreateExpression(); @@ -2206,11 +2206,11 @@ namespace System.Management if (arrKeyType.Count > 0) { - for (int i=0; i < arrKeys.Count; i++) + for (int i = 0; i < arrKeys.Count; i++) { cpde = new CodeParameterDeclarationExpression(); cpde.Type = new CodeTypeReference(((CodeTypeReference)arrKeyType[i]).BaseType); - cpde.Name = "key"+arrKeys[i].ToString(); + cpde.Name = "key" + arrKeys[i].ToString(); cctor.Parameters.Add(cpde); } @@ -2233,9 +2233,9 @@ namespace System.Management cmie.Method.TargetObject = new CodeTypeReferenceExpression(PrivateNamesUsed["GeneratedClassName"].ToString()); cmie.Method.MethodName = PublicNamesUsed["ConstructPathFunction"].ToString(); - for (int i=0; i < arrKeys.Count; i++) + for (int i = 0; i < arrKeys.Count; i++) { - cmie.Parameters.Add(new CodeVariableReferenceExpression("key"+arrKeys[i])); + cmie.Parameters.Add(new CodeVariableReferenceExpression("key" + arrKeys[i])); } coce = new CodeObjectCreateExpression(); @@ -2357,7 +2357,7 @@ namespace System.Management cmieInit.Parameters.Add(new CodeVariableReferenceExpression(PrivateNamesUsed["ScopeParam"].ToString())); cmie = new CodeMethodInvokeExpression(); - cmie.Method.TargetObject =new CodeTypeReferenceExpression(PrivateNamesUsed["GeneratedClassName"].ToString()); + cmie.Method.TargetObject = new CodeTypeReferenceExpression(PrivateNamesUsed["GeneratedClassName"].ToString()); cmie.Method.MethodName = PublicNamesUsed["ConstructPathFunction"].ToString(); coce = new CodeObjectCreateExpression(); @@ -2777,9 +2777,9 @@ namespace System.Management { string strInParams = "inParams"; string strOutParams = "outParams"; - string strClassObj = "classObj"; - bool bStatic = false; - bool bPrivileges = false; + string strClassObj = "classObj"; + bool bStatic = false; + bool bPrivileges = false; CodePropertyReferenceExpression cprePriveleges = null; CimType cimRetType = CimType.SInt8; // Initialized to remove warnings CodeTypeReference retRefType = null; @@ -2789,7 +2789,7 @@ namespace System.Management ArrayList outParamsName = new ArrayList(5); ArrayList inoutParams = new ArrayList(5); ArrayList inoutParamsType = new ArrayList(5); - for (int k=0; k< PublicMethods.Count; k++) + for (int k = 0; k < PublicMethods.Count; k++) { bStatic = false; @@ -2920,7 +2920,7 @@ namespace System.Management cpde.Direction = FieldDirection.In; - if ( prop.Type == CimType.DateTime) + if (prop.Type == CimType.DateTime) { CodeTypeReference dateType = cpde.Type; // Check if it is Time interval and if so change the type to Time Interval @@ -2929,7 +2929,7 @@ namespace System.Management } //Find out whether it is a in/out Parameter - for (int i=0; i < outParamsName.Count; i++) + for (int i = 0; i < outParamsName.Count; i++) { if (string.Equals(prop.Name, outParamsName[i].ToString(), StringComparison.OrdinalIgnoreCase)) { @@ -3017,7 +3017,7 @@ namespace System.Management } bInOut = false; - for (int i=0; i < inoutParams.Count; i++) + for (int i = 0; i < inoutParams.Count; i++) { if (string.Equals(prop.Name, inoutParams[i].ToString(), StringComparison.OrdinalIgnoreCase)) { @@ -3033,7 +3033,7 @@ namespace System.Management bRetVal = true; cimRetType = prop.Type; - if ( prop.Type == CimType.DateTime) + if (prop.Type == CimType.DateTime) { CodeTypeReference dateType = cmm.ReturnType; // Check if it is Time interval and if so change the type to Time Interval @@ -3051,7 +3051,7 @@ namespace System.Management cpde.Direction = FieldDirection.Out; cmm.Parameters.Add(cpde); - if ( prop.Type == CimType.DateTime) + if (prop.Type == CimType.DateTime) { CodeTypeReference dateType = cpde.Type; // Check if it is Time interval and if so change the type to Time Interval @@ -3167,7 +3167,7 @@ namespace System.Management //Now for each in/out params generate the statement // = outParams.Properties[""]; - for (int i=0; i < inoutParams.Count; i++) + for (int i = 0; i < inoutParams.Count; i++) { cpre = new CodePropertyReferenceExpression(new CodeVariableReferenceExpression(strOutParams), "Properties"); cie = new CodeIndexerExpression(cpre, new CodePrimitiveExpression(inoutParams[i].ToString())); @@ -3250,7 +3250,7 @@ namespace System.Management cis.FalseStatements.Add(new CodeMethodReturnStatement(cmie)); } - // if the return type is array, then just do type casting before returning + // if the return type is array, then just do type casting before returning else { cis.TrueStatements.Add(new CodeMethodReturnStatement( @@ -3723,19 +3723,19 @@ namespace System.Management string contextObject = "context"; string TypeDstObject = "destinationType"; string ValueVar = "value"; - string CultureInfoClass = "System.Globalization.CultureInfo"; + string CultureInfoClass = "System.Globalization.CultureInfo"; string CultureInfoVar = "culture"; - string IDictionary = "System.Collections.IDictionary"; - string DictVar = "dictionary"; - string propColl = "PropertyDescriptorCollection"; - string AttributeVar = "attributeVar"; + string IDictionary = "System.Collections.IDictionary"; + string DictVar = "dictionary"; + string propColl = "PropertyDescriptorCollection"; + string AttributeVar = "attributeVar"; string baseTypeParam = "inBaseType"; string baseTypeMemberVariable = "baseConverter"; string typeMemberVariable = "baseType"; string TypeDescriptorClass = "TypeDescriptor"; - string srcType = "srcType"; + string srcType = "srcType"; /* @@ -3796,7 +3796,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "CanConvertFrom"; cmm.ReturnType = new CodeTypeReference("System.Boolean"); @@ -3820,7 +3820,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "CanConvertTo"; cmm.ReturnType = new CodeTypeReference("System.Boolean"); @@ -3844,7 +3844,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "ConvertFrom"; cmm.ReturnType = new CodeTypeReference("System.Object"); @@ -3870,7 +3870,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.ReturnType = new CodeTypeReference("System.Object"); cmm.Name = "CreateInstance"; @@ -3893,7 +3893,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "GetCreateInstanceSupported"; cmm.ReturnType = new CodeTypeReference("System.Boolean"); @@ -3913,7 +3913,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "GetProperties"; cmm.Parameters.Add(new CodeParameterDeclarationExpression(TypeDescriptorContextClass, contextObject)); cmm.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference("System.Object"), ValueVar)); @@ -3938,7 +3938,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "GetPropertiesSupported"; cmm.Parameters.Add(new CodeParameterDeclarationExpression(TypeDescriptorContextClass, contextObject)); cmm.ReturnType = new CodeTypeReference("System.Boolean"); @@ -3957,7 +3957,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "GetStandardValues"; cmm.Parameters.Add(new CodeParameterDeclarationExpression(TypeDescriptorContextClass, contextObject)); cmm.ReturnType = new CodeTypeReference("System.ComponentModel.TypeConverter.StandardValuesCollection"); @@ -3976,7 +3976,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "GetStandardValuesExclusive"; cmm.Parameters.Add(new CodeParameterDeclarationExpression(TypeDescriptorContextClass, contextObject)); cmm.ReturnType = new CodeTypeReference("System.Boolean"); @@ -3995,7 +3995,7 @@ namespace System.Management */ cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "GetStandardValuesSupported"; cmm.Parameters.Add(new CodeParameterDeclarationExpression(TypeDescriptorContextClass, contextObject)); cmm.ReturnType = new CodeTypeReference("System.Boolean"); @@ -4043,7 +4043,7 @@ namespace System.Management // make the member method cmm = new CodeMemberMethod(); - cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; + cmm.Attributes = MemberAttributes.Public | MemberAttributes.Override | MemberAttributes.Overloaded; cmm.Name = "ConvertTo"; // add the 3 parameters cmm.Parameters.Add(new CodeParameterDeclarationExpression(TypeDescriptorContextClass, contextObject)); @@ -4088,7 +4088,7 @@ namespace System.Management */ CodeBinaryOperatorExpression cboe2 = new CodeBinaryOperatorExpression(); - cboe2.Left = new CodeMethodInvokeExpression( + cboe2.Left = new CodeMethodInvokeExpression( new CodeVariableReferenceExpression("value"), "GetType"); cboe2.Right = new CodeVariableReferenceExpression("destinationType"); cboe2.Operator = CodeBinaryOperatorType.IdentityEquality; @@ -4131,8 +4131,8 @@ namespace System.Management // if ( (baseType == typeof(System.Boolean)) && (baseType.BaseType == typeof(System.ValueType)) ) cis = new CodeConditionStatement(); cboe1 = new CodeBinaryOperatorExpression(); - cboe1.Left = new CodeVariableReferenceExpression(typeMemberVariable); - cboe1.Right = new CodeTypeOfExpression (PublicNamesUsed["Boolean"].ToString()); + cboe1.Left = new CodeVariableReferenceExpression(typeMemberVariable); + cboe1.Right = new CodeTypeOfExpression(PublicNamesUsed["Boolean"].ToString()); cboe1.Operator = CodeBinaryOperatorType.IdentityEquality; cboe2 = new CodeBinaryOperatorExpression(); @@ -4140,7 +4140,7 @@ namespace System.Management new CodeVariableReferenceExpression(typeMemberVariable), "BaseType"); - cboe2.Right = new CodeTypeOfExpression (PublicNamesUsed["ValueType"].ToString()); + cboe2.Right = new CodeTypeOfExpression(PublicNamesUsed["ValueType"].ToString()); cboe2.Operator = CodeBinaryOperatorType.IdentityEquality; cboe3 = new CodeBinaryOperatorExpression(); @@ -4247,7 +4247,7 @@ namespace System.Management ccc.BaseTypes.Add("System.Object"); ccc.BaseTypes.Add("ICollection"); - ccc.TypeAttributes =TypeAttributes.NestedPublic; + ccc.TypeAttributes = TypeAttributes.NestedPublic; cf = new CodeMemberField(); cf.Name = strObjectCollection; @@ -4423,7 +4423,7 @@ namespace System.Management //public class ServiceEnumerator : IEnumerator ecc = new CodeTypeDeclaration(PrivateNamesUsed["EnumeratorClass"].ToString()); - ecc.TypeAttributes =TypeAttributes.NestedPublic; + ecc.TypeAttributes = TypeAttributes.NestedPublic; ecc.BaseTypes.Add("System.Object"); ecc.BaseTypes.Add("System.Collections.IEnumerator"); @@ -4432,7 +4432,7 @@ namespace System.Management cf = new CodeMemberField(); cf.Name = strObjectEnumerator; cf.Attributes = MemberAttributes.Private | MemberAttributes.Final; - cf.Type = new CodeTypeReference(strManagementObjectCollectionType+"."+ + cf.Type = new CodeTypeReference(strManagementObjectCollectionType + "." + strManagementObjectEnumeratorType); ecc.Members.Add(cf); @@ -4504,7 +4504,7 @@ namespace System.Management new CodeVariableReferenceExpression(strObjectEnumerator), "Reset" ); - cmm.Statements.Add(new CodeExpressionStatement (cmie)); + cmm.Statements.Add(new CodeExpressionStatement(cmie)); ecc.Members.Add(cmm); ccc.Members.Add(ecc); @@ -4517,7 +4517,7 @@ namespace System.Management private int IsContainedIn(string strToFind, ref SortedList sortedList) { int nIndex = -1; - for (int i=0; i < sortedList.Count; i++) + for (int i = 0; i < sortedList.Count; i++) { if (string.Equals(sortedList.GetByIndex(i).ToString(), strToFind, StringComparison.OrdinalIgnoreCase)) { @@ -4544,108 +4544,108 @@ namespace System.Management switch (cType) { case CimType.SInt8: - { - strType = "System.SByte"; - break; - } + { + strType = "System.SByte"; + break; + } case CimType.UInt8: - { - strType = "System.Byte"; - break; - } + { + strType = "System.Byte"; + break; + } case CimType.SInt16: - { - strType = "System.Int16"; - break; - } - case CimType.UInt16: - { - if (bUnsignedSupported == false) { strType = "System.Int16"; + break; } - else + case CimType.UInt16: { - strType = "System.UInt16"; + if (bUnsignedSupported == false) + { + strType = "System.Int16"; + } + else + { + strType = "System.UInt16"; + } + break; } - break; - } case CimType.SInt32: - { - strType = "System.Int32"; - break; - } - case CimType.UInt32: - { - if (bUnsignedSupported == false) { strType = "System.Int32"; + break; } - else + case CimType.UInt32: { - strType = "System.UInt32"; + if (bUnsignedSupported == false) + { + strType = "System.Int32"; + } + else + { + strType = "System.UInt32"; + } + break; } - break; - } case CimType.SInt64: - { - strType = "System.Int64"; - break; - } - case CimType.UInt64: - { - if (bUnsignedSupported == false) { strType = "System.Int64"; + break; } - else + case CimType.UInt64: { - strType = "System.UInt64"; + if (bUnsignedSupported == false) + { + strType = "System.Int64"; + } + else + { + strType = "System.UInt64"; + } + break; } - break; - } case CimType.Real32: - { - strType = "System.Single"; - break; - } + { + strType = "System.Single"; + break; + } case CimType.Real64: - { - strType = "System.Double"; - break; - } + { + strType = "System.Double"; + break; + } case CimType.Boolean: - { - strType = "System.Boolean"; - break; - } + { + strType = "System.Boolean"; + break; + } case CimType.String: - { - strType = "System.String"; - break; - } + { + strType = "System.String"; + break; + } case CimType.DateTime: - { - strType = "System.DateTime"; - break; - } + { + strType = "System.DateTime"; + break; + } case CimType.Reference: - { - strType = PublicNamesUsed["PathClass"].ToString(); - break; - } + { + strType = PublicNamesUsed["PathClass"].ToString(); + break; + } case CimType.Char16: - { - strType = "System.Char"; - break; - } + { + strType = "System.Char"; + break; + } case CimType.Object: default: strType = PublicNamesUsed["BaseObjClass"].ToString(); break; } - if (isArray ) + if (isArray) { return new CodeTypeReference(strType, 1); } @@ -4670,10 +4670,10 @@ namespace System.Management case CimType.SInt8: case CimType.SInt16: case CimType.SInt32: - { - retVal = true; - break; - } + { + retVal = true; + break; + } case CimType.SInt64: case CimType.UInt64: case CimType.Real32: @@ -4724,7 +4724,7 @@ namespace System.Management string strRet = string.Empty; string strToReplace = "_"; string strToAdd = string.Empty; - bool bAdd = true; + bool bAdd = true; if (str.Length == 0) { return string.Copy(""); @@ -4738,7 +4738,7 @@ namespace System.Management strToAdd = "l"; } - for (int i=0; i < str.Length; i++) + for (int i = 0; i < str.Length; i++) { bAdd = true; if (char.IsLetterOrDigit(arrString[i]) == false) @@ -4774,11 +4774,11 @@ namespace System.Management private void ResolveEnumNameValues(ArrayList arrIn, ref ArrayList arrayOut) { arrayOut.Clear(); - int nCurIndex = 0; + int nCurIndex = 0; string strToAdd = string.Empty; IFormatProvider formatProv = (IFormatProvider)CultureInfo.InvariantCulture.GetFormat(typeof(int)); - for ( int i = 0; i < arrIn.Count; i++) + for (int i = 0; i < arrIn.Count; i++) { strToAdd = arrIn[i].ToString(); strToAdd = ResolveCollision(strToAdd, true); @@ -4804,7 +4804,7 @@ namespace System.Management /// private static bool IsContainedInArray(string strToFind, ArrayList arrToSearch) { - for (int i=0; i < arrToSearch.Count; i++) + for (int i = 0; i < arrToSearch.Count; i++) { if (string.Equals(arrToSearch[i].ToString(), strToFind, StringComparison.OrdinalIgnoreCase)) { @@ -4842,7 +4842,7 @@ namespace System.Management case CodeLanguage.CSharp: strProvider = "C#."; - cp= new CSharpCodeProvider(); + cp = new CSharpCodeProvider(); break; case CodeLanguage.VJSharp: @@ -4860,7 +4860,7 @@ namespace System.Management if (asm != null) { codeProvType = asm.GetType("Microsoft.VJSharp.VJSharpCodeProvider"); - if ( codeProvType != null) + if (codeProvType != null) { cp = (System.CodeDom.Compiler.CodeDomProvider)Activator.CreateInstance(codeProvType); bSucceeded = true; @@ -4882,7 +4882,7 @@ namespace System.Management if (asm != null) { codeProvType = asm.GetType("Microsoft.VisualC.CppCodeProvider"); - if ( codeProvType != null) + if (codeProvType != null) { cp = (System.CodeDom.Compiler.CodeDomProvider)Activator.CreateInstance(codeProvType); bSucceeded = true; @@ -4893,7 +4893,7 @@ namespace System.Management } catch { - throw new ArgumentOutOfRangeException(SR.Format(SR.UnableToCreateCodeGeneratorException, strProvider )); + throw new ArgumentOutOfRangeException(SR.Format(SR.UnableToCreateCodeGeneratorException, strProvider)); } if (bSucceeded == true) @@ -5064,61 +5064,61 @@ namespace System.Management break; case CimType.UInt32: - { - if (bUnsignedSupported == false) { - retFunctionName = "ToInt32"; + if (bUnsignedSupported == false) + { + retFunctionName = "ToInt32"; + } + else + { + retFunctionName = "ToUInt32"; + } + break; } - else - { - retFunctionName = "ToUInt32"; - } - break; - } case CimType.SInt64: - { - retFunctionName = "ToInt64"; - break; - } - case CimType.UInt64: - { - if (bUnsignedSupported == false) { retFunctionName = "ToInt64"; + break; } - else + case CimType.UInt64: { - retFunctionName = "ToUInt64"; + if (bUnsignedSupported == false) + { + retFunctionName = "ToInt64"; + } + else + { + retFunctionName = "ToUInt64"; + } + break; } - break; - } case CimType.Real32: - { - retFunctionName = "ToSingle"; - break; - } + { + retFunctionName = "ToSingle"; + break; + } case CimType.Real64: - { - retFunctionName = "ToDouble"; - break; - } + { + retFunctionName = "ToDouble"; + break; + } case CimType.Boolean: - { - retFunctionName = "ToBoolean"; - break; - } + { + retFunctionName = "ToBoolean"; + break; + } case CimType.Char16: - { - retFunctionName = "ToChar"; - break; - } + { + retFunctionName = "ToChar"; + break; + } case CimType.String: - { - retFunctionName = "ToString"; - break; - } + { + retFunctionName = "ToString"; + break; + } } return retFunctionName; @@ -5159,7 +5159,7 @@ namespace System.Management /// Gets the dynamic qualifier on the class to find if the /// class is a dynamic class /// - private bool IsDynamicClass() + private bool IsDynamicClass() { bool ret = false; try @@ -5315,7 +5315,7 @@ namespace System.Management private void GenerateClassNameProperty() { string strRetVar = "strRet"; - cmp = new CodeMemberProperty (); + cmp = new CodeMemberProperty(); cmp.Name = PublicNamesUsed["ClassNameProperty"].ToString(); cmp.Attributes = MemberAttributes.Public | MemberAttributes.Final; cmp.Type = new CodeTypeReference("System.String"); @@ -5335,7 +5335,7 @@ namespace System.Management cad.Arguments.Add(caa); cmp.CustomAttributes.Add(cad); - cmp.GetStatements.Add (new CodeVariableDeclarationStatement("System.String", strRetVar, + cmp.GetStatements.Add(new CodeVariableDeclarationStatement("System.String", strRetVar, new CodeVariableReferenceExpression(PrivateNamesUsed["CreationClassName"].ToString()))); @@ -5388,8 +5388,8 @@ namespace System.Management cmp.GetStatements.Add(cis); - cmp.GetStatements.Add (new CodeMethodReturnStatement (new CodeVariableReferenceExpression(strRetVar))); - cc.Members.Add (cmp); + cmp.GetStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression(strRetVar))); + cc.Members.Add(cmp); } /// @@ -5401,7 +5401,7 @@ namespace System.Management string strPathParam = "path"; string strGetOptions = "OptionsParam"; - cmm = new CodeMemberMethod (); + cmm = new CodeMemberMethod(); cmm.Name = PrivateNamesUsed["ClassNameCheckFunc"].ToString(); cmm.Attributes = MemberAttributes.Private | MemberAttributes.Final; cmm.ReturnType = new CodeTypeReference("System.Boolean"); @@ -5469,11 +5469,11 @@ namespace System.Management // Call this function to generate the first overload of this function GenerateIfClassvalidFuncWithAllParams(); - string strTempObj = "theObj"; - string strnCtr = "count"; + string strTempObj = "theObj"; + string strnCtr = "count"; string strDerivation = "parentClasses"; - cmm = new CodeMemberMethod (); + cmm = new CodeMemberMethod(); cmm.Name = PrivateNamesUsed["ClassNameCheckFunc"].ToString(); cmm.Attributes = MemberAttributes.Private | MemberAttributes.Final; cmm.ReturnType = new CodeTypeReference("System.Boolean"); @@ -5612,15 +5612,15 @@ namespace System.Management if (varToAssign == null) { - cis1.TrueStatements.Add (new CodeMethodReturnStatement(CreateObjectForProperty(strType, cmie))); + cis1.TrueStatements.Add(new CodeMethodReturnStatement(CreateObjectForProperty(strType, cmie))); statColl.Add(cis1); - statColl.Add (new CodeMethodReturnStatement(new CodePrimitiveExpression(null))); + statColl.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null))); } else { // Assign null to variable statColl.Add(new CodeAssignStatement(varToAssign, new CodePrimitiveExpression(null))); - cis1.TrueStatements.Add (new CodeAssignStatement(varToAssign, CreateObjectForProperty(strType, cmie))); + cis1.TrueStatements.Add(new CodeAssignStatement(varToAssign, CreateObjectForProperty(strType, cmie))); statColl.Add(cis1); } } @@ -5749,14 +5749,14 @@ namespace System.Management cmie2.Method.MethodName = "ToString"; cmie2.Method.TargetObject = cmie1; - cfls.Statements.Add( new CodeAssignStatement(new CodeIndexerExpression(new CodeVariableReferenceExpression(strArray), + cfls.Statements.Add(new CodeAssignStatement(new CodeIndexerExpression(new CodeVariableReferenceExpression(strArray), new CodeVariableReferenceExpression(strnCtr)), CreateObjectForProperty(strType, cmie2))); cis1.TrueStatements.Add(cfls); if (varToAssign == null) { cis1.TrueStatements.Add(new CodeMethodReturnStatement(new CodeVariableReferenceExpression(strArray))); - statColl.Add (cis1); + statColl.Add(cis1); statColl.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null))); } else @@ -5764,7 +5764,7 @@ namespace System.Management // Assign null to variable statColl.Add(new CodeAssignStatement(varToAssign, new CodePrimitiveExpression(null))); cis1.TrueStatements.Add(new CodeAssignStatement(varToAssign, new CodeVariableReferenceExpression(strArray))); - statColl.Add (cis1); + statColl.Add(cis1); } } @@ -5861,14 +5861,14 @@ namespace System.Management cmie1.Parameters.Add(new CodeVariableReferenceExpression(strnCtr)); - cfls.Statements.Add( new CodeAssignStatement(new CodeIndexerExpression(new CodeVariableReferenceExpression(strArray), + cfls.Statements.Add(new CodeAssignStatement(new CodeIndexerExpression(new CodeVariableReferenceExpression(strArray), new CodeVariableReferenceExpression(strnCtr)), ConvertPropertyToString(strType, cmie1))); cis1.TrueStatements.Add(cfls); cis1.TrueStatements.Add(new CodeAssignStatement(prop, new CodeVariableReferenceExpression(strArray))); cis1.FalseStatements.Add(new CodeAssignStatement(prop, new CodePrimitiveExpression(null))); - statColl.Add (cis1); + statColl.Add(cis1); } } @@ -5879,7 +5879,7 @@ namespace System.Management { switch (strType) { - case "System.DateTime" : + case "System.DateTime": if (param == null) { return new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("System.DateTime"), "MinValue"); @@ -5892,7 +5892,7 @@ namespace System.Management return cmie; } - case "System.TimeSpan" : + case "System.TimeSpan": if (param == null) { coce = new CodeObjectCreateExpression(); @@ -5931,14 +5931,14 @@ namespace System.Management { switch (strType) { - case "System.DateTime" : + case "System.DateTime": CodeMethodInvokeExpression cmie1 = new CodeMethodInvokeExpression(); cmie1.Parameters.Add(new CodeCastExpression(new CodeTypeReference("System.DateTime"), beginingExpression)); cmie1.Method.MethodName = PrivateNamesUsed["ToDMTFDateTimeMethod"].ToString(); return cmie1; - case "System.TimeSpan" : + case "System.TimeSpan": CodeMethodInvokeExpression cmie2 = new CodeMethodInvokeExpression(); cmie2.Parameters.Add(new CodeCastExpression(new CodeTypeReference("System.TimeSpan"), beginingExpression)); @@ -5946,7 +5946,7 @@ namespace System.Management return cmie2; case "System.Management.ManagementPath": - return new CodePropertyReferenceExpression(new CodeCastExpression( + return new CodePropertyReferenceExpression(new CodeCastExpression( new CodeTypeReference(PublicNamesUsed["PathClass"].ToString()), beginingExpression), PublicNamesUsed["PathProperty"].ToString()); @@ -6056,7 +6056,7 @@ namespace System.Management cmie2.Method.MethodName = arrConvFuncName; cfls.Statements.Add(new CodeAssignStatement(new CodeIndexerExpression(new CodeVariableReferenceExpression(ArrToRet), new CodeVariableReferenceExpression(strnCtr)), - new CodeCastExpression(new CodeTypeReference(strEnumName), cmie2 ))); + new CodeCastExpression(new CodeTypeReference(strEnumName), cmie2))); cmProp.GetStatements.Add(cfls); @@ -6114,7 +6114,7 @@ namespace System.Management // is "interval" then the returned CodeTypeReference is of type System.TimeSpan // otherwise the returned type will be System.DateTime. // This functions is called only for cimtype.DateTime type properties - private bool GetDateTimeType(PropertyData prop, ref CodeTypeReference codeType ) + private bool GetDateTimeType(PropertyData prop, ref CodeTypeReference codeType) { bool isTimeInterval = false; codeType = null; @@ -6124,7 +6124,7 @@ namespace System.Management } else { - codeType = new CodeTypeReference("System.DateTime"); + codeType = new CodeTypeReference("System.DateTime"); } try @@ -6138,7 +6138,7 @@ namespace System.Management } else { - codeType = new CodeTypeReference("System.TimeSpan"); + codeType = new CodeTypeReference("System.TimeSpan"); } } @@ -6313,7 +6313,7 @@ namespace System.Management private void AddToDateTimeFunction() { string dmtfParam = "dmtfDate"; - string year = "year"; + string year = "year"; string month = "month"; string day = "day"; string hour = "hour"; @@ -6341,7 +6341,7 @@ namespace System.Management cmmdt.Statements.Add(new CodeVariableDeclarationStatement(new CodeTypeReference("System.Int32"), year, new CodePropertyReferenceExpression(cvreInitializer, "Year"))); //Int32 month = initializer.Month; - cmmdt.Statements.Add(new CodeVariableDeclarationStatement(new CodeTypeReference("System.Int32"), month, new CodePropertyReferenceExpression(cvreInitializer, "Month"))); + cmmdt.Statements.Add(new CodeVariableDeclarationStatement(new CodeTypeReference("System.Int32"), month, new CodePropertyReferenceExpression(cvreInitializer, "Month"))); //Int32 day = initializer.Day; cmmdt.Statements.Add(new CodeVariableDeclarationStatement(new CodeTypeReference("System.Int32"), day, new CodePropertyReferenceExpression(cvreInitializer, "Day"))); @@ -6435,7 +6435,7 @@ namespace System.Management } */ - CodeMethodReferenceExpression cmre = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(dmtf), "Substring"); + CodeMethodReferenceExpression cmre = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(dmtf), "Substring"); CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression(); cmie.Method = cmre; cmie.Parameters.Add(new CodePrimitiveExpression(15)); @@ -6450,7 +6450,7 @@ namespace System.Management cis = new CodeConditionStatement(); cis.Condition = cboe; - CodeMethodReferenceExpression cmre1 = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression("System.Int64"), "Parse"); + CodeMethodReferenceExpression cmre1 = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression("System.Int64"), "Parse"); CodeMethodInvokeExpression cmie1 = new CodeMethodInvokeExpression(); cmie1.Method = cmre1; cmie1.Parameters.Add(new CodeVariableReferenceExpression(tempStr)); @@ -6604,7 +6604,7 @@ namespace System.Management /* datetime = datetime.AddTicks(ticks); */ - CodeMethodReferenceExpression cmre2 = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(datetimeVariable), "AddTicks"); + CodeMethodReferenceExpression cmre2 = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(datetimeVariable), "AddTicks"); CodeMethodInvokeExpression cmie2 = new CodeMethodInvokeExpression(); cmie2.Method = cmre2; cmie2.Parameters.Add(new CodeVariableReferenceExpression(ticks)); @@ -6738,7 +6738,7 @@ namespace System.Management int SubStringParam1, int SubStringParam2) { - CodeMethodReferenceExpression cmre = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(dmtfVarName), "Substring"); + CodeMethodReferenceExpression cmre = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(dmtfVarName), "Substring"); CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression(); cmie.Method = cmre; cmie.Parameters.Add(new CodePrimitiveExpression(SubStringParam1)); @@ -6757,7 +6757,7 @@ namespace System.Management cmie.Method = cmre; cmie.Parameters.Add(new CodeVariableReferenceExpression(tempVarName)); - cis.TrueStatements.Add( new CodeAssignStatement(new CodeVariableReferenceExpression(toAssign), cmie)); + cis.TrueStatements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(toAssign), cmie)); cmmdt.Add(cis); } @@ -6765,7 +6765,7 @@ namespace System.Management private void AddToDMTFTimeIntervalFunction() { string dmtfTimeSpan = "dmtftimespan"; - string timespan = "timespan"; + string timespan = "timespan"; string tsTemp = "tsTemp"; string microsec = "microsec"; string strmicrosec = "strMicroSec"; @@ -7028,7 +7028,7 @@ namespace System.Management private void AddToDMTFDateTimeFunction() { string strUtc = "utcString"; - string dateParam = "date"; + string dateParam = "date"; CodeCastExpression cast = null; @@ -7352,7 +7352,7 @@ namespace System.Management private void AddToTimeSpanFunction() { - string tsParam = "dmtfTimespan"; + string tsParam = "dmtfTimespan"; string days = "days"; string hours = "hours"; string minutes = "minutes"; @@ -7661,7 +7661,7 @@ namespace System.Management private static void ToTimeSpanHelper(int start, int numOfCharacters, string strVarToAssign, CodeStatementCollection statCol) { string strTemp = "tempString"; - string tsParam = "dmtfTimespan"; + string tsParam = "dmtfTimespan"; CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression(); cmie.Method = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(tsParam), "Substring"); @@ -7688,7 +7688,7 @@ namespace System.Management private void GenerateMethodToInitializeVariables() { - CodeMemberMethod cmmInit = new CodeMemberMethod (); + CodeMemberMethod cmmInit = new CodeMemberMethod(); cmmInit.Name = PrivateNamesUsed["initVariable"].ToString(); cmmInit.Attributes = MemberAttributes.Private | MemberAttributes.Final; @@ -7706,7 +7706,7 @@ namespace System.Management // private static CodeMethodInvokeExpression GenerateConcatStrings(CodeExpression ce1, CodeExpression ce2) { - CodeExpression []cmieParams = {ce1, ce2 }; + CodeExpression[] cmieParams = { ce1, ce2 }; CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("System.String"), "Concat", diff --git a/src/libraries/System.Management/src/System/Management/WmiEventSink.cs b/src/libraries/System.Management/src/System/Management/WmiEventSink.cs index aa90f04363b..962017aafb9 100644 --- a/src/libraries/System.Management/src/System/Management/WmiEventSink.cs +++ b/src/libraries/System.Management/src/System/Management/WmiEventSink.cs @@ -7,278 +7,298 @@ using System.Runtime.InteropServices; namespace System.Management { -internal class WmiEventSink : IWmiEventSource -{ - private static int s_hash = 0; - private readonly int hash; - private readonly ManagementOperationObserver watcher; - private readonly object context; - private readonly ManagementScope scope; - private object stub; // The secured IWbemObjectSink - - // Used for Put's only - internal event InternalObjectPutEventHandler InternalObjectPut; - private readonly ManagementPath path; - private readonly string className; - private readonly bool isLocal; - - - private static ManagementOperationObserver watcherParameter; - private static object contextParameter; - private static ManagementScope scopeParameter; - private static string pathParameter; - private static string classNameParameter; - private static WmiEventSink wmiEventSinkNew; - - internal static WmiEventSink GetWmiEventSink( - ManagementOperationObserver watcher, - object context, - ManagementScope scope, - string path, - string className) + internal class WmiEventSink : IWmiEventSource { - if (MTAHelper.IsNoContextMTA()) - return new WmiEventSink(watcher, context, scope, path, className); + private static int s_hash = 0; + private readonly int hash; + private readonly ManagementOperationObserver watcher; + private readonly object context; + private readonly ManagementScope scope; + private object stub; // The secured IWbemObjectSink - watcherParameter = watcher; - contextParameter = context; - scopeParameter = scope; - pathParameter = path; - classNameParameter = className; + // Used for Put's only + internal event InternalObjectPutEventHandler InternalObjectPut; + private readonly ManagementPath path; + private readonly string className; + private readonly bool isLocal; - // - // Ensure we are able to trap exceptions from worker thread. - // - ThreadDispatch disp = new ThreadDispatch ( new ThreadDispatch.ThreadWorkerMethod ( HackToCreateWmiEventSink ) ); - disp.Start ( ); - return wmiEventSinkNew; - } + private static ManagementOperationObserver watcherParameter; + private static object contextParameter; + private static ManagementScope scopeParameter; + private static string pathParameter; + private static string classNameParameter; + private static WmiEventSink wmiEventSinkNew; - private static void HackToCreateWmiEventSink() - { - wmiEventSinkNew = new WmiEventSink(watcherParameter, contextParameter, scopeParameter, pathParameter, classNameParameter); - } - - protected WmiEventSink (ManagementOperationObserver watcher, - object context, - ManagementScope scope, - string path, - string className) - { - try { - this.context = context; - this.watcher = watcher; - this.className = className; - this.isLocal = false; - - if (null != path) - { - this.path = new ManagementPath (path); - if ((0==string.Compare(this.path.Server, ".", StringComparison.OrdinalIgnoreCase)) || - (0==string.Compare(this.path.Server, System.Environment.MachineName, StringComparison.OrdinalIgnoreCase))) - { - this.isLocal = true; - } - } - - if (null != scope) - { - this.scope = (ManagementScope) scope.Clone (); - if (null == path) // use scope to see if sink is local - { - if ((0==string.Compare(this.scope.Path.Server, ".", StringComparison.OrdinalIgnoreCase)) || - (0==string.Compare(this.scope.Path.Server, System.Environment.MachineName, StringComparison.OrdinalIgnoreCase))) - { - this.isLocal = true; - } - } - } - - WmiNetUtilsHelper.GetDemultiplexedStub_f (this, this.isLocal, out stub); - hash = Threading.Interlocked.Increment(ref s_hash); - } catch {} - } - - public override int GetHashCode () { - return hash; - } - - public IWbemObjectSink Stub { - get { - try { - return (null != stub) ? (IWbemObjectSink) stub : null; - } catch { - return null; - } - } - } - - public virtual void Indicate (IntPtr pIWbemClassObject) - { - Marshal.AddRef(pIWbemClassObject); - IWbemClassObjectFreeThreaded obj = new IWbemClassObjectFreeThreaded(pIWbemClassObject); - try { - ObjectReadyEventArgs args = new ObjectReadyEventArgs (context, - ManagementBaseObject.GetBaseObject (obj, scope)); - watcher.FireObjectReady (args); - } catch {} - } - - public void SetStatus ( - int flags, - int hResult, - string message, - IntPtr pErrorObj) - { - IWbemClassObjectFreeThreaded errObj = null; - if (pErrorObj != IntPtr.Zero) + internal static WmiEventSink GetWmiEventSink( + ManagementOperationObserver watcher, + object context, + ManagementScope scope, + string path, + string className) { - Marshal.AddRef(pErrorObj); - errObj = new IWbemClassObjectFreeThreaded(pErrorObj); + if (MTAHelper.IsNoContextMTA()) + return new WmiEventSink(watcher, context, scope, path, className); + + watcherParameter = watcher; + contextParameter = context; + scopeParameter = scope; + pathParameter = path; + classNameParameter = className; + + // + // Ensure we are able to trap exceptions from worker thread. + // + ThreadDispatch disp = new ThreadDispatch(new ThreadDispatch.ThreadWorkerMethod(HackToCreateWmiEventSink)); + disp.Start(); + + return wmiEventSinkNew; } - try { - if (flags == (int) tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE) + private static void HackToCreateWmiEventSink() + { + wmiEventSinkNew = new WmiEventSink(watcherParameter, contextParameter, scopeParameter, pathParameter, classNameParameter); + } + + protected WmiEventSink(ManagementOperationObserver watcher, + object context, + ManagementScope scope, + string path, + string className) + { + try { - // Is this a Put? If so fire the ObjectPut event + this.context = context; + this.watcher = watcher; + this.className = className; + this.isLocal = false; + if (null != path) { - if (null == className) - path.RelativePath = message; - else - path.RelativePath = className; - - // Fire the internal event (if anyone is interested) - if (null != InternalObjectPut) + this.path = new ManagementPath(path); + if ((0 == string.Compare(this.path.Server, ".", StringComparison.OrdinalIgnoreCase)) || + (0 == string.Compare(this.path.Server, System.Environment.MachineName, StringComparison.OrdinalIgnoreCase))) { - try { - InternalObjectPutEventArgs iargs = new InternalObjectPutEventArgs (path); - InternalObjectPut (this, iargs); - } catch {} + this.isLocal = true; } - - ObjectPutEventArgs args = new ObjectPutEventArgs (context, path); - watcher.FireObjectPut(args); } - // Fire Completed event - CompletedEventArgs args2 = null; - if ( errObj != null ) + if (null != scope) + { + this.scope = (ManagementScope)scope.Clone(); + if (null == path) // use scope to see if sink is local { - args2 = new CompletedEventArgs (context, hResult, - new ManagementBaseObject (errObj) + if ((0 == string.Compare(this.scope.Path.Server, ".", StringComparison.OrdinalIgnoreCase)) || + (0 == string.Compare(this.scope.Path.Server, System.Environment.MachineName, StringComparison.OrdinalIgnoreCase))) + { + this.isLocal = true; + } + } + } + + WmiNetUtilsHelper.GetDemultiplexedStub_f(this, this.isLocal, out stub); + hash = Threading.Interlocked.Increment(ref s_hash); + } + catch { } + } + + public override int GetHashCode() + { + return hash; + } + + public IWbemObjectSink Stub + { + get + { + try + { + return (null != stub) ? (IWbemObjectSink)stub : null; + } + catch + { + return null; + } + } + } + + public virtual void Indicate(IntPtr pIWbemClassObject) + { + Marshal.AddRef(pIWbemClassObject); + IWbemClassObjectFreeThreaded obj = new IWbemClassObjectFreeThreaded(pIWbemClassObject); + try + { + ObjectReadyEventArgs args = new ObjectReadyEventArgs(context, + ManagementBaseObject.GetBaseObject(obj, scope)); + watcher.FireObjectReady(args); + } + catch { } + } + + public void SetStatus( + int flags, + int hResult, + string message, + IntPtr pErrorObj) + { + IWbemClassObjectFreeThreaded errObj = null; + if (pErrorObj != IntPtr.Zero) + { + Marshal.AddRef(pErrorObj); + errObj = new IWbemClassObjectFreeThreaded(pErrorObj); + } + + try + { + if (flags == (int)tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE) + { + // Is this a Put? If so fire the ObjectPut event + if (null != path) + { + if (null == className) + path.RelativePath = message; + else + path.RelativePath = className; + + // Fire the internal event (if anyone is interested) + if (null != InternalObjectPut) + { + try + { + InternalObjectPutEventArgs iargs = new InternalObjectPutEventArgs(path); + InternalObjectPut(this, iargs); + } + catch { } + } + + ObjectPutEventArgs args = new ObjectPutEventArgs(context, path); + watcher.FireObjectPut(args); + } + + // Fire Completed event + CompletedEventArgs args2 = null; + if (errObj != null) + { + args2 = new CompletedEventArgs(context, hResult, + new ManagementBaseObject(errObj) ); } - else + else { - args2 = new CompletedEventArgs (context, hResult, + args2 = new CompletedEventArgs(context, hResult, null ); } - watcher.FireCompleted (args2); + watcher.FireCompleted(args2); - // Unhook and tidy up - watcher.RemoveSink (this); + // Unhook and tidy up + watcher.RemoveSink(this); + } + else if (0 != (flags & (int)tag_WBEM_STATUS_TYPE.WBEM_STATUS_PROGRESS)) + { + // Fire Progress event + ProgressEventArgs args = new ProgressEventArgs(context, + (int)(((uint)hResult & 0xFFFF0000) >> 16), hResult & 0xFFFF, message); + + watcher.FireProgress(args); + } } - else if (0 != (flags & (int) tag_WBEM_STATUS_TYPE.WBEM_STATUS_PROGRESS)) - { - // Fire Progress event - ProgressEventArgs args = new ProgressEventArgs (context, - (int) (((uint)hResult & 0xFFFF0000) >> 16), hResult & 0xFFFF, message); + catch { } + } - watcher.FireProgress (args); - } - } catch {} - } - - internal void Cancel () - { - try { - scope.GetIWbemServices().CancelAsyncCall_((IWbemObjectSink) stub); - } catch {} - } - - internal void ReleaseStub () - { - try { - /* - * We force a release of the stub here so as to allow - * unsecapp.exe to die as soon as possible. - */ - if (null != stub) - { - System.Runtime.InteropServices.Marshal.ReleaseComObject(stub); - stub = null; - } - } catch {} - } - -} - -// Special sink implementation for ManagementObject.Get -// Doesn't issue ObjectReady events -internal class WmiGetEventSink : WmiEventSink -{ - private readonly ManagementObject managementObject; - - private static ManagementOperationObserver watcherParameter; - private static object contextParameter; - private static ManagementScope scopeParameter; - private static ManagementObject managementObjectParameter; - - private static WmiGetEventSink wmiGetEventSinkNew; - - internal static WmiGetEventSink GetWmiGetEventSink( - ManagementOperationObserver watcher, - object context, - ManagementScope scope, - ManagementObject managementObject) - { - if (MTAHelper.IsNoContextMTA()) - return new WmiGetEventSink(watcher, context, scope, managementObject); - - watcherParameter = watcher; - contextParameter = context; - scopeParameter = scope; - managementObjectParameter = managementObject; - - // - // Ensure we are able to trap exceptions from worker thread. - // - ThreadDispatch disp = new ThreadDispatch ( new ThreadDispatch.ThreadWorkerMethod ( HackToCreateWmiGetEventSink ) ); - disp.Start ( ); - - return wmiGetEventSinkNew; - } - - private static void HackToCreateWmiGetEventSink() - { - wmiGetEventSinkNew = new WmiGetEventSink(watcherParameter, contextParameter, scopeParameter, managementObjectParameter); - } - - - private WmiGetEventSink (ManagementOperationObserver watcher, - object context, - ManagementScope scope, - ManagementObject managementObject) : - base (watcher, context, scope, null, null) - { - this.managementObject = managementObject; - } - - public override void Indicate (IntPtr pIWbemClassObject) - { - Marshal.AddRef(pIWbemClassObject); - IWbemClassObjectFreeThreaded obj = new IWbemClassObjectFreeThreaded(pIWbemClassObject); - if (null != managementObject) + internal void Cancel() { - try { - managementObject.wbemObject = obj; - } catch {} + try + { + scope.GetIWbemServices().CancelAsyncCall_((IWbemObjectSink)stub); + } + catch { } + } + + internal void ReleaseStub() + { + try + { + /* + * We force a release of the stub here so as to allow + * unsecapp.exe to die as soon as possible. + */ + if (null != stub) + { + System.Runtime.InteropServices.Marshal.ReleaseComObject(stub); + stub = null; + } + } + catch { } + } + + } + + // Special sink implementation for ManagementObject.Get + // Doesn't issue ObjectReady events + internal class WmiGetEventSink : WmiEventSink + { + private readonly ManagementObject managementObject; + + private static ManagementOperationObserver watcherParameter; + private static object contextParameter; + private static ManagementScope scopeParameter; + private static ManagementObject managementObjectParameter; + + private static WmiGetEventSink wmiGetEventSinkNew; + + internal static WmiGetEventSink GetWmiGetEventSink( + ManagementOperationObserver watcher, + object context, + ManagementScope scope, + ManagementObject managementObject) + { + if (MTAHelper.IsNoContextMTA()) + return new WmiGetEventSink(watcher, context, scope, managementObject); + + watcherParameter = watcher; + contextParameter = context; + scopeParameter = scope; + managementObjectParameter = managementObject; + + // + // Ensure we are able to trap exceptions from worker thread. + // + ThreadDispatch disp = new ThreadDispatch(new ThreadDispatch.ThreadWorkerMethod(HackToCreateWmiGetEventSink)); + disp.Start(); + + return wmiGetEventSinkNew; + } + + private static void HackToCreateWmiGetEventSink() + { + wmiGetEventSinkNew = new WmiGetEventSink(watcherParameter, contextParameter, scopeParameter, managementObjectParameter); + } + + + private WmiGetEventSink(ManagementOperationObserver watcher, + object context, + ManagementScope scope, + ManagementObject managementObject) : + base(watcher, context, scope, null, null) + { + this.managementObject = managementObject; + } + + public override void Indicate(IntPtr pIWbemClassObject) + { + Marshal.AddRef(pIWbemClassObject); + IWbemClassObjectFreeThreaded obj = new IWbemClassObjectFreeThreaded(pIWbemClassObject); + if (null != managementObject) + { + try + { + managementObject.wbemObject = obj; + } + catch { } + } } } -} diff --git a/src/libraries/System.Management/src/System/Management/wmiutil.cs b/src/libraries/System.Management/src/System/Management/wmiutil.cs index 91a318a629d..9bd9bc1a547 100644 --- a/src/libraries/System.Management/src/System/Management/wmiutil.cs +++ b/src/libraries/System.Management/src/System/Management/wmiutil.cs @@ -45,17 +45,17 @@ namespace System.Management [ComImport] [Guid("1CF2B120-547D-101B-8E65-08002B2BD119")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - internal interface IErrorInfo + internal interface IErrorInfo { Guid GetGUID(); - [return:MarshalAs(UnmanagedType.BStr)] + [return: MarshalAs(UnmanagedType.BStr)] string GetSource(); - [return:MarshalAs(UnmanagedType.BStr)] + [return: MarshalAs(UnmanagedType.BStr)] string GetDescription(); - [return:MarshalAs(UnmanagedType.BStr)] + [return: MarshalAs(UnmanagedType.BStr)] string GetHelpFile(); uint GetHelpContext(); diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpAuthHelper.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpAuthHelper.cs index cc585043b0d..a941139306f 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpAuthHelper.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpAuthHelper.cs @@ -131,10 +131,10 @@ namespace System.Net.Http ICredentials proxyCreds = state.Proxy == null ? state.DefaultProxyCredentials : state.Proxy.Credentials; - if (proxyCreds == null) - { - break; - } + if (proxyCreds == null) + { + break; + } // Determine authorization scheme to use. We ignore the firstScheme // parameter which is included in the supportedSchemes flags already. @@ -336,7 +336,7 @@ namespace System.Net.Http authScheme == Interop.WinHttp.WINHTTP_AUTH_SCHEME_NTLM) { // Allow WinHTTP to transmit the default credentials. - ChangeDefaultCredentialsPolicy(requestHandle, authTarget, allowDefaultCredentials:true); + ChangeDefaultCredentialsPolicy(requestHandle, authTarget, allowDefaultCredentials: true); userName = null; password = null; } diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs index 06e1d0e3aa5..cea24d3bebe 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs @@ -554,8 +554,8 @@ namespace System.Net.Http state.DefaultProxyCredentials = _defaultProxyCredentials; state.PreAuthenticate = _preAuthenticate; - Task.Factory.StartNew( - s => { + Task.Factory.StartNew(s => + { var whrs = (WinHttpRequestState)s; _ = whrs.Handler.StartRequestAsync(whrs); }, @@ -1223,7 +1223,7 @@ namespace System.Net.Http _authHelper.ChangeDefaultCredentialsPolicy( state.RequestHandle, Interop.WinHttp.WINHTTP_AUTH_TARGET_SERVER, - allowDefaultCredentials:false); + allowDefaultCredentials: false); } private void SetRequestHandleBufferingOptions(SafeWinHttpHandle requestHandle) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestState.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestState.cs index 75247086d51..11a2c5d0212 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestState.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestState.cs @@ -125,12 +125,7 @@ namespace System.Net.Http public bool CheckCertificateRevocationList { get; set; } - public Func< - HttpRequestMessage, - X509Certificate2, - X509Chain, - SslPolicyErrors, - bool> ServerCertificateValidationCallback { get; set; } + public Func ServerCertificateValidationCallback { get; set; } public WinHttpTransportContext TransportContext { diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpGeneralHeaders.cs b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpGeneralHeaders.cs index a90c56f3dd2..550b1117e78 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpGeneralHeaders.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpGeneralHeaders.cs @@ -70,7 +70,7 @@ namespace System.Net.Http.Headers return true; } } - else if (parent.ContainsParsedValue(KnownHeaders.Connection.Descriptor, HeaderUtilities.ConnectionClose)) + else if (parent.ContainsParsedValue(KnownHeaders.Connection.Descriptor, HeaderUtilities.ConnectionClose)) { return true; } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs index 07c33a28718..a6a932fe729 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpRuleParser.cs @@ -113,7 +113,7 @@ namespace System.Net.Http { for (int i = 0; i < input.Length; i++) { - if (!IsTokenChar((char) input[i])) + if (!IsTokenChar((char)input[i])) { return false; } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/MultipartContent.cs b/src/libraries/System.Net.Http/src/System/Net/Http/MultipartContent.cs index d561f7f2a90..c2277fc253c 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/MultipartContent.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/MultipartContent.cs @@ -210,7 +210,7 @@ namespace System.Net.Http { try { - var streams = new Stream[2 + (_nestedContent.Count*2)]; + var streams = new Stream[2 + (_nestedContent.Count * 2)]; var scratch = new StringBuilder(); int streamIndex = 0; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs b/src/libraries/System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs index acf4041c470..e7d52d86fcd 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs @@ -61,12 +61,10 @@ namespace System.Net [Event(HandlerMessageId, Keywords = Keywords.Debug, Level = EventLevel.Verbose)] public void HandlerMessage(int poolId, int workerId, int requestId, string memberName, string message) => WriteEvent(HandlerMessageId, poolId, workerId, requestId, memberName, message); - //Console.WriteLine($"{poolId}/{workerId}/{requestId}: ({memberName}): {message}"); // uncomment for debugging only [Event(HandlerErrorId, Keywords = Keywords.Debug, Level = EventLevel.Error)] public void HandlerMessageError(int poolId, int workerId, int requestId, string memberName, string message) => WriteEvent(HandlerErrorId, poolId, workerId, requestId, memberName, message); - //Console.WriteLine($"{poolId}/{workerId}/{requestId}: ({memberName}): {message}"); // uncomment for debugging only [NonEvent] public static void AuthenticationInfo(Uri uri, string message) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs index dad19b6dee6..f6c126aef8c 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs @@ -120,7 +120,7 @@ namespace System.Net.Http } ChannelBinding channelBinding = connection.TransportContext?.GetChannelBinding(ChannelBindingKind.Endpoint); - NTAuthentication authContext = new NTAuthentication(isServer:false, challenge.SchemeName, challenge.Credential, spn, ContextFlagsPal.Connection, channelBinding); + NTAuthentication authContext = new NTAuthentication(isServer: false, challenge.SchemeName, challenge.Credential, spn, ContextFlagsPal.Connection, channelBinding); string challengeData = challenge.ChallengeData; try { @@ -169,12 +169,12 @@ namespace System.Net.Http public static Task SendWithNtProxyAuthAsync(HttpRequestMessage request, Uri proxyUri, ICredentials proxyCredentials, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken) { - return SendWithNtAuthAsync(request, proxyUri, proxyCredentials, isProxyAuth:true, connection, connectionPool, cancellationToken); + return SendWithNtAuthAsync(request, proxyUri, proxyCredentials, isProxyAuth: true, connection, connectionPool, cancellationToken); } public static Task SendWithNtConnectionAuthAsync(HttpRequestMessage request, ICredentials credentials, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken) { - return SendWithNtAuthAsync(request, request.RequestUri, credentials, isProxyAuth:false, connection, connectionPool, cancellationToken); + return SendWithNtAuthAsync(request, request.RequestUri, credentials, isProxyAuth: false, connection, connectionPool, cancellationToken); } } } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.cs index de989db538a..c310a4d6386 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.cs @@ -327,12 +327,12 @@ namespace System.Net.Http public static Task SendWithProxyAuthAsync(HttpRequestMessage request, Uri proxyUri, ICredentials proxyCredentials, bool doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken) { - return SendWithAuthAsync(request, proxyUri, proxyCredentials, preAuthenticate:false, isProxyAuth:true, doRequestAuth, pool, cancellationToken); + return SendWithAuthAsync(request, proxyUri, proxyCredentials, preAuthenticate: false, isProxyAuth: true, doRequestAuth, pool, cancellationToken); } public static Task SendWithRequestAuthAsync(HttpRequestMessage request, ICredentials credentials, bool preAuthenticate, HttpConnectionPool pool, CancellationToken cancellationToken) { - return SendWithAuthAsync(request, request.RequestUri, credentials, preAuthenticate, isProxyAuth:false, doRequestAuth:true, pool, cancellationToken); + return SendWithAuthAsync(request, request.RequestUri, credentials, preAuthenticate, isProxyAuth: false, doRequestAuth: true, pool, cancellationToken); } } } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/CancellationHelper.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/CancellationHelper.cs index e13dc680923..ad5a79a4b9a 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/CancellationHelper.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/CancellationHelper.cs @@ -39,7 +39,7 @@ namespace System.Net.Http { if (cancellationToken.IsCancellationRequested) { - ThrowOperationCanceledException(innerException:null, cancellationToken); + ThrowOperationCanceledException(innerException: null, cancellationToken); } } } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs index ff53f10c685..c526c2f2e87 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs @@ -21,9 +21,9 @@ namespace System.Net.Http /// "chunk extensions" are allowed. We place a limit on how long a line can be to avoid OOM issues if an /// infinite chunk length is sent. This value is arbitrary and can be changed as needed. /// - private const int MaxChunkBytesAllowed = 16*1024; + private const int MaxChunkBytesAllowed = 16 * 1024; /// How long a trailing header can be. This value is arbitrary and can be changed as needed. - private const int MaxTrailingHeaderLength = 16*1024; + private const int MaxTrailingHeaderLength = 16 * 1024; /// The number of bytes remaining in the chunk. private ulong _chunkBytesRemaining; /// The current state of the parsing state machine for the chunked response. @@ -374,7 +374,7 @@ namespace System.Net.Http { // Make sure that we don't inadvertently consume trailing headers // while draining a connection that's being returned back to the pool. - HttpConnection.ParseHeaderNameValue(_connection, currentLine, _response, isFromTrailer : true); + HttpConnection.ParseHeaderNameValue(_connection, currentLine, _response, isFromTrailer: true); } } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs index bd3e83d69f2..bfd003d10c7 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs @@ -1353,8 +1353,8 @@ namespace System.Net.Http _outgoingBuffer.Commit(FrameHeader.Size); } - /// Abort all streams and cause further processing to fail. - /// Exception causing Abort to be called. + /// Abort all streams and cause further processing to fail. + /// Exception causing Abort to be called. private void Abort(Exception abortException) { // The connection has failed, e.g. failed IO or a connection-level frame error. diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs index cc80779f78d..07b0638506c 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs @@ -683,7 +683,7 @@ namespace System.Net.Http // (4) Receiving EOF from the server. If so, resetException will contain an exception like "expected 9 bytes of data", and canRetry will be false. public void OnReset(Exception resetException, Http2ProtocolErrorCode? resetStreamErrorCode = null, bool canRetry = false) { - if (NetEventSource.IsEnabled) Trace($"{nameof(resetException)}={resetException}, {nameof(resetStreamErrorCode )}={resetStreamErrorCode}"); + if (NetEventSource.IsEnabled) Trace($"{nameof(resetException)}={resetException}, {nameof(resetStreamErrorCode)}={resetStreamErrorCode}"); bool cancel = false; CancellationTokenSource requestBodyCancellationSource = null; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs index eb0eb3d9592..7ad432fdf5b 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs @@ -18,7 +18,7 @@ namespace System.Net.Http protected internal override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - return _poolManager.SendAsync(request, doRequestAuth:true, cancellationToken); + return _poolManager.SendAsync(request, doRequestAuth: true, cancellationToken); } protected override void Dispose(bool disposing) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs index 6e4e0acf7e9..19bba82c837 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs @@ -888,7 +888,7 @@ namespace System.Net.Http // TODO: Remove this overload once https://github.com/dotnet/csharplang/issues/1331 is addressed // and the compiler doesn't prevent using spans in async methods. private static void ParseHeaderNameValue(HttpConnection connection, ArraySegment line, HttpResponseMessage response) => - ParseHeaderNameValue(connection, (Span)line, response, isFromTrailer:false); + ParseHeaderNameValue(connection, (Span)line, response, isFromTrailer: false); private static void ParseHeaderNameValue(HttpConnection connection, ReadOnlySpan line, HttpResponseMessage response, bool isFromTrailer) { diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs index 59d440f4bf2..e0aac9fa4c6 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs @@ -18,7 +18,7 @@ namespace System.Net.Http protected internal override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - return _poolManager.SendAsync(request, doRequestAuth:false, cancellationToken); + return _poolManager.SendAsync(request, doRequestAuth: false, cancellationToken); } protected override void Dispose(bool disposing) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs index f2b27f00f00..5a7a96b5e69 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs @@ -265,14 +265,14 @@ namespace System.Net.Http public Task SendProxyConnectAsync(HttpRequestMessage request, Uri proxyUri, CancellationToken cancellationToken) { - return SendAsyncCore(request, proxyUri, doRequestAuth:false, isProxyConnect:true, cancellationToken); + return SendAsyncCore(request, proxyUri, doRequestAuth: false, isProxyConnect: true, cancellationToken); } public Task SendAsync(HttpRequestMessage request, bool doRequestAuth, CancellationToken cancellationToken) { if (_proxy == null) { - return SendAsyncCore(request, null, doRequestAuth, isProxyConnect:false, cancellationToken); + return SendAsyncCore(request, null, doRequestAuth, isProxyConnect: false, cancellationToken); } // Do proxy lookup. @@ -296,7 +296,7 @@ namespace System.Net.Http throw new NotSupportedException(SR.net_http_invalid_proxy_scheme); } - return SendAsyncCore(request, proxyUri, doRequestAuth, isProxyConnect:false, cancellationToken); + return SendAsyncCore(request, proxyUri, doRequestAuth, isProxyConnect: false, cancellationToken); } /// Disposes of the pools, disposing of each individual pool. diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs index 88bd901ff6f..83408c7306f 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpWindowsProxy.cs @@ -22,7 +22,7 @@ namespace System.Net.Http private readonly WinInetProxyHelper _proxyHelper; private SafeWinHttpHandle _sessionHandle; private bool _disposed; - private static readonly char[] s_proxyDelimiters = {';', ' ', '\n', '\r', '\t'}; + private static readonly char[] s_proxyDelimiters = { ';', ' ', '\n', '\r', '\t' }; public static bool TryCreate(out IWebProxy proxy) { @@ -55,7 +55,7 @@ namespace System.Net.Http } } - proxy = new HttpWindowsProxy(proxyHelper, sessionHandle); + proxy = new HttpWindowsProxy(proxyHelper, sessionHandle); return true; } @@ -95,11 +95,11 @@ namespace System.Net.Http if (idx < proxyHelper.ProxyBypass.Length && proxyHelper.ProxyBypass[idx] == '[') { // Strip [] from IPv6 so we can use IdnHost laster for matching. - idx +=1; + idx += 1; } start = idx; - while (idx < proxyHelper.ProxyBypass.Length && proxyHelper.ProxyBypass[idx] != ' ' && proxyHelper.ProxyBypass[idx] != ';' && proxyHelper.ProxyBypass[idx] != ']') {idx += 1; }; + while (idx < proxyHelper.ProxyBypass.Length && proxyHelper.ProxyBypass[idx] != ' ' && proxyHelper.ProxyBypass[idx] != ';' && proxyHelper.ProxyBypass[idx] != ']') { idx += 1; }; if (idx == start) { @@ -113,16 +113,16 @@ namespace System.Net.Http } else { - tmp = proxyHelper.ProxyBypass.Substring(start, idx-start); + tmp = proxyHelper.ProxyBypass.Substring(start, idx - start); } // Skip trailing characters if any. if (idx < proxyHelper.ProxyBypass.Length && proxyHelper.ProxyBypass[idx] != ';') { // Got stopped at space or ']'. Strip until next ';' or end. - while (idx < proxyHelper.ProxyBypass.Length && proxyHelper.ProxyBypass[idx] != ';' ) {idx += 1; }; + while (idx < proxyHelper.ProxyBypass.Length && proxyHelper.ProxyBypass[idx] != ';') { idx += 1; }; } - if (idx < proxyHelper.ProxyBypass.Length && proxyHelper.ProxyBypass[idx] == ';') + if (idx < proxyHelper.ProxyBypass.Length && proxyHelper.ProxyBypass[idx] == ';') { idx++; } @@ -155,7 +155,7 @@ namespace System.Net.Http if (_bypassLocal) { - _localIp = new List(); + _localIp = new List(); foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces()) { IPInterfaceProperties ipProps = netInterface.GetIPProperties(); diff --git a/src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs b/src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs index 04a51e37209..7652ab73de7 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/Cookie.cs @@ -67,13 +67,13 @@ namespace System.Net private string m_domainKey = string.Empty; // Do not rename (binary serialization) -/* - TODO: #13607 - VSO 449560 - Reflecting on internal method won't work on AOT without rd.xml and DisableReflection - block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive - public, this is a temporary workaround till that happens. -*/ + /* + TODO: #13607 + VSO 449560 + Reflecting on internal method won't work on AOT without rd.xml and DisableReflection + block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive + public, this is a temporary workaround till that happens. + */ #if uap public #else @@ -81,13 +81,13 @@ namespace System.Net #endif bool IsQuotedVersion = false; -/* - TODO: #13607 - VSO 449560 - Reflecting on internal method won't work on AOT without rd.xml and DisableReflection - block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive - public, this is a temporary workaround till that happens. -*/ + /* + TODO: #13607 + VSO 449560 + Reflecting on internal method won't work on AOT without rd.xml and DisableReflection + block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive + public, this is a temporary workaround till that happens. + */ #if uap public #else @@ -242,13 +242,13 @@ namespace System.Net } } -/* - TODO: #13607 - VSO 449560 - Reflecting on internal method won't work on AOT without rd.xml and DisableReflection - block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive - public, this is a temporary workaround till that happens. -*/ + /* + TODO: #13607 + VSO 449560 + Reflecting on internal method won't work on AOT without rd.xml and DisableReflection + block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive + public, this is a temporary workaround till that happens. + */ #if uap public #else @@ -286,13 +286,13 @@ namespace System.Net } } -/* - TODO: #13607 - VSO 449560 - Reflecting on internal method won't work on AOT without rd.xml and DisableReflection - block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive - public, this is a temporary workaround till that happens. -*/ + /* + TODO: #13607 + VSO 449560 + Reflecting on internal method won't work on AOT without rd.xml and DisableReflection + block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive + public, this is a temporary workaround till that happens. + */ #if uap public #else @@ -703,13 +703,13 @@ namespace System.Net } } -/* - TODO: #13607 - VSO 449560 - Reflecting on internal method won't work on AOT without rd.xml and DisableReflection - block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive - public, this is a temporary workaround till that happens. -*/ + /* + TODO: #13607 + VSO 449560 + Reflecting on internal method won't work on AOT without rd.xml and DisableReflection + block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive + public, this is a temporary workaround till that happens. + */ #if uap public #else @@ -844,13 +844,13 @@ namespace System.Net } } -/* - TODO: #13607 - VSO 449560 - Reflecting on internal method won't work on AOT without rd.xml and DisableReflection - block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive - public, this is a temporary workaround till that happens. -*/ + /* + TODO: #13607 + VSO 449560 + Reflecting on internal method won't work on AOT without rd.xml and DisableReflection + block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive + public, this is a temporary workaround till that happens. + */ #if uap public #else diff --git a/src/libraries/System.Net.Primitives/src/System/Net/CookieCollection.cs b/src/libraries/System.Net.Primitives/src/System/Net/CookieCollection.cs index 667b828af3e..01e19e5026c 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/CookieCollection.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/CookieCollection.cs @@ -194,13 +194,13 @@ namespace System.Net // If isStrict == true, replace the cookie if found same with newest Variant. // Returns 1 if added, 0 if replaced or rejected. -/* - TODO: #13607 - VSO 449560 - Reflecting on internal method won't work on AOT without rd.xml and DisableReflection - block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive - public, this is a temporary workaround till that happens. -*/ + /* + TODO: #13607 + VSO 449560 + Reflecting on internal method won't work on AOT without rd.xml and DisableReflection + block in toolchain.Networking team will be working on exposing methods from S.Net.Primitive + public, this is a temporary workaround till that happens. + */ #if uap public #else diff --git a/src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs b/src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs index 198670fef61..a320990a530 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs @@ -13,7 +13,7 @@ using System.Threading; using System.Threading.Tasks; namespace System.Net { - public abstract class WebRequest : MarshalByRefObject, ISerializable + public abstract class WebRequest : MarshalByRefObject, ISerializable { internal class WebRequestPrefixElement { diff --git a/src/libraries/System.Net.Requests/src/System/Net/WebResponse.cs b/src/libraries/System.Net.Requests/src/System/Net/WebResponse.cs index e565db99335..6296ed91e3e 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/WebResponse.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/WebResponse.cs @@ -107,7 +107,7 @@ namespace System.Net /// public virtual Stream GetResponseStream() { - throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException); + throw NotImplemented.ByDesignWithMessage(SR.net_MethodNotImplementedException); } /// diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs b/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs index c68689346e7..e29252fb510 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs @@ -372,7 +372,7 @@ namespace System.Net.Security SetException(e); if (_exception.SourceException != e) { - ThrowIfExceptional(); + ThrowIfExceptional(); } throw; } diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/DynamicWinsockMethods.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/DynamicWinsockMethods.cs index 306ca9730d0..d62adc6b9fe 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/DynamicWinsockMethods.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/DynamicWinsockMethods.cs @@ -261,7 +261,7 @@ namespace System.Net.Sockets } } - [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError=true)] + [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] internal unsafe delegate bool AcceptExDelegate( SafeSocketHandle listenSocketHandle, SafeSocketHandle acceptSocketHandle, @@ -272,7 +272,7 @@ namespace System.Net.Sockets out int bytesReceived, NativeOverlapped* overlapped); - [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError=true)] + [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] internal delegate void GetAcceptExSockaddrsDelegate( IntPtr buffer, int receiveDataLength, @@ -284,7 +284,7 @@ namespace System.Net.Sockets out int remoteSocketAddressLength); - [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError=true)] + [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] internal unsafe delegate bool ConnectExDelegate( SafeSocketHandle socketHandle, IntPtr socketAddress, @@ -294,21 +294,21 @@ namespace System.Net.Sockets out int bytesSent, NativeOverlapped* overlapped); - [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError=true)] + [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] internal unsafe delegate bool DisconnectExDelegate( SafeSocketHandle socketHandle, NativeOverlapped* overlapped, int flags, int reserved); - [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError=true)] + [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] internal delegate bool DisconnectExDelegateBlocking( SafeSocketHandle socketHandle, IntPtr overlapped, int flags, int reserved); - [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError=true)] + [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] internal unsafe delegate SocketError WSARecvMsgDelegate( SafeSocketHandle socketHandle, IntPtr msg, @@ -316,7 +316,7 @@ namespace System.Net.Sockets NativeOverlapped* overlapped, IntPtr completionRoutine); - [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError=true)] + [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] internal delegate SocketError WSARecvMsgDelegateBlocking( SafeSocketHandle socketHandle, IntPtr msg, @@ -324,7 +324,7 @@ namespace System.Net.Sockets IntPtr overlapped, IntPtr completionRoutine); - [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError=true)] + [UnmanagedFunctionPointer(CallingConvention.StdCall, SetLastError = true)] internal unsafe delegate bool TransmitPacketsDelegate( SafeSocketHandle socketHandle, IntPtr packetArray, diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.cs index b321bb0f0e1..0e146df7c23 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SafeSocketHandle.cs @@ -162,7 +162,7 @@ namespace System.Net.Sockets if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"_innerSocket={_innerSocket}"); #if DEBUG - // If this throws it could be very bad. + // If this throws it could be very bad. try { #endif diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs index 7d5d81913fe..9b85ee3102a 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs @@ -2132,7 +2132,7 @@ namespace System.Net.Sockets } ValidateForMultiConnect(isMultiEndpoint: false); - return UnsafeBeginConnect(remoteEP, callback, state, flowContext:true); + return UnsafeBeginConnect(remoteEP, callback, state, flowContext: true); } private bool CanUseConnectEx(EndPoint remoteEP) diff --git a/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs b/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs index 3150fa5a7a8..31d33e733d8 100644 --- a/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs +++ b/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs @@ -1199,7 +1199,7 @@ namespace System.Net // Count them first. for (int i = 0; i < count; i++) { - char ch = (char) bytes[offset + i]; + char ch = (char)bytes[offset + i]; if (ch == ' ') { @@ -1221,8 +1221,8 @@ namespace System.Net for (int i = 0; i < count; i++) { - byte b = bytes[offset+i]; - char ch = (char) b; + byte b = bytes[offset + i]; + char ch = (char)b; if (IsSafe(ch)) { @@ -1230,13 +1230,13 @@ namespace System.Net } else if (ch == ' ') { - expandedBytes[pos++] = (byte) '+'; + expandedBytes[pos++] = (byte)'+'; } else { - expandedBytes[pos++] = (byte) '%'; - expandedBytes[pos++] = (byte) IntToHex((b >> 4) & 0xf); - expandedBytes[pos++] = (byte) IntToHex(b & 0x0f); + expandedBytes[pos++] = (byte)'%'; + expandedBytes[pos++] = (byte)IntToHex((b >> 4) & 0xf); + expandedBytes[pos++] = (byte)IntToHex(b & 0x0f); } } diff --git a/src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs b/src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs index 375e4f4f0d9..69f534146cc 100644 --- a/src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs +++ b/src/libraries/System.Net.WebHeaderCollection/src/System/Net/WebHeaderCollection.cs @@ -218,7 +218,7 @@ namespace System.Net public static bool IsRestricted(string headerName, bool response) { - headerName = HttpValidationHelpers.CheckBadHeaderNameChars(headerName); + headerName = HttpValidationHelpers.CheckBadHeaderNameChars(headerName); return response ? HeaderInfo[headerName].IsResponseRestricted : HeaderInfo[headerName].IsRequestRestricted; } diff --git a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs index dac5b93c33e..63dbd3b1b90 100644 --- a/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs +++ b/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs @@ -174,7 +174,7 @@ namespace System.Net.WebSockets if (response.StatusCode != HttpStatusCode.SwitchingProtocols) { - throw new WebSocketException(WebSocketError.NotAWebSocket, SR.Format(SR.net_WebSockets_Connect101Expected, (int) response.StatusCode)); + throw new WebSocketException(WebSocketError.NotAWebSocket, SR.Format(SR.net_WebSockets_Connect101Expected, (int)response.StatusCode)); } // The Connection, Upgrade, and SecWebSocketAccept headers are required and with specific values. diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/ArrayUtilities.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/ArrayUtilities.cs index 03a39e47099..b19096dfdb5 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/ArrayUtilities.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/ArrayUtilities.cs @@ -202,7 +202,7 @@ namespace System.Numerics.Tensors for (int i = 0; i < sourceStrides.Length; i++) { // reverse the index for reverseStride so that we divide by largest stride first - var nIndex = sourceReverseStride ? sourceStrides.Length - 1 - i: i; + var nIndex = sourceReverseStride ? sourceStrides.Length - 1 - i : i; var sourceStride = sourceStrides[nIndex]; var transformStride = transformStrides[nIndex]; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Globals.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Globals.cs index e0d9f6e27d5..6cad09abb38 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Globals.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Globals.cs @@ -767,7 +767,7 @@ namespace System.Runtime.Serialization private static Type s_typeOfDBNull; internal static Type TypeOfDBNull { - get + get { if (s_typeOfDBNull == null) s_typeOfDBNull = typeof(DBNull); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonCollectionDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonCollectionDataContract.cs index 677e2c10ad2..17d4ef23c60 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonCollectionDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonCollectionDataContract.cs @@ -81,7 +81,7 @@ namespace System.Runtime.Serialization.Json } else { - tempDelegate = new JsonFormatReaderGenerator().GenerateGetOnlyCollectionReader(TraditionalCollectionDataContract); + tempDelegate = new JsonFormatReaderGenerator().GenerateGetOnlyCollectionReader(TraditionalCollectionDataContract); } Interlocked.MemoryBarrier(); diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonReaderDelegator.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonReaderDelegator.cs index e480e4710f8..a659fc80219 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonReaderDelegator.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonReaderDelegator.cs @@ -236,7 +236,7 @@ namespace System.Runtime.Serialization.Json return ParseJsonDate(ReadElementContentAsString(), _dateTimeFormat); } - #if USE_REFEMIT +#if USE_REFEMIT public override bool TryReadDateTimeArray(XmlObjectSerializerReadContext context, #else internal override bool TryReadDateTimeArray(XmlObjectSerializerReadContext context, diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionClassWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionClassWriter.cs index 041dff541b7..af38aafd4e5 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionClassWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionClassWriter.cs @@ -23,7 +23,7 @@ namespace System.Runtime.Serialization obj = ResolveAdapterType(obj, classContract); if (classContract.IsISerializable) { - context.WriteISerializable(xmlWriter, (ISerializable) obj); + context.WriteISerializable(xmlWriter, (ISerializable)obj); } else { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs index b7c4e72a5c7..f3c9f2f4e8e 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/XmlObjectSerializerReadContext.cs @@ -1065,7 +1065,7 @@ namespace System.Runtime.Serialization { for (int i = 0; i < xmlAttributes.Count; i++) { - wrapperElement.Attributes.Append((XmlAttribute) xmlAttributes[i]); + wrapperElement.Attributes.Append((XmlAttribute)xmlAttributes[i]); } } if (xmlChildNodes != null) diff --git a/src/libraries/System.Private.Uri/src/System/Uri.cs b/src/libraries/System.Private.Uri/src/System/Uri.cs index b6a68481a5f..2848b00fd3f 100644 --- a/src/libraries/System.Private.Uri/src/System/Uri.cs +++ b/src/libraries/System.Private.Uri/src/System/Uri.cs @@ -126,8 +126,8 @@ namespace System public string? String; public Offset Offset; public string? DnsSafeHost; // stores dns safe host when idn is on and we have unicode or idn host - public MoreInfo? MoreInfo; // Multi-threading: This field must be always accessed through a _local_ - // stack copy of m_Info. + public MoreInfo? MoreInfo; // Multi-threading: This field must be always accessed through a _local_ + // stack copy of m_Info. }; [StructLayout(LayoutKind.Sequential, Pack = 1)] diff --git a/src/libraries/System.Private.Uri/src/System/UriParserTemplates.cs b/src/libraries/System.Private.Uri/src/System/UriParserTemplates.cs index d714f3aca58..9103afdc463 100644 --- a/src/libraries/System.Private.Uri/src/System/UriParserTemplates.cs +++ b/src/libraries/System.Private.Uri/src/System/UriParserTemplates.cs @@ -2,60 +2,61 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -namespace System { +namespace System +{ - public class HttpStyleUriParser: UriParser + public class HttpStyleUriParser : UriParser { - public HttpStyleUriParser():base(UriParser.HttpUri.Flags) + public HttpStyleUriParser() : base(UriParser.HttpUri.Flags) { } } - public class FtpStyleUriParser: UriParser + public class FtpStyleUriParser : UriParser { - public FtpStyleUriParser():base(UriParser.FtpUri.Flags) + public FtpStyleUriParser() : base(UriParser.FtpUri.Flags) { } } - public class FileStyleUriParser: UriParser + public class FileStyleUriParser : UriParser { - public FileStyleUriParser():base(UriParser.FileUri.Flags) + public FileStyleUriParser() : base(UriParser.FileUri.Flags) { } } - public class NewsStyleUriParser: UriParser + public class NewsStyleUriParser : UriParser { - public NewsStyleUriParser():base(UriParser.NewsUri.Flags) + public NewsStyleUriParser() : base(UriParser.NewsUri.Flags) { } } - public class GopherStyleUriParser: UriParser + public class GopherStyleUriParser : UriParser { - public GopherStyleUriParser():base(UriParser.GopherUri.Flags) + public GopherStyleUriParser() : base(UriParser.GopherUri.Flags) { } } - public class LdapStyleUriParser: UriParser + public class LdapStyleUriParser : UriParser { - public LdapStyleUriParser():base(UriParser.LdapUri.Flags) + public LdapStyleUriParser() : base(UriParser.LdapUri.Flags) { } } - public class NetPipeStyleUriParser: UriParser + public class NetPipeStyleUriParser : UriParser { - public NetPipeStyleUriParser():base(UriParser.NetPipeUri.Flags) + public NetPipeStyleUriParser() : base(UriParser.NetPipeUri.Flags) { } } - public class NetTcpStyleUriParser: UriParser + public class NetTcpStyleUriParser : UriParser { - public NetTcpStyleUriParser():base(UriParser.NetTcpUri.Flags) + public NetTcpStyleUriParser() : base(UriParser.NetTcpUri.Flags) { } } diff --git a/src/libraries/System.Private.Uri/src/System/UriSyntax.cs b/src/libraries/System.Private.Uri/src/System/UriSyntax.cs index 1bea7bc9327..2e64f227762 100644 --- a/src/libraries/System.Private.Uri/src/System/UriSyntax.cs +++ b/src/libraries/System.Private.Uri/src/System/UriSyntax.cs @@ -252,17 +252,17 @@ namespace System internal void CheckSetIsSimpleFlag() { - Type type = this.GetType(); + Type type = this.GetType(); - if ( type == typeof(GenericUriParser) - || type == typeof(HttpStyleUriParser) - || type == typeof(FtpStyleUriParser) - || type == typeof(FileStyleUriParser) - || type == typeof(NewsStyleUriParser) - || type == typeof(GopherStyleUriParser) - || type == typeof(NetPipeStyleUriParser) - || type == typeof(NetTcpStyleUriParser) - || type == typeof(LdapStyleUriParser) + if (type == typeof(GenericUriParser) + || type == typeof(HttpStyleUriParser) + || type == typeof(FtpStyleUriParser) + || type == typeof(FileStyleUriParser) + || type == typeof(NewsStyleUriParser) + || type == typeof(GopherStyleUriParser) + || type == typeof(NetPipeStyleUriParser) + || type == typeof(NetTcpStyleUriParser) + || type == typeof(LdapStyleUriParser) ) { _flags |= UriSyntaxFlags.SimpleUserSyntax; diff --git a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XAttribute.cs b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XAttribute.cs index d6ed5ad1b92..9adafce0b9c 100644 --- a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XAttribute.cs +++ b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XAttribute.cs @@ -228,7 +228,7 @@ namespace System.Xml.Linq /// The content of this as a . /// [CLSCompliant(false)] - public static explicit operator string (XAttribute attribute) + public static explicit operator string(XAttribute attribute) { if (attribute == null) return null; return attribute.value; @@ -247,7 +247,7 @@ namespace System.Xml.Linq /// Thrown if the specified attribute is null. /// [CLSCompliant(false)] - public static explicit operator bool (XAttribute attribute) + public static explicit operator bool(XAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); return XmlConvert.ToBoolean(attribute.value.ToLowerInvariant()); @@ -263,7 +263,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator bool? (XAttribute attribute) + public static explicit operator bool?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToBoolean(attribute.value.ToLowerInvariant()); @@ -282,7 +282,7 @@ namespace System.Xml.Linq /// Thrown if the specified attribute is null. /// [CLSCompliant(false)] - public static explicit operator int (XAttribute attribute) + public static explicit operator int(XAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); return XmlConvert.ToInt32(attribute.value); @@ -298,7 +298,7 @@ namespace System.Xml.Linq /// The content of this as an ?. /// [CLSCompliant(false)] - public static explicit operator int? (XAttribute attribute) + public static explicit operator int?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToInt32(attribute.value); @@ -317,7 +317,7 @@ namespace System.Xml.Linq /// Thrown if the specified attribute is null. /// [CLSCompliant(false)] - public static explicit operator uint (XAttribute attribute) + public static explicit operator uint(XAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); return XmlConvert.ToUInt32(attribute.value); @@ -333,7 +333,7 @@ namespace System.Xml.Linq /// The content of this as an ?. /// [CLSCompliant(false)] - public static explicit operator uint? (XAttribute attribute) + public static explicit operator uint?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToUInt32(attribute.value); @@ -352,7 +352,7 @@ namespace System.Xml.Linq /// Thrown if the specified attribute is null. /// [CLSCompliant(false)] - public static explicit operator long (XAttribute attribute) + public static explicit operator long(XAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); return XmlConvert.ToInt64(attribute.value); @@ -368,7 +368,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator long? (XAttribute attribute) + public static explicit operator long?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToInt64(attribute.value); @@ -387,7 +387,7 @@ namespace System.Xml.Linq /// Thrown if the specified attribute is null. /// [CLSCompliant(false)] - public static explicit operator ulong (XAttribute attribute) + public static explicit operator ulong(XAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); return XmlConvert.ToUInt64(attribute.value); @@ -403,7 +403,7 @@ namespace System.Xml.Linq /// The content of this as an ?. /// [CLSCompliant(false)] - public static explicit operator ulong? (XAttribute attribute) + public static explicit operator ulong?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToUInt64(attribute.value); @@ -422,7 +422,7 @@ namespace System.Xml.Linq /// Thrown if the specified attribute is null. /// [CLSCompliant(false)] - public static explicit operator float (XAttribute attribute) + public static explicit operator float(XAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); return XmlConvert.ToSingle(attribute.value); @@ -438,7 +438,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator float? (XAttribute attribute) + public static explicit operator float?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToSingle(attribute.value); @@ -457,7 +457,7 @@ namespace System.Xml.Linq /// Thrown if the specified attribute is null. /// [CLSCompliant(false)] - public static explicit operator double (XAttribute attribute) + public static explicit operator double(XAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); return XmlConvert.ToDouble(attribute.value); @@ -473,7 +473,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator double? (XAttribute attribute) + public static explicit operator double?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToDouble(attribute.value); @@ -492,7 +492,7 @@ namespace System.Xml.Linq /// Thrown if the specified attribute is null. /// [CLSCompliant(false)] - public static explicit operator decimal (XAttribute attribute) + public static explicit operator decimal(XAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); return XmlConvert.ToDecimal(attribute.value); @@ -508,7 +508,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator decimal? (XAttribute attribute) + public static explicit operator decimal?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToDecimal(attribute.value); @@ -543,7 +543,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator DateTime? (XAttribute attribute) + public static explicit operator DateTime?(XAttribute attribute) { if (attribute == null) return null; return DateTime.Parse(attribute.value, CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.RoundtripKind); @@ -578,7 +578,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator DateTimeOffset? (XAttribute attribute) + public static explicit operator DateTimeOffset?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToDateTimeOffset(attribute.value); @@ -613,7 +613,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator TimeSpan? (XAttribute attribute) + public static explicit operator TimeSpan?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToTimeSpan(attribute.value); @@ -648,7 +648,7 @@ namespace System.Xml.Linq /// The content of this as a ?. /// [CLSCompliant(false)] - public static explicit operator Guid? (XAttribute attribute) + public static explicit operator Guid?(XAttribute attribute) { if (attribute == null) return null; return XmlConvert.ToGuid(attribute.value); diff --git a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XDocument.cs b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XDocument.cs index 160c856e474..85959975350 100644 --- a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XDocument.cs +++ b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XDocument.cs @@ -429,7 +429,7 @@ namespace System.Xml.Linq XDocument d = InitLoad(reader, options); d.ReadContentFrom(reader, options); - if ( !reader.EOF) throw new InvalidOperationException(SR.InvalidOperation_ExpectedEndOfFile); + if (!reader.EOF) throw new InvalidOperationException(SR.InvalidOperation_ExpectedEndOfFile); if (d.Root == null) throw new InvalidOperationException(SR.InvalidOperation_MissingRoot); return d; } diff --git a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XElement.cs b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XElement.cs index bd05752cc5c..521fcc179f3 100644 --- a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XElement.cs +++ b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XElement.cs @@ -1338,7 +1338,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator string (XElement element) + public static explicit operator string(XElement element) { if (element == null) return null; return element.Value; @@ -1361,7 +1361,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator bool (XElement element) + public static explicit operator bool(XElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); return XmlConvert.ToBoolean(element.Value.ToLowerInvariant()); @@ -1381,7 +1381,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator bool? (XElement element) + public static explicit operator bool?(XElement element) { if (element == null) return null; return XmlConvert.ToBoolean(element.Value.ToLowerInvariant()); @@ -1404,7 +1404,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator int (XElement element) + public static explicit operator int(XElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); return XmlConvert.ToInt32(element.Value); @@ -1424,7 +1424,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator int? (XElement element) + public static explicit operator int?(XElement element) { if (element == null) return null; return XmlConvert.ToInt32(element.Value); @@ -1447,7 +1447,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator uint (XElement element) + public static explicit operator uint(XElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); return XmlConvert.ToUInt32(element.Value); @@ -1467,7 +1467,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator uint? (XElement element) + public static explicit operator uint?(XElement element) { if (element == null) return null; return XmlConvert.ToUInt32(element.Value); @@ -1490,7 +1490,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator long (XElement element) + public static explicit operator long(XElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); return XmlConvert.ToInt64(element.Value); @@ -1510,7 +1510,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator long? (XElement element) + public static explicit operator long?(XElement element) { if (element == null) return null; return XmlConvert.ToInt64(element.Value); @@ -1533,7 +1533,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator ulong (XElement element) + public static explicit operator ulong(XElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); return XmlConvert.ToUInt64(element.Value); @@ -1553,7 +1553,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator ulong? (XElement element) + public static explicit operator ulong?(XElement element) { if (element == null) return null; return XmlConvert.ToUInt64(element.Value); @@ -1576,7 +1576,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator float (XElement element) + public static explicit operator float(XElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); return XmlConvert.ToSingle(element.Value); @@ -1596,7 +1596,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator float? (XElement element) + public static explicit operator float?(XElement element) { if (element == null) return null; return XmlConvert.ToSingle(element.Value); @@ -1619,7 +1619,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator double (XElement element) + public static explicit operator double(XElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); return XmlConvert.ToDouble(element.Value); @@ -1639,7 +1639,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator double? (XElement element) + public static explicit operator double?(XElement element) { if (element == null) return null; return XmlConvert.ToDouble(element.Value); @@ -1662,7 +1662,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator decimal (XElement element) + public static explicit operator decimal(XElement element) { if (element == null) throw new ArgumentNullException(nameof(element)); return XmlConvert.ToDecimal(element.Value); @@ -1682,7 +1682,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator decimal? (XElement element) + public static explicit operator decimal?(XElement element) { if (element == null) return null; return XmlConvert.ToDecimal(element.Value); @@ -1725,7 +1725,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator DateTime? (XElement element) + public static explicit operator DateTime?(XElement element) { if (element == null) return null; return DateTime.Parse(element.Value, CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.RoundtripKind); @@ -1768,7 +1768,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator DateTimeOffset? (XElement element) + public static explicit operator DateTimeOffset?(XElement element) { if (element == null) return null; return XmlConvert.ToDateTimeOffset(element.Value); @@ -1811,7 +1811,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator TimeSpan? (XElement element) + public static explicit operator TimeSpan?(XElement element) { if (element == null) return null; return XmlConvert.ToTimeSpan(element.Value); @@ -1854,7 +1854,7 @@ namespace System.Xml.Linq /// [CLSCompliant(false)] [SuppressMessage("Microsoft.Usage", "CA2225:OperatorOverloadsHaveNamedAlternates", Justification = "Operator marked with CLSCompliant(false).")] - public static explicit operator Guid? (XElement element) + public static explicit operator Guid?(XElement element) { if (element == null) return null; return XmlConvert.ToGuid(element.Value); diff --git a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XLinq.cs b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XLinq.cs index f1d8c5df62b..1f6fa3b4b72 100644 --- a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XLinq.cs +++ b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XLinq.cs @@ -274,7 +274,7 @@ namespace System.Xml.Linq } else { - n = ((XNode) e.content).next; + n = ((XNode)e.content).next; continue; } } diff --git a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XObject.cs b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XObject.cs index 306f9458633..0e8e7d38c2e 100644 --- a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XObject.cs +++ b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XObject.cs @@ -81,7 +81,7 @@ namespace System.Xml.Linq if (annotation == null) throw new ArgumentNullException(nameof(annotation)); if (annotations == null) { - annotations = annotation is object[] ? new object[] { annotation } : annotation; + annotations = annotation is object[]? new object[] { annotation } : annotation; } else { diff --git a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XText.cs b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XText.cs index 7ca06139f08..cb00e97300a 100644 --- a/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XText.cs +++ b/src/libraries/System.Private.Xml.Linq/src/System/Xml/Linq/XText.cs @@ -108,7 +108,7 @@ namespace System.Xml.Linq if (cancellationToken.IsCancellationRequested) return Task.FromCanceled(cancellationToken); - return parent is XDocument? + return parent is XDocument ? writer.WriteWhitespaceAsync(text) : writer.WriteStringAsync(text); } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEncodedRawTextWriter.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEncodedRawTextWriter.cs index 94a4cf1667a..cf4cd69daeb 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEncodedRawTextWriter.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEncodedRawTextWriter.cs @@ -997,7 +997,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, true); pSrc++; @@ -1117,7 +1117,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, true); pSrc++; @@ -1195,7 +1195,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; @@ -1299,7 +1299,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; @@ -1448,7 +1448,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; @@ -1593,7 +1593,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; @@ -1658,8 +1658,8 @@ namespace System.Xml } else { - *pDst = (char)ch; - pDst++; + *pDst = (char)ch; + pDst++; return pDst; } } @@ -1675,7 +1675,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; @@ -1818,7 +1818,7 @@ namespace System.Xml fixed (char* pSrc = s) { char* pS = pSrc; - while ((*pDst++ = (char)*pS++) != 0); + while ((*pDst++ = (char)*pS++) != 0) ; } pDst[-1] = (char)';'; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEncodedRawTextWriterAsync.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEncodedRawTextWriterAsync.cs index 4a8de8d8ba4..3dd97591e12 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEncodedRawTextWriterAsync.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlEncodedRawTextWriterAsync.cs @@ -762,7 +762,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, true); pSrc++; @@ -966,7 +966,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, true); pSrc++; @@ -1150,7 +1150,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; @@ -1369,7 +1369,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; @@ -1600,7 +1600,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; @@ -1784,7 +1784,7 @@ namespace System.Xml pSrc += 2; } /* Invalid XML character */ - else if (ch <= 0x7F || ch >= 0xFFFE) + else if (ch <= 0x7F || ch >= 0xFFFE) { pDst = InvalidXmlChar(ch, pDst, false); pSrc++; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs index 36555266afb..e02d5b9ec0f 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReader.cs @@ -1870,7 +1870,7 @@ namespace System.Xml { read = input.Read(bytes, byteCount, bytes.Length - byteCount); byteCount += read; - } while (read > 0 && byteCount< 2); + } while (read > 0 && byteCount < 2); // create text or binary XML reader depenting on the stream first 2 bytes if (byteCount >= 2 && (bytes[0] == 0xdf && bytes[1] == 0xff)) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs index 14a59063262..4d9c43ef7d9 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs @@ -598,7 +598,7 @@ namespace System.Xml } } - return AddValidationAndConformanceInternal(reader, resolver, addConformanceWrapper: false); + return AddValidationAndConformanceInternal(reader, resolver, addConformanceWrapper: false); } private XmlReader AddValidationAndConformanceWrapper(XmlReader reader) @@ -609,7 +609,7 @@ namespace System.Xml resolver = GetXmlResolver_CheckConfig(); } - return AddValidationAndConformanceInternal(reader, resolver, addConformanceWrapper: true); + return AddValidationAndConformanceInternal(reader, resolver, addConformanceWrapper: true); } private XmlReader AddValidationAndConformanceInternal(XmlReader reader, XmlResolver resolver, bool addConformanceWrapper) diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs index 502b2be49cc..19a93c075fc 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReaderImplAsync.cs @@ -3962,7 +3962,7 @@ namespace System.Xml if (_dtdInfo == null || ((entity = _dtdInfo.LookupEntity(name)) == null)) { - // Needed only for XmlTextReader (when used from XmlDocument) + // Needed only for XmlTextReader (when used from XmlDocument) if (_disableUndeclaredEntityCheck) { SchemaEntity schemaEntity = new SchemaEntity(new XmlQualifiedName(name), false); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaDataType.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaDataType.cs index 7a01835db38..1283ea32cdb 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaDataType.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaDataType.cs @@ -22,7 +22,7 @@ namespace System.Xml.Schema public virtual XmlSchemaDatatypeVariety Variety { get { return XmlSchemaDatatypeVariety.Atomic; } } - internal XmlSchemaDatatype() {} + internal XmlSchemaDatatype() { } public virtual object ChangeType(object value, Type targetType) { diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaGroupBase.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaGroupBase.cs index 47d5e448b91..9794d9fe2cb 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaGroupBase.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/XmlSchemaGroupBase.cs @@ -8,7 +8,7 @@ namespace System.Xml.Schema public abstract class XmlSchemaGroupBase : XmlSchemaParticle { - internal XmlSchemaGroupBase() {} + internal XmlSchemaGroupBase() { } [XmlIgnore] public abstract XmlSchemaObjectCollection Items { get; } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs index 14a5d4f4e9f..761ed3f6cb6 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compiler.cs @@ -48,10 +48,10 @@ namespace System.Xml.Serialization AddImport(intf, types); ConstructorInfo[] ctors = type.GetConstructors(); - for (int i = 0; i(); diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/Ecma/EcmaCustomAttributeHelpers.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/Ecma/EcmaCustomAttributeHelpers.cs index b06f14ab210..e616b375c42 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/Ecma/EcmaCustomAttributeHelpers.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/Ecma/EcmaCustomAttributeHelpers.cs @@ -238,7 +238,7 @@ namespace System.Reflection.TypeLoading.Ecma if (br.RemainingBytes == 0) break; - ma.MarshalType = br.ReadSerializedString(); + ma.MarshalType = br.ReadSerializedString(); ma.MarshalTypeRef = Helpers.LoadTypeFromAssemblyQualifiedName(ma.MarshalType, module.GetRoAssembly(), ignoreCase: false, throwOnError: false); if (br.RemainingBytes == 0) diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Utf8Constants.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Utf8Constants.cs index d9c8968c906..20bc2fb0689 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Utf8Constants.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Utf8Constants.cs @@ -6,60 +6,60 @@ namespace System.Reflection.TypeLoading { internal static class Utf8Constants { - public static readonly byte[] System = {83, 121, 115, 116, 101, 109}; - public static readonly byte[] SystemReflection = {83, 121, 115, 116, 101, 109, 46, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110}; - public static readonly byte[] SystemCollectionsGeneric = {83, 121, 115, 116, 101, 109, 46, 67, 111, 108, 108, 101, 99, 116, 105, 111, 110, 115, 46, 71, 101, 110, 101, 114, 105, 99}; - public static readonly byte[] SystemRuntimeInteropServices = {83, 121, 115, 116, 101, 109, 46, 82, 117, 110, 116, 105, 109, 101, 46, 73, 110, 116, 101, 114, 111, 112, 83, 101, 114, 118, 105, 99, 101, 115}; - public static readonly byte[] SystemRuntimeCompilerServices = {83, 121, 115, 116, 101, 109, 46, 82, 117, 110, 116, 105, 109, 101, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115}; + public static readonly byte[] System = { 83, 121, 115, 116, 101, 109 }; + public static readonly byte[] SystemReflection = { 83, 121, 115, 116, 101, 109, 46, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110 }; + public static readonly byte[] SystemCollectionsGeneric = { 83, 121, 115, 116, 101, 109, 46, 67, 111, 108, 108, 101, 99, 116, 105, 111, 110, 115, 46, 71, 101, 110, 101, 114, 105, 99 }; + public static readonly byte[] SystemRuntimeInteropServices = { 83, 121, 115, 116, 101, 109, 46, 82, 117, 110, 116, 105, 109, 101, 46, 73, 110, 116, 101, 114, 111, 112, 83, 101, 114, 118, 105, 99, 101, 115 }; + public static readonly byte[] SystemRuntimeCompilerServices = { 83, 121, 115, 116, 101, 109, 46, 82, 117, 110, 116, 105, 109, 101, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115 }; - public static readonly byte[] Array = {65, 114, 114, 97, 121}; - public static readonly byte[] Boolean = {66, 111, 111, 108, 101, 97, 110}; - public static readonly byte[] Byte = {66, 121, 116, 101}; - public static readonly byte[] Char = {67, 104, 97, 114}; - public static readonly byte[] Double = {68, 111, 117, 98, 108, 101}; - public static readonly byte[] Enum = {69, 110, 117, 109}; - public static readonly byte[] Int16 = {73, 110, 116, 49, 54}; - public static readonly byte[] Int32 = {73, 110, 116, 51, 50}; - public static readonly byte[] Int64 = {73, 110, 116, 54, 52}; - public static readonly byte[] IntPtr = {73, 110, 116, 80, 116, 114}; - public static readonly byte[] Object = {79, 98, 106, 101, 99, 116}; + public static readonly byte[] Array = { 65, 114, 114, 97, 121 }; + public static readonly byte[] Boolean = { 66, 111, 111, 108, 101, 97, 110 }; + public static readonly byte[] Byte = { 66, 121, 116, 101 }; + public static readonly byte[] Char = { 67, 104, 97, 114 }; + public static readonly byte[] Double = { 68, 111, 117, 98, 108, 101 }; + public static readonly byte[] Enum = { 69, 110, 117, 109 }; + public static readonly byte[] Int16 = { 73, 110, 116, 49, 54 }; + public static readonly byte[] Int32 = { 73, 110, 116, 51, 50 }; + public static readonly byte[] Int64 = { 73, 110, 116, 54, 52 }; + public static readonly byte[] IntPtr = { 73, 110, 116, 80, 116, 114 }; + public static readonly byte[] Object = { 79, 98, 106, 101, 99, 116 }; public static readonly byte[] NullableT = { 78, 117, 108, 108, 97, 98, 108, 101, 96, 49 }; - public static readonly byte[] SByte = {83, 66, 121, 116, 101}; - public static readonly byte[] Single = {83, 105, 110, 103, 108, 101}; - public static readonly byte[] String = {83, 116, 114, 105, 110, 103}; - public static readonly byte[] TypedReference = {84, 121, 112, 101, 100, 82, 101, 102, 101, 114, 101, 110, 99, 101}; - public static readonly byte[] UInt16 = {85, 73, 110, 116, 49, 54}; - public static readonly byte[] UInt32 = {85, 73, 110, 116, 51, 50}; - public static readonly byte[] UInt64 = {85, 73, 110, 116, 54, 52}; - public static readonly byte[] UIntPtr = {85, 73, 110, 116, 80, 116, 114}; - public static readonly byte[] ValueType = {86, 97, 108, 117, 101, 84, 121, 112, 101}; - public static readonly byte[] Void = {86, 111, 105, 100}; - public static readonly byte[] MulticastDelegate = {77, 117, 108, 116, 105, 99, 97, 115, 116, 68, 101, 108, 101, 103, 97, 116, 101}; - public static readonly byte[] IEnumerableT = {73, 69, 110, 117, 109, 101, 114, 97, 98, 108, 101, 96, 49}; - public static readonly byte[] ICollectionT = {73, 67, 111, 108, 108, 101, 99, 116, 105, 111, 110, 96, 49}; - public static readonly byte[] IListT = {73, 76, 105, 115, 116, 96, 49}; - public static readonly byte[] IReadOnlyListT = {73, 82, 101, 97, 100, 79, 110, 108, 121, 76, 105, 115, 116, 96, 49}; - public static readonly byte[] Type = {84, 121, 112, 101}; - public static readonly byte[] DBNull = {68, 66, 78, 117, 108, 108}; - public static readonly byte[] Decimal = {68, 101, 99, 105, 109, 97, 108}; - public static readonly byte[] DateTime = {68, 97, 116, 101, 84, 105, 109, 101}; - public static readonly byte[] ComImportAttribute = {67, 111, 109, 73, 109, 112, 111, 114, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] DllImportAttribute = {68, 108, 108, 73, 109, 112, 111, 114, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] CallingConvention = {67, 97, 108, 108, 105, 110, 103, 67, 111, 110, 118, 101, 110, 116, 105, 111, 110}; - public static readonly byte[] CharSet = {67, 104, 97, 114, 83, 101, 116}; - public static readonly byte[] MarshalAsAttribute = {77, 97, 114, 115, 104, 97, 108, 65, 115, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] UnmanagedType = {85, 110, 109, 97, 110, 97, 103, 101, 100, 84, 121, 112, 101}; - public static readonly byte[] VarEnum = {86, 97, 114, 69, 110, 117, 109}; - public static readonly byte[] InAttribute = {73, 110, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] OutAttriubute = {79, 117, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] OptionalAttribute = {79, 112, 116, 105, 111, 110, 97, 108, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] PreserveSigAttribute = {80, 114, 101, 115, 101, 114, 118, 101, 83, 105, 103, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] FieldOffsetAttribute = {70, 105, 101, 108, 100, 79, 102, 102, 115, 101, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] IsByRefLikeAttribute = {73, 115, 66, 121, 82, 101, 102, 76, 105, 107, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] DecimalConstantAttribute = {68, 101, 99, 105, 109, 97, 108, 67, 111, 110, 115, 116, 97, 110, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] CustomConstantAttribute = {67, 117, 115, 116, 111, 109, 67, 111, 110, 115, 116, 97, 110, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] GuidAttribute = {71, 117, 105, 100, 65, 116, 116, 114, 105, 98, 117, 116, 101}; - public static readonly byte[] DefaultMemberAttribute = {68, 101, 102, 97, 117, 108, 116, 77, 101, 109, 98, 101, 114, 65, 116, 116, 114, 105, 98, 117, 116, 101}; + public static readonly byte[] SByte = { 83, 66, 121, 116, 101 }; + public static readonly byte[] Single = { 83, 105, 110, 103, 108, 101 }; + public static readonly byte[] String = { 83, 116, 114, 105, 110, 103 }; + public static readonly byte[] TypedReference = { 84, 121, 112, 101, 100, 82, 101, 102, 101, 114, 101, 110, 99, 101 }; + public static readonly byte[] UInt16 = { 85, 73, 110, 116, 49, 54 }; + public static readonly byte[] UInt32 = { 85, 73, 110, 116, 51, 50 }; + public static readonly byte[] UInt64 = { 85, 73, 110, 116, 54, 52 }; + public static readonly byte[] UIntPtr = { 85, 73, 110, 116, 80, 116, 114 }; + public static readonly byte[] ValueType = { 86, 97, 108, 117, 101, 84, 121, 112, 101 }; + public static readonly byte[] Void = { 86, 111, 105, 100 }; + public static readonly byte[] MulticastDelegate = { 77, 117, 108, 116, 105, 99, 97, 115, 116, 68, 101, 108, 101, 103, 97, 116, 101 }; + public static readonly byte[] IEnumerableT = { 73, 69, 110, 117, 109, 101, 114, 97, 98, 108, 101, 96, 49 }; + public static readonly byte[] ICollectionT = { 73, 67, 111, 108, 108, 101, 99, 116, 105, 111, 110, 96, 49 }; + public static readonly byte[] IListT = { 73, 76, 105, 115, 116, 96, 49 }; + public static readonly byte[] IReadOnlyListT = { 73, 82, 101, 97, 100, 79, 110, 108, 121, 76, 105, 115, 116, 96, 49 }; + public static readonly byte[] Type = { 84, 121, 112, 101 }; + public static readonly byte[] DBNull = { 68, 66, 78, 117, 108, 108 }; + public static readonly byte[] Decimal = { 68, 101, 99, 105, 109, 97, 108 }; + public static readonly byte[] DateTime = { 68, 97, 116, 101, 84, 105, 109, 101 }; + public static readonly byte[] ComImportAttribute = { 67, 111, 109, 73, 109, 112, 111, 114, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] DllImportAttribute = { 68, 108, 108, 73, 109, 112, 111, 114, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] CallingConvention = { 67, 97, 108, 108, 105, 110, 103, 67, 111, 110, 118, 101, 110, 116, 105, 111, 110 }; + public static readonly byte[] CharSet = { 67, 104, 97, 114, 83, 101, 116 }; + public static readonly byte[] MarshalAsAttribute = { 77, 97, 114, 115, 104, 97, 108, 65, 115, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] UnmanagedType = { 85, 110, 109, 97, 110, 97, 103, 101, 100, 84, 121, 112, 101 }; + public static readonly byte[] VarEnum = { 86, 97, 114, 69, 110, 117, 109 }; + public static readonly byte[] InAttribute = { 73, 110, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] OutAttriubute = { 79, 117, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] OptionalAttribute = { 79, 112, 116, 105, 111, 110, 97, 108, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] PreserveSigAttribute = { 80, 114, 101, 115, 101, 114, 118, 101, 83, 105, 103, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] FieldOffsetAttribute = { 70, 105, 101, 108, 100, 79, 102, 102, 115, 101, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] IsByRefLikeAttribute = { 73, 115, 66, 121, 82, 101, 102, 76, 105, 107, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] DecimalConstantAttribute = { 68, 101, 99, 105, 109, 97, 108, 67, 111, 110, 115, 116, 97, 110, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] CustomConstantAttribute = { 67, 117, 115, 116, 111, 109, 67, 111, 110, 115, 116, 97, 110, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] GuidAttribute = { 71, 117, 105, 100, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; + public static readonly byte[] DefaultMemberAttribute = { 68, 101, 102, 97, 117, 108, 116, 77, 101, 109, 98, 101, 114, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; public static readonly byte[] DateTimeConstantAttribute = { 68, 97, 116, 101, 84, 105, 109, 101, 67, 111, 110, 115, 116, 97, 110, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101 }; } } diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/Ecma/EcmaModule.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/Ecma/EcmaModule.cs index fb721d53bc2..b3a9e08a6da 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/Ecma/EcmaModule.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Modules/Ecma/EcmaModule.cs @@ -45,7 +45,7 @@ namespace System.Reflection.TypeLoading.Ecma public sealed override Guid ModuleVersionId => ModuleDefinition.Mvid.GetGuid(Reader); public sealed override string ScopeName => ModuleDefinition.Name.GetString(Reader); - public sealed override IEnumerable CustomAttributes => ModuleDefinition.GetCustomAttributes().ToTrueCustomAttributes(this); + public sealed override IEnumerable CustomAttributes => ModuleDefinition.GetCustomAttributes().ToTrueCustomAttributes(this); internal MethodInfo ComputeEntryPoint(bool fileRefEntryPointAllowed) { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/RuntimeTypeInfo.GetMember.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/RuntimeTypeInfo.GetMember.cs index e84ae2ae53a..d4a4ad9d5e1 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/RuntimeTypeInfo.GetMember.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/RuntimeTypeInfo.GetMember.cs @@ -41,9 +41,9 @@ namespace System.Reflection.TypeLoading MemberInfo[] results; - if ((results = QuerySpecificMemberTypeIfRequested(type, optionalName, bindingAttr, predicate, MemberTypes.Method, out QueryResult methods)) != null) + if ((results = QuerySpecificMemberTypeIfRequested(type, optionalName, bindingAttr, predicate, MemberTypes.Method, out QueryResult methods)) != null) return results; - if ((results = QuerySpecificMemberTypeIfRequested(type, optionalName, bindingAttr, predicate, MemberTypes.Constructor, out QueryResult constructors)) != null) + if ((results = QuerySpecificMemberTypeIfRequested(type, optionalName, bindingAttr, predicate, MemberTypes.Constructor, out QueryResult constructors)) != null) return results; if ((results = QuerySpecificMemberTypeIfRequested(type, optionalName, bindingAttr, predicate, MemberTypes.Property, out QueryResult properties)) != null) return results; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs index 0f872391c40..81b0d9f3052 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs @@ -150,7 +150,7 @@ namespace System.Reflection.TypeLoading internal sealed override IEnumerable GetMethodsCore(NameFilter filter, Type reflectedType) { - int rank =_rank; + int rank = _rank; int uniquifier = 0; RoType systemInt32 = Loader.GetCoreType(CoreType.Int32); diff --git a/src/libraries/System.Reflection.TypeExtensions/src/System/Reflection/TypeExtensions.cs b/src/libraries/System.Reflection.TypeExtensions/src/System/Reflection/TypeExtensions.cs index 80c25794e33..aa63d7fa905 100644 --- a/src/libraries/System.Reflection.TypeExtensions/src/System/Reflection/TypeExtensions.cs +++ b/src/libraries/System.Reflection.TypeExtensions/src/System/Reflection/TypeExtensions.cs @@ -332,7 +332,7 @@ namespace System.Reflection } return token; - } + } } public static class MethodInfoExtensions diff --git a/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/TypeNameComparer.cs b/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/TypeNameComparer.cs index 7ad88336c4f..64191f6cc46 100644 --- a/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/TypeNameComparer.cs +++ b/src/libraries/System.Resources.Extensions/src/System/Resources/Extensions/TypeNameComparer.cs @@ -119,7 +119,7 @@ namespace System.Resources.Extensions ReadOnlySpan typeSpan = assemblyQualifiedTypeName.AsSpan().TrimStart(s_whiteSpaceChars); ReadOnlySpan typeName = ReadTypeName(typeSpan); - int hashCode = 0; + int hashCode = 0; for (int i = 0; i < typeName.Length; i++) { hashCode = HashHelpers.Combine(hashCode, typeName[i].GetHashCode()); diff --git a/src/libraries/System.Resources.Writer/src/System/Resources/__FastResourceComparer.cs b/src/libraries/System.Resources.Writer/src/System/Resources/__FastResourceComparer.cs index 3fc14b20c0f..eef88126261 100644 --- a/src/libraries/System.Resources.Writer/src/System/Resources/__FastResourceComparer.cs +++ b/src/libraries/System.Resources.Writer/src/System/Resources/__FastResourceComparer.cs @@ -10,7 +10,7 @@ using System.Diagnostics; namespace System.Resources { //internal sealed class FastResourceComparer : IComparer, IEqualityComparer, IComparer, IEqualityComparer - internal sealed class FastResourceComparer :IComparer, IEqualityComparer + internal sealed class FastResourceComparer : IComparer, IEqualityComparer { internal static readonly FastResourceComparer Default = new FastResourceComparer(); diff --git a/src/libraries/System.Runtime.CompilerServices.VisualC/src/System/Runtime/CompilerServices/Attributes.cs b/src/libraries/System.Runtime.CompilerServices.VisualC/src/System/Runtime/CompilerServices/Attributes.cs index 37b8ce8fc44..ec989201762 100644 --- a/src/libraries/System.Runtime.CompilerServices.VisualC/src/System/Runtime/CompilerServices/Attributes.cs +++ b/src/libraries/System.Runtime.CompilerServices.VisualC/src/System/Runtime/CompilerServices/Attributes.cs @@ -59,7 +59,7 @@ namespace System.Runtime.CompilerServices [AttributeUsage(AttributeTargets.All)] internal sealed class DecoratedNameAttribute : Attribute { - public DecoratedNameAttribute(string decoratedName) {} + public DecoratedNameAttribute(string decoratedName) { } } // Indicates that the modified instance is pinned in memory. @@ -121,7 +121,7 @@ namespace System.Runtime.CompilerServices public NativeCppClassAttribute() { } } - [AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface, AllowMultiple=true, Inherited=false)] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)] public sealed class RequiredAttributeAttribute : Attribute { public RequiredAttributeAttribute(Type requiredContract) => RequiredContract = requiredContract; diff --git a/src/libraries/System.Runtime.Extensions/src/System/Context.cs b/src/libraries/System.Runtime.Extensions/src/System/Context.cs index 376198f1d53..1f53dfddbc5 100644 --- a/src/libraries/System.Runtime.Extensions/src/System/Context.cs +++ b/src/libraries/System.Runtime.Extensions/src/System/Context.cs @@ -28,7 +28,7 @@ namespace System HResult = HResults.COR_E_CONTEXTMARSHAL; } - protected ContextMarshalException(SerializationInfo info, StreamingContext context): base(info, context) + protected ContextMarshalException(SerializationInfo info, StreamingContext context) : base(info, context) { } } diff --git a/src/libraries/System.Runtime.Extensions/src/System/LoaderOptimizationAttribute.cs b/src/libraries/System.Runtime.Extensions/src/System/LoaderOptimizationAttribute.cs index 10e182b8ea3..33151f0322d 100644 --- a/src/libraries/System.Runtime.Extensions/src/System/LoaderOptimizationAttribute.cs +++ b/src/libraries/System.Runtime.Extensions/src/System/LoaderOptimizationAttribute.cs @@ -14,7 +14,7 @@ namespace System } public LoaderOptimizationAttribute(LoaderOptimization value) { - _val = (byte) value; + _val = (byte)value; } public LoaderOptimization Value => (LoaderOptimization)_val; } diff --git a/src/libraries/System.Runtime.Extensions/src/System/Runtime/CompilerServices/SwitchExpressionException.cs b/src/libraries/System.Runtime.Extensions/src/System/Runtime/CompilerServices/SwitchExpressionException.cs index b67200c6b56..6017ddba931 100644 --- a/src/libraries/System.Runtime.Extensions/src/System/Runtime/CompilerServices/SwitchExpressionException.cs +++ b/src/libraries/System.Runtime.Extensions/src/System/Runtime/CompilerServices/SwitchExpressionException.cs @@ -18,7 +18,9 @@ namespace System.Runtime.CompilerServices : base(SR.Arg_SwitchExpressionException) { } public SwitchExpressionException(Exception? innerException) : - base(SR.Arg_SwitchExpressionException, innerException) { } + base(SR.Arg_SwitchExpressionException, innerException) + { + } public SwitchExpressionException(object? unmatchedValue) : this() { diff --git a/src/libraries/System.Runtime.Extensions/src/System/Runtime/Versioning/VersioningHelper.cs b/src/libraries/System.Runtime.Extensions/src/System/Runtime/Versioning/VersioningHelper.cs index b7fc1c01906..5b88be0dd04 100644 --- a/src/libraries/System.Runtime.Extensions/src/System/Runtime/Versioning/VersioningHelper.cs +++ b/src/libraries/System.Runtime.Extensions/src/System/Runtime/Versioning/VersioningHelper.cs @@ -60,7 +60,8 @@ namespace System.Runtime.Versioning safeName.Append('r'); safeName.Append(clrID); } - if ((requires & SxSRequirements.AppDomainID) != 0) { + if ((requires & SxSRequirements.AppDomainID) != 0) + { safeName.Append(separator); safeName.Append("ad"); safeName.Append(AppDomain.CurrentDomain.Id); diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IDataObject.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IDataObject.cs index a72d0471e84..3baa883240d 100644 --- a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IDataObject.cs +++ b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IDataObject.cs @@ -18,7 +18,8 @@ namespace System.Runtime.InteropServices.ComTypes [ComImport] [Guid("0000010E-0000-0000-C000-000000000046")] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - public interface IDataObject { + public interface IDataObject + { /// /// Called by a data consumer to obtain data from a source data object. diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IEnumSTATDATA.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IEnumSTATDATA.cs index 7d000580a10..596e5e32efa 100644 --- a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IEnumSTATDATA.cs +++ b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IEnumSTATDATA.cs @@ -24,7 +24,7 @@ namespace System.Runtime.InteropServices.ComTypes /// in NULL for that parameter). /// [PreserveSig] - int Next(int celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] STATDATA[] rgelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeConst=1)] int[] pceltFetched); + int Next(int celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] STATDATA[] rgelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeConst = 1)] int[] pceltFetched); /// /// Skips over the next specified number of elements in the enumeration sequence. diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs index 62d7d400dac..7da0f0100c2 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs @@ -253,7 +253,7 @@ namespace System.Numerics { } - public BigInteger(ReadOnlySpan value, bool isUnsigned=false, bool isBigEndian=false) + public BigInteger(ReadOnlySpan value, bool isUnsigned = false, bool isBigEndian = false) { int byteCount = value.Length; @@ -1150,7 +1150,7 @@ namespace System.Numerics /// /// /// - public byte[] ToByteArray(bool isUnsigned=false, bool isBigEndian=false) + public byte[] ToByteArray(bool isUnsigned = false, bool isBigEndian = false) { int ignored = 0; return TryGetBytes(GetBytesMode.AllocateArray, default, isUnsigned, isBigEndian, ref ignored); @@ -1167,7 +1167,7 @@ namespace System.Numerics /// Whether or not to write the bytes in a big-endian byte order /// true if the bytes fit in ; false if not all bytes could be written due to lack of space. /// If is true and is negative. - public bool TryWriteBytes(Span destination, out int bytesWritten, bool isUnsigned=false, bool isBigEndian=false) + public bool TryWriteBytes(Span destination, out int bytesWritten, bool isUnsigned = false, bool isBigEndian = false) { bytesWritten = 0; if (TryGetBytes(GetBytesMode.Span, destination, isUnsigned, isBigEndian, ref bytesWritten) == null) @@ -1186,7 +1186,7 @@ namespace System.Numerics /// Gets the number of bytes that will be output by and . /// The number of bytes. - public int GetByteCount(bool isUnsigned=false) + public int GetByteCount(bool isUnsigned = false) { int count = 0; // Big or Little Endian doesn't matter for the byte count. diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs index 6fa62c11f9f..d94653ed5e6 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/Complex.cs @@ -453,7 +453,8 @@ namespace System.Numerics return new Complex(u, v); } - public static Complex Cos(Complex value) { + public static Complex Cos(Complex value) + { double p = Math.Exp(value.m_imaginary); double q = 1.0 / p; double sinh = (p - q) * 0.5; @@ -532,7 +533,8 @@ namespace System.Numerics return (ImaginaryOne / two) * (Log(One - ImaginaryOne * value) - Log(One + ImaginaryOne * value)); } - private static void Asin_Internal (double x, double y, out double b, out double bPrime, out double v) { + private static void Asin_Internal(double x, double y, out double b, out double bPrime, out double v) + { // This method for the inverse complex sine (and cosine) is described in Hull, Fairgrieve, // and Tang, "Implementing the Complex Arcsine and Arccosine Functions Using Exception Handling", diff --git a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryUtilClasses.cs b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryUtilClasses.cs index fbf99a3d48e..4805dc7ef33 100644 --- a/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryUtilClasses.cs +++ b/src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/Formatters/Binary/BinaryUtilClasses.cs @@ -229,7 +229,7 @@ namespace System.Runtime.Serialization.Formatters.Binary } else { - return index > _objects.Length - 1 ? null : _objects[index]; + return index > _objects.Length - 1 ? null : _objects[index]; } } set diff --git a/src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/LayoutCycleException.cs b/src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/LayoutCycleException.cs index 01095e7694a..bd3f7b8b071 100644 --- a/src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/LayoutCycleException.cs +++ b/src/libraries/System.Runtime.WindowsRuntime.UI.Xaml/src/System/Windows/LayoutCycleException.cs @@ -39,7 +39,7 @@ namespace Windows.UI.Xaml } protected LayoutCycleException(SerializationInfo serializationInfo, StreamingContext streamingContext) - : base (serializationInfo, streamingContext) + : base(serializationInfo, streamingContext) { } } diff --git a/src/libraries/System.Runtime.WindowsRuntime/src/System/Threading/Tasks/TaskToAsyncInfoAdapter.cs b/src/libraries/System.Runtime.WindowsRuntime/src/System/Threading/Tasks/TaskToAsyncInfoAdapter.cs index e0d60fb3832..affa25f4863 100644 --- a/src/libraries/System.Runtime.WindowsRuntime/src/System/Threading/Tasks/TaskToAsyncInfoAdapter.cs +++ b/src/libraries/System.Runtime.WindowsRuntime/src/System/Threading/Tasks/TaskToAsyncInfoAdapter.cs @@ -296,15 +296,15 @@ namespace System.Threading.Tasks #region State bit field operations - internal bool CompletedSynchronously {[Pure] get { return (0 != (_state & STATEFLAG_COMPLETED_SYNCHRONOUSLY)); } } + internal bool CompletedSynchronously { [Pure] get { return (0 != (_state & STATEFLAG_COMPLETED_SYNCHRONOUSLY)); } } - private bool IsInStartedState {[Pure] get { return (0 != (_state & STATE_STARTED)); } } + private bool IsInStartedState { [Pure] get { return (0 != (_state & STATE_STARTED)); } } - private bool IsInRunToCompletionState {[Pure] get { return (0 != (_state & STATE_RUN_TO_COMPLETION)); } } + private bool IsInRunToCompletionState { [Pure] get { return (0 != (_state & STATE_RUN_TO_COMPLETION)); } } - private bool IsInErrorState {[Pure] get { return (0 != (_state & STATE_ERROR)); } } + private bool IsInErrorState { [Pure] get { return (0 != (_state & STATE_ERROR)); } } - private bool IsInClosedState {[Pure] get { return (0 != (_state & STATE_CLOSED)); } } + private bool IsInClosedState { [Pure] get { return (0 != (_state & STATE_CLOSED)); } } private bool IsInRunningState { diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs index d9b391ca74f..ad194850e22 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ACL.cs @@ -37,11 +37,11 @@ namespace System.Security.AccessControl #region Constructors - internal AceEnumerator( GenericAcl collection ) + internal AceEnumerator(GenericAcl collection) { - if ( collection == null ) + if (collection == null) { - throw new ArgumentNullException( nameof(collection)); + throw new ArgumentNullException(nameof(collection)); } _acl = collection; @@ -56,10 +56,10 @@ namespace System.Security.AccessControl { get { - if ( _current == -1 || - _current >= _acl.Count ) + if (_current == -1 || + _current >= _acl.Count) { - throw new InvalidOperationException( SR.Arg_InvalidOperationException ); + throw new InvalidOperationException(SR.Arg_InvalidOperationException); } return _acl[_current]; @@ -68,14 +68,14 @@ namespace System.Security.AccessControl public GenericAce Current { - get { return (( IEnumerator )this ).Current as GenericAce; } + get { return ((IEnumerator)this).Current as GenericAce; } } public bool MoveNext() { _current++; - return ( _current < _acl.Count ); + return (_current < _acl.Count); } public void Reset() @@ -161,46 +161,42 @@ namespace System.Security.AccessControl // Returns the binary representation of the ACL // - public abstract void GetBinaryForm( byte[] binaryForm, int offset ); + public abstract void GetBinaryForm(byte[] binaryForm, int offset); #endregion #region ICollection Implementation - void ICollection.CopyTo( Array array, int index ) + void ICollection.CopyTo(Array array, int index) { - if ( array == null ) + if (array == null) { - throw new ArgumentNullException( nameof(array)); + throw new ArgumentNullException(nameof(array)); } - if ( array.Rank != 1 ) + if (array.Rank != 1) { - throw new RankException( SR.Rank_MultiDimNotSupported ); + throw new RankException(SR.Rank_MultiDimNotSupported); } - if ( index < 0 ) + if (index < 0) { - throw new ArgumentOutOfRangeException( -nameof(index), - SR.ArgumentOutOfRange_NeedNonNegNum ); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum); } - else if ( array.Length - index < Count ) + else if (array.Length - index < Count) { - throw new ArgumentOutOfRangeException( -nameof(array), - SR.ArgumentOutOfRange_ArrayTooSmall ); + throw new ArgumentOutOfRangeException(nameof(array), SR.ArgumentOutOfRange_ArrayTooSmall); } - for ( int i = 0; i < Count; i++ ) + for (int i = 0; i < Count; i++) { - array.SetValue( this[i], index + i ); + array.SetValue(this[i], index + i); } } - public void CopyTo( GenericAce[] array, int index ) + public void CopyTo(GenericAce[] array, int index) { - (( ICollection )this ).CopyTo( array, index ); + ((ICollection)this).CopyTo(array, index); } public abstract int Count { get; } @@ -221,12 +217,12 @@ nameof(array), IEnumerator IEnumerable.GetEnumerator() { - return new AceEnumerator( this ); + return new AceEnumerator(this); } public AceEnumerator GetEnumerator() { - return (( IEnumerable )this ).GetEnumerator() as AceEnumerator; + return ((IEnumerable)this).GetEnumerator() as AceEnumerator; } #endregion @@ -244,25 +240,23 @@ nameof(array), #region Private Methods - private static void VerifyHeader( byte[] binaryForm, int offset, out byte revision, out int count, out int length ) + private static void VerifyHeader(byte[] binaryForm, int offset, out byte revision, out int count, out int length) { - if ( binaryForm == null ) + if (binaryForm == null) { - throw new ArgumentNullException( nameof(binaryForm)); + throw new ArgumentNullException(nameof(binaryForm)); } - if ( offset < 0 ) + if (offset < 0) { // // Offset must not be negative // - throw new ArgumentOutOfRangeException( -nameof(offset), - SR.ArgumentOutOfRange_NeedNonNegNum ); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); } - if ( binaryForm.Length - offset < HeaderLength ) + if (binaryForm.Length - offset < HeaderLength) { // // We expect at least the ACL header @@ -272,10 +266,10 @@ nameof(offset), } revision = binaryForm[offset + 0]; - length = ( binaryForm[offset + 2] << 0 ) + ( binaryForm[offset + 3] << 8 ); - count = ( binaryForm[offset + 4] << 0 ) + ( binaryForm[offset + 5] << 8 ); + length = (binaryForm[offset + 2] << 0) + (binaryForm[offset + 3] << 8); + count = (binaryForm[offset + 4] << 0) + (binaryForm[offset + 5] << 8); - if ( length > binaryForm.Length - offset ) + if (length > binaryForm.Length - offset) { // // Reported length of ACL ought to be no longer than the @@ -289,45 +283,39 @@ nameof(offset), InvalidParameter: - throw new ArgumentOutOfRangeException( -nameof(binaryForm), - SR.ArgumentOutOfRange_ArrayTooSmall ); + throw new ArgumentOutOfRangeException(nameof(binaryForm), SR.ArgumentOutOfRange_ArrayTooSmall); } - private void MarshalHeader( byte[] binaryForm, int offset ) + private void MarshalHeader(byte[] binaryForm, int offset) { - if ( binaryForm == null ) + if (binaryForm == null) { - throw new ArgumentNullException( nameof(binaryForm)); + throw new ArgumentNullException(nameof(binaryForm)); } - else if ( offset < 0 ) + else if (offset < 0) { - throw new ArgumentOutOfRangeException( -nameof(offset), - SR.ArgumentOutOfRange_NeedNonNegNum ); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); } - else if ( BinaryLength > MaxBinaryLength ) + else if (BinaryLength > MaxBinaryLength) { - throw new InvalidOperationException( SR.AccessControl_AclTooLong ); + throw new InvalidOperationException(SR.AccessControl_AclTooLong); } - else if ( binaryForm.Length - offset < BinaryLength ) + else if (binaryForm.Length - offset < BinaryLength) { - throw new ArgumentOutOfRangeException( -nameof(binaryForm), - SR.ArgumentOutOfRange_ArrayTooSmall ); + throw new ArgumentOutOfRangeException(nameof(binaryForm), SR.ArgumentOutOfRange_ArrayTooSmall); } binaryForm[offset + 0] = Revision; binaryForm[offset + 1] = 0; - binaryForm[offset + 2] = unchecked(( byte )( BinaryLength >> 0 )); - binaryForm[offset + 3] = ( byte )( BinaryLength >> 8 ); - binaryForm[offset + 4] = unchecked(( byte )( Count >> 0 )); - binaryForm[offset + 5] = ( byte )( Count >> 8 ); + binaryForm[offset + 2] = unchecked((byte)(BinaryLength >> 0)); + binaryForm[offset + 3] = (byte)(BinaryLength >> 8); + binaryForm[offset + 4] = unchecked((byte)(Count >> 0)); + binaryForm[offset + 5] = (byte)(Count >> 8); binaryForm[offset + 6] = 0; binaryForm[offset + 7] = 0; } - internal void SetBinaryForm( byte[] binaryForm, int offset ) + internal void SetBinaryForm(byte[] binaryForm, int offset) { int count, length; @@ -335,7 +323,7 @@ nameof(binaryForm), // Verify the header and extract interesting header info // - VerifyHeader( binaryForm, offset, out _revision, out count, out length ); + VerifyHeader(binaryForm, offset, out _revision, out count, out length); // // Remember how far ahead the binary form should end (for later verification) @@ -345,16 +333,16 @@ nameof(binaryForm), offset += HeaderLength; - _aces = new List( count ); + _aces = new List(count); int binaryLength = HeaderLength; - for ( int i = 0; i < count; i++ ) + for (int i = 0; i < count; i++) { - GenericAce ace = GenericAce.CreateFromBinaryForm( binaryForm, offset ); + GenericAce ace = GenericAce.CreateFromBinaryForm(binaryForm, offset); int aceLength = ace.BinaryLength; - if ( binaryLength + aceLength > MaxBinaryLength ) + if (binaryLength + aceLength > MaxBinaryLength) { // // The ACE was too long - it would overflow the ACL maximum length @@ -363,16 +351,16 @@ nameof(binaryForm), throw new ArgumentException(SR.ArgumentException_InvalidAclBinaryForm, nameof(binaryForm)); } - _aces.Add( ace ); + _aces.Add(ace); - if ( aceLength % 4 != 0 ) + if (aceLength % 4 != 0) { // // This indicates a bug in one of the ACE classes. // Binary length of an ace must ALWAYS be divisible by 4. // - Debug.Assert( false, "aceLength % 4 != 0" ); + Debug.Assert(false, "aceLength % 4 != 0"); // Replacing SystemException with InvalidOperationException. This code path // indicates a bad ACE, but I don't know of a great exception to represent that. // InvalidOperation seems to be the closest, though it's definitely not exactly @@ -382,7 +370,7 @@ nameof(binaryForm), binaryLength += aceLength; - if ( _revision == AclRevisionDS ) + if (_revision == AclRevisionDS) { // // Increment the offset by the advertised length rather than the @@ -401,7 +389,7 @@ nameof(binaryForm), // Verify that no more than the advertised length of the ACL was consumed // - if ( offset > length ) + if (offset > length) { goto InvalidParameter; } @@ -424,21 +412,21 @@ nameof(binaryForm)); // Creates an empty ACL // - public RawAcl( byte revision, int capacity ) + public RawAcl(byte revision, int capacity) : base() { _revision = revision; - _aces = new List( capacity ); + _aces = new List(capacity); } // // Creates an ACL from its binary representation // - public RawAcl( byte[] binaryForm, int offset ) + public RawAcl(byte[] binaryForm, int offset) : base() { - SetBinaryForm( binaryForm, offset ); + SetBinaryForm(binaryForm, offset); } #endregion @@ -491,31 +479,31 @@ nameof(binaryForm)); // Returns the binary representation of the ACL // - public override void GetBinaryForm( byte[] binaryForm, int offset ) + public override void GetBinaryForm(byte[] binaryForm, int offset) { // // Populate the header // - MarshalHeader( binaryForm, offset ); + MarshalHeader(binaryForm, offset); offset += HeaderLength; - for ( int i = 0; i < Count; i++ ) + for (int i = 0; i < Count; i++) { GenericAce ace = _aces[i]; - ace.GetBinaryForm( binaryForm, offset ); + ace.GetBinaryForm(binaryForm, offset); int aceLength = ace.BinaryLength; - if ( aceLength % 4 != 0 ) + if (aceLength % 4 != 0) { // // This indicates a bug in one of the ACE classes. // Binary length of an ace must ALWAYS be divisible by 4. // - Debug.Assert( false, "aceLength % 4 != 0" ); + Debug.Assert(false, "aceLength % 4 != 0"); // Replacing SystemException with InvalidOperationException. This code path // indicates a bad ACE, but I don't know of a great exception to represent that. // InvalidOperation seems to be the closest, though it's definitely not exactly @@ -542,19 +530,19 @@ nameof(binaryForm)); set { - if ( value == null ) + if (value == null) { - throw new ArgumentNullException( nameof(value)); + throw new ArgumentNullException(nameof(value)); } - if ( value.BinaryLength % 4 != 0 ) + if (value.BinaryLength % 4 != 0) { // // This indicates a bug in one of the ACE classes. // Binary length of an ace must ALWAYS be divisible by 4. // - Debug.Assert( false, "aceLength % 4 != 0" ); + Debug.Assert(false, "aceLength % 4 != 0"); // Replacing SystemException with InvalidOperationException. This code path // indicates a bad ACE, but I don't know of a great exception to represent that. // InvalidOperation seems to be the closest, though it's definitely not exactly @@ -562,11 +550,11 @@ nameof(binaryForm)); throw new InvalidOperationException(); } - int newBinaryLength = BinaryLength - ( index < _aces.Count ? _aces[index].BinaryLength : 0 ) + value.BinaryLength; + int newBinaryLength = BinaryLength - (index < _aces.Count ? _aces[index].BinaryLength : 0) + value.BinaryLength; - if ( newBinaryLength > MaxBinaryLength ) + if (newBinaryLength > MaxBinaryLength) { - throw new OverflowException( SR.AccessControl_AclTooLong ); + throw new OverflowException(SR.AccessControl_AclTooLong); } _aces[index] = value; @@ -577,29 +565,29 @@ nameof(binaryForm)); // Adds an ACE at the specified index // - public void InsertAce( int index, GenericAce ace ) + public void InsertAce(int index, GenericAce ace) { - if ( ace == null ) + if (ace == null) { - throw new ArgumentNullException( nameof(ace)); + throw new ArgumentNullException(nameof(ace)); } - if ( BinaryLength + ace.BinaryLength > MaxBinaryLength ) + if (BinaryLength + ace.BinaryLength > MaxBinaryLength) { - throw new OverflowException( SR.AccessControl_AclTooLong ); + throw new OverflowException(SR.AccessControl_AclTooLong); } - _aces.Insert( index, ace ); + _aces.Insert(index, ace); } // // Removes an ACE at the specified index // - public void RemoveAce( int index ) + public void RemoveAce(int index) { GenericAce ace = _aces[index]; - _aces.RemoveAt( index ); + _aces.RemoveAt(index); } #endregion @@ -613,22 +601,22 @@ nameof(binaryForm)); [Flags] private enum AF // ACE flags { - CI = 0x8, // container inherit - OI = 0x4, // object inherit - IO = 0x2, // inherit only - NP = 0x1, // no propagate inherit - Invalid = NP, // not a valid combination of flags + CI = 0x8, // container inherit + OI = 0x4, // object inherit + IO = 0x2, // inherit only + NP = 0x1, // no propagate inherit + Invalid = NP, // not a valid combination of flags } [Flags] private enum PM // Propagation matrix { - F = 0x10, // folder - CF = 0x08, // child folder - CO = 0x04, // child object - GF = 0x02, // grandchild folder - GO = 0x01, // grandchild object - Invalid = GO, // not a valid combination of flags + F = 0x10, // folder + CF = 0x08, // child folder + CO = 0x04, // child object + GF = 0x02, // grandchild folder + GO = 0x01, // grandchild object + Invalid = GO, // not a valid combination of flags } private static readonly PM[] s_AFtoPM = CreateAFtoPMConversionMatrix(); // AceFlags-to-Propagation conversion matrix @@ -638,7 +626,7 @@ nameof(binaryForm)); { var afToPm = new PM[16]; - for ( int i = 0; i < afToPm.Length; i++ ) + for (int i = 0; i < afToPm.Length; i++) { afToPm[i] = PM.Invalid; } @@ -649,19 +637,19 @@ nameof(binaryForm)); // Important: Not all combinations of inheritance bits are valid // - afToPm[( int )( 0 | 0 | 0 | 0 )] = PM.F | 0 | 0 | 0 | 0; - afToPm[( int )( 0 | AF.OI | 0 | 0 )] = PM.F | 0 | PM.CO | 0 | PM.GO; - afToPm[( int )( 0 | AF.OI | 0 | AF.NP )] = PM.F | 0 | PM.CO | 0 | 0; - afToPm[( int )( 0 | AF.OI | AF.IO | 0 )] = 0 | 0 | PM.CO | 0 | PM.GO; - afToPm[( int )( 0 | AF.OI | AF.IO | AF.NP )] = 0 | 0 | PM.CO | 0 | 0; - afToPm[( int )( AF.CI | 0 | 0 | 0 )] = PM.F | PM.CF | 0 | PM.GF | 0; - afToPm[( int )( AF.CI | 0 | 0 | AF.NP )] = PM.F | PM.CF | 0 | 0 | 0; - afToPm[( int )( AF.CI | 0 | AF.IO | 0 )] = 0 | PM.CF | 0 | PM.GF | 0; - afToPm[( int )( AF.CI | 0 | AF.IO | AF.NP )] = 0 | PM.CF | 0 | 0 | 0; - afToPm[( int )( AF.CI | AF.OI | 0 | 0 )] = PM.F | PM.CF | PM.CO | PM.GF | PM.GO; - afToPm[( int )( AF.CI | AF.OI | 0 | AF.NP )] = PM.F | PM.CF | PM.CO | 0 | 0; - afToPm[( int )( AF.CI | AF.OI | AF.IO | 0 )] = 0 | PM.CF | PM.CO | PM.GF | PM.GO; - afToPm[( int )( AF.CI | AF.OI | AF.IO | AF.NP )] = 0 | PM.CF | PM.CO | 0 | 0; + afToPm[(int)( 0 | 0 | 0 | 0 )] = PM.F | 0 | 0 | 0 | 0; + afToPm[(int)( 0 | AF.OI | 0 | 0 )] = PM.F | 0 | PM.CO | 0 | PM.GO; + afToPm[(int)( 0 | AF.OI | 0 | AF.NP )] = PM.F | 0 | PM.CO | 0 | 0; + afToPm[(int)( 0 | AF.OI | AF.IO | 0 )] = 0 | 0 | PM.CO | 0 | PM.GO; + afToPm[(int)( 0 | AF.OI | AF.IO | AF.NP )] = 0 | 0 | PM.CO | 0 | 0; + afToPm[(int)( AF.CI | 0 | 0 | 0 )] = PM.F | PM.CF | 0 | PM.GF | 0; + afToPm[(int)( AF.CI | 0 | 0 | AF.NP )] = PM.F | PM.CF | 0 | 0 | 0; + afToPm[(int)( AF.CI | 0 | AF.IO | 0 )] = 0 | PM.CF | 0 | PM.GF | 0; + afToPm[(int)( AF.CI | 0 | AF.IO | AF.NP )] = 0 | PM.CF | 0 | 0 | 0; + afToPm[(int)( AF.CI | AF.OI | 0 | 0 )] = PM.F | PM.CF | PM.CO | PM.GF | PM.GO; + afToPm[(int)( AF.CI | AF.OI | 0 | AF.NP )] = PM.F | PM.CF | PM.CO | 0 | 0; + afToPm[(int)( AF.CI | AF.OI | AF.IO | 0 )] = 0 | PM.CF | PM.CO | PM.GF | PM.GO; + afToPm[(int)( AF.CI | AF.OI | AF.IO | AF.NP )] = 0 | PM.CF | PM.CO | 0 | 0; return afToPm; } @@ -670,7 +658,7 @@ nameof(binaryForm)); { var pmToAf = new AF[32]; - for ( int i = 0; i < pmToAf.Length; i++ ) + for (int i = 0; i < pmToAf.Length; i++) { pmToAf[i] = AF.Invalid; } @@ -682,19 +670,19 @@ nameof(binaryForm)); // the four ACE inheritance bits // - pmToAf[( int )( PM.F | 0 | 0 | 0 | 0 )] = 0 | 0 | 0 | 0; - pmToAf[( int )( PM.F | 0 | PM.CO | 0 | PM.GO )] = 0 | AF.OI | 0 | 0; - pmToAf[( int )( PM.F | 0 | PM.CO | 0 | 0 )] = 0 | AF.OI | 0 | AF.NP; - pmToAf[( int )( 0 | 0 | PM.CO | 0 | PM.GO )] = 0 | AF.OI | AF.IO | 0; - pmToAf[( int )( 0 | 0 | PM.CO | 0 | 0 )] = 0 | AF.OI | AF.IO | AF.NP; - pmToAf[( int )( PM.F | PM.CF | 0 | PM.GF | 0 )] = AF.CI | 0 | 0 | 0; - pmToAf[( int )( PM.F | PM.CF | 0 | 0 | 0 )] = AF.CI | 0 | 0 | AF.NP; - pmToAf[( int )( 0 | PM.CF | 0 | PM.GF | 0 )] = AF.CI | 0 | AF.IO | 0; - pmToAf[( int )( 0 | PM.CF | 0 | 0 | 0 )] = AF.CI | 0 | AF.IO | AF.NP; - pmToAf[( int )( PM.F | PM.CF | PM.CO | PM.GF | PM.GO )] = AF.CI | AF.OI | 0 | 0; - pmToAf[( int )( PM.F | PM.CF | PM.CO | 0 | 0 )] = AF.CI | AF.OI | 0 | AF.NP; - pmToAf[( int )( 0 | PM.CF | PM.CO | PM.GF | PM.GO )] = AF.CI | AF.OI | AF.IO | 0; - pmToAf[( int )( 0 | PM.CF | PM.CO | 0 | 0 )] = AF.CI | AF.OI | AF.IO | AF.NP; + pmToAf[(int)( PM.F | 0 | 0 | 0 | 0 )] = 0 | 0 | 0 | 0; + pmToAf[(int)( PM.F | 0 | PM.CO | 0 | PM.GO )] = 0 | AF.OI | 0 | 0; + pmToAf[(int)( PM.F | 0 | PM.CO | 0 | 0 )] = 0 | AF.OI | 0 | AF.NP; + pmToAf[(int)( 0 | 0 | PM.CO | 0 | PM.GO )] = 0 | AF.OI | AF.IO | 0; + pmToAf[(int)( 0 | 0 | PM.CO | 0 | 0 )] = 0 | AF.OI | AF.IO | AF.NP; + pmToAf[(int)( PM.F | PM.CF | 0 | PM.GF | 0 )] = AF.CI | 0 | 0 | 0; + pmToAf[(int)( PM.F | PM.CF | 0 | 0 | 0 )] = AF.CI | 0 | 0 | AF.NP; + pmToAf[(int)( 0 | PM.CF | 0 | PM.GF | 0 )] = AF.CI | 0 | AF.IO | 0; + pmToAf[(int)( 0 | PM.CF | 0 | 0 | 0 )] = AF.CI | 0 | AF.IO | AF.NP; + pmToAf[(int)( PM.F | PM.CF | PM.CO | PM.GF | PM.GO )] = AF.CI | AF.OI | 0 | 0; + pmToAf[(int)( PM.F | PM.CF | PM.CO | 0 | 0 )] = AF.CI | AF.OI | 0 | AF.NP; + pmToAf[(int)( 0 | PM.CF | PM.CO | PM.GF | PM.GO )] = AF.CI | AF.OI | AF.IO | 0; + pmToAf[(int)( 0 | PM.CF | PM.CO | 0 | 0 )] = AF.CI | AF.OI | AF.IO | AF.NP; return pmToAf; } @@ -703,11 +691,11 @@ nameof(binaryForm)); // Canonicalizes AceFlags into a form that the mapping tables understand // - private static AF AFFromAceFlags( AceFlags aceFlags, bool isDS ) + private static AF AFFromAceFlags(AceFlags aceFlags, bool isDS) { AF af = 0; - if (( aceFlags & AceFlags.ContainerInherit ) != 0) + if ((aceFlags & AceFlags.ContainerInherit) != 0) { af |= AF.CI; } @@ -716,17 +704,17 @@ nameof(binaryForm)); // ObjectInherit applies only to regular aces not object aces // so it can be ignored in the object aces case // - if (( !isDS ) && (( aceFlags & AceFlags.ObjectInherit ) != 0 )) + if ((!isDS) && ((aceFlags & AceFlags.ObjectInherit) != 0)) { af |= AF.OI; } - if (( aceFlags & AceFlags.InheritOnly ) != 0 ) + if ((aceFlags & AceFlags.InheritOnly) != 0) { af |= AF.IO; } - if (( aceFlags & AceFlags.NoPropagateInherit ) != 0 ) + if ((aceFlags & AceFlags.NoPropagateInherit) != 0) { af |= AF.NP; } @@ -738,11 +726,11 @@ nameof(binaryForm)); // Converts lookup table representation of AceFlags into the "public" form // - private static AceFlags AceFlagsFromAF( AF af, bool isDS ) + private static AceFlags AceFlagsFromAF(AF af, bool isDS) { AceFlags aceFlags = 0; - if (( af & AF.CI ) != 0 ) + if ((af & AF.CI) != 0) { aceFlags |= AceFlags.ContainerInherit; } @@ -751,17 +739,17 @@ nameof(binaryForm)); // ObjectInherit applies only to regular aces not object aces // so it can be ignored in the object aces case // - if (( !isDS ) && (( af & AF.OI ) != 0 )) + if ((!isDS) && ((af & AF.OI) != 0)) { aceFlags |= AceFlags.ObjectInherit; } - if (( af & AF.IO ) != 0 ) + if ((af & AF.IO) != 0) { aceFlags |= AceFlags.InheritOnly; } - if (( af & AF.NP ) != 0 ) + if ((af & AF.NP) != 0) { aceFlags |= AceFlags.NoPropagateInherit; } @@ -773,47 +761,47 @@ nameof(binaryForm)); // Implements the merge of inheritance bits during the 'ADD' operation // - private static bool MergeInheritanceBits( AceFlags left, AceFlags right, bool isDS, out AceFlags result ) + private static bool MergeInheritanceBits(AceFlags left, AceFlags right, bool isDS, out AceFlags result) { result = 0; - AF leftAF = AFFromAceFlags( left, isDS ); - AF rightAF = AFFromAceFlags( right, isDS ); + AF leftAF = AFFromAceFlags(left, isDS); + AF rightAF = AFFromAceFlags(right, isDS); PM leftPM = s_AFtoPM[(int)leftAF]; PM rightPM = s_AFtoPM[(int)rightAF]; - if ( leftPM == PM.Invalid || rightPM == PM.Invalid ) + if (leftPM == PM.Invalid || rightPM == PM.Invalid) { return false; // incorrect ACE flags? } PM resultPM = leftPM | rightPM; - AF resultAF = s_PMtoAF[( int )resultPM]; + AF resultAF = s_PMtoAF[(int)resultPM]; - if ( resultAF == AF.Invalid ) + if (resultAF == AF.Invalid) { return false; } else { - result = AceFlagsFromAF( resultAF, isDS ); + result = AceFlagsFromAF(resultAF, isDS); return true; } } - private static bool RemoveInheritanceBits( AceFlags existing, AceFlags remove, bool isDS, out AceFlags result, out bool total ) + private static bool RemoveInheritanceBits(AceFlags existing, AceFlags remove, bool isDS, out AceFlags result, out bool total) { result = 0; total = false; - AF leftAF = AFFromAceFlags( existing, isDS ); - AF rightAF = AFFromAceFlags( remove, isDS ); + AF leftAF = AFFromAceFlags(existing, isDS); + AF rightAF = AFFromAceFlags(remove, isDS); - PM leftPM = s_AFtoPM[( int )leftAF]; - PM rightPM = s_AFtoPM[( int )rightAF]; + PM leftPM = s_AFtoPM[(int)leftAF]; + PM rightPM = s_AFtoPM[(int)rightAF]; - if ( leftPM == PM.Invalid || rightPM == PM.Invalid ) + if (leftPM == PM.Invalid || rightPM == PM.Invalid) { return false; // incorrect ACE flags? } @@ -826,21 +814,21 @@ nameof(binaryForm)); // communicate back the fact that removal is "total" // - if ( resultPM == 0 ) + if (resultPM == 0) { total = true; return true; } - AF resultAF = s_PMtoAF[( int )resultPM]; + AF resultAF = s_PMtoAF[(int)resultPM]; - if ( resultAF == AF.Invalid ) + if (resultAF == AF.Invalid) { return false; } else { - result = AceFlagsFromAF( resultAF, isDS ); + result = AceFlagsFromAF(resultAF, isDS); return true; } } @@ -866,9 +854,9 @@ nameof(binaryForm)); private void CanonicalizeIfNecessary() { - if ( _isDirty ) + if (_isDirty) { - Canonicalize( false, this is DiscretionaryAcl ); + Canonicalize(false, this is DiscretionaryAcl); _isDirty = false; } } @@ -895,12 +883,12 @@ nameof(binaryForm)); // - user-defined ACEs (in the original order ) // - private static int DaclAcePriority( GenericAce ace) + private static int DaclAcePriority(GenericAce ace) { int result; AceType type = ace.AceType; - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { // // inherited aces are at the end as a group @@ -908,23 +896,23 @@ nameof(binaryForm)); result = 2 * ushort.MaxValue + ace._indexInAcl; } - else if ( type == AceType.AccessDenied || - type == AceType.AccessDeniedCallback ) + else if (type == AceType.AccessDenied || + type == AceType.AccessDeniedCallback) { result = 0; } - else if ( type == AceType.AccessDeniedObject || - type == AceType.AccessDeniedCallbackObject ) + else if (type == AceType.AccessDeniedObject || + type == AceType.AccessDeniedCallbackObject) { result = 1; } - else if ( type == AceType.AccessAllowed || - type == AceType.AccessAllowedCallback ) + else if (type == AceType.AccessAllowed || + type == AceType.AccessAllowedCallback) { result = 2; } - else if ( type == AceType.AccessAllowedObject || - type == AceType.AccessAllowedCallbackObject ) + else if (type == AceType.AccessAllowedObject || + type == AceType.AccessAllowedCallbackObject) { result = 3; } @@ -952,26 +940,26 @@ nameof(binaryForm)); // - user-defined ACEs (in the original order ) // - private static int SaclAcePriority( GenericAce ace ) + private static int SaclAcePriority(GenericAce ace) { int result; AceType type = ace.AceType; - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { result = 2 * ushort.MaxValue + ace._indexInAcl; } - else if ( type == AceType.SystemAudit || + else if (type == AceType.SystemAudit || type == AceType.SystemAlarm || type == AceType.SystemAuditCallback || - type == AceType.SystemAlarmCallback ) + type == AceType.SystemAlarmCallback) { result = 0; } - else if ( type == AceType.SystemAuditObject || + else if (type == AceType.SystemAuditObject || type == AceType.SystemAlarmObject || type == AceType.SystemAuditCallbackObject || - type == AceType.SystemAlarmCallbackObject ) + type == AceType.SystemAlarmCallbackObject) { result = 1; } @@ -983,16 +971,16 @@ nameof(binaryForm)); return result; } - private static ComparisonResult CompareAces( GenericAce ace1, GenericAce ace2, bool isDacl ) + private static ComparisonResult CompareAces(GenericAce ace1, GenericAce ace2, bool isDacl) { - int ace1Priority = isDacl ? DaclAcePriority( ace1 ) : SaclAcePriority( ace1 ); - int ace2Priority = isDacl ? DaclAcePriority( ace2 ) : SaclAcePriority( ace2 ); + int ace1Priority = isDacl ? DaclAcePriority(ace1) : SaclAcePriority(ace1); + int ace2Priority = isDacl ? DaclAcePriority(ace2) : SaclAcePriority(ace2); - if ( ace1Priority < ace2Priority ) + if (ace1Priority < ace2Priority) { return ComparisonResult.LessThan; } - else if ( ace1Priority > ace2Priority ) + else if (ace1Priority > ace2Priority) { return ComparisonResult.GreaterThan; } @@ -1001,15 +989,15 @@ nameof(binaryForm)); KnownAce k_ace1 = ace1 as KnownAce; KnownAce k_ace2 = ace2 as KnownAce; - if ( k_ace1 != null && k_ace2 != null ) + if (k_ace1 != null && k_ace2 != null) { - int result = k_ace1.SecurityIdentifier.CompareTo( k_ace2.SecurityIdentifier ); + int result = k_ace1.SecurityIdentifier.CompareTo(k_ace2.SecurityIdentifier); - if ( result < 0 ) + if (result < 0) { return ComparisonResult.LessThan; } - else if ( result > 0 ) + else if (result > 0) { return ComparisonResult.GreaterThan; } @@ -1019,13 +1007,13 @@ nameof(binaryForm)); } } - private void QuickSort( int left, int right, bool isDacl ) + private void QuickSort(int left, int right, bool isDacl) { GenericAce pivot; int leftHold, rightHold; int pivotIndex; - if ( left >= right ) + if (left >= right) { return; } @@ -1036,27 +1024,27 @@ nameof(binaryForm)); pivot = _acl[left]; pivotIndex = left; - while ( left < right ) + while (left < right) { -// while (( _acl[right] >= pivot ) && ( left < right )) - while (( ComparisonResult.LessThan != CompareAces( _acl[right], pivot, isDacl ) ) && ( left < right )) + // while (( _acl[right] >= pivot ) && ( left < right )) + while ((ComparisonResult.LessThan != CompareAces(_acl[right], pivot, isDacl)) && (left < right)) { right--; } - if ( left != right ) + if (left != right) { _acl[left] = _acl[right]; left++; } -// while (( _acl[left] <= pivot ) && ( left < right )) - while (( ComparisonResult.GreaterThan != CompareAces( _acl[left], pivot, isDacl ) ) && ( left < right )) + // while (( _acl[left] <= pivot ) && ( left < right )) + while ((ComparisonResult.GreaterThan != CompareAces(_acl[left], pivot, isDacl)) && (left < right)) { left++; } - if ( left != right ) + if (left != right) { _acl[right] = _acl[left]; right--; @@ -1068,14 +1056,14 @@ nameof(binaryForm)); left = leftHold; right = rightHold; - if ( left < pivotIndex ) + if (left < pivotIndex) { - QuickSort( left, pivotIndex - 1, isDacl ); + QuickSort(left, pivotIndex - 1, isDacl); } - if ( right > pivotIndex ) + if (right > pivotIndex) { - QuickSort( pivotIndex + 1, right, isDacl ); + QuickSort(pivotIndex + 1, right, isDacl); } } @@ -1085,7 +1073,7 @@ nameof(binaryForm)); // Returns 'true' if the ACE should remain in the ACL, 'false' otherwise // - private bool InspectAce( ref GenericAce ace, bool isDacl ) + private bool InspectAce(ref GenericAce ace, bool isDacl) { const AceFlags AuditFlags = AceFlags.SuccessfulAccess | @@ -1103,15 +1091,15 @@ nameof(binaryForm)); KnownAce knownAce = ace as KnownAce; - if ( knownAce != null ) + if (knownAce != null) { - if ( knownAce.AccessMask == 0 ) + if (knownAce.AccessMask == 0) { return false; } } - if ( !IsContainer ) + if (!IsContainer) { // // On a leaf object ACL, inheritance bits are meaningless. @@ -1122,12 +1110,12 @@ nameof(binaryForm)); // no meaning. // - if (( ace.AceFlags & AceFlags.InheritOnly ) != 0 ) + if ((ace.AceFlags & AceFlags.InheritOnly) != 0) { return false; } - if (( ace.AceFlags & InheritFlags ) != 0 ) + if ((ace.AceFlags & InheritFlags) != 0) { unchecked { ace.AceFlags &= ~InheritFlags; } } @@ -1139,9 +1127,9 @@ nameof(binaryForm)); // the InheritOnly bit is meaningless and the entire ACE can be removed. // - if ((( ace.AceFlags & AceFlags.InheritOnly ) != 0 ) && - (( ace.AceFlags & AceFlags.ContainerInherit ) == 0 ) && - (( ace.AceFlags & AceFlags.ObjectInherit ) == 0 )) + if (((ace.AceFlags & AceFlags.InheritOnly) != 0) && + ((ace.AceFlags & AceFlags.ContainerInherit) == 0) && + ((ace.AceFlags & AceFlags.ObjectInherit) == 0)) { return false; } @@ -1150,9 +1138,9 @@ nameof(binaryForm)); // Without either "container inherit" or "object inherit" to go with it, // the NoPropagateInherit bit is meaningless and can be turned off. // - if ((( ace.AceFlags & AceFlags.NoPropagateInherit ) != 0 ) && - (( ace.AceFlags & AceFlags.ContainerInherit ) == 0 ) && - (( ace.AceFlags & AceFlags.ObjectInherit ) == 0 )) + if (((ace.AceFlags & AceFlags.NoPropagateInherit) != 0) && + ((ace.AceFlags & AceFlags.ContainerInherit) == 0) && + ((ace.AceFlags & AceFlags.ObjectInherit) == 0)) { unchecked { ace.AceFlags &= ~AceFlags.NoPropagateInherit; } } @@ -1160,7 +1148,7 @@ nameof(binaryForm)); QualifiedAce qualifiedAce = knownAce as QualifiedAce; - if ( isDacl ) + if (isDacl) { // // There is no place for audit flags on a DACL @@ -1168,14 +1156,14 @@ nameof(binaryForm)); unchecked { ace.AceFlags &= ~AuditFlags; } - if ( qualifiedAce != null ) + if (qualifiedAce != null) { // // Qualified ACEs in a DACL must be allow or deny ACEs // - if ( qualifiedAce.AceQualifier != AceQualifier.AccessAllowed && - qualifiedAce.AceQualifier != AceQualifier.AccessDenied ) + if (qualifiedAce.AceQualifier != AceQualifier.AccessAllowed && + qualifiedAce.AceQualifier != AceQualifier.AccessDenied) { return false; } @@ -1188,7 +1176,7 @@ nameof(binaryForm)); // flags can be removed // - if (( ace.AceFlags & AuditFlags ) == 0 ) + if ((ace.AceFlags & AuditFlags) == 0) { return false; } @@ -1197,9 +1185,9 @@ nameof(binaryForm)); // Qualified ACEs in a SACL must be audit ACEs // - if ( qualifiedAce != null ) + if (qualifiedAce != null) { - if ( qualifiedAce.AceQualifier != AceQualifier.SystemAudit ) + if (qualifiedAce.AceQualifier != AceQualifier.SystemAudit) { return false; } @@ -1212,20 +1200,20 @@ nameof(binaryForm)); // Strips meaningless flags from ACEs, removes meaningless ACEs // - private void RemoveMeaninglessAcesAndFlags( bool isDacl ) + private void RemoveMeaninglessAcesAndFlags(bool isDacl) { // // Be warned: do NOT use the Count property because it has // side-effect of calling canonicalization. // - for ( int i = _acl.Count - 1; i >= 0; i-- ) + for (int i = _acl.Count - 1; i >= 0; i--) { GenericAce ace = _acl[i]; - if ( false == InspectAce( ref ace, isDacl )) + if (false == InspectAce(ref ace, isDacl)) { - _acl.RemoveAce( i ); + _acl.RemoveAce(i); } } } @@ -1234,7 +1222,7 @@ nameof(binaryForm)); // Converts the ACL to its canonical form // - private void Canonicalize( bool compact, bool isDacl ) + private void Canonicalize(bool compact, bool isDacl) { // // for quick sort to work, we must not allow the ace's indexes - which are constantly @@ -1248,27 +1236,27 @@ nameof(binaryForm)); _acl[aclIndex]._indexInAcl = aclIndex; } - QuickSort( 0, _acl.Count - 1, isDacl ); + QuickSort(0, _acl.Count - 1, isDacl); - if ( compact ) + if (compact) { - for ( int i = 0; i < Count - 1; i++ ) + for (int i = 0; i < Count - 1; i++) { QualifiedAce thisAce = _acl[i] as QualifiedAce; - if ( thisAce == null ) + if (thisAce == null) { continue; } QualifiedAce nextAce = _acl[i + 1] as QualifiedAce; - if ( nextAce == null ) + if (nextAce == null) { continue; } - if ( true == MergeAces( ref thisAce, nextAce )) + if (true == MergeAces(ref thisAce, nextAce)) { _acl.RemoveAce(i + 1); } @@ -1280,7 +1268,7 @@ nameof(binaryForm)); // This method determines whether the object type and inherited object type from the original ace // should be retained or not based on access mask and aceflags for a given split // - private void GetObjectTypesForSplit( ObjectAce originalAce, int accessMask, AceFlags aceFlags, out ObjectAceFlags objectFlags, out Guid objectType, out Guid inheritedObjectType ) + private void GetObjectTypesForSplit(ObjectAce originalAce, int accessMask, AceFlags aceFlags, out ObjectAceFlags objectFlags, out Guid objectType, out Guid inheritedObjectType) { objectFlags = 0; @@ -1290,7 +1278,7 @@ nameof(binaryForm)); // // We should retain the object type if the access mask for this split contains any bits that refer to object type // - if (( accessMask & ObjectAce.AccessMaskWithObjectType ) != 0 ) + if ((accessMask & ObjectAce.AccessMaskWithObjectType) != 0) { // keep the original ace's object flags and object type objectType = originalAce.ObjectAceType; @@ -1300,7 +1288,7 @@ nameof(binaryForm)); // // We should retain the inherited object type if the aceflags for this contains inheritance (ContainerInherit) // - if (( aceFlags & AceFlags.ContainerInherit ) != 0 ) + if ((aceFlags & AceFlags.ContainerInherit) != 0) { // keep the original ace's object flags and object type inheritedObjectType = originalAce.InheritedObjectAceType; @@ -1308,23 +1296,23 @@ nameof(binaryForm)); } } - private bool ObjectTypesMatch( QualifiedAce ace, QualifiedAce newAce ) + private bool ObjectTypesMatch(QualifiedAce ace, QualifiedAce newAce) { - Guid objectType = ( ace is ObjectAce ) ? (( ObjectAce ) ace ).ObjectAceType : Guid.Empty; - Guid newObjectType = ( newAce is ObjectAce ) ? (( ObjectAce ) newAce ).ObjectAceType : Guid.Empty; + Guid objectType = (ace is ObjectAce) ? ((ObjectAce)ace).ObjectAceType : Guid.Empty; + Guid newObjectType = (newAce is ObjectAce) ? ((ObjectAce)newAce).ObjectAceType : Guid.Empty; - return objectType.Equals( newObjectType ); + return objectType.Equals(newObjectType); } - private bool InheritedObjectTypesMatch( QualifiedAce ace, QualifiedAce newAce ) + private bool InheritedObjectTypesMatch(QualifiedAce ace, QualifiedAce newAce) { - Guid inheritedObjectType = ( ace is ObjectAce ) ? (( ObjectAce ) ace ).InheritedObjectAceType : Guid.Empty; - Guid newInheritedObjectType = ( newAce is ObjectAce ) ? (( ObjectAce ) newAce ).InheritedObjectAceType : Guid.Empty; + Guid inheritedObjectType = (ace is ObjectAce) ? ((ObjectAce)ace).InheritedObjectAceType : Guid.Empty; + Guid newInheritedObjectType = (newAce is ObjectAce) ? ((ObjectAce)newAce).InheritedObjectAceType : Guid.Empty; - return inheritedObjectType.Equals( newInheritedObjectType ); + return inheritedObjectType.Equals(newInheritedObjectType); } - private bool AccessMasksAreMergeable( QualifiedAce ace, QualifiedAce newAce ) + private bool AccessMasksAreMergeable(QualifiedAce ace, QualifiedAce newAce) { // // The access masks are mergeable in any of the following conditions @@ -1333,15 +1321,15 @@ nameof(binaryForm)); // already contains all the bits of the new ace which refer to the object type // - if ( ObjectTypesMatch( ace, newAce )) + if (ObjectTypesMatch(ace, newAce)) { // case 1 return true; } - ObjectAceFlags objectFlags = ( ace is ObjectAce ) ? (( ObjectAce ) ace ).ObjectAceFlags : ObjectAceFlags.None; - if ((( ace.AccessMask & newAce.AccessMask & ObjectAce.AccessMaskWithObjectType ) == ( newAce.AccessMask & ObjectAce.AccessMaskWithObjectType )) && - (( objectFlags & ObjectAceFlags.ObjectAceTypePresent ) == 0 )) + ObjectAceFlags objectFlags = (ace is ObjectAce) ? ((ObjectAce)ace).ObjectAceFlags : ObjectAceFlags.None; + if (((ace.AccessMask & newAce.AccessMask & ObjectAce.AccessMaskWithObjectType) == (newAce.AccessMask & ObjectAce.AccessMaskWithObjectType)) && + ((objectFlags & ObjectAceFlags.ObjectAceTypePresent) == 0)) { // case 2 return true; @@ -1350,7 +1338,7 @@ nameof(binaryForm)); return false; } - private bool AceFlagsAreMergeable( QualifiedAce ace, QualifiedAce newAce ) + private bool AceFlagsAreMergeable(QualifiedAce ace, QualifiedAce newAce) { // // The ace flags can be considered for merge in any of the following conditions @@ -1359,14 +1347,14 @@ nameof(binaryForm)); // already contains all the bits of the new ace // - if ( InheritedObjectTypesMatch( ace, newAce )) + if (InheritedObjectTypesMatch(ace, newAce)) { // case 1 return true; } - ObjectAceFlags objectFlags = ( ace is ObjectAce ) ? (( ObjectAce ) ace ).ObjectAceFlags : ObjectAceFlags.None; - if (( objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent ) == 0 ) + ObjectAceFlags objectFlags = (ace is ObjectAce) ? ((ObjectAce)ace).ObjectAceFlags : ObjectAceFlags.None; + if ((objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent) == 0) { // case 2 @@ -1374,16 +1362,16 @@ nameof(binaryForm)); // This method is called only when the access masks of the two aces are already confirmed to be exact matches // therefore the second condition of case 2 is already verified // - Debug.Assert(( ace.AccessMask & newAce.AccessMask) == newAce.AccessMask, "AceFlagsAreMergeable:: AccessMask of existing ace does not contain all access bits of new ace."); + Debug.Assert((ace.AccessMask & newAce.AccessMask) == newAce.AccessMask, "AceFlagsAreMergeable:: AccessMask of existing ace does not contain all access bits of new ace."); return true; } return false; } - private bool GetAccessMaskForRemoval( QualifiedAce ace, ObjectAceFlags objectFlags, Guid objectType, ref int accessMask ) + private bool GetAccessMaskForRemoval(QualifiedAce ace, ObjectAceFlags objectFlags, Guid objectType, ref int accessMask) { - if (( ace.AccessMask & accessMask & ObjectAce.AccessMaskWithObjectType ) != 0 ) + if ((ace.AccessMask & accessMask & ObjectAce.AccessMaskWithObjectType) != 0) { // @@ -1399,7 +1387,7 @@ nameof(binaryForm)); // - if ( ace is ObjectAce ) + if (ace is ObjectAce) { bool commonAccessBitsWithObjectTypeExist = true; ObjectAce objectAce = ace as ObjectAce; @@ -1408,8 +1396,8 @@ nameof(binaryForm)); // if what we are trying to remove has an object type // but the existing ace does not then this is an invalid case // - if ((( objectFlags & ObjectAceFlags.ObjectAceTypePresent ) != 0 ) && - (( objectAce.ObjectAceFlags & ObjectAceFlags.ObjectAceTypePresent ) == 0 )) + if (((objectFlags & ObjectAceFlags.ObjectAceTypePresent) != 0) && + ((objectAce.ObjectAceFlags & ObjectAceFlags.ObjectAceTypePresent) == 0)) { return false; } @@ -1419,14 +1407,14 @@ nameof(binaryForm)); // if object types match (since at this point we have ensured that both have object types present) // then we have common access bits with object type // - commonAccessBitsWithObjectTypeExist = (( objectFlags & ObjectAceFlags.ObjectAceTypePresent ) == 0 ) || - objectAce.ObjectTypesMatch( objectFlags, objectType ); - if ( !commonAccessBitsWithObjectTypeExist ) + commonAccessBitsWithObjectTypeExist = ((objectFlags & ObjectAceFlags.ObjectAceTypePresent) == 0) || + objectAce.ObjectTypesMatch(objectFlags, objectType); + if (!commonAccessBitsWithObjectTypeExist) { accessMask &= ~ObjectAce.AccessMaskWithObjectType; } } - else if (( objectFlags & ObjectAceFlags.ObjectAceTypePresent ) != 0 ) + else if ((objectFlags & ObjectAceFlags.ObjectAceTypePresent) != 0) { // the existing ace is a common ace and the one we're removing // refers to a specific object type so this is invalid @@ -1438,9 +1426,9 @@ nameof(binaryForm)); } - private bool GetInheritanceFlagsForRemoval( QualifiedAce ace, ObjectAceFlags objectFlags, Guid inheritedObjectType, ref AceFlags aceFlags ) + private bool GetInheritanceFlagsForRemoval(QualifiedAce ace, ObjectAceFlags objectFlags, Guid inheritedObjectType, ref AceFlags aceFlags) { - if ((( ace.AceFlags & AceFlags.ContainerInherit ) != 0 ) && (( aceFlags & AceFlags.ContainerInherit ) != 0 )) + if (((ace.AceFlags & AceFlags.ContainerInherit) != 0) && ((aceFlags & AceFlags.ContainerInherit) != 0)) { // @@ -1456,7 +1444,7 @@ nameof(binaryForm)); // - if ( ace is ObjectAce ) + if (ace is ObjectAce) { bool commonInheritanceFlagsExist = true; ObjectAce objectAce = ace as ObjectAce; @@ -1465,8 +1453,8 @@ nameof(binaryForm)); // if what we are trying to remove has an inherited object type // but the existing ace does not then this is an invalid case // - if ((( objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent ) != 0 ) && - (( objectAce.ObjectAceFlags & ObjectAceFlags.InheritedObjectAceTypePresent ) == 0 )) + if (((objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent) != 0) && + ((objectAce.ObjectAceFlags & ObjectAceFlags.InheritedObjectAceTypePresent) == 0)) { return false; } @@ -1475,14 +1463,14 @@ nameof(binaryForm)); // if what we are trying to remove has no inherited object type or // if inherited object types match then we have common inheritance flags // - commonInheritanceFlagsExist = (( objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent ) == 0 ) || - objectAce.InheritedObjectTypesMatch( objectFlags, inheritedObjectType ); - if ( !commonInheritanceFlagsExist ) + commonInheritanceFlagsExist = ((objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent) == 0) || + objectAce.InheritedObjectTypesMatch(objectFlags, inheritedObjectType); + if (!commonInheritanceFlagsExist) { aceFlags &= ~AceFlags.InheritanceFlags; } } - else if (( objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent ) != 0 ) + else if ((objectFlags & ObjectAceFlags.InheritedObjectAceTypePresent) != 0) { // the existing ace is a common ace and the one we're removing // refers to a specific child type so this is invalid @@ -1494,24 +1482,24 @@ nameof(binaryForm)); } - private static bool AceOpaquesMatch( QualifiedAce ace, QualifiedAce newAce ) + private static bool AceOpaquesMatch(QualifiedAce ace, QualifiedAce newAce) { byte[] aceOpaque = ace.GetOpaque(); byte[] newAceOpaque = newAce.GetOpaque(); - if ( aceOpaque == null || newAceOpaque == null ) + if (aceOpaque == null || newAceOpaque == null) { return aceOpaque == newAceOpaque; } - if ( aceOpaque.Length != newAceOpaque.Length ) + if (aceOpaque.Length != newAceOpaque.Length) { return false; } - for ( int i = 0; i < aceOpaque.Length; ++i ) + for (int i = 0; i < aceOpaque.Length; ++i) { - if ( aceOpaque[i] != newAceOpaque[i] ) + if (aceOpaque[i] != newAceOpaque[i]) { return false; } @@ -1520,13 +1508,13 @@ nameof(binaryForm)); return true; } - private static bool AcesAreMergeable( QualifiedAce ace, QualifiedAce newAce ) + private static bool AcesAreMergeable(QualifiedAce ace, QualifiedAce newAce) { // // Only interested in ACEs with the specified type // - if ( ace.AceType != newAce.AceType ) + if (ace.AceType != newAce.AceType) { return false; } @@ -1535,12 +1523,12 @@ nameof(binaryForm)); // Only interested in explicit (non-inherited) ACEs // - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { return false; } - if (( newAce.AceFlags & AceFlags.Inherited ) != 0 ) + if ((newAce.AceFlags & AceFlags.Inherited) != 0) { return false; } @@ -1549,7 +1537,7 @@ nameof(binaryForm)); // Only interested in ACEs with the specified qualifier // - if ( ace.AceQualifier != newAce.AceQualifier ) + if (ace.AceQualifier != newAce.AceQualifier) { return false; } @@ -1558,7 +1546,7 @@ nameof(binaryForm)); // Only interested in ACEs with the specified SID // - if ( ace.SecurityIdentifier != newAce.SecurityIdentifier ) + if (ace.SecurityIdentifier != newAce.SecurityIdentifier) { return false; } @@ -1567,7 +1555,7 @@ nameof(binaryForm)); // Only interested in ACEs with the specified callback data // - if ( !AceOpaquesMatch( ace, newAce )) + if (!AceOpaquesMatch(ace, newAce)) { return false; } @@ -1579,13 +1567,13 @@ nameof(binaryForm)); // Merge routine for qualified ACEs // - private bool MergeAces( ref QualifiedAce ace, QualifiedAce newAce ) + private bool MergeAces(ref QualifiedAce ace, QualifiedAce newAce) { // // Check whether the ACEs are potentially mergeable // - if ( !AcesAreMergeable( ace, newAce )) + if (!AcesAreMergeable(ace, newAce)) { return false; } @@ -1596,15 +1584,15 @@ nameof(binaryForm)); // Stage 1: if flags match, add to the access mask // - if ( ace.AceFlags == newAce.AceFlags ) + if (ace.AceFlags == newAce.AceFlags) { - if ( ace is ObjectAce || newAce is ObjectAce ) + if (ace is ObjectAce || newAce is ObjectAce) { // for object aces we need to match the inherited object types (for ace flags equality) - if ( InheritedObjectTypesMatch( ace, newAce )) + if (InheritedObjectTypesMatch(ace, newAce)) { // also since access mask bits are further qualified by object type, they cannot always be added on - if ( AccessMasksAreMergeable( ace, newAce )) + if (AccessMasksAreMergeable(ace, newAce)) { ace.AccessMask |= newAce.AccessMask; return true; @@ -1625,22 +1613,22 @@ nameof(binaryForm)); // flags (both access mask and inheritance) match // - if ((( ace.AceFlags & AceFlags.InheritanceFlags ) == ( newAce.AceFlags & AceFlags.InheritanceFlags )) && - ( ace.AccessMask == newAce.AccessMask )) + if (((ace.AceFlags & AceFlags.InheritanceFlags) == (newAce.AceFlags & AceFlags.InheritanceFlags)) && + (ace.AccessMask == newAce.AccessMask)) { - if (( ace is ObjectAce ) || ( newAce is ObjectAce )) + if ((ace is ObjectAce) || (newAce is ObjectAce)) { // for object aces we need to match the inherited object types (for inheritance flags equality) and object type (for access mask equality) as well - if ( InheritedObjectTypesMatch( ace, newAce ) && - ( ObjectTypesMatch( ace, newAce ))) + if (InheritedObjectTypesMatch(ace, newAce) && + (ObjectTypesMatch(ace, newAce))) { - ace.AceFlags |= ( newAce.AceFlags & AceFlags.AuditFlags ); + ace.AceFlags |= (newAce.AceFlags & AceFlags.AuditFlags); return true; } } else { - ace.AceFlags |= ( newAce.AceFlags & AceFlags.AuditFlags ); + ace.AceFlags |= (newAce.AceFlags & AceFlags.AuditFlags); return true; } @@ -1651,8 +1639,8 @@ nameof(binaryForm)); // provided access mask and audit bits are the same // - if ((( ace.AceFlags & AceFlags.AuditFlags ) == ( newAce.AceFlags & AceFlags.AuditFlags )) && - ( ace.AccessMask == newAce.AccessMask )) + if (((ace.AceFlags & AceFlags.AuditFlags) == (newAce.AceFlags & AceFlags.AuditFlags)) && + (ace.AccessMask == newAce.AccessMask)) { AceFlags merged; @@ -1660,25 +1648,25 @@ nameof(binaryForm)); // See whether the inheritance bits can be merged // - if (( ace is ObjectAce ) || ( newAce is ObjectAce )) + if ((ace is ObjectAce) || (newAce is ObjectAce)) { // object types need to match (for access mask equality) and inheritance flags need additional DS specific logic // to check whether they can be merged - if (( ObjectTypesMatch( ace, newAce )) && - ( AceFlagsAreMergeable( ace, newAce ))) + if ((ObjectTypesMatch(ace, newAce)) && + (AceFlagsAreMergeable(ace, newAce))) { - if ( true == MergeInheritanceBits( ace.AceFlags, newAce.AceFlags, IsDS, out merged )) + if (true == MergeInheritanceBits(ace.AceFlags, newAce.AceFlags, IsDS, out merged)) { - ace.AceFlags = ( merged | ( ace.AceFlags & AceFlags.AuditFlags )); + ace.AceFlags = (merged | (ace.AceFlags & AceFlags.AuditFlags)); return true; } } } else { - if ( true == MergeInheritanceBits( ace.AceFlags, newAce.AceFlags, IsDS, out merged )) + if (true == MergeInheritanceBits(ace.AceFlags, newAce.AceFlags, IsDS, out merged)) { - ace.AceFlags = ( merged | ( ace.AceFlags & AceFlags.AuditFlags )); + ace.AceFlags = (merged | (ace.AceFlags & AceFlags.AuditFlags)); return true; } } @@ -1692,9 +1680,9 @@ nameof(binaryForm)); // Returns 'true' if the ACL is in canonical order; 'false' otherwise // - private bool CanonicalCheck( bool isDacl ) + private bool CanonicalCheck(bool isDacl) { - if ( isDacl ) + if (isDacl) { // // DACL canonical order: @@ -1713,13 +1701,13 @@ nameof(binaryForm)); // of this check! // - for ( int i = 0; i < _acl.Count; i++ ) + for (int i = 0; i < _acl.Count; i++) { int aceStage; GenericAce ace = _acl[i]; - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { aceStage = Inherited; } @@ -1727,7 +1715,7 @@ nameof(binaryForm)); { QualifiedAce qualifiedAce = ace as QualifiedAce; - if ( qualifiedAce == null ) + if (qualifiedAce == null) { // // Explicit ACE is not recognized - this is not a canonical ACL @@ -1736,11 +1724,11 @@ nameof(binaryForm)); return false; } - if ( qualifiedAce.AceQualifier == AceQualifier.AccessAllowed ) + if (qualifiedAce.AceQualifier == AceQualifier.AccessAllowed) { aceStage = AccessAllowed; } - else if ( qualifiedAce.AceQualifier == AceQualifier.AccessDenied ) + else if (qualifiedAce.AceQualifier == AceQualifier.AccessDenied) { aceStage = AccessDenied; } @@ -1750,16 +1738,16 @@ nameof(binaryForm)); // Only allow and deny ACEs are allowed here // - Debug.Assert( false, "Audit and alarm ACEs must have been stripped by remove-meaningless logic" ); + Debug.Assert(false, "Audit and alarm ACEs must have been stripped by remove-meaningless logic"); return false; } } - if ( aceStage > currentStage ) + if (aceStage > currentStage) { currentStage = aceStage; } - else if ( aceStage < currentStage ) + else if (aceStage < currentStage) { return false; } @@ -1783,24 +1771,24 @@ nameof(binaryForm)); // of this check! // - for ( int i = 0; i < _acl.Count; i++ ) + for (int i = 0; i < _acl.Count; i++) { int aceStage; GenericAce ace = _acl[i]; - if ( ace == null ) + if (ace == null) { // // Afraid to yank this statement now // for fear of destabilization, so adding an assert instead // - Debug.Assert( ace != null, "How did a null ACE end up in a SACL?" ); + Debug.Assert(ace != null, "How did a null ACE end up in a SACL?"); continue; } - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { aceStage = Inherited; } @@ -1808,7 +1796,7 @@ nameof(binaryForm)); { QualifiedAce qualifiedAce = ace as QualifiedAce; - if ( qualifiedAce == null ) + if (qualifiedAce == null) { // // Explicit ACE is not recognized - this is not a canonical ACL @@ -1817,8 +1805,8 @@ nameof(binaryForm)); return false; } - if ( qualifiedAce.AceQualifier == AceQualifier.SystemAudit || - qualifiedAce.AceQualifier == AceQualifier.SystemAlarm ) + if (qualifiedAce.AceQualifier == AceQualifier.SystemAudit || + qualifiedAce.AceQualifier == AceQualifier.SystemAlarm) { aceStage = Explicit; } @@ -1828,16 +1816,16 @@ nameof(binaryForm)); // Only audit and alarm ACEs are allowed here // - Debug.Assert( false, "Allow and deny ACEs must have been stripped by remove-meaningless logic" ); + Debug.Assert(false, "Allow and deny ACEs must have been stripped by remove-meaningless logic"); return false; } } - if ( aceStage > currentStage ) + if (aceStage > currentStage) { currentStage = aceStage; } - else if ( aceStage < currentStage ) + else if (aceStage < currentStage) { return false; } @@ -1849,9 +1837,9 @@ nameof(binaryForm)); private void ThrowIfNotCanonical() { - if ( !_isCanonical ) + if (!_isCanonical) { - throw new InvalidOperationException( SR.InvalidOperation_ModificationOfNonCanonicalAcl ); + throw new InvalidOperationException(SR.InvalidOperation_ModificationOfNonCanonicalAcl); } } @@ -1863,12 +1851,12 @@ nameof(binaryForm)); // Creates an empty ACL // - internal CommonAcl( bool isContainer, bool isDS, byte revision, int capacity ) + internal CommonAcl(bool isContainer, bool isDS, byte revision, int capacity) : base() { _isContainer = isContainer; _isDS = isDS; - _acl = new RawAcl( revision, capacity ); + _acl = new RawAcl(revision, capacity); _isCanonical = true; // since it is empty } @@ -1880,12 +1868,12 @@ nameof(binaryForm)); // copy of the ACL passed in // - internal CommonAcl( bool isContainer, bool isDS, RawAcl rawAcl, bool trusted, bool isDacl ) + internal CommonAcl(bool isContainer, bool isDS, RawAcl rawAcl, bool trusted, bool isDacl) : base() { - if ( rawAcl == null ) + if (rawAcl == null) { - throw new ArgumentNullException( nameof(rawAcl)); + throw new ArgumentNullException(nameof(rawAcl)); } _isContainer = isContainer; @@ -1899,7 +1887,7 @@ nameof(binaryForm)); _acl = rawAcl; - RemoveMeaninglessAcesAndFlags( isDacl ); + RemoveMeaninglessAcesAndFlags(isDacl); } else { @@ -1907,9 +1895,9 @@ nameof(binaryForm)); // In the untrusted case, we create our own raw ACL to keep the ACEs in // - _acl = new RawAcl( rawAcl.Revision, rawAcl.Count ); + _acl = new RawAcl(rawAcl.Revision, rawAcl.Count); - for ( int i = 0; i < rawAcl.Count; i++ ) + for (int i = 0; i < rawAcl.Count; i++) { // // Clone each ACE prior to putting it in @@ -1921,9 +1909,9 @@ nameof(binaryForm)); // Avoid inserting meaningless ACEs // - if ( true == InspectAce( ref ace, isDacl )) + if (true == InspectAce(ref ace, isDacl)) { - _acl.InsertAce( _acl.Count, ace ); + _acl.InsertAce(_acl.Count, ace); } } } @@ -1932,13 +1920,13 @@ nameof(binaryForm)); // See whether the ACL is canonical to begin with // - if ( true == CanonicalCheck( isDacl )) + if (true == CanonicalCheck(isDacl)) { // // Sort and compact the array // - Canonicalize( true, isDacl ); + Canonicalize(true, isDacl); _isCanonical = true; } @@ -1961,40 +1949,40 @@ nameof(binaryForm)); #region Protected Methods - internal void CheckAccessType( AccessControlType accessType ) + internal void CheckAccessType(AccessControlType accessType) { - if ( accessType != AccessControlType.Allow && - accessType != AccessControlType.Deny ) + if (accessType != AccessControlType.Allow && + accessType != AccessControlType.Deny) { throw new ArgumentOutOfRangeException( nameof(accessType), - SR.ArgumentOutOfRange_Enum ); + SR.ArgumentOutOfRange_Enum); } } - internal void CheckFlags( InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + internal void CheckFlags(InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - if ( IsContainer ) + if (IsContainer) { // // Supplying propagation flags without inheritance flags is illegal // - if ( inheritanceFlags == InheritanceFlags.None && - propagationFlags != PropagationFlags.None ) + if (inheritanceFlags == InheritanceFlags.None && + propagationFlags != PropagationFlags.None) { throw new ArgumentException( SR.Argument_InvalidAnyFlag, nameof(propagationFlags)); } } - else if ( inheritanceFlags != InheritanceFlags.None ) + else if (inheritanceFlags != InheritanceFlags.None) { throw new ArgumentException( SR.Argument_InvalidAnyFlag, nameof(inheritanceFlags)); } - else if ( propagationFlags != PropagationFlags.None ) + else if (propagationFlags != PropagationFlags.None) { throw new ArgumentException( SR.Argument_InvalidAnyFlag, @@ -2008,26 +1996,26 @@ nameof(propagationFlags)); // Helper function behind all the AddXXX methods for qualified aces // - internal void AddQualifiedAce( SecurityIdentifier sid, AceQualifier qualifier, int accessMask, AceFlags flags, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType ) + internal void AddQualifiedAce(SecurityIdentifier sid, AceQualifier qualifier, int accessMask, AceFlags flags, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType) { - if ( sid == null ) + if (sid == null) { - throw new ArgumentNullException( nameof(sid)); + throw new ArgumentNullException(nameof(sid)); } ThrowIfNotCanonical(); bool aceMerged = false; // if still false after all attempts to merge, create new entry - if ( qualifier == AceQualifier.SystemAudit && - (( flags & AceFlags.AuditFlags ) == 0 )) + if (qualifier == AceQualifier.SystemAudit && + ((flags & AceFlags.AuditFlags) == 0)) { throw new ArgumentException( SR.Arg_EnumAtLeastOneFlag, nameof(flags)); } - if ( accessMask == 0 ) + if (accessMask == 0) { throw new ArgumentException( SR.Argument_ArgumentZero, @@ -2036,20 +2024,20 @@ nameof(accessMask)); GenericAce newAce; - if (( !IsDS ) || ( objectFlags == ObjectAceFlags.None )) + if ((!IsDS) || (objectFlags == ObjectAceFlags.None)) { - newAce = new CommonAce( flags, qualifier, accessMask, sid, false, null ); + newAce = new CommonAce(flags, qualifier, accessMask, sid, false, null); } else { - newAce = new ObjectAce( flags, qualifier, accessMask, sid, objectFlags, objectType, inheritedObjectType, false, null ); + newAce = new ObjectAce(flags, qualifier, accessMask, sid, objectFlags, objectType, inheritedObjectType, false, null); } // // Make sure the new ACE wouldn't be meaningless before proceeding // - if ( false == InspectAce( ref newAce, ( this is DiscretionaryAcl ))) + if (false == InspectAce(ref newAce, (this is DiscretionaryAcl))) { return; } @@ -2058,16 +2046,16 @@ nameof(accessMask)); // See if the new ACE can be merged with any of the existing ones // - for ( int i = 0; i < Count; i++ ) + for (int i = 0; i < Count; i++) { QualifiedAce ace = _acl[i] as QualifiedAce; - if ( ace == null ) + if (ace == null) { continue; } - if ( true == MergeAces( ref ace, newAce as QualifiedAce )) + if (true == MergeAces(ref ace, newAce as QualifiedAce)) { aceMerged = true; break; @@ -2078,9 +2066,9 @@ nameof(accessMask)); // Couldn't modify any existing entry, so add a new one // - if ( !aceMerged ) + if (!aceMerged) { - _acl.InsertAce( _acl.Count, newAce ); + _acl.InsertAce(_acl.Count, newAce); _isDirty = true; } @@ -2091,22 +2079,22 @@ nameof(accessMask)); // Helper function behind all the SetXXX methods // - internal void SetQualifiedAce( SecurityIdentifier sid, AceQualifier qualifier, int accessMask, AceFlags flags, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType ) + internal void SetQualifiedAce(SecurityIdentifier sid, AceQualifier qualifier, int accessMask, AceFlags flags, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType) { - if ( sid == null ) + if (sid == null) { - throw new ArgumentNullException( nameof(sid)); + throw new ArgumentNullException(nameof(sid)); } - if ( qualifier == AceQualifier.SystemAudit && - (( flags & AceFlags.AuditFlags ) == 0 )) + if (qualifier == AceQualifier.SystemAudit && + ((flags & AceFlags.AuditFlags) == 0)) { throw new ArgumentException( SR.Arg_EnumAtLeastOneFlag, nameof(flags)); } - if ( accessMask == 0 ) + if (accessMask == 0) { throw new ArgumentException( SR.Argument_ArgumentZero, @@ -2117,25 +2105,25 @@ nameof(accessMask)); GenericAce newAce; - if (( !IsDS ) || ( objectFlags == ObjectAceFlags.None )) + if ((!IsDS) || (objectFlags == ObjectAceFlags.None)) { - newAce = new CommonAce( flags, qualifier, accessMask, sid, false, null ); + newAce = new CommonAce(flags, qualifier, accessMask, sid, false, null); } else { - newAce = new ObjectAce( flags, qualifier, accessMask, sid, objectFlags, objectType, inheritedObjectType, false, null ); + newAce = new ObjectAce(flags, qualifier, accessMask, sid, objectFlags, objectType, inheritedObjectType, false, null); } // // Make sure the new ACE wouldn't be meaningless before proceeding // - if ( false == InspectAce( ref newAce, ( this is DiscretionaryAcl ))) + if (false == InspectAce(ref newAce, (this is DiscretionaryAcl))) { return; } - for ( int i = 0; i < Count; i++ ) + for (int i = 0; i < Count; i++) { QualifiedAce ace = _acl[i] as QualifiedAce; @@ -2143,7 +2131,7 @@ nameof(accessMask)); // Not a qualified ACE - keep going // - if ( ace == null ) + if (ace == null) { continue; } @@ -2152,7 +2140,7 @@ nameof(accessMask)); // Only interested in explicit (non-inherited) ACEs // - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { continue; } @@ -2161,7 +2149,7 @@ nameof(accessMask)); // Only interested in ACEs with the specified qualifier // - if ( ace.AceQualifier != qualifier ) + if (ace.AceQualifier != qualifier) { continue; } @@ -2170,7 +2158,7 @@ nameof(accessMask)); // Only interested in ACEs with the specified SID // - if ( ace.SecurityIdentifier != sid ) + if (ace.SecurityIdentifier != sid) { continue; } @@ -2179,7 +2167,7 @@ nameof(accessMask)); // This ACE corresponds to the SID and qualifier in question - remove it // - _acl.RemoveAce( i ); + _acl.RemoveAce(i); i--; } @@ -2188,7 +2176,7 @@ nameof(accessMask)); // Add it at the end - we'll re-canonicalize later. // - _acl.InsertAce( _acl.Count, newAce ); + _acl.InsertAce(_acl.Count, newAce); // // To aid the efficiency of batch operations, recanonicalize this later @@ -2202,26 +2190,26 @@ nameof(accessMask)); // Helper function behind all the RemoveXXX methods // - internal bool RemoveQualifiedAces( SecurityIdentifier sid, AceQualifier qualifier, int accessMask, AceFlags flags, bool saclSemantics, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType ) + internal bool RemoveQualifiedAces(SecurityIdentifier sid, AceQualifier qualifier, int accessMask, AceFlags flags, bool saclSemantics, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType) { - if ( accessMask == 0 ) + if (accessMask == 0) { throw new ArgumentException( SR.Argument_ArgumentZero, nameof(accessMask)); } - if ( qualifier == AceQualifier.SystemAudit && - (( flags & AceFlags.AuditFlags ) == 0 )) + if (qualifier == AceQualifier.SystemAudit && + ((flags & AceFlags.AuditFlags) == 0)) { throw new ArgumentException( SR.Arg_EnumAtLeastOneFlag, nameof(flags)); } - if ( sid == null ) + if (sid == null) { - throw new ArgumentNullException( nameof(sid)); + throw new ArgumentNullException(nameof(sid)); } ThrowIfNotCanonical(); @@ -2252,13 +2240,13 @@ nameof(flags)); // byte[] recovery = new byte[BinaryLength]; - GetBinaryForm( recovery, 0 ); + GetBinaryForm(recovery, 0); MakeAnotherPass: try { - for ( int i = 0; i < Count; i++ ) + for (int i = 0; i < Count; i++) { QualifiedAce ace = _acl[i] as QualifiedAce; @@ -2266,7 +2254,7 @@ nameof(flags)); // Not a qualified ACE - keep going // - if ( ace == null ) + if (ace == null) { continue; } @@ -2275,7 +2263,7 @@ nameof(flags)); // Only interested in explicit (non-inherited) ACEs // - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { continue; } @@ -2284,7 +2272,7 @@ nameof(flags)); // Only interested in ACEs with the specified qualifier // - if ( ace.AceQualifier != qualifier ) + if (ace.AceQualifier != qualifier) { continue; } @@ -2293,7 +2281,7 @@ nameof(flags)); // Only interested in ACEs with the specified SID // - if ( ace.SecurityIdentifier != sid ) + if (ace.SecurityIdentifier != sid) { continue; } @@ -2302,7 +2290,7 @@ nameof(flags)); // If access masks have nothing in common, skip the whole exercise // - if ( IsDS ) + if (IsDS) { // // incase of directory aces, if the access mask of the @@ -2314,10 +2302,10 @@ nameof(flags)); // the object types are different in which case they are really not common bits. // accessMask = originalAccessMask; - bool objectTypesConflict = !GetAccessMaskForRemoval( ace, objectFlags, objectType, ref accessMask ); + bool objectTypesConflict = !GetAccessMaskForRemoval(ace, objectFlags, objectType, ref accessMask); // if the access masks have nothing in common, skip - if (( ace.AccessMask & accessMask ) == 0 ) + if ((ace.AccessMask & accessMask) == 0) { continue; } @@ -2331,10 +2319,10 @@ nameof(flags)); // the inherited object types are different the inheritance may not be common. // flags = originalFlags; - bool inheritedObjectTypesConflict = !GetInheritanceFlagsForRemoval( ace, objectFlags, inheritedObjectType, ref flags ); + bool inheritedObjectTypesConflict = !GetInheritanceFlagsForRemoval(ace, objectFlags, inheritedObjectType, ref flags); - if (((( ace.AceFlags & AceFlags.ContainerInherit ) == 0 ) && (( flags & AceFlags.ContainerInherit ) != 0 ) && (( flags & AceFlags.InheritOnly ) != 0 )) || - ((( flags & AceFlags.ContainerInherit ) == 0 ) && (( ace.AceFlags & AceFlags.ContainerInherit ) != 0 ) && (( ace.AceFlags & AceFlags.InheritOnly ) != 0))) + if ((((ace.AceFlags & AceFlags.ContainerInherit) == 0) && ((flags & AceFlags.ContainerInherit) != 0) && ((flags & AceFlags.InheritOnly) != 0)) || + (((flags & AceFlags.ContainerInherit) == 0) && ((ace.AceFlags & AceFlags.ContainerInherit) != 0) && ((ace.AceFlags & AceFlags.InheritOnly) != 0))) { // if one ace applies only to self and the other only to children/descendents we have nothing in common continue; @@ -2344,12 +2332,12 @@ nameof(flags)); // if the ace being removed referred only to child types and child types among existing ace and // ace being removed are not common then there is nothing in common between these aces (skip) // - if ((( originalFlags & AceFlags.ContainerInherit ) != 0 ) && (( originalFlags & AceFlags.InheritOnly ) != 0 ) && (( flags & AceFlags.ContainerInherit ) == 0 )) + if (((originalFlags & AceFlags.ContainerInherit) != 0) && ((originalFlags & AceFlags.InheritOnly) != 0) && ((flags & AceFlags.ContainerInherit) == 0)) { continue; } - if ( objectTypesConflict || inheritedObjectTypesConflict ) + if (objectTypesConflict || inheritedObjectTypesConflict) { // // if we reached this stage, then we've found something common between the two aces. @@ -2361,7 +2349,7 @@ nameof(flags)); } else { - if (( ace.AccessMask & accessMask ) == 0 ) + if ((ace.AccessMask & accessMask) == 0) { continue; } @@ -2372,8 +2360,8 @@ nameof(flags)); // skip the whole exercise // - if ( saclSemantics && - (( ace.AceFlags & flags & AceFlags.AuditFlags ) == 0 )) + if (saclSemantics && + ((ace.AceFlags & flags & AceFlags.AuditFlags) == 0)) { continue; } @@ -2452,19 +2440,19 @@ nameof(flags)); ps_AceFlags = ace.AceFlags; unchecked { ps_AccessMask = ace.AccessMask & ~accessMask; } - if ( ace is ObjectAce ) + if (ace is ObjectAce) { // // determine what should be the object/inherited object types on the permission split // - GetObjectTypesForSplit( ace as ObjectAce, ps_AccessMask /* access mask for this split */, ps_AceFlags /* flags remain the same */, out ps_ObjectAceFlags, out ps_ObjectAceType, out ps_InheritedObjectAceType ); + GetObjectTypesForSplit(ace as ObjectAce, ps_AccessMask /* access mask for this split */, ps_AceFlags /* flags remain the same */, out ps_ObjectAceFlags, out ps_ObjectAceType, out ps_InheritedObjectAceType); } // // Next, for SACLs only, compute the auditing split // - if ( saclSemantics ) + if (saclSemantics) { // // This operation can set the audit bits region @@ -2472,21 +2460,21 @@ nameof(flags)); // This case will be handled later // - unchecked { as_AceFlags = ace.AceFlags & ~( flags & AceFlags.AuditFlags ); } + unchecked { as_AceFlags = ace.AceFlags & ~(flags & AceFlags.AuditFlags); } // // The result of this evaluation is guaranteed // not to be zero by now // - as_AccessMask = ( ace.AccessMask & accessMask ); + as_AccessMask = (ace.AccessMask & accessMask); - if ( ace is ObjectAce ) + if (ace is ObjectAce) { // // determine what should be the object/inherited object types on the audit split // - GetObjectTypesForSplit( ace as ObjectAce, as_AccessMask /* access mask for this split */, as_AceFlags /* flags remain the same for inheritance */, out as_ObjectAceFlags, out as_ObjectAceType, out as_InheritedObjectAceType ); + GetObjectTypesForSplit(ace as ObjectAce, as_AccessMask /* access mask for this split */, as_AceFlags /* flags remain the same for inheritance */, out as_ObjectAceFlags, out as_ObjectAceType, out as_InheritedObjectAceType); } } @@ -2494,8 +2482,8 @@ nameof(flags)); // Finally, compute the merge split // - ms_AceFlags = ( ace.AceFlags & AceFlags.InheritanceFlags ) | ( flags & ace.AceFlags & AceFlags.AuditFlags ); - ms_AccessMask = ( ace.AccessMask & accessMask ); + ms_AceFlags = (ace.AceFlags & AceFlags.InheritanceFlags) | (flags & ace.AceFlags & AceFlags.AuditFlags); + ms_AccessMask = (ace.AccessMask & accessMask); // @@ -2505,25 +2493,25 @@ nameof(flags)); // produced no auditing flags // - if ( !saclSemantics || - (( ms_AceFlags & AceFlags.AuditFlags ) != 0 )) + if (!saclSemantics || + ((ms_AceFlags & AceFlags.AuditFlags) != 0)) { - if ( false == RemoveInheritanceBits( ms_AceFlags, flags, IsDS, out mergeResultFlags, out mergeRemoveTotal )) + if (false == RemoveInheritanceBits(ms_AceFlags, flags, IsDS, out mergeResultFlags, out mergeRemoveTotal)) { removePossible = false; break; } - if ( !mergeRemoveTotal ) + if (!mergeRemoveTotal) { - mergeResultFlags |= ( ms_AceFlags & AceFlags.AuditFlags ); + mergeResultFlags |= (ms_AceFlags & AceFlags.AuditFlags); - if ( ace is ObjectAce ) + if (ace is ObjectAce) { // // determine what should be the object/inherited object types on the merge split // - GetObjectTypesForSplit( ace as ObjectAce, ms_AccessMask /* access mask for this split */, mergeResultFlags /* flags for this split */, out ms_ObjectAceFlags, out ms_ObjectAceType, out ms_InheritedObjectAceType ); + GetObjectTypesForSplit(ace as ObjectAce, ms_AccessMask /* access mask for this split */, mergeResultFlags /* flags for this split */, out ms_ObjectAceFlags, out ms_ObjectAceType, out ms_InheritedObjectAceType); } } } @@ -2532,7 +2520,7 @@ nameof(flags)); // If this is no longer an evaluation, go ahead and make the changes // - if ( !evaluationPass ) + if (!evaluationPass) { QualifiedAce newAce; @@ -2544,24 +2532,24 @@ nameof(flags)); // we would be changing the size of this ace // - if ( ps_AccessMask != 0 ) + if (ps_AccessMask != 0) { - if (( ace is ObjectAce ) && - (((( ObjectAce) ace ).ObjectAceFlags & ObjectAceFlags.ObjectAceTypePresent ) != 0 ) && - (( ps_ObjectAceFlags & ObjectAceFlags.ObjectAceTypePresent ) == 0 )) + if ((ace is ObjectAce) && + ((((ObjectAce)ace).ObjectAceFlags & ObjectAceFlags.ObjectAceTypePresent) != 0) && + ((ps_ObjectAceFlags & ObjectAceFlags.ObjectAceTypePresent) == 0)) { ObjectAce newObjectAce; _acl.RemoveAce(i); - newObjectAce = new ObjectAce( ps_AceFlags, qualifier, ps_AccessMask, ace.SecurityIdentifier, ps_ObjectAceFlags, ps_ObjectAceType, ps_InheritedObjectAceType, false, null ); - _acl.InsertAce( i, newObjectAce ); + newObjectAce = new ObjectAce(ps_AceFlags, qualifier, ps_AccessMask, ace.SecurityIdentifier, ps_ObjectAceFlags, ps_ObjectAceType, ps_InheritedObjectAceType, false, null); + _acl.InsertAce(i, newObjectAce); } else { ace.AceFlags = ps_AceFlags; ace.AccessMask = ps_AccessMask; - if ( ace is ObjectAce ) + if (ace is ObjectAce) { ObjectAce objectAce = ace as ObjectAce; @@ -2581,20 +2569,20 @@ nameof(flags)); // On a SACL, the result of the auditing split must be recorded // - if ( saclSemantics && (( as_AceFlags & AceFlags.AuditFlags ) != 0 )) + if (saclSemantics && ((as_AceFlags & AceFlags.AuditFlags) != 0)) { - if ( ace is CommonAce ) + if (ace is CommonAce) { - newAce = new CommonAce( as_AceFlags, qualifier, as_AccessMask, ace.SecurityIdentifier, false, null ); + newAce = new CommonAce(as_AceFlags, qualifier, as_AccessMask, ace.SecurityIdentifier, false, null); } else { // object ace - newAce = new ObjectAce( as_AceFlags, qualifier, as_AccessMask, ace.SecurityIdentifier, as_ObjectAceFlags, as_ObjectAceType, as_InheritedObjectAceType, false, null ); + newAce = new ObjectAce(as_AceFlags, qualifier, as_AccessMask, ace.SecurityIdentifier, as_ObjectAceFlags, as_ObjectAceType, as_InheritedObjectAceType, false, null); } i++; // so it's not considered again - _acl.InsertAce( i, newAce ); + _acl.InsertAce(i, newAce); } // @@ -2602,32 +2590,32 @@ nameof(flags)); // as a separate ACE // - if ( !mergeRemoveTotal ) + if (!mergeRemoveTotal) { - if ( ace is CommonAce ) + if (ace is CommonAce) { - newAce = new CommonAce( mergeResultFlags, qualifier, ms_AccessMask, ace.SecurityIdentifier, false, null ); + newAce = new CommonAce(mergeResultFlags, qualifier, ms_AccessMask, ace.SecurityIdentifier, false, null); } else { // object ace - newAce = new ObjectAce( mergeResultFlags, qualifier, ms_AccessMask, ace.SecurityIdentifier, ms_ObjectAceFlags, ms_ObjectAceType, ms_InheritedObjectAceType, false, null ); + newAce = new ObjectAce(mergeResultFlags, qualifier, ms_AccessMask, ace.SecurityIdentifier, ms_ObjectAceFlags, ms_ObjectAceType, ms_InheritedObjectAceType, false, null); } i++; // so it's not considered again - _acl.InsertAce( i, newAce ); + _acl.InsertAce(i, newAce); } } } } - catch ( OverflowException ) + catch (OverflowException) { // // Oops, overflow means that the ACL became too big. // Inform the caller that the remove was not possible. // - _acl.SetBinaryForm( recovery, 0 ); + _acl.SetBinaryForm(recovery, 0); return false; } @@ -2636,7 +2624,7 @@ nameof(flags)); // If it looks like it's doable, go ahead and do it. // - if ( evaluationPass && removePossible ) + if (evaluationPass && removePossible) { evaluationPass = false; goto MakeAnotherPass; @@ -2647,31 +2635,31 @@ nameof(flags)); return removePossible; } - internal void RemoveQualifiedAcesSpecific( SecurityIdentifier sid, AceQualifier qualifier, int accessMask, AceFlags flags, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType ) + internal void RemoveQualifiedAcesSpecific(SecurityIdentifier sid, AceQualifier qualifier, int accessMask, AceFlags flags, ObjectAceFlags objectFlags, Guid objectType, Guid inheritedObjectType) { - if ( accessMask == 0 ) + if (accessMask == 0) { throw new ArgumentException( SR.Argument_ArgumentZero, nameof(accessMask)); } - if ( qualifier == AceQualifier.SystemAudit && - (( flags & AceFlags.AuditFlags ) == 0 )) + if (qualifier == AceQualifier.SystemAudit && + ((flags & AceFlags.AuditFlags) == 0)) { throw new ArgumentException( SR.Arg_EnumAtLeastOneFlag, nameof(flags)); } - if ( sid == null ) + if (sid == null) { - throw new ArgumentNullException( nameof(sid)); + throw new ArgumentNullException(nameof(sid)); } ThrowIfNotCanonical(); - for ( int i = 0; i < Count; i++ ) + for (int i = 0; i < Count; i++) { QualifiedAce ace = _acl[i] as QualifiedAce; @@ -2679,7 +2667,7 @@ nameof(flags)); // Not a qualified ACE - keep going // - if ( ace == null ) + if (ace == null) { continue; } @@ -2688,7 +2676,7 @@ nameof(flags)); // Only interested in explicit (non-inherited) ACEs // - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { continue; } @@ -2697,7 +2685,7 @@ nameof(flags)); // Only interested in ACEs with the specified qualifier // - if ( ace.AceQualifier != qualifier ) + if (ace.AceQualifier != qualifier) { continue; } @@ -2706,7 +2694,7 @@ nameof(flags)); // Only interested in ACEs with the specified SID // - if ( ace.SecurityIdentifier != sid ) + if (ace.SecurityIdentifier != sid) { continue; } @@ -2715,7 +2703,7 @@ nameof(flags)); // Only interested in exact ACE flag matches // - if ( ace.AceFlags != flags ) + if (ace.AceFlags != flags) { continue; } @@ -2724,32 +2712,32 @@ nameof(flags)); // Only interested in exact access mask matches // - if ( ace.AccessMask != accessMask ) + if (ace.AccessMask != accessMask) { continue; } - if ( IsDS ) + if (IsDS) { // // Incase of object aces, only interested in ACEs which match in their // objectType and inheritedObjectType // - if (( ace is ObjectAce ) && ( objectFlags != ObjectAceFlags.None )) + if ((ace is ObjectAce) && (objectFlags != ObjectAceFlags.None)) { // // both are object aces, so must match in object type and inherited object type // ObjectAce objectAce = ace as ObjectAce; - if (( !objectAce.ObjectTypesMatch( objectFlags, objectType )) - || ( !objectAce.InheritedObjectTypesMatch( objectFlags, inheritedObjectType ))) + if ((!objectAce.ObjectTypesMatch(objectFlags, objectType)) + || (!objectAce.InheritedObjectTypesMatch(objectFlags, inheritedObjectType))) { continue; } } - else if (( ace is ObjectAce ) || ( objectFlags != ObjectAceFlags.None )) + else if ((ace is ObjectAce) || (objectFlags != ObjectAceFlags.None)) { // one is object ace and the other is not, so no match continue; @@ -2835,10 +2823,10 @@ nameof(flags)); // Returns the binary representation of the ACL // - public sealed override void GetBinaryForm( byte[] binaryForm, int offset ) + public sealed override void GetBinaryForm(byte[] binaryForm, int offset) { CanonicalizeIfNecessary(); - _acl.GetBinaryForm( binaryForm, offset ); + _acl.GetBinaryForm(binaryForm, offset); } // @@ -2857,7 +2845,7 @@ nameof(flags)); set { - throw new NotSupportedException( SR.NotSupported_SetMethod ); + throw new NotSupportedException(SR.NotSupported_SetMethod); } } @@ -2870,28 +2858,28 @@ nameof(flags)); // are usually in the back of the ACL // - for ( int i = _acl.Count - 1; i >= 0; i-- ) + for (int i = _acl.Count - 1; i >= 0; i--) { GenericAce ace = _acl[i]; - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { - _acl.RemoveAce( i ); + _acl.RemoveAce(i); } } OnAclModificationTried(); } - public void Purge( SecurityIdentifier sid ) + public void Purge(SecurityIdentifier sid) { - if ( sid == null ) + if (sid == null) { - throw new ArgumentNullException( nameof(sid)); + throw new ArgumentNullException(nameof(sid)); } ThrowIfNotCanonical(); - for ( int i = Count - 1; i >= 0; i-- ) + for (int i = Count - 1; i >= 0; i--) { KnownAce ace = _acl[i] as KnownAce; @@ -2899,7 +2887,7 @@ nameof(flags)); // Skip over unknown ACEs // - if ( ace == null ) + if (ace == null) { continue; } @@ -2908,7 +2896,7 @@ nameof(flags)); // Skip over inherited ACEs // - if (( ace.AceFlags & AceFlags.Inherited ) != 0 ) + if ((ace.AceFlags & AceFlags.Inherited) != 0) { continue; } @@ -2917,9 +2905,9 @@ nameof(flags)); // SID matches - ACE is out // - if ( ace.SecurityIdentifier == sid ) + if (ace.SecurityIdentifier == sid) { - _acl.RemoveAce( i ); + _acl.RemoveAce(i); } } OnAclModificationTried(); @@ -2937,13 +2925,13 @@ nameof(flags)); // Creates an emtpy ACL // - public SystemAcl( bool isContainer, bool isDS, int capacity ) - : this( isContainer, isDS, isDS ? AclRevisionDS : AclRevision, capacity ) + public SystemAcl(bool isContainer, bool isDS, int capacity) + : this(isContainer, isDS, isDS ? AclRevisionDS : AclRevision, capacity) { } - public SystemAcl( bool isContainer, bool isDS, byte revision, int capacity ) - : base( isContainer, isDS, revision, capacity ) + public SystemAcl(bool isContainer, bool isDS, byte revision, int capacity) + : base(isContainer, isDS, revision, capacity) { } @@ -2952,8 +2940,8 @@ nameof(flags)); // after canonicalizing it // - public SystemAcl( bool isContainer, bool isDS, RawAcl rawAcl ) - : this( isContainer, isDS, rawAcl, false ) + public SystemAcl(bool isContainer, bool isDS, RawAcl rawAcl) + : this(isContainer, isDS, rawAcl, false) { } @@ -2962,8 +2950,8 @@ nameof(flags)); // takes ownership of the given raw ACL // - internal SystemAcl( bool isContainer, bool isDS, RawAcl rawAcl, bool trusted ) - : base( isContainer, isDS, rawAcl, trusted, false ) + internal SystemAcl(bool isContainer, bool isDS, RawAcl rawAcl, bool trusted) + : base(isContainer, isDS, rawAcl, trusted, false) { } @@ -2971,26 +2959,26 @@ nameof(flags)); #region Public Methods - public void AddAudit( AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + public void AddAudit(AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - CheckFlags( inheritanceFlags, propagationFlags ); - AddQualifiedAce( sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags( auditFlags ) | GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), ObjectAceFlags.None, Guid.Empty, Guid.Empty ); + CheckFlags(inheritanceFlags, propagationFlags); + AddQualifiedAce(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags(auditFlags) | GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), ObjectAceFlags.None, Guid.Empty, Guid.Empty); } - public void SetAudit( AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + public void SetAudit(AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - CheckFlags( inheritanceFlags, propagationFlags ); - SetQualifiedAce( sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags( auditFlags ) | GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), ObjectAceFlags.None, Guid.Empty, Guid.Empty ); + CheckFlags(inheritanceFlags, propagationFlags); + SetQualifiedAce(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags(auditFlags) | GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), ObjectAceFlags.None, Guid.Empty, Guid.Empty); } - public bool RemoveAudit( AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + public bool RemoveAudit(AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - return RemoveQualifiedAces(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags( auditFlags ) | GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), true, ObjectAceFlags.None, Guid.Empty, Guid.Empty ); + return RemoveQualifiedAces(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags(auditFlags) | GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), true, ObjectAceFlags.None, Guid.Empty, Guid.Empty); } - public void RemoveAuditSpecific( AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + public void RemoveAuditSpecific(AuditFlags auditFlags, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - RemoveQualifiedAcesSpecific( sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags( auditFlags ) | GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), ObjectAceFlags.None, Guid.Empty, Guid.Empty ); + RemoveQualifiedAcesSpecific(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags(auditFlags) | GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), ObjectAceFlags.None, Guid.Empty, Guid.Empty); } public void AddAudit(SecurityIdentifier sid, ObjectAuditRule rule) @@ -3003,13 +2991,13 @@ nameof(flags)); // // This is valid only for DS Acls // - if ( !IsDS ) + if (!IsDS) { throw new InvalidOperationException( - SR.InvalidOperation_OnlyValidForDS ); + SR.InvalidOperation_OnlyValidForDS); } - CheckFlags( inheritanceFlags, propagationFlags ); + CheckFlags(inheritanceFlags, propagationFlags); AddQualifiedAce(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags(auditFlags) | GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), objectFlags, objectType, inheritedObjectType); } @@ -3023,13 +3011,13 @@ nameof(flags)); // // This is valid only for DS Acls // - if ( !IsDS ) + if (!IsDS) { throw new InvalidOperationException( - SR.InvalidOperation_OnlyValidForDS ); + SR.InvalidOperation_OnlyValidForDS); } - CheckFlags( inheritanceFlags, propagationFlags ); + CheckFlags(inheritanceFlags, propagationFlags); SetQualifiedAce(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags(auditFlags) | GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), objectFlags, objectType, inheritedObjectType); } @@ -3043,10 +3031,10 @@ nameof(flags)); // // This is valid only for DS Acls // - if ( !IsDS ) + if (!IsDS) { throw new InvalidOperationException( - SR.InvalidOperation_OnlyValidForDS ); + SR.InvalidOperation_OnlyValidForDS); } return RemoveQualifiedAces(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags(auditFlags) | GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), true, objectFlags, objectType, inheritedObjectType); @@ -3062,10 +3050,10 @@ nameof(flags)); // // This is valid only for DS Acls // - if ( !IsDS ) + if (!IsDS) { throw new InvalidOperationException( - SR.InvalidOperation_OnlyValidForDS ); + SR.InvalidOperation_OnlyValidForDS); } RemoveQualifiedAcesSpecific(sid, AceQualifier.SystemAudit, accessMask, GenericAce.AceFlagsFromAuditFlags(auditFlags) | GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), objectFlags, objectType, inheritedObjectType); @@ -3078,7 +3066,7 @@ nameof(flags)); public sealed class DiscretionaryAcl : CommonAcl { #region - private static readonly SecurityIdentifier _sidEveryone = new SecurityIdentifier( WellKnownSidType.WorldSid, null ); + private static readonly SecurityIdentifier _sidEveryone = new SecurityIdentifier(WellKnownSidType.WorldSid, null); private bool everyOneFullAccessForNullDacl = false; #endregion @@ -3088,13 +3076,13 @@ nameof(flags)); // Creates an emtpy ACL // - public DiscretionaryAcl( bool isContainer, bool isDS, int capacity ) - : this( isContainer, isDS, isDS ? AclRevisionDS : AclRevision, capacity ) + public DiscretionaryAcl(bool isContainer, bool isDS, int capacity) + : this(isContainer, isDS, isDS ? AclRevisionDS : AclRevision, capacity) { } - public DiscretionaryAcl( bool isContainer, bool isDS, byte revision, int capacity ) - : base( isContainer, isDS, revision, capacity ) + public DiscretionaryAcl(bool isContainer, bool isDS, byte revision, int capacity) + : base(isContainer, isDS, revision, capacity) { } @@ -3103,8 +3091,8 @@ nameof(flags)); // after canonicalizing it // - public DiscretionaryAcl( bool isContainer, bool isDS, RawAcl rawAcl ) - : this( isContainer, isDS, rawAcl, false ) + public DiscretionaryAcl(bool isContainer, bool isDS, RawAcl rawAcl) + : this(isContainer, isDS, rawAcl, false) { } @@ -3113,8 +3101,8 @@ nameof(flags)); // takes ownership of the given raw ACL // - internal DiscretionaryAcl( bool isContainer, bool isDS, RawAcl rawAcl, bool trusted ) - : base( isContainer, isDS, rawAcl == null ? new RawAcl( isDS ? AclRevisionDS : AclRevision, 0 ) : rawAcl, trusted, true ) + internal DiscretionaryAcl(bool isContainer, bool isDS, RawAcl rawAcl, bool trusted) + : base(isContainer, isDS, rawAcl == null ? new RawAcl(isDS ? AclRevisionDS : AclRevision, 0) : rawAcl, trusted, true) { } @@ -3122,34 +3110,34 @@ nameof(flags)); #region Public Methods - public void AddAccess( AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + public void AddAccess(AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - CheckAccessType( accessType ); - CheckFlags( inheritanceFlags, propagationFlags ); + CheckAccessType(accessType); + CheckFlags(inheritanceFlags, propagationFlags); everyOneFullAccessForNullDacl = false; - AddQualifiedAce( sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), ObjectAceFlags.None, Guid.Empty, Guid.Empty ); + AddQualifiedAce(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), ObjectAceFlags.None, Guid.Empty, Guid.Empty); } - public void SetAccess( AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + public void SetAccess(AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - CheckAccessType( accessType ); - CheckFlags( inheritanceFlags, propagationFlags ); + CheckAccessType(accessType); + CheckFlags(inheritanceFlags, propagationFlags); everyOneFullAccessForNullDacl = false; - SetQualifiedAce( sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), ObjectAceFlags.None, Guid.Empty, Guid.Empty ); + SetQualifiedAce(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), ObjectAceFlags.None, Guid.Empty, Guid.Empty); } - public bool RemoveAccess( AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + public bool RemoveAccess(AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - CheckAccessType( accessType ); + CheckAccessType(accessType); everyOneFullAccessForNullDacl = false; - return RemoveQualifiedAces( sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), false, ObjectAceFlags.None, Guid.Empty, Guid.Empty ); + return RemoveQualifiedAces(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), false, ObjectAceFlags.None, Guid.Empty, Guid.Empty); } - public void RemoveAccessSpecific( AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags ) + public void RemoveAccessSpecific(AccessControlType accessType, SecurityIdentifier sid, int accessMask, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags) { - CheckAccessType( accessType ); + CheckAccessType(accessType); everyOneFullAccessForNullDacl = false; - RemoveQualifiedAcesSpecific(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), ObjectAceFlags.None, Guid.Empty, Guid.Empty ); + RemoveQualifiedAcesSpecific(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), ObjectAceFlags.None, Guid.Empty, Guid.Empty); } public void AddAccess(AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule) @@ -3162,16 +3150,16 @@ nameof(flags)); // // This is valid only for DS Acls // - if ( !IsDS ) + if (!IsDS) { throw new InvalidOperationException( - SR.InvalidOperation_OnlyValidForDS ); + SR.InvalidOperation_OnlyValidForDS); } - CheckAccessType( accessType ); - CheckFlags( inheritanceFlags, propagationFlags ); + CheckAccessType(accessType); + CheckFlags(inheritanceFlags, propagationFlags); everyOneFullAccessForNullDacl = false; - AddQualifiedAce( sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), objectFlags, objectType, inheritedObjectType ); + AddQualifiedAce(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), objectFlags, objectType, inheritedObjectType); } public void SetAccess(AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule) @@ -3184,16 +3172,16 @@ nameof(flags)); // // This is valid only for DS Acls // - if ( !IsDS ) + if (!IsDS) { throw new InvalidOperationException( - SR.InvalidOperation_OnlyValidForDS ); + SR.InvalidOperation_OnlyValidForDS); } - CheckAccessType( accessType ); - CheckFlags( inheritanceFlags, propagationFlags ); + CheckAccessType(accessType); + CheckFlags(inheritanceFlags, propagationFlags); everyOneFullAccessForNullDacl = false; - SetQualifiedAce( sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), objectFlags, objectType, inheritedObjectType); + SetQualifiedAce(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), objectFlags, objectType, inheritedObjectType); } public bool RemoveAccess(AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule) @@ -3206,15 +3194,15 @@ nameof(flags)); // // This is valid only for DS Acls // - if ( !IsDS ) + if (!IsDS) { throw new InvalidOperationException( - SR.InvalidOperation_OnlyValidForDS ); + SR.InvalidOperation_OnlyValidForDS); } - CheckAccessType( accessType ); + CheckAccessType(accessType); everyOneFullAccessForNullDacl = false; - return RemoveQualifiedAces(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), false, objectFlags, objectType, inheritedObjectType ); + return RemoveQualifiedAces(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), false, objectFlags, objectType, inheritedObjectType); } public void RemoveAccessSpecific(AccessControlType accessType, SecurityIdentifier sid, ObjectAccessRule rule) @@ -3227,15 +3215,15 @@ nameof(flags)); // // This is valid only for DS Acls // - if ( !IsDS ) + if (!IsDS) { throw new InvalidOperationException( - SR.InvalidOperation_OnlyValidForDS ); + SR.InvalidOperation_OnlyValidForDS); } - CheckAccessType( accessType ); + CheckAccessType(accessType); everyOneFullAccessForNullDacl = false; - RemoveQualifiedAcesSpecific( sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags( inheritanceFlags, propagationFlags ), objectFlags, objectType, inheritedObjectType ); + RemoveQualifiedAcesSpecific(sid, accessType == AccessControlType.Allow ? AceQualifier.AccessAllowed : AceQualifier.AccessDenied, accessMask, GenericAce.AceFlagsFromInheritanceFlags(inheritanceFlags, propagationFlags), objectFlags, objectType, inheritedObjectType); } #endregion @@ -3273,13 +3261,13 @@ nameof(flags)); /// single ACE DACL to replace null DACL from CommonSecurityObject. internal static DiscretionaryAcl CreateAllowEveryoneFullAccess(bool isDS, bool isContainer) { - DiscretionaryAcl dcl = new DiscretionaryAcl( isContainer, isDS, 1 ); + DiscretionaryAcl dcl = new DiscretionaryAcl(isContainer, isDS, 1); dcl.AddAccess( AccessControlType.Allow, _sidEveryone, -1, - isContainer ? ( InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit ) : InheritanceFlags.None, - PropagationFlags.None ); + isContainer ? (InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit) : InheritanceFlags.None, + PropagationFlags.None); dcl.everyOneFullAccessForNullDacl = true; return dcl; diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs index 528f63e1266..111b35e890d 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs @@ -20,12 +20,12 @@ namespace System.Security.AccessControl public enum AccessControlModification { - Add = 0, - Set = 1, - Reset = 2, - Remove = 3, - RemoveAll = 4, - RemoveSpecific = 5, + Add = 0, + Set = 1, + Reset = 2, + Remove = 3, + RemoveAll = 4, + RemoveSpecific = 5, } @@ -64,51 +64,51 @@ namespace System.Security.AccessControl { } - protected ObjectSecurity( bool isContainer, bool isDS ) + protected ObjectSecurity(bool isContainer, bool isDS) : this() { // we will create an empty DACL, denying anyone any access as the default. 5 is the capacity. DiscretionaryAcl dacl = new DiscretionaryAcl(isContainer, isDS, 5); - _securityDescriptor = new CommonSecurityDescriptor( isContainer, isDS, ControlFlags.None, null, null, null, dacl ); + _securityDescriptor = new CommonSecurityDescriptor(isContainer, isDS, ControlFlags.None, null, null, null, dacl); } protected ObjectSecurity(CommonSecurityDescriptor securityDescriptor) : this() { - if ( securityDescriptor == null ) + if (securityDescriptor == null) { - throw new ArgumentNullException( nameof(securityDescriptor)); + throw new ArgumentNullException(nameof(securityDescriptor)); } - _securityDescriptor = securityDescriptor; + _securityDescriptor = securityDescriptor; } #endregion #region Private methods - private void UpdateWithNewSecurityDescriptor( RawSecurityDescriptor newOne, AccessControlSections includeSections ) + private void UpdateWithNewSecurityDescriptor(RawSecurityDescriptor newOne, AccessControlSections includeSections) { - Debug.Assert( newOne != null, "Must not supply a null parameter here" ); + Debug.Assert(newOne != null, "Must not supply a null parameter here"); - if (( includeSections & AccessControlSections.Owner ) != 0 ) + if ((includeSections & AccessControlSections.Owner) != 0) { _ownerModified = true; _securityDescriptor.Owner = newOne.Owner; } - if (( includeSections & AccessControlSections.Group ) != 0 ) + if ((includeSections & AccessControlSections.Group) != 0) { _groupModified = true; _securityDescriptor.Group = newOne.Group; } - if (( includeSections & AccessControlSections.Audit ) != 0 ) + if ((includeSections & AccessControlSections.Audit) != 0) { _saclModified = true; - if ( newOne.SystemAcl != null ) + if (newOne.SystemAcl != null) { - _securityDescriptor.SystemAcl = new SystemAcl( IsContainer, IsDS, newOne.SystemAcl, true ); + _securityDescriptor.SystemAcl = new SystemAcl(IsContainer, IsDS, newOne.SystemAcl, true); } else { @@ -118,12 +118,12 @@ namespace System.Security.AccessControl _securityDescriptor.UpdateControlFlags(SACL_CONTROL_FLAGS, (ControlFlags)(newOne.ControlFlags & SACL_CONTROL_FLAGS)); } - if (( includeSections & AccessControlSections.Access ) != 0 ) + if ((includeSections & AccessControlSections.Access) != 0) { _daclModified = true; - if ( newOne.DiscretionaryAcl != null ) + if (newOne.DiscretionaryAcl != null) { - _securityDescriptor.DiscretionaryAcl = new DiscretionaryAcl( IsContainer, IsDS, newOne.DiscretionaryAcl, true ); + _securityDescriptor.DiscretionaryAcl = new DiscretionaryAcl(IsContainer, IsDS, newOne.DiscretionaryAcl, true); } else { @@ -137,7 +137,7 @@ namespace System.Security.AccessControl _securityDescriptor.UpdateControlFlags(DACL_CONTROL_FLAGS, (ControlFlags)((newOne.ControlFlags | daclFlag) & DACL_CONTROL_FLAGS)); } - } + } #endregion @@ -172,9 +172,9 @@ namespace System.Security.AccessControl { get { - if (!( _lock.IsReadLockHeld || _lock.IsWriteLockHeld )) + if (!(_lock.IsReadLockHeld || _lock.IsWriteLockHeld)) { - throw new InvalidOperationException( SR.InvalidOperation_MustLockForReadOrWrite ); + throw new InvalidOperationException(SR.InvalidOperation_MustLockForReadOrWrite); } return _ownerModified; @@ -182,9 +182,9 @@ namespace System.Security.AccessControl set { - if ( !_lock.IsWriteLockHeld ) + if (!_lock.IsWriteLockHeld) { - throw new InvalidOperationException( SR.InvalidOperation_MustLockForWrite ); + throw new InvalidOperationException(SR.InvalidOperation_MustLockForWrite); } _ownerModified = value; @@ -195,9 +195,9 @@ namespace System.Security.AccessControl { get { - if (!( _lock.IsReadLockHeld || _lock.IsWriteLockHeld )) + if (!(_lock.IsReadLockHeld || _lock.IsWriteLockHeld)) { - throw new InvalidOperationException( SR.InvalidOperation_MustLockForReadOrWrite ); + throw new InvalidOperationException(SR.InvalidOperation_MustLockForReadOrWrite); } return _groupModified; @@ -205,9 +205,9 @@ namespace System.Security.AccessControl set { - if ( !_lock.IsWriteLockHeld ) + if (!_lock.IsWriteLockHeld) { - throw new InvalidOperationException( SR.InvalidOperation_MustLockForWrite ); + throw new InvalidOperationException(SR.InvalidOperation_MustLockForWrite); } _groupModified = value; @@ -218,9 +218,9 @@ namespace System.Security.AccessControl { get { - if (!( _lock.IsReadLockHeld || _lock.IsWriteLockHeld )) + if (!(_lock.IsReadLockHeld || _lock.IsWriteLockHeld)) { - throw new InvalidOperationException( SR.InvalidOperation_MustLockForReadOrWrite ); + throw new InvalidOperationException(SR.InvalidOperation_MustLockForReadOrWrite); } return _saclModified; @@ -228,9 +228,9 @@ namespace System.Security.AccessControl set { - if ( !_lock.IsWriteLockHeld ) + if (!_lock.IsWriteLockHeld) { - throw new InvalidOperationException( SR.InvalidOperation_MustLockForWrite ); + throw new InvalidOperationException(SR.InvalidOperation_MustLockForWrite); } _saclModified = value; @@ -241,9 +241,9 @@ namespace System.Security.AccessControl { get { - if (!( _lock.IsReadLockHeld || _lock.IsWriteLockHeld )) + if (!(_lock.IsReadLockHeld || _lock.IsWriteLockHeld)) { - throw new InvalidOperationException( SR.InvalidOperation_MustLockForReadOrWrite ); + throw new InvalidOperationException(SR.InvalidOperation_MustLockForReadOrWrite); } return _daclModified; @@ -251,9 +251,9 @@ namespace System.Security.AccessControl set { - if ( !_lock.IsWriteLockHeld ) + if (!_lock.IsWriteLockHeld) { - throw new InvalidOperationException( SR.InvalidOperation_MustLockForWrite ); + throw new InvalidOperationException(SR.InvalidOperation_MustLockForWrite); } _daclModified = value; @@ -276,7 +276,7 @@ namespace System.Security.AccessControl // This overloaded method takes a name of an existing object // - protected virtual void Persist( string name, AccessControlSections includeSections ) + protected virtual void Persist(string name, AccessControlSections includeSections) { throw NotImplemented.ByDesign; } @@ -286,7 +286,7 @@ namespace System.Security.AccessControl // privilege while persisting if the enableOwnershipPrivilege is true. // Integrators can override it if this is not desired. // - protected virtual void Persist(bool enableOwnershipPrivilege, string name, AccessControlSections includeSections ) + protected virtual void Persist(bool enableOwnershipPrivilege, string name, AccessControlSections includeSections) { Privilege ownerPrivilege = null; @@ -309,7 +309,7 @@ namespace System.Security.AccessControl catch { // protection against exception filter-based luring attacks - if ( ownerPrivilege != null ) + if (ownerPrivilege != null) { ownerPrivilege.Revert(); } @@ -330,7 +330,7 @@ namespace System.Security.AccessControl // This overloaded method takes a handle to an existing object // - protected virtual void Persist( SafeHandle handle, AccessControlSections includeSections ) + protected virtual void Persist(SafeHandle handle, AccessControlSections includeSections) { throw NotImplemented.ByDesign; } @@ -343,18 +343,18 @@ namespace System.Security.AccessControl // Sets and retrieves the owner of this object // - public IdentityReference GetOwner( System.Type targetType ) + public IdentityReference GetOwner(System.Type targetType) { ReadLock(); try { - if ( _securityDescriptor.Owner == null ) + if (_securityDescriptor.Owner == null) { return null; } - return _securityDescriptor.Owner.Translate( targetType ); + return _securityDescriptor.Owner.Translate(targetType); } finally { @@ -362,18 +362,18 @@ namespace System.Security.AccessControl } } - public void SetOwner( IdentityReference identity ) + public void SetOwner(IdentityReference identity) { - if ( identity == null ) + if (identity == null) { - throw new ArgumentNullException( nameof(identity)); + throw new ArgumentNullException(nameof(identity)); } WriteLock(); try { - _securityDescriptor.Owner = identity.Translate( typeof( SecurityIdentifier )) as SecurityIdentifier; + _securityDescriptor.Owner = identity.Translate(typeof(SecurityIdentifier)) as SecurityIdentifier; _ownerModified = true; } finally @@ -386,18 +386,18 @@ namespace System.Security.AccessControl // Sets and retrieves the group of this object // - public IdentityReference GetGroup( System.Type targetType ) + public IdentityReference GetGroup(System.Type targetType) { ReadLock(); try { - if ( _securityDescriptor.Group == null ) + if (_securityDescriptor.Group == null) { return null; } - return _securityDescriptor.Group.Translate( targetType ); + return _securityDescriptor.Group.Translate(targetType); } finally { @@ -405,18 +405,18 @@ namespace System.Security.AccessControl } } - public void SetGroup( IdentityReference identity ) + public void SetGroup(IdentityReference identity) { - if ( identity == null ) + if (identity == null) { - throw new ArgumentNullException( nameof(identity)); + throw new ArgumentNullException(nameof(identity)); } WriteLock(); try { - _securityDescriptor.Group = identity.Translate( typeof( SecurityIdentifier )) as SecurityIdentifier; + _securityDescriptor.Group = identity.Translate(typeof(SecurityIdentifier)) as SecurityIdentifier; _groupModified = true; } finally @@ -425,18 +425,18 @@ namespace System.Security.AccessControl } } - public virtual void PurgeAccessRules( IdentityReference identity ) + public virtual void PurgeAccessRules(IdentityReference identity) { - if ( identity == null ) + if (identity == null) { - throw new ArgumentNullException( nameof(identity)); + throw new ArgumentNullException(nameof(identity)); } WriteLock(); try { - _securityDescriptor.PurgeAccessControl( identity.Translate( typeof( SecurityIdentifier )) as SecurityIdentifier ); + _securityDescriptor.PurgeAccessControl(identity.Translate(typeof(SecurityIdentifier)) as SecurityIdentifier); _daclModified = true; } finally @@ -447,16 +447,16 @@ namespace System.Security.AccessControl public virtual void PurgeAuditRules(IdentityReference identity) { - if ( identity == null ) + if (identity == null) { - throw new ArgumentNullException( nameof(identity)); + throw new ArgumentNullException(nameof(identity)); } WriteLock(); try { - _securityDescriptor.PurgeAudit( identity.Translate( typeof( SecurityIdentifier )) as SecurityIdentifier ); + _securityDescriptor.PurgeAudit(identity.Translate(typeof(SecurityIdentifier)) as SecurityIdentifier); _saclModified = true; } finally @@ -473,7 +473,7 @@ namespace System.Security.AccessControl try { - return (( _securityDescriptor.ControlFlags & ControlFlags.DiscretionaryAclProtected ) != 0 ); + return ((_securityDescriptor.ControlFlags & ControlFlags.DiscretionaryAclProtected) != 0); } finally { @@ -482,13 +482,13 @@ namespace System.Security.AccessControl } } - public void SetAccessRuleProtection( bool isProtected, bool preserveInheritance ) + public void SetAccessRuleProtection(bool isProtected, bool preserveInheritance) { WriteLock(); try { - _securityDescriptor.SetDiscretionaryAclProtection( isProtected, preserveInheritance ); + _securityDescriptor.SetDiscretionaryAclProtection(isProtected, preserveInheritance); _daclModified = true; } finally @@ -505,7 +505,7 @@ namespace System.Security.AccessControl try { - return (( _securityDescriptor.ControlFlags & ControlFlags.SystemAclProtected ) != 0 ); + return ((_securityDescriptor.ControlFlags & ControlFlags.SystemAclProtected) != 0); } finally { @@ -514,13 +514,13 @@ namespace System.Security.AccessControl } } - public void SetAuditRuleProtection( bool isProtected, bool preserveInheritance ) + public void SetAuditRuleProtection(bool isProtected, bool preserveInheritance) { WriteLock(); try { - _securityDescriptor.SetSystemAclProtection( isProtected, preserveInheritance ); + _securityDescriptor.SetSystemAclProtection(isProtected, preserveInheritance); _saclModified = true; } finally @@ -568,13 +568,13 @@ namespace System.Security.AccessControl return true; // SDDL to binary conversions are supported on Windows 2000 and higher } - public string GetSecurityDescriptorSddlForm( AccessControlSections includeSections ) + public string GetSecurityDescriptorSddlForm(AccessControlSections includeSections) { ReadLock(); try { - return _securityDescriptor.GetSddlForm( includeSections ); + return _securityDescriptor.GetSddlForm(includeSections); } finally { @@ -582,19 +582,19 @@ namespace System.Security.AccessControl } } - public void SetSecurityDescriptorSddlForm( string sddlForm ) + public void SetSecurityDescriptorSddlForm(string sddlForm) { - SetSecurityDescriptorSddlForm( sddlForm, AccessControlSections.All ); + SetSecurityDescriptorSddlForm(sddlForm, AccessControlSections.All); } - public void SetSecurityDescriptorSddlForm( string sddlForm, AccessControlSections includeSections ) + public void SetSecurityDescriptorSddlForm(string sddlForm, AccessControlSections includeSections) { - if ( sddlForm == null ) + if (sddlForm == null) { - throw new ArgumentNullException( nameof(sddlForm)); + throw new ArgumentNullException(nameof(sddlForm)); } - if (( includeSections & AccessControlSections.All ) == 0 ) + if ((includeSections & AccessControlSections.All) == 0) { throw new ArgumentException( SR.Arg_EnumAtLeastOneFlag, @@ -605,7 +605,7 @@ nameof(includeSections)); try { - UpdateWithNewSecurityDescriptor( new RawSecurityDescriptor( sddlForm ), includeSections ); + UpdateWithNewSecurityDescriptor(new RawSecurityDescriptor(sddlForm), includeSections); } finally { @@ -621,7 +621,7 @@ nameof(includeSections)); { byte[] result = new byte[_securityDescriptor.BinaryLength]; - _securityDescriptor.GetBinaryForm( result, 0 ); + _securityDescriptor.GetBinaryForm(result, 0); return result; } @@ -631,19 +631,19 @@ nameof(includeSections)); } } - public void SetSecurityDescriptorBinaryForm( byte[] binaryForm ) + public void SetSecurityDescriptorBinaryForm(byte[] binaryForm) { - SetSecurityDescriptorBinaryForm( binaryForm, AccessControlSections.All ); + SetSecurityDescriptorBinaryForm(binaryForm, AccessControlSections.All); } - public void SetSecurityDescriptorBinaryForm( byte[] binaryForm, AccessControlSections includeSections ) + public void SetSecurityDescriptorBinaryForm(byte[] binaryForm, AccessControlSections includeSections) { - if ( binaryForm == null ) + if (binaryForm == null) { - throw new ArgumentNullException( nameof(binaryForm)); + throw new ArgumentNullException(nameof(binaryForm)); } - if (( includeSections & AccessControlSections.All ) == 0 ) + if ((includeSections & AccessControlSections.All) == 0) { throw new ArgumentException( SR.Arg_EnumAtLeastOneFlag, @@ -654,7 +654,7 @@ nameof(includeSections)); try { - UpdateWithNewSecurityDescriptor( new RawSecurityDescriptor( binaryForm, 0 ), includeSections ); + UpdateWithNewSecurityDescriptor(new RawSecurityDescriptor(binaryForm, 0), includeSections); } finally { @@ -666,17 +666,17 @@ nameof(includeSections)); public abstract Type AccessRuleType { get; } public abstract Type AuditRuleType { get; } - protected abstract bool ModifyAccess( AccessControlModification modification, AccessRule rule, out bool modified); - protected abstract bool ModifyAudit( AccessControlModification modification, AuditRule rule, out bool modified ); + protected abstract bool ModifyAccess(AccessControlModification modification, AccessRule rule, out bool modified); + protected abstract bool ModifyAudit(AccessControlModification modification, AuditRule rule, out bool modified); public virtual bool ModifyAccessRule(AccessControlModification modification, AccessRule rule, out bool modified) { - if ( rule == null ) + if (rule == null) { - throw new ArgumentNullException( nameof(rule)); + throw new ArgumentNullException(nameof(rule)); } - if ( !this.AccessRuleType.GetTypeInfo().IsAssignableFrom(rule.GetType().GetTypeInfo()) ) + if (!this.AccessRuleType.GetTypeInfo().IsAssignableFrom(rule.GetType().GetTypeInfo())) { throw new ArgumentException( SR.AccessControl_InvalidAccessRuleType, @@ -697,12 +697,12 @@ nameof(rule)); public virtual bool ModifyAuditRule(AccessControlModification modification, AuditRule rule, out bool modified) { - if ( rule == null ) + if (rule == null) { - throw new ArgumentNullException( nameof(rule)); + throw new ArgumentNullException(nameof(rule)); } - if ( !this.AuditRuleType.GetTypeInfo().IsAssignableFrom(rule.GetType().GetTypeInfo()) ) + if (!this.AuditRuleType.GetTypeInfo().IsAssignableFrom(rule.GetType().GetTypeInfo())) { throw new ArgumentException( SR.AccessControl_InvalidAuditRuleType, @@ -721,9 +721,9 @@ nameof(rule)); } } - public abstract AccessRule AccessRuleFactory( IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type ); + public abstract AccessRule AccessRuleFactory(IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type); - public abstract AuditRule AuditRuleFactory( IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags ); + public abstract AuditRule AuditRuleFactory(IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags); #endregion } } diff --git a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Rules.cs b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Rules.cs index 75bbc9fc969..4d3b8fd0615 100644 --- a/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Rules.cs +++ b/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/Rules.cs @@ -12,8 +12,8 @@ namespace System.Security.AccessControl public enum AccessControlType { - Allow = 0, - Deny = 1, + Allow = 0, + Deny = 1, } @@ -36,32 +36,28 @@ namespace System.Security.AccessControl int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, - PropagationFlags propagationFlags ) + PropagationFlags propagationFlags) { - if ( identity == null ) + if (identity == null) { - throw new ArgumentNullException( nameof(identity)); + throw new ArgumentNullException(nameof(identity)); } - if ( accessMask == 0 ) + if (accessMask == 0) { - throw new ArgumentException( - SR.Argument_ArgumentZero, -nameof(accessMask)); + throw new ArgumentException(SR.Argument_ArgumentZero, nameof(accessMask)); } - if ( inheritanceFlags < InheritanceFlags.None || inheritanceFlags > (InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit) ) + if (inheritanceFlags < InheritanceFlags.None || inheritanceFlags > (InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit)) { throw new ArgumentOutOfRangeException( -nameof(inheritanceFlags), - SR.Format( SR.Argument_InvalidEnumValue, inheritanceFlags, "InheritanceFlags" )); + nameof(inheritanceFlags), SR.Format(SR.Argument_InvalidEnumValue, inheritanceFlags, "InheritanceFlags")); } - if ( propagationFlags < PropagationFlags.None || propagationFlags > (PropagationFlags.NoPropagateInherit | PropagationFlags.InheritOnly) ) + if (propagationFlags < PropagationFlags.None || propagationFlags > (PropagationFlags.NoPropagateInherit | PropagationFlags.InheritOnly)) { throw new ArgumentOutOfRangeException( -nameof(propagationFlags), - SR.Format(SR.Argument_InvalidEnumValue, inheritanceFlags, "PropagationFlags")); + nameof(propagationFlags), SR.Format(SR.Argument_InvalidEnumValue, inheritanceFlags, "PropagationFlags")); } if (identity.IsValidTargetType(typeof(SecurityIdentifier)) == false) @@ -76,7 +72,7 @@ nameof(identity)); _isInherited = isInherited; _inheritanceFlags = inheritanceFlags; - if ( inheritanceFlags != 0 ) + if (inheritanceFlags != 0) { _propagationFlags = propagationFlags; } @@ -135,29 +131,25 @@ nameof(identity)); bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, - AccessControlType type ) - : base( identity, accessMask, isInherited, inheritanceFlags, propagationFlags ) + AccessControlType type) + : base(identity, accessMask, isInherited, inheritanceFlags, propagationFlags) { - if ( type != AccessControlType.Allow && - type != AccessControlType.Deny ) + if (type != AccessControlType.Allow && + type != AccessControlType.Deny) { - throw new ArgumentOutOfRangeException( -nameof(type), - SR.ArgumentOutOfRange_Enum ); + throw new ArgumentOutOfRangeException(nameof(type), SR.ArgumentOutOfRange_Enum); } - if ( inheritanceFlags < InheritanceFlags.None || inheritanceFlags > (InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit) ) + if (inheritanceFlags < InheritanceFlags.None || inheritanceFlags > (InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit)) { throw new ArgumentOutOfRangeException( -nameof(inheritanceFlags), - SR.Format(SR.Argument_InvalidEnumValue, inheritanceFlags, "InheritanceFlags")); + nameof(inheritanceFlags), SR.Format(SR.Argument_InvalidEnumValue, inheritanceFlags, "InheritanceFlags")); } - if ( propagationFlags < PropagationFlags.None || propagationFlags > (PropagationFlags.NoPropagateInherit | PropagationFlags.InheritOnly) ) + if (propagationFlags < PropagationFlags.None || propagationFlags > (PropagationFlags.NoPropagateInherit | PropagationFlags.InheritOnly)) { throw new ArgumentOutOfRangeException( -nameof(propagationFlags), - SR.Format(SR.Argument_InvalidEnumValue, inheritanceFlags, "PropagationFlags")); + nameof(propagationFlags), SR.Format(SR.Argument_InvalidEnumValue, inheritanceFlags, "PropagationFlags")); } _type = type; @@ -176,7 +168,7 @@ nameof(propagationFlags), } - public abstract class ObjectAccessRule: AccessRule + public abstract class ObjectAccessRule : AccessRule { #region Private Members @@ -188,10 +180,10 @@ nameof(propagationFlags), #region Constructors - protected ObjectAccessRule( IdentityReference identity, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, Guid objectType, Guid inheritedObjectType, AccessControlType type ) - : base( identity, accessMask, isInherited, inheritanceFlags, propagationFlags, type ) + protected ObjectAccessRule(IdentityReference identity, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, Guid objectType, Guid inheritedObjectType, AccessControlType type) + : base(identity, accessMask, isInherited, inheritanceFlags, propagationFlags, type) { - if (( !objectType.Equals( Guid.Empty )) && (( accessMask & ObjectAce.AccessMaskWithObjectType ) != 0 )) + if ((!objectType.Equals(Guid.Empty)) && ((accessMask & ObjectAce.AccessMaskWithObjectType) != 0)) { _objectType = objectType; _objectFlags |= ObjectAceFlags.ObjectAceTypePresent; @@ -201,7 +193,7 @@ nameof(propagationFlags), _objectType = Guid.Empty; } - if (( !inheritedObjectType.Equals( Guid.Empty )) && ((inheritanceFlags & InheritanceFlags.ContainerInherit ) != 0 )) + if ((!inheritedObjectType.Equals(Guid.Empty)) && ((inheritanceFlags & InheritanceFlags.ContainerInherit) != 0)) { _inheritedObjectType = inheritedObjectType; _objectFlags |= ObjectAceFlags.InheritedObjectAceTypePresent; @@ -251,16 +243,16 @@ nameof(propagationFlags), bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, - AuditFlags auditFlags ) - : base( identity, accessMask, isInherited, inheritanceFlags, propagationFlags ) + AuditFlags auditFlags) + : base(identity, accessMask, isInherited, inheritanceFlags, propagationFlags) { - if ( auditFlags == AuditFlags.None ) + if (auditFlags == AuditFlags.None) { throw new ArgumentException(SR.Arg_EnumAtLeastOneFlag, nameof(auditFlags)); } - else if (( auditFlags & ~( AuditFlags.Success | AuditFlags.Failure )) != 0 ) + else if ((auditFlags & ~(AuditFlags.Success | AuditFlags.Failure)) != 0) { - throw new ArgumentOutOfRangeException(nameof(auditFlags), SR.ArgumentOutOfRange_Enum ); + throw new ArgumentOutOfRangeException(nameof(auditFlags), SR.ArgumentOutOfRange_Enum); } _flags = auditFlags; @@ -279,7 +271,7 @@ nameof(propagationFlags), } - public abstract class ObjectAuditRule: AuditRule + public abstract class ObjectAuditRule : AuditRule { #region Private Members @@ -291,11 +283,11 @@ nameof(propagationFlags), #region Constructors - protected ObjectAuditRule( IdentityReference identity, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, Guid objectType, Guid inheritedObjectType, AuditFlags auditFlags ) - : base( identity, accessMask, isInherited, inheritanceFlags, propagationFlags, auditFlags ) + protected ObjectAuditRule(IdentityReference identity, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, Guid objectType, Guid inheritedObjectType, AuditFlags auditFlags) + : base(identity, accessMask, isInherited, inheritanceFlags, propagationFlags, auditFlags) { - if (( !objectType.Equals( Guid.Empty )) && (( accessMask & ObjectAce.AccessMaskWithObjectType ) != 0 )) + if ((!objectType.Equals(Guid.Empty)) && ((accessMask & ObjectAce.AccessMaskWithObjectType) != 0)) { _objectType = objectType; _objectFlags |= ObjectAceFlags.ObjectAceTypePresent; @@ -305,7 +297,7 @@ nameof(propagationFlags), _objectType = Guid.Empty; } - if (( !inheritedObjectType.Equals( Guid.Empty )) && ((inheritanceFlags & InheritanceFlags.ContainerInherit ) != 0 )) + if ((!inheritedObjectType.Equals(Guid.Empty)) && ((inheritanceFlags & InheritanceFlags.ContainerInherit) != 0)) { _inheritedObjectType = inheritedObjectType; _objectFlags |= ObjectAceFlags.InheritedObjectAceTypePresent; @@ -355,16 +347,16 @@ nameof(propagationFlags), public void AddRule(AuthorizationRule rule) { - InnerList.Add( rule ); + InnerList.Add(rule); } #endregion #region ICollection Members - public void CopyTo( AuthorizationRule[] rules, int index ) + public void CopyTo(AuthorizationRule[] rules, int index) { - (( ICollection )this ).CopyTo( rules, index ); + ((ICollection)this).CopyTo(rules, index); } #endregion diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricKeyExchangeDeformatter.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricKeyExchangeDeformatter.cs index 9a544f10af2..da3dfac2eae 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricKeyExchangeDeformatter.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricKeyExchangeDeformatter.cs @@ -6,8 +6,8 @@ namespace System.Security.Cryptography { public abstract class AsymmetricKeyExchangeDeformatter { - protected AsymmetricKeyExchangeDeformatter() {} - public abstract string Parameters {get; set; } + protected AsymmetricKeyExchangeDeformatter() { } + public abstract string Parameters { get; set; } public abstract void SetKey(AsymmetricAlgorithm key); public abstract byte[] DecryptKeyExchange(byte[] rgb); } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricKeyExchangeFormatter.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricKeyExchangeFormatter.cs index 4c5bfbbce46..42b37ce03e5 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricKeyExchangeFormatter.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricKeyExchangeFormatter.cs @@ -6,9 +6,9 @@ namespace System.Security.Cryptography { public abstract class AsymmetricKeyExchangeFormatter { - protected AsymmetricKeyExchangeFormatter() {} + protected AsymmetricKeyExchangeFormatter() { } - public abstract string Parameters {get; } + public abstract string Parameters { get; } public abstract void SetKey(AsymmetricAlgorithm key); public abstract byte[] CreateKeyExchange(byte[] data); diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricSignatureDeformatter.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricSignatureDeformatter.cs index 014ce941e4f..91feca94172 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricSignatureDeformatter.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricSignatureDeformatter.cs @@ -8,7 +8,7 @@ namespace System.Security.Cryptography { public abstract class AsymmetricSignatureDeformatter { - protected AsymmetricSignatureDeformatter() {} + protected AsymmetricSignatureDeformatter() { } public abstract void SetKey(AsymmetricAlgorithm key); public abstract void SetHashAlgorithm(string strName); diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricSignatureFormatter.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricSignatureFormatter.cs index 24fdad5767b..ec2bcbdb036 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricSignatureFormatter.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AsymmetricSignatureFormatter.cs @@ -8,7 +8,7 @@ namespace System.Security.Cryptography { public abstract class AsymmetricSignatureFormatter { - protected AsymmetricSignatureFormatter() {} + protected AsymmetricSignatureFormatter() { } public abstract void SetKey(AsymmetricAlgorithm key); public abstract void SetHashAlgorithm(string strName); diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/CngKeyLite.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/CngKeyLite.cs index 3dffd6f68cf..90f1551201d 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/CngKeyLite.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/CngKeyLite.cs @@ -10,7 +10,7 @@ using Internal.Cryptography; using Microsoft.Win32.SafeHandles; -using ErrorCode=Interop.NCrypt.ErrorCode; +using ErrorCode = Interop.NCrypt.ErrorCode; namespace System.Security.Cryptography { diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAOAEPKeyExchangeDeformatter.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAOAEPKeyExchangeDeformatter.cs index 7d7eb7396db..898233372d9 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAOAEPKeyExchangeDeformatter.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAOAEPKeyExchangeDeformatter.cs @@ -19,7 +19,7 @@ namespace System.Security.Cryptography public override string Parameters { - get {return null; } + get { return null; } set { } } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAOAEPKeyExchangeFormatter.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAOAEPKeyExchangeFormatter.cs index ca0f87693de..df67717df76 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAOAEPKeyExchangeFormatter.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAOAEPKeyExchangeFormatter.cs @@ -45,10 +45,11 @@ namespace System.Security.Cryptography public override string Parameters { - get {return null; } + get { return null; } } - public RandomNumberGenerator Rng { + public RandomNumberGenerator Rng + { get { return RngValue; } set { RngValue = value; } } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAPKCS1KeyExchangeDeformatter.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAPKCS1KeyExchangeDeformatter.cs index 38785e0cf94..d69b14cba02 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAPKCS1KeyExchangeDeformatter.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAPKCS1KeyExchangeDeformatter.cs @@ -19,14 +19,15 @@ namespace System.Security.Cryptography _rsaKey = (RSA)key; } - public RandomNumberGenerator RNG { + public RandomNumberGenerator RNG + { get { return RngValue; } set { RngValue = value; } } public override string Parameters { - get {return null; } + get { return null; } set { } } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAPKCS1KeyExchangeFormatter.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAPKCS1KeyExchangeFormatter.cs index 2353f876ed1..37f541e3df2 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAPKCS1KeyExchangeFormatter.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/RSAPKCS1KeyExchangeFormatter.cs @@ -27,7 +27,8 @@ namespace System.Security.Cryptography } } - public RandomNumberGenerator Rng { + public RandomNumberGenerator Rng + { get { return RngValue; } set { RngValue = value; } } diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/TripleDES.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/TripleDES.cs index f21b8d122d0..74c9f743fdc 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/TripleDES.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/TripleDES.cs @@ -13,7 +13,7 @@ namespace System.Security.Cryptography { protected TripleDES() { - KeySizeValue = 3*64; + KeySizeValue = 3 * 64; BlockSizeValue = 64; FeedbackSizeValue = BlockSizeValue; LegalBlockSizesValue = s_legalBlockSizes.CloneKeySizesArray(); @@ -48,7 +48,7 @@ namespace System.Security.Cryptography if (value == null) throw new ArgumentNullException(nameof(value)); - if (!(value.Length*8).IsLegalSize(s_legalKeySizes)) + if (!(value.Length * 8).IsLegalSize(s_legalKeySizes)) throw new ArgumentException(SR.Cryptography_InvalidKeySize); if (IsWeakKey(value)) @@ -63,7 +63,7 @@ namespace System.Security.Cryptography if (rgbKey == null) throw new CryptographicException(SR.Cryptography_InvalidKeySize); // Desktop compat: Strange exception for a null value, but this is what we threw in classic CLR. - if (!(rgbKey.Length*8).IsLegalSize(s_legalKeySizes)) + if (!(rgbKey.Length * 8).IsLegalSize(s_legalKeySizes)) throw new CryptographicException(SR.Cryptography_InvalidKeySize); byte[] rgbOddParityKey = rgbKey.FixupKeyParity(); diff --git a/src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/ECDsaCng.Key.cs b/src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/ECDsaCng.Key.cs index 1f87e6d7cb6..783e8070ffc 100644 --- a/src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/ECDsaCng.Key.cs +++ b/src/libraries/System.Security.Cryptography.Cng/src/System/Security/Cryptography/ECDsaCng.Key.cs @@ -56,7 +56,8 @@ namespace System.Security.Cryptography CngKey key = _core.GetOrGenerateKey(curve); ForceSetKeySize(key.KeySize); } - else { + else + { int keySize = 0; // Get the proper KeySize from algorithm name if (alg == CngAlgorithm.ECDsaP256) diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs index 59b8efcfba2..1fa90d5e384 100644 --- a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs +++ b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/CspKeyContainerInfo.Windows.cs @@ -196,7 +196,7 @@ namespace System.Security.Cryptography /// /// Read a parameter from the current key using CRYPT_SILENT, to avoid any potential UI prompts. /// - private object ReadKeyParameterSilent(int keyParam, bool throwOnNotFound=true) + private object ReadKeyParameterSilent(int keyParam, bool throwOnNotFound = true) { const uint SilentFlags = (uint)Interop.Advapi32.CryptAcquireContextFlags.CRYPT_SILENT; diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RNGCryptoServiceProvider.cs b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RNGCryptoServiceProvider.cs index f1da5bfe0d6..d8af32dc19a 100644 --- a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RNGCryptoServiceProvider.cs +++ b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/RNGCryptoServiceProvider.cs @@ -11,7 +11,7 @@ namespace System.Security.Cryptography { private readonly RandomNumberGenerator _impl; - public RNGCryptoServiceProvider() : this((CspParameters) null) { } + public RNGCryptoServiceProvider() : this((CspParameters)null) { } public RNGCryptoServiceProvider(string str) : this((CspParameters)null) { } public RNGCryptoServiceProvider(byte[] rgb) : this((CspParameters)null) { } diff --git a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/SHA512CryptoServiceProvider.cs b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/SHA512CryptoServiceProvider.cs index 99291c8f77d..c18b535f84d 100644 --- a/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/SHA512CryptoServiceProvider.cs +++ b/src/libraries/System.Security.Cryptography.Csp/src/System/Security/Cryptography/SHA512CryptoServiceProvider.cs @@ -48,6 +48,6 @@ namespace System.Security.Cryptography _incrementalHash.Dispose(); } base.Dispose(disposing); - } + } } } diff --git a/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/AsnEncodedDataCollection.cs b/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/AsnEncodedDataCollection.cs index b7bbc369079..159645782ea 100644 --- a/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/AsnEncodedDataCollection.cs +++ b/src/libraries/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/AsnEncodedDataCollection.cs @@ -93,7 +93,7 @@ namespace System.Security.Cryptography if (index < 0 || index >= array.Length) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); - _list.CopyTo(array, index); + _list.CopyTo(array, index); } public bool IsSynchronized diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/AnyOS/AsnHelpers.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/AnyOS/AsnHelpers.cs index 1d6221fcf4a..37e4a5d6e11 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/AnyOS/AsnHelpers.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/AnyOS/AsnHelpers.cs @@ -139,7 +139,8 @@ namespace Internal.Cryptography.Pal.AnyOS break; } - return new AlgorithmIdentifier(new Oid(asn.Algorithm), keyLength) { + return new AlgorithmIdentifier(new Oid(asn.Algorithm), keyLength) + { Parameters = parameters }; } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs index 334007b7683..e5a15411976 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/HelpersWindows.cs @@ -15,7 +15,7 @@ using X509IssuerSerial = System.Security.Cryptography.Xml.X509IssuerSerial; using Microsoft.Win32.SafeHandles; -using CryptProvParam=Interop.Advapi32.CryptProvParam; +using CryptProvParam = Interop.Advapi32.CryptProvParam; using static Interop.Crypt32; namespace Internal.Cryptography.Pal.Windows diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs index 84b073cfb47..1cedc0d47ec 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/PkcsHelpers.cs @@ -120,7 +120,7 @@ namespace Internal.Cryptography public static AttributeAsn[] NormalizeAttributeSet( AttributeAsn[] setItems, - Action encodedValueProcessor=null) + Action encodedValueProcessor = null) { byte[] normalizedValue; diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsRecipient.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsRecipient.cs index 6bb5cb3b3ea..69bfefbdd6c 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsRecipient.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsRecipient.cs @@ -17,9 +17,9 @@ namespace System.Security.Cryptography.Pkcs } #if netstandard -internal + internal #else -public + public #endif CmsRecipient(X509Certificate2 certificate, RSAEncryptionPadding rsaEncryptionPadding) : this(certificate) @@ -29,9 +29,9 @@ public } #if netstandard -internal + internal #else -public + public #endif CmsRecipient(SubjectIdentifierType recipientIdentifierType, X509Certificate2 certificate, RSAEncryptionPadding rsaEncryptionPadding) : this(recipientIdentifierType, certificate) @@ -63,9 +63,9 @@ public } #if netstandard -internal + internal #else -public + public #endif RSAEncryptionPadding? RSAEncryptionPadding { get; } public SubjectIdentifierType RecipientIdentifierType { get; } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12KeyBag.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12KeyBag.cs index 0c0972b3026..aa1c250e461 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12KeyBag.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12KeyBag.cs @@ -6,7 +6,7 @@ namespace System.Security.Cryptography.Pkcs { public sealed class Pkcs12KeyBag : Pkcs12SafeBag { - public Pkcs12KeyBag(ReadOnlyMemory pkcs8PrivateKey, bool skipCopy=false) + public Pkcs12KeyBag(ReadOnlyMemory pkcs8PrivateKey, bool skipCopy = false) : base(Oids.Pkcs12KeyBag, pkcs8PrivateKey, skipCopy) { } diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12SafeBag.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12SafeBag.cs index 7d3b7edc21b..1d2c71940bf 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12SafeBag.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12SafeBag.cs @@ -35,7 +35,7 @@ namespace System.Security.Cryptography.Pkcs } } - protected Pkcs12SafeBag(string bagIdValue, ReadOnlyMemory encodedBagValue, bool skipCopy=false) + protected Pkcs12SafeBag(string bagIdValue, ReadOnlyMemory encodedBagValue, bool skipCopy = false) { if (string.IsNullOrEmpty(bagIdValue)) throw new ArgumentNullException(nameof(bagIdValue)); diff --git a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12ShroudedKeyBag.cs b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12ShroudedKeyBag.cs index e3599392357..db72f3759ca 100644 --- a/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12ShroudedKeyBag.cs +++ b/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/Pkcs12ShroudedKeyBag.cs @@ -6,7 +6,7 @@ namespace System.Security.Cryptography.Pkcs { public sealed class Pkcs12ShroudedKeyBag : Pkcs12SafeBag { - public Pkcs12ShroudedKeyBag(ReadOnlyMemory encryptedPkcs8PrivateKey, bool skipCopy=false) + public Pkcs12ShroudedKeyBag(ReadOnlyMemory encryptedPkcs8PrivateKey, bool skipCopy = false) : base(Oids.Pkcs12ShroudedKeyBag, encryptedPkcs8PrivateKey, skipCopy) { } diff --git a/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CipherMode.cs b/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CipherMode.cs index e1c6cd56e11..2b59feee784 100644 --- a/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CipherMode.cs +++ b/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/CipherMode.cs @@ -15,8 +15,8 @@ namespace System.Security.Cryptography { CBC = 1, ECB = 2, - [EditorBrowsable(EditorBrowsableState.Never)]OFB = 3, - [EditorBrowsable(EditorBrowsableState.Never)]CFB = 4, + [EditorBrowsable(EditorBrowsableState.Never)] OFB = 3, + [EditorBrowsable(EditorBrowsableState.Never)] CFB = 4, CTS = 5 } } diff --git a/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs b/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs index b0a3c56a6e2..2e8f7bc5263 100644 --- a/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs +++ b/src/libraries/System.Security.Cryptography.Primitives/src/System/Security/Cryptography/HashAlgorithm.cs @@ -55,7 +55,7 @@ namespace System.Security.Cryptography throw new ObjectDisposedException(null); } - if (destination.Length < HashSizeValue/8) + if (destination.Length < HashSizeValue / 8) { bytesWritten = 0; return false; diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs index 803491be7b1..6d1b4bcfbf1 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs @@ -76,7 +76,7 @@ namespace Internal.Cryptography.Pal byte[] thumbprint = new byte[cbData]; if (!Interop.crypt32.CertGetCertificateContextProperty(_certContext, CertContextPropId.CERT_SHA1_HASH_PROP_ID, thumbprint, ref cbData)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); return thumbprint; } } @@ -151,14 +151,14 @@ namespace Internal.Cryptography.Pal CERT_CHAIN_PARA chainPara = new CERT_CHAIN_PARA(); chainPara.cbSize = sizeof(CERT_CHAIN_PARA); if (!Interop.crypt32.CertGetCertificateChain(ChainEngine.HCCE_CURRENT_USER, _certContext, (FILETIME*)null, SafeCertStoreHandle.InvalidHandle, ref chainPara, CertChainFlags.None, IntPtr.Zero, out certChainContext)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); if (!Interop.crypt32.CertGetCertificateContextProperty(_certContext, CertContextPropId.CERT_PUBKEY_ALG_PARA_PROP_ID, null, ref cbData)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); } byte[] keyAlgorithmParameters = new byte[cbData]; if (!Interop.crypt32.CertGetCertificateContextProperty(_certContext, CertContextPropId.CERT_PUBKEY_ALG_PARA_PROP_ID, keyAlgorithmParameters, ref cbData)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); return keyAlgorithmParameters; } @@ -546,7 +546,7 @@ namespace Internal.Cryptography.Pal { using (IExportPal storePal = StorePal.FromCertificate(this)) { - return storePal.Export (contentType, password); + return storePal.Export(contentType, password); } } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/FindPal.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/FindPal.cs index 0adbadfc65d..a03e97e3028 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/FindPal.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/FindPal.cs @@ -66,7 +66,7 @@ namespace Internal.Cryptography.Pal public void FindBySubjectDistinguishedName(string subjectDistinguishedName) { FindCore( - delegate(SafeCertContextHandle pCertContext) + delegate (SafeCertContextHandle pCertContext) { string actual = GetCertNameInfo(pCertContext, CertNameType.CERT_NAME_RDN_TYPE, CertNameFlags.None); return subjectDistinguishedName.Equals(actual, StringComparison.OrdinalIgnoreCase); @@ -84,7 +84,7 @@ namespace Internal.Cryptography.Pal public void FindByIssuerDistinguishedName(string issuerDistinguishedName) { FindCore( - delegate(SafeCertContextHandle pCertContext) + delegate (SafeCertContextHandle pCertContext) { string actual = GetCertNameInfo(pCertContext, CertNameType.CERT_NAME_RDN_TYPE, CertNameFlags.CERT_NAME_ISSUER_FLAG); return issuerDistinguishedName.Equals(actual, StringComparison.OrdinalIgnoreCase); @@ -94,7 +94,7 @@ namespace Internal.Cryptography.Pal public unsafe void FindBySerialNumber(BigInteger hexValue, BigInteger decimalValue) { FindCore( - delegate(SafeCertContextHandle pCertContext) + delegate (SafeCertContextHandle pCertContext) { byte[] actual = pCertContext.CertContext->pCertInfo->SerialNumber.ToByteArray(); GC.KeepAlive(pCertContext); @@ -126,7 +126,7 @@ namespace Internal.Cryptography.Pal FILETIME fileTime = FILETIME.FromDateTime(dateTime); FindCore( - delegate(SafeCertContextHandle pCertContext) + delegate (SafeCertContextHandle pCertContext) { int comparison = Interop.crypt32.CertVerifyTimeValidity(ref fileTime, pCertContext.CertContext->pCertInfo); @@ -138,7 +138,7 @@ namespace Internal.Cryptography.Pal public unsafe void FindByTemplateName(string templateName) { FindCore( - delegate(SafeCertContextHandle pCertContext) + delegate (SafeCertContextHandle pCertContext) { // The template name can have 2 different formats: V1 format (<= Win2K) is just a string // V2 format (XP only) can be a friendly name or an OID. @@ -154,7 +154,7 @@ namespace Internal.Cryptography.Pal byte[] extensionRawData = pV1Template->Value.ToByteArray(); if (!extensionRawData.DecodeObjectNoThrow( CryptDecodeObjectStructType.X509_UNICODE_ANY_STRING, - delegate(void* pvDecoded, int cbDecoded) + delegate (void* pvDecoded, int cbDecoded) { Debug.Assert(cbDecoded >= sizeof(CERT_NAME_VALUE)); CERT_NAME_VALUE* pNameValue = (CERT_NAME_VALUE*)pvDecoded; @@ -177,7 +177,7 @@ namespace Internal.Cryptography.Pal byte[] extensionRawData = pV2Template->Value.ToByteArray(); if (!extensionRawData.DecodeObjectNoThrow( CryptDecodeObjectStructType.X509_CERTIFICATE_TEMPLATE, - delegate(void* pvDecoded, int cbDecoded) + delegate (void* pvDecoded, int cbDecoded) { Debug.Assert(cbDecoded >= sizeof(CERT_TEMPLATE_EXT)); CERT_TEMPLATE_EXT* pTemplateExt = (CERT_TEMPLATE_EXT*)pvDecoded; @@ -235,7 +235,7 @@ namespace Internal.Cryptography.Pal public unsafe void FindByCertificatePolicy(string oidValue) { FindCore( - delegate(SafeCertContextHandle pCertContext) + delegate (SafeCertContextHandle pCertContext) { CERT_INFO* pCertInfo = pCertContext.CertContext->pCertInfo; CERT_EXTENSION* pCertExtension = Interop.crypt32.CertFindExtension(Oids.CertPolicies, @@ -247,7 +247,7 @@ namespace Internal.Cryptography.Pal byte[] extensionRawData = pCertExtension->Value.ToByteArray(); if (!extensionRawData.DecodeObjectNoThrow( CryptDecodeObjectStructType.X509_CERT_POLICIES, - delegate(void* pvDecoded, int cbDecoded) + delegate (void* pvDecoded, int cbDecoded) { Debug.Assert(cbDecoded >= sizeof(CERT_POLICIES_INFO)); CERT_POLICIES_INFO* pCertPoliciesInfo = (CERT_POLICIES_INFO*)pvDecoded; diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Export.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Export.cs index e58698b35d8..c85ee8fa2ce 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Export.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Export.cs @@ -58,11 +58,11 @@ namespace Internal.Cryptography.Pal { int cbEncoded = 0; if (!Interop.crypt32.CertSerializeCertificateStoreElement(pCertContext, 0, null, ref cbEncoded)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); byte[] pbEncoded = new byte[cbEncoded]; if (!Interop.crypt32.CertSerializeCertificateStoreElement(pCertContext, 0, pbEncoded, ref cbEncoded)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); return pbEncoded; } @@ -79,14 +79,14 @@ namespace Internal.Cryptography.Pal CRYPTOAPI_BLOB dataBlob = new CRYPTOAPI_BLOB(0, (byte*)null); if (!Interop.crypt32.PFXExportCertStore(_certStore, ref dataBlob, password, PFXExportFlags.EXPORT_PRIVATE_KEYS | PFXExportFlags.REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); byte[] pbEncoded = new byte[dataBlob.cbData]; fixed (byte* ppbEncoded = pbEncoded) { dataBlob.pbData = ppbEncoded; if (!Interop.crypt32.PFXExportCertStore(_certStore, ref dataBlob, password, PFXExportFlags.EXPORT_PRIVATE_KEYS | PFXExportFlags.REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); } return pbEncoded; diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Import.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Import.cs index 69c9425bf0d..59dd24d969d 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Import.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.Import.cs @@ -111,9 +111,9 @@ namespace Internal.Cryptography.Pal CertStoreFlags.CERT_STORE_ENUM_ARCHIVED_FLAG | CertStoreFlags.CERT_STORE_CREATE_NEW_FLAG | CertStoreFlags.CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG, null); if (certStore.IsInvalid) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); if (!Interop.crypt32.CertAddCertificateLinkToStore(certStore, certificatePal.CertContext, CertStoreAddDisposition.CERT_STORE_ADD_ALWAYS, IntPtr.Zero)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); return new StorePal(certStore); } @@ -133,7 +133,7 @@ namespace Internal.Cryptography.Pal CertStoreFlags.CERT_STORE_ENUM_ARCHIVED_FLAG | CertStoreFlags.CERT_STORE_CREATE_NEW_FLAG, null); if (certStore.IsInvalid) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); // // We use CertAddCertificateLinkToStore to keep a link to the original store, so any property changes get diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.cs index 1fc19106ddf..8d5bd7f4cea 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/StorePal.cs @@ -79,7 +79,7 @@ namespace Internal.Cryptography.Pal internal SafeCertStoreHandle SafeCertStoreHandle { - get {return _certStore; } + get { return _certStore; } } SafeHandle IStorePal.SafeHandle diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/X509Pal.CustomExtensions.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/X509Pal.CustomExtensions.cs index a59f5e5c725..13951648efc 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/X509Pal.CustomExtensions.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/X509Pal.CustomExtensions.cs @@ -250,7 +250,7 @@ namespace Internal.Cryptography.Pal int cb = 20; byte[] buffer = new byte[cb]; if (!Interop.crypt32.CryptHashPublicKeyInfo(IntPtr.Zero, AlgId.CALG_SHA1, 0, CertEncodingType.All, ref publicKeyInfo, buffer, ref cb)) - throw Marshal.GetHRForLastWin32Error().ToCryptographicException();; + throw Marshal.GetHRForLastWin32Error().ToCryptographicException(); if (cb < buffer.Length) { byte[] newBuffer = new byte[cb]; diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/SubjectAlternativeNameBuilder.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/SubjectAlternativeNameBuilder.cs index b105981de5c..8796d3003e6 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/SubjectAlternativeNameBuilder.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/SubjectAlternativeNameBuilder.cs @@ -71,7 +71,7 @@ namespace System.Security.Cryptography.X509Certificates AddGeneralName(new GeneralNameAsn { OtherName = otherName }); } - public X509Extension Build(bool critical=false) + public X509Extension Build(bool critical = false) { using (AsnWriter writer = new AsnWriter(AsnEncodingRules.DER)) { diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509CertificateCollection.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509CertificateCollection.cs index 893a1ef27c4..85878544f35 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509CertificateCollection.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509CertificateCollection.cs @@ -113,7 +113,7 @@ namespace System.Security.Cryptography.X509Certificates base.OnValidate(value); if (!(value is X509Certificate)) - throw new ArgumentException(SR.Arg_InvalidType, nameof(value)); + throw new ArgumentException(SR.Arg_InvalidType, nameof(value)); } } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs index 90309909b1e..bda82f36e3b 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Chain.cs @@ -31,7 +31,8 @@ namespace System.Security.Cryptography.X509Certificates _chainElements = new X509ChainElementCollection(_pal.ChainElements); } - public static X509Chain Create() { + public static X509Chain Create() + { return new X509Chain(); } diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedXml.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedXml.cs index 850fc11e812..5d50f48dfd6 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedXml.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/EncryptedXml.cs @@ -65,7 +65,7 @@ namespace System.Security.Cryptography.Xml private XmlResolver _xmlResolver; // hash table defining the key name mapping private const int _capacity = 4; // 4 is a reasonable capacity for - // the key name mapping hash table + // the key name mapping hash table private readonly Hashtable _keyNameMapping; private PaddingMode _padding; private CipherMode _mode; diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs index 67a4b872306..0d4ef3bf4d5 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoX509Data.cs @@ -66,7 +66,7 @@ namespace System.Security.Cryptography.Xml throw new CryptographicException(SR.Cryptography_Partial_Chain); } - elements = (X509ChainElementCollection)chain.ChainElements; + elements = (X509ChainElementCollection)chain.ChainElements; for (int index = 0; index < (Utils.IsSelfSigned(chain) ? 1 : elements.Count - 1); index++) { AddCertificate(elements[index].Certificate); diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs index b4e896c3bff..5b496026325 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs @@ -727,7 +727,7 @@ namespace System.Security.Cryptography.Xml return collection; } - private static readonly char[] s_hexValues = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + private static readonly char[] s_hexValues = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; internal static string EncodeHexString(byte[] sArray) { return EncodeHexString(sArray, 0, (uint)sArray.Length); diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs index 676be60bbe0..9cc2777c14e 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Atom10FeedFormatter.cs @@ -603,7 +603,7 @@ namespace System.ServiceModel.Syndication { foreach (XmlQualifiedName attr in attrs.Keys) { - Debug.Assert(!FeedUtils.IsXmlns(attr.Name, attr.Namespace), "XML namespace attributes should not be added to the list." ); + Debug.Assert(!FeedUtils.IsXmlns(attr.Name, attr.Namespace), "XML namespace attributes should not be added to the list."); result.AttributeExtensions.Add(attr, attrs[attr]); } } diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs index 9b5e0c31314..f5eada8e339 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/SyndicationFeed.cs @@ -143,7 +143,7 @@ namespace System.ServiceModel.Syndication public IEnumerable Items { - get =>_items ?? (_items = new NullNotAllowedCollection()); + get => _items ?? (_items = new NullNotAllowedCollection()); set => _items = value ?? throw new ArgumentNullException(nameof(value)); } @@ -171,7 +171,7 @@ namespace System.ServiceModel.Syndication public Collection Links { - get =>_links ?? (_links = new NullNotAllowedCollection()); + get => _links ?? (_links = new NullNotAllowedCollection()); } public TextSyndicationContent Title { get; set; } diff --git a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs index a0004300ac8..b9c73676865 100644 --- a/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs +++ b/src/libraries/System.ServiceProcess.ServiceController/src/System/ServiceProcess/ServiceBase.cs @@ -237,7 +237,7 @@ namespace System.ServiceProcess /// /// can be used to write notification of service command calls, such as Start and Stop, to the Application event log. This property is read-only. /// - [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] + [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public virtual EventLog EventLog { get diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DecoderNLS.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DecoderNLS.cs index ba5f5be938e..ba1fc9a0f85 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DecoderNLS.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/DecoderNLS.cs @@ -96,7 +96,7 @@ namespace System.Text throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index): nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -138,10 +138,10 @@ namespace System.Text { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? nameof(bytes): nameof(chars), SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - byteIndex < byteCount) throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -159,10 +159,9 @@ namespace System.Text // Just call pointer version fixed (byte* pBytes = &bytes[0]) - fixed (char* pChars = &chars[0]) - // Remember that charCount is # to decode, not size of array - return GetChars(pBytes + byteIndex, byteCount, - pChars + charIndex, charCount, flush); + fixed (char* pChars = &chars[0]) + // Remember that charCount is # to decode, not size of array + return GetChars(pBytes + byteIndex, byteCount, pChars + charIndex, charCount, flush); } public override unsafe int GetChars(byte* bytes, int byteCount, @@ -170,10 +169,10 @@ namespace System.Text { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? nameof(chars): nameof(bytes)), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); // Remember our flush m_mustFlush = flush; @@ -191,13 +190,13 @@ namespace System.Text { // Validate parameters if (bytes == null || chars == null) - throw new ArgumentNullException((bytes == null ? nameof(bytes): nameof(chars)), SR.ArgumentNull_Array); + throw new ArgumentNullException((bytes == null ? nameof(bytes) : nameof(chars)), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - byteIndex < byteCount) throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -230,10 +229,10 @@ namespace System.Text { // Validate input parameters if (chars == null || bytes == null) - throw new ArgumentNullException(chars == null ? nameof(chars): nameof(bytes), SR.ArgumentNull_Array); + throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes), SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); // We don't want to throw m_mustFlush = flush; diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncoderNLS.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncoderNLS.cs index 01af288ac33..b894aceba4b 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncoderNLS.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncoderNLS.cs @@ -94,7 +94,7 @@ namespace System.Text throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index): nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -131,10 +131,10 @@ namespace System.Text { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? nameof(chars): nameof(bytes)), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -151,21 +151,19 @@ namespace System.Text // Just call pointer version fixed (char* pChars = &chars[0]) - fixed (byte* pBytes = &bytes[0]) - - // Remember that charCount is # to decode, not size of array. - return GetBytes(pChars + charIndex, charCount, - pBytes + byteIndex, byteCount, flush); + fixed (byte* pBytes = &bytes[0]) + // Remember that charCount is # to decode, not size of array. + return GetBytes(pChars + charIndex, charCount, pBytes + byteIndex, byteCount, flush); } public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, bool flush) { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? nameof(chars): nameof(bytes)), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); m_mustFlush = flush; m_throwOnOverflow = true; @@ -180,13 +178,13 @@ namespace System.Text { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? nameof(chars): nameof(bytes)), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -219,10 +217,10 @@ namespace System.Text { // Validate input parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? nameof(bytes): nameof(chars), SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); // We don't want to throw m_mustFlush = flush; diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingNLS.cs b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingNLS.cs index bc45f09a35d..18a6ead21a5 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingNLS.cs +++ b/src/libraries/System.Text.Encoding.CodePages/src/System/Text/EncodingNLS.cs @@ -52,7 +52,7 @@ namespace System.Text throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index): nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -102,10 +102,10 @@ namespace System.Text byte[] bytes, int byteIndex) { if (s == null || bytes == null) - throw new ArgumentNullException((s == null ? nameof(s): nameof(bytes)), SR.ArgumentNull_Array); + throw new ArgumentNullException((s == null ? nameof(s) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (s.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(s), SR.ArgumentOutOfRange_IndexCount); @@ -120,9 +120,9 @@ namespace System.Text bytes = new byte[1]; fixed (char* pChars = s) - fixed (byte* pBytes = &bytes[0]) - return GetBytes(pChars + charIndex, charCount, - pBytes + byteIndex, byteCount, null); + fixed (byte* pBytes = &bytes[0]) + return GetBytes(pChars + charIndex, charCount, + pBytes + byteIndex, byteCount, null); } // Encodes a range of characters in a character array into a range of bytes @@ -142,10 +142,10 @@ namespace System.Text { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? nameof(chars): nameof(bytes)), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex): nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -165,10 +165,10 @@ namespace System.Text bytes = new byte[1]; fixed (char* pChars = &chars[0]) - fixed (byte* pBytes = &bytes[0]) - // Remember that byteCount is # to decode, not size of array. - return GetBytes(pChars + charIndex, charCount, - pBytes + byteIndex, byteCount, null); + fixed (byte* pBytes = &bytes[0]) + // Remember that byteCount is # to decode, not size of array. + return GetBytes(pChars + charIndex, charCount, + pBytes + byteIndex, byteCount, null); } // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) @@ -177,10 +177,10 @@ namespace System.Text { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? nameof(bytes): nameof(chars), SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetBytes(chars, charCount, bytes, byteCount, null); } @@ -198,7 +198,7 @@ namespace System.Text throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index): nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -234,10 +234,10 @@ namespace System.Text { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? nameof(bytes): nameof(chars), SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - byteIndex < byteCount) throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); @@ -257,10 +257,10 @@ namespace System.Text chars = new char[1]; fixed (byte* pBytes = &bytes[0]) - fixed (char* pChars = &chars[0]) - // Remember that charCount is # to decode, not size of array - return GetChars(pBytes + byteIndex, byteCount, - pChars + charIndex, charCount, null); + fixed (char* pChars = &chars[0]) + // Remember that charCount is # to decode, not size of array + return GetChars(pBytes + byteIndex, byteCount, + pChars + charIndex, charCount, null); } // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) @@ -269,10 +269,10 @@ namespace System.Text { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? nameof(bytes): nameof(chars), SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount): nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetChars(bytes, byteCount, chars, charCount, null); } @@ -290,7 +290,7 @@ namespace System.Text throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index): nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocumentOptions.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocumentOptions.cs index 5218f60b781..26c5c17e863 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocumentOptions.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonDocumentOptions.cs @@ -27,7 +27,7 @@ namespace System.Text.Json /// public JsonCommentHandling CommentHandling { - readonly get => _commentHandling; + readonly get => _commentHandling; set { Debug.Assert(value >= 0); diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs index d0a90679d0d..2fa33d96b1d 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/JsonReaderException.cs @@ -10,7 +10,7 @@ namespace System.Text.Json [Serializable] internal sealed class JsonReaderException : JsonException { - public JsonReaderException(string message, long lineNumber, long bytePositionInLine) : base(message, path : null, lineNumber, bytePositionInLine) + public JsonReaderException(string message, long lineNumber, long bytePositionInLine) : base(message, path: null, lineNumber, bytePositionInLine) { } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/EnumConverterOptions.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/EnumConverterOptions.cs index 9a12bcb4805..89ce2d15403 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/EnumConverterOptions.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/EnumConverterOptions.cs @@ -10,11 +10,11 @@ namespace System.Text.Json.Serialization.Converters /// /// Allow string values. /// - AllowStrings = 0b0001, + AllowStrings = 0b0001, /// /// Allow number values. /// - AllowNumbers = 0b0010 + AllowNumbers = 0b0010 } } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/JsonValueConverterEnum.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/JsonValueConverterEnum.cs index 027e3df24e3..d7ab4e19c2e 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/JsonValueConverterEnum.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/JsonValueConverterEnum.cs @@ -26,7 +26,7 @@ namespace System.Text.Json.Serialization.Converters } public JsonConverterEnum(EnumConverterOptions options) - : this (options, namingPolicy: null) + : this(options, namingPolicy: null) { } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.AddProperty.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.AddProperty.cs index e11e8c8ee5a..c34ccfc830b 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.AddProperty.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.AddProperty.cs @@ -18,9 +18,9 @@ namespace System.Text.Json // dictionaries. Typically it would represent a CLR type such as System.String. PolicyProperty = AddProperty( propertyType, - propertyInfo : null, // Not a real property so this is null. - classType : typeof(object), // A dummy type (not used). - options : options); + propertyInfo: null, // Not a real property so this is null. + classType: typeof(object), // A dummy type (not used). + options: options); } private JsonPropertyInfo AddProperty(Type propertyType, PropertyInfo propertyInfo, Type classType, JsonSerializerOptions options) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.cs index 977273ee60d..2fa525bbf67 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonClassInfo.cs @@ -170,7 +170,7 @@ namespace System.Text.Json case ClassType.Dictionary: { // Add a single property that maps to the class type so we can have policies applied. - AddPolicyProperty(type, options); + AddPolicyProperty(type, options); Type objectType; if (IsNativelySupportedCollection(type)) diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.HandleNull.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.HandleNull.cs index a9b5ab2ffde..39f24204958 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.HandleNull.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.HandleNull.cs @@ -67,7 +67,7 @@ namespace System.Text.Json if (!jsonPropertyInfo.IgnoreNullValues) { - state.Current.JsonPropertyInfo.SetValueAsObject(state.Current.ReturnValue, value : null); + state.Current.JsonPropertyInfo.SetValueAsObject(state.Current.ReturnValue, value: null); } return false; diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Cache.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Cache.cs index 19b1d17dda6..9d4be84258c 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Cache.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Cache.cs @@ -18,7 +18,7 @@ namespace System.Text.RegularExpressions // the cache of code and factories that are currently loaded: // Dictionary for large cache private static readonly Dictionary s_cache = new Dictionary(s_cacheSize); - // linked list for LRU and for small cache + // linked list for LRU and for small cache private static int s_cacheCount = 0; private static CachedCodeEntry s_cacheFirst; private static CachedCodeEntry s_cacheLast; diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCode.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCode.cs index 7cae75ac45e..b4bda3abf4a 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCode.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCode.cs @@ -26,7 +26,7 @@ namespace System.Text.RegularExpressions { // The following primitive operations come directly from the parser - // lef/back operands description + // lef/back operands description public const int Onerep = 0; // lef,back char,min,max a {n} public const int Notonerep = 1; // lef,back char,min,max .{n} public const int Setrep = 2; // lef,back set,min,max [\d]{n} diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs index bdf830f52cd..f81e0973208 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs @@ -266,14 +266,16 @@ namespace System.Text.RegularExpressions /* * True if we need to do the backtrack logic for the current operation */ - private bool IsBack() { + private bool IsBack() + { return (_regexopcode & RegexCode.Back) != 0; } /* * True if we need to do the second-backtrack logic for the current operation */ - private bool IsBack2() { + private bool IsBack2() + { return (_regexopcode & RegexCode.Back2) != 0; } #endif @@ -953,8 +955,8 @@ namespace System.Text.RegularExpressions private void CallToLower() { - Ldloc(_cultureV); - Call(s_chartolowerM); + Ldloc(_cultureV); + Call(s_chartolowerM); } /* @@ -1608,12 +1610,13 @@ namespace System.Text.RegularExpressions /* * Some simple debugging stuff */ - private static readonly MethodInfo s_debugWriteLine = typeof(Debug).GetMethod("WriteLine", new Type[] {typeof(string)}); + private static readonly MethodInfo s_debugWriteLine = typeof(Debug).GetMethod("WriteLine", new Type[] { typeof(string) }); /* * Debug only: emit code to print out a message */ - private void Message(string str) { + private void Message(string str) + { Ldstr(str); Call(s_debugWriteLine); } @@ -1635,7 +1638,8 @@ namespace System.Text.RegularExpressions private void GenerateOneCode() { #if DEBUG - if ((_options & RegexOptions.Debug) != 0) { + if ((_options & RegexOptions.Debug) != 0) + { Mvlocfld(_textposV, s_textposF); Mvlocfld(_trackposV, s_trackposF); Mvlocfld(_stackposV, s_stackposF); diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFCD.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFCD.cs index 283ec6f157b..e1baf0ec11c 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFCD.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFCD.cs @@ -103,11 +103,11 @@ namespace System.Text.RegularExpressions // In release, cutoff at a length to which we can still reasonably construct a string // In debug, use a smaller cutoff to exercise the cutoff path in tests const int Cutoff = - #if DEBUG +#if DEBUG 50; - #else +#else 1_000_000; - #endif +#endif if (curNode.M > 0 && curNode.M < Cutoff) { diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexReplacement.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexReplacement.cs index 1c6f126a639..d0b37082a7e 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexReplacement.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexReplacement.cs @@ -140,7 +140,7 @@ namespace System.Text.RegularExpressions } } - /// + /// /// Given a Match, emits into the ValueStringBuilder the evaluated /// Right-to-Left substitution pattern. /// diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexRunner.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexRunner.cs index 11c86a06b65..f3f7f13ecc2 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexRunner.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexRunner.cs @@ -30,28 +30,28 @@ namespace System.Text.RegularExpressions protected internal int[] runtrack; // The backtracking stack. Opcodes use this to store data regarding protected internal int runtrackpos; // what they have matched and where to backtrack to. Each "frame" on - // the stack takes the form of [CodePosition Data1 Data2...], where - // CodePosition is the position of the current opcode and - // the data values are all optional. The CodePosition can be negative, and - // these values (also called "back2") are used by the BranchMark family of opcodes - // to indicate whether they are backtracking after a successful or failed - // match. - // When we backtrack, we pop the CodePosition off the stack, set the current - // instruction pointer to that code position, and mark the opcode - // with a backtracking flag ("Back"). Each opcode then knows how to - // handle its own data. + // the stack takes the form of [CodePosition Data1 Data2...], where + // CodePosition is the position of the current opcode and + // the data values are all optional. The CodePosition can be negative, and + // these values (also called "back2") are used by the BranchMark family of opcodes + // to indicate whether they are backtracking after a successful or failed + // match. + // When we backtrack, we pop the CodePosition off the stack, set the current + // instruction pointer to that code position, and mark the opcode + // with a backtracking flag ("Back"). Each opcode then knows how to + // handle its own data. protected internal int[] runstack; // This stack is used to track text positions across different opcodes. protected internal int runstackpos; // For example, in /(a*b)+/, the parentheses result in a SetMark/CaptureMark - // pair. SetMark records the text position before we match a*b. Then - // CaptureMark uses that position to figure out where the capture starts. - // Opcodes which push onto this stack are always paired with other opcodes - // which will pop the value from it later. A successful match should mean - // that this stack is empty. + // pair. SetMark records the text position before we match a*b. Then + // CaptureMark uses that position to figure out where the capture starts. + // Opcodes which push onto this stack are always paired with other opcodes + // which will pop the value from it later. A successful match should mean + // that this stack is empty. protected internal int[] runcrawl; // The crawl stack is used to keep track of captures. Every time a group protected internal int runcrawlpos; // has a capture, we push its group number onto the runcrawl stack. In - // the case of a balanced match, we push BOTH groups onto the stack. + // the case of a balanced match, we push BOTH groups onto the stack. protected internal int runtrackcount; // count of states that may do backtracking diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs index 160228dc50e..68d8eb6a35d 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/CommittableTransaction.cs @@ -6,7 +6,7 @@ using System.Threading; namespace System.Transactions { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2229", Justification="Serialization not yet supported and will be done using DistributedTransaction")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2229", Justification = "Serialization not yet supported and will be done using DistributedTransaction")] public sealed class CommittableTransaction : Transaction, IAsyncResult { internal bool _completedSynchronously = false; diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs index c6fbbba7f5f..469a1a2d822 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionException.cs @@ -24,7 +24,7 @@ namespace System.Transactions TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { - etwLog.TransactionExceptionTrace(TransactionExceptionType.TransactionException, message, innerException==null?string.Empty:innerException.ToString()); + etwLog.TransactionExceptionTrace(TransactionExceptionType.TransactionException, message, innerException == null ? string.Empty : innerException.ToString()); } return new TransactionException(message, innerException); @@ -35,7 +35,7 @@ namespace System.Transactions TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { - etwLog.TransactionExceptionTrace(TransactionExceptionType.TransactionException, message, innerException==null?string.Empty:innerException.ToString()); + etwLog.TransactionExceptionTrace(TransactionExceptionType.TransactionException, message, innerException == null ? string.Empty : innerException.ToString()); } return new TransactionException(message, innerException); @@ -54,7 +54,7 @@ namespace System.Transactions TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { - etwLog.TransactionExceptionTrace(TransactionExceptionType.InvalidOperationException, messagewithTxId, innerException==null?string.Empty:innerException.ToString()); + etwLog.TransactionExceptionTrace(TransactionExceptionType.InvalidOperationException, messagewithTxId, innerException == null ? string.Empty : innerException.ToString()); } return new InvalidOperationException(messagewithTxId, innerException); } @@ -64,7 +64,7 @@ namespace System.Transactions TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { - etwLog.TransactionExceptionTrace(traceSource, TransactionExceptionType.InvalidOperationException, message, innerException==null?string.Empty:innerException.ToString()); + etwLog.TransactionExceptionTrace(traceSource, TransactionExceptionType.InvalidOperationException, message, innerException == null ? string.Empty : innerException.ToString()); } return new InvalidOperationException(message, innerException); @@ -191,7 +191,7 @@ namespace System.Transactions TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { - etwLog.TransactionExceptionTrace(TransactionExceptionType.TransactionAbortedException, message, innerException==null?string.Empty:innerException.ToString()); + etwLog.TransactionExceptionTrace(TransactionExceptionType.TransactionAbortedException, message, innerException == null ? string.Empty : innerException.ToString()); } return new TransactionAbortedException(message, innerException); @@ -266,7 +266,7 @@ namespace System.Transactions TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { - etwLog.TransactionExceptionTrace(traceSource, TransactionExceptionType.TransactionInDoubtException, message, innerException==null?string.Empty:innerException.ToString()); + etwLog.TransactionExceptionTrace(traceSource, TransactionExceptionType.TransactionInDoubtException, message, innerException == null ? string.Empty : innerException.ToString()); } return new TransactionInDoubtException(message, innerException); @@ -318,7 +318,7 @@ namespace System.Transactions TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log; if (etwLog.IsEnabled()) { - etwLog.TransactionExceptionTrace(TransactionExceptionType.TransactionManagerCommunicationException, message, innerException==null?string.Empty:innerException.ToString()); + etwLog.TransactionExceptionTrace(TransactionExceptionType.TransactionManagerCommunicationException, message, innerException == null ? string.Empty : innerException.ToString()); } return new TransactionManagerCommunicationException(message, innerException); diff --git a/src/libraries/System.Windows.Extensions/src/System/Drawing/ImageConverter.cs b/src/libraries/System.Windows.Extensions/src/System/Drawing/ImageConverter.cs index 96370f96304..6674e95ac13 100644 --- a/src/libraries/System.Windows.Extensions/src/System/Drawing/ImageConverter.cs +++ b/src/libraries/System.Windows.Extensions/src/System/Drawing/ImageConverter.cs @@ -125,7 +125,7 @@ namespace System.Drawing // pHeader.signature will always be 0x1c15. // "PBrush" should be the 6 chars after position 12 as well. - if ( rawData.Length <= pHeader.headersize + 18 || + if (rawData.Length <= pHeader.headersize + 18 || !rawData.Slice(pHeader.headersize + 12, 6).SequenceEqual(PBrush)) { return null; diff --git a/src/libraries/System.Windows.Extensions/src/System/Security/Cryptography/X509Certificates/SafeX509Handles.cs b/src/libraries/System.Windows.Extensions/src/System/Security/Cryptography/X509Certificates/SafeX509Handles.cs index 51c6dc8e63d..80d550e1f64 100644 --- a/src/libraries/System.Windows.Extensions/src/System/Security/Cryptography/X509Certificates/SafeX509Handles.cs +++ b/src/libraries/System.Windows.Extensions/src/System/Security/Cryptography/X509Certificates/SafeX509Handles.cs @@ -27,7 +27,7 @@ namespace System.Security.Cryptography.X509Certificates internal abstract class SafePointerHandle : SafeHandle where T : SafeHandle, new() { - protected SafePointerHandle(): base(IntPtr.Zero, true) + protected SafePointerHandle() : base(IntPtr.Zero, true) { }