1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-09 17:44:48 +09:00

Enable IDE0031 (Use null propagation) (#70965)

This commit is contained in:
Stephen Toub 2022-06-20 05:47:48 -04:00 committed by GitHub
parent 38794de5f2
commit de170cc1c1
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 120 additions and 121 deletions

View file

@ -1389,7 +1389,7 @@ dotnet_diagnostic.IDE0029.severity = warning
dotnet_diagnostic.IDE0030.severity = warning
# IDE0031: Use null propagation
dotnet_diagnostic.IDE0031.severity = silent
dotnet_diagnostic.IDE0031.severity = warning
# IDE0032: Use auto property
dotnet_diagnostic.IDE0032.severity = silent

View file

@ -275,7 +275,7 @@ namespace System.Collections.Specialized
protected object? BaseGet(string? name)
{
NameObjectEntry? e = FindEntry(name);
return (e != null) ? e.Value : null;
return e?.Value;
}
/// <devdoc>

View file

@ -41,7 +41,7 @@ namespace System.Collections.Specialized
/// provider and the default case-insensitive comparer.</para>
/// </devdoc>
public NameValueCollection(NameValueCollection col)
: base(col != null ? col.Comparer : null)
: base(col?.Comparer)
{
Add(col!);
}

View file

@ -55,7 +55,7 @@ namespace System.Collections.Generic
public LinkedListNode<T>? Last
{
get { return head == null ? null : head.prev; }
get { return head?.prev; }
}
bool ICollection<T>.IsReadOnly

View file

@ -80,7 +80,7 @@ namespace System.ComponentModel.Composition.Hosting
/// </para>
/// </remarks>
public AggregateExportProvider(IEnumerable<ExportProvider>? providers)
: this((providers != null) ? providers.AsArray() : null)
: this(providers?.AsArray())
{
}

View file

@ -253,7 +253,7 @@ namespace System.ComponentModel.Composition.Hosting
{
ThrowIfDisposed();
return (_catalogExportProvider != null) ? _catalogExportProvider.Catalog : null;
return _catalogExportProvider?.Catalog;
}
}

View file

@ -394,7 +394,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
public IDictionary<string, object?>? GetMetadata()
{
return (_metadata != null) ? _metadata.Value : null;
return _metadata?.Value;
}
public IEnumerable<ExportDefinition> GetExports()

View file

@ -240,7 +240,7 @@ namespace MS.Internal.Xml.Linq.ComponentModel
{
case XObjectChange.Name:
XElement? e = sender as XElement;
_changeState = e != null ? e.Name : null;
_changeState = e?.Name;
break;
}
}
@ -368,11 +368,11 @@ namespace MS.Internal.Xml.Linq.ComponentModel
{
case XObjectChange.Remove:
XElement? e = sender as XElement;
_changeState = e != null ? e.Parent : null;
_changeState = e?.Parent;
break;
case XObjectChange.Name:
e = sender as XElement;
_changeState = e != null ? e.Name : null;
_changeState = e?.Name;
break;
}
}

View file

@ -716,7 +716,7 @@ namespace System.Configuration
// on an infinite recursion when calling Properties[propertyName] as that calls this.
_ = base[propertyName];
SettingsProperty setting = Properties[propertyName];
SettingsProvider provider = setting != null ? setting.Provider : null;
SettingsProvider provider = setting?.Provider;
Debug.Assert(provider != null, "Could not determine provider from which settings were loaded");

View file

@ -1570,7 +1570,7 @@ namespace System.Data.Common
if ((null != command) && (null == command.Connection))
{
DbDataAdapter? adapter = DataAdapter;
DbCommand? select = ((null != adapter) ? adapter.SelectCommand : null);
DbCommand? select = adapter?.SelectCommand;
if (null != select)
{
command.Connection = select.Connection;

View file

@ -17,7 +17,7 @@ namespace System.Data
public ConstraintEnumerator(DataSet? dataSet)
{
_tables = (dataSet != null) ? dataSet.Tables.GetEnumerator() : null;
_tables = dataSet?.Tables.GetEnumerator();
_currentObject = null;
}

View file

@ -348,8 +348,8 @@ namespace System.Data
{
get
{
RowPredicateFilter? filter = (GetFilter() as RowPredicateFilter);
return ((null != filter) ? filter._predicateFilter : null);
RowPredicateFilter? filter = GetFilter() as RowPredicateFilter;
return filter?._predicateFilter;
}
set
{

View file

@ -168,7 +168,7 @@ namespace System.Data
public DataViewRowState RecordStates => _recordStates;
public IFilter? RowFilter => (IFilter?)((null != _rowFilter) ? _rowFilter.Target : null);
public IFilter? RowFilter => (IFilter?)(_rowFilter?.Target);
public int GetRecord(int recordIndex)
{

View file

@ -225,7 +225,7 @@ namespace System.Data
_udSimpleTypes[type.QualifiedName.ToString()] = xmlSimpleType;
DataColumn? dc = (DataColumn?)_existingSimpleTypeMap![type.QualifiedName.ToString()];
// Assumption is that our simple type qualified name ihas the same output as XmlSchemaSimpleType type.QualifiedName.ToString()
SimpleType? tmpSimpleType = (dc != null) ? dc.SimpleType : null;
SimpleType? tmpSimpleType = dc?.SimpleType;
if (tmpSimpleType != null)
{

View file

@ -65,7 +65,7 @@ namespace System.Data.Odbc
get
{
System.Data.ProviderBase.DbConnectionPoolGroup? poolGroup = PoolGroup;
return ((null != poolGroup) ? poolGroup.ConnectionOptions : null);
return poolGroup?.ConnectionOptions;
}
}
@ -198,7 +198,7 @@ namespace System.Data.Odbc
{
Debug.Assert(DbConnectionClosedConnecting.SingletonInstance == _innerConnection, "not connecting");
System.Data.ProviderBase.DbConnectionPoolGroup? poolGroup = PoolGroup;
DbConnectionOptions? connectionOptions = ((null != poolGroup) ? poolGroup.ConnectionOptions : null);
DbConnectionOptions? connectionOptions = poolGroup?.ConnectionOptions;
if ((null == connectionOptions) || connectionOptions.IsEmpty)
{
throw ADP.NoConnectionString();

View file

@ -616,7 +616,7 @@ namespace System.Data.OleDb
}
else if ((int)hresult < 0)
{
e = ODB.NoErrorInformation((null != connection) ? connection.Provider : null, hresult, null); // OleDbException
e = ODB.NoErrorInformation(connection?.Provider, hresult, null); // OleDbException
ResetState(connection);
}

View file

@ -151,7 +151,7 @@ namespace System.Data.OleDb
for (int indexWithinAccessor = 0; indexWithinAccessor < columns.Length; ++indexWithinAccessor)
{
int index = indexStart + indexWithinAccessor;
OleDbParameter? parameter = ((null != parameters) ? parameters[index] : null);
OleDbParameter? parameter = parameters?[index];
columns[indexWithinAccessor] = new ColumnBinding(
dataReader!, index, indexForAccessor, indexWithinAccessor,
parameter, this, bindings, dbbindings[indexWithinAccessor], _headerLength,

View file

@ -1099,7 +1099,7 @@ namespace System.Data.Common
{
using (RegistryKey? key = Registry.ClassesRoot.OpenSubKey(subkey, false))
{
return ((null != key) ? key.GetValue(queryvalue) : null);
return key?.GetValue(queryvalue);
}
}
catch (SecurityException e)
@ -1117,7 +1117,7 @@ namespace System.Data.Common
{
using (RegistryKey? key = Registry.LocalMachine.OpenSubKey(subkey, false))
{
return ((null != key) ? key.GetValue(queryvalue) : null);
return key?.GetValue(queryvalue);
}
}
catch (SecurityException e)

View file

@ -56,7 +56,7 @@ namespace System.Data.OleDb
get
{
System.Data.ProviderBase.DbConnectionPoolGroup? poolGroup = PoolGroup;
return ((null != poolGroup) ? poolGroup.ConnectionOptions : null);
return poolGroup?.ConnectionOptions;
}
}
@ -249,7 +249,7 @@ namespace System.Data.OleDb
Debug.Assert(DbConnectionClosedConnecting.SingletonInstance == _innerConnection, "not connecting");
System.Data.ProviderBase.DbConnectionPoolGroup? poolGroup = PoolGroup;
DbConnectionOptions? connectionOptions = ((null != poolGroup) ? poolGroup.ConnectionOptions : null);
DbConnectionOptions? connectionOptions = poolGroup?.ConnectionOptions;
if ((null == connectionOptions) || connectionOptions.IsEmpty)
{
throw ADP.NoConnectionString();

View file

@ -266,7 +266,7 @@ namespace System.DirectoryServices.AccountManagement
try
{
using (DirectoryEntry deRoot = new DirectoryEntry("LDAP://" + userSuppliedServerName + "/rootDSE", credentials == null ? null : credentials.UserName, credentials == null ? null : credentials.Password, authTypes))
using (DirectoryEntry deRoot = new DirectoryEntry("LDAP://" + userSuppliedServerName + "/rootDSE", credentials?.UserName, credentials?.Password, authTypes))
{
if (deRoot.Properties["schemaNamingContext"].Count == 0)
{
@ -277,7 +277,7 @@ namespace System.DirectoryServices.AccountManagement
SchemaNamingContext = (string)deRoot.Properties["schemaNamingContext"].Value;
}
using (DirectoryEntry deSCN = new DirectoryEntry("LDAP://" + userSuppliedServerName + "/" + SchemaNamingContext, credentials == null ? null : credentials.UserName, credentials == null ? null : credentials.Password, authTypes))
using (DirectoryEntry deSCN = new DirectoryEntry("LDAP://" + userSuppliedServerName + "/" + SchemaNamingContext, credentials?.UserName, credentials?.Password, authTypes))
{
using (DirectorySearcher dirSearcher = new DirectorySearcher(deSCN))
{

View file

@ -1192,9 +1192,9 @@ namespace System.DirectoryServices.AccountManagement
// duplicates because the list of global groups will show up on both the GC and DC.
Debug.Assert(p.ContextType == ContextType.Domain);
Forest forest = Forest.GetForest(new DirectoryContext(DirectoryContextType.Forest, this.DnsForestName, this.credentials != null ? this.credentials.UserName : null, this.credentials != null ? this.credentials.Password : null));
Forest forest = Forest.GetForest(new DirectoryContext(DirectoryContextType.Forest, this.DnsForestName, this.credentials?.UserName, this.credentials?.Password));
DirectoryContext dc = new DirectoryContext(DirectoryContextType.Domain, this.DnsDomainName, this.credentials != null ? this.credentials.UserName : null, this.credentials != null ? this.credentials.Password : null);
DirectoryContext dc = new DirectoryContext(DirectoryContextType.Domain, this.DnsDomainName, this.credentials?.UserName, this.credentials?.Password);
DomainController dd = DomainController.FindOne(dc);
GlobalCatalog gc = null;
@ -1213,7 +1213,7 @@ namespace System.DirectoryServices.AccountManagement
}
}
roots.Add(new DirectoryEntry("GC://" + gc.Name + "/" + p.DistinguishedName, this.credentials != null ? this.credentials.UserName : null, this.credentials != null ? this.credentials.Password : null, this.AuthTypes));
roots.Add(new DirectoryEntry("GC://" + gc.Name + "/" + p.DistinguishedName, this.credentials?.UserName, this.credentials?.Password, this.AuthTypes));
if (!string.Equals(this.DnsDomainName, gc.Domain.Name, StringComparison.OrdinalIgnoreCase))
{

View file

@ -171,8 +171,8 @@ namespace System.DirectoryServices.AccountManagement
contextName,
null,
contextOptions,
(credentials != null ? credentials.UserName : null),
(credentials != null ? credentials.Password : null)
credentials?.UserName,
credentials?.Password
);
lock (_tableLock)

View file

@ -373,8 +373,8 @@ namespace System.DirectoryServices.AccountManagement
internal static DirectoryEntry BuildDirectoryEntry(string path, NetCred credentials, AuthenticationTypes authTypes)
{
DirectoryEntry de = new DirectoryEntry(path,
credentials != null ? credentials.UserName : null,
credentials != null ? credentials.Password : null,
credentials?.UserName,
credentials?.Password,
authTypes);
GlobalDebug.WriteLineIf(GlobalDebug.Info, "SDSUtils", "BuildDirectoryEntry (1): built DE for " + de.Path);
@ -386,8 +386,8 @@ namespace System.DirectoryServices.AccountManagement
{
DirectoryEntry de = new DirectoryEntry();
de.Username = credentials != null ? credentials.UserName : null;
de.Password = credentials != null ? credentials.Password : null;
de.Username = credentials?.UserName;
de.Password = credentials?.Password;
de.AuthenticationType = authTypes;
GlobalDebug.WriteLineIf(GlobalDebug.Info, "SDSUtils", "BuildDirectoryEntry (2): built DE");

View file

@ -1049,9 +1049,9 @@ namespace System.DirectoryServices.ActiveDirectory
if (isBound)
{
// set the value on the directory entry
SetProperty(PropertyManager.DefaultSecurityDescriptor, (value == null) ? null : value.GetSecurityDescriptorSddlForm(AccessControlSections.All));
SetProperty(PropertyManager.DefaultSecurityDescriptor, value?.GetSecurityDescriptorSddlForm(AccessControlSections.All));
}
_defaultSDSddlForm = (value == null) ? null : value.GetSecurityDescriptorSddlForm(AccessControlSections.All);
_defaultSDSddlForm = value?.GetSecurityDescriptorSddlForm(AccessControlSections.All);
}
}

View file

@ -2308,7 +2308,7 @@ namespace System.Management
{
securityHandler = scope.GetSecurityHandler();
IWbemClassObjectFreeThreaded inParams = (null == inParameters) ? null : inParameters.wbemObject;
IWbemClassObjectFreeThreaded inParams = inParameters?.wbemObject;
IWbemClassObjectFreeThreaded outParams = null;
status = scope.GetSecuredIWbemServicesHandler(scope.GetIWbemServices()).ExecMethod_(

View file

@ -617,7 +617,7 @@ namespace System.Management
}
internal ManagementScope(ManagementPath path, ManagementScope scope)
: this(path, (null != scope) ? scope.options : null) { }
: this(path, scope?.options) { }
internal static ManagementScope _Clone(ManagementScope scope)
{

View file

@ -303,7 +303,7 @@ namespace System.Net.Mail
#endif
try
{
ExecutionContext? x = context == null ? null : context.ContextCopy;
ExecutionContext? x = context?.ContextCopy;
if (x != null)
{
AuthenticateCallbackContext authenticationContext =

View file

@ -845,7 +845,7 @@ namespace System.Net
{
get
{
return (_bannerMessage != null) ? _bannerMessage.ToString() : null;
return _bannerMessage?.ToString();
}
}
@ -856,7 +856,7 @@ namespace System.Net
{
get
{
return (_welcomeMessage != null) ? _welcomeMessage.ToString() : null;
return _welcomeMessage?.ToString();
}
}
@ -867,7 +867,7 @@ namespace System.Net
{
get
{
return (_exitMessage != null) ? _exitMessage.ToString() : null;
return _exitMessage?.ToString();
}
}

View file

@ -3291,7 +3291,7 @@ namespace System.Net.Sockets
// DualMode: When bound to IPv6Any you must enable both socket options.
// When bound to an IPv4 mapped IPv6 address you must enable the IPv4 socket option.
IPEndPoint? ipEndPoint = _rightEndPoint as IPEndPoint;
IPAddress? boundAddress = (ipEndPoint != null ? ipEndPoint.Address : null);
IPAddress? boundAddress = ipEndPoint?.Address;
Debug.Assert(boundAddress != null, "Not Bound");
if (_addressFamily == AddressFamily.InterNetwork)
{

View file

@ -23,7 +23,7 @@ namespace System.Runtime.Serialization.Json
string xmlContent = jsonReader.ReadElementContentAsString();
DataContractSerializer dataContractSerializer = new DataContractSerializer(TraditionalDataContract.UnderlyingType,
GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false); // maxItemsInObjectGraph // ignoreExtensionDataObject // preserveObjectReferences
GetKnownTypesFromContext(context, context?.SerializerKnownTypeList), 1, false, false); // maxItemsInObjectGraph // ignoreExtensionDataObject // preserveObjectReferences
MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(xmlContent));
object? xmlValue;
@ -47,7 +47,7 @@ namespace System.Runtime.Serialization.Json
public override void WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson? context, RuntimeTypeHandle declaredTypeHandle)
{
DataContractSerializer dataContractSerializer = new DataContractSerializer(Type.GetTypeFromHandle(declaredTypeHandle)!,
GetKnownTypesFromContext(context, (context == null) ? null : context.SerializerKnownTypeList), 1, false, false); // maxItemsInObjectGraph // ignoreExtensionDataObject // preserveObjectReferences
GetKnownTypesFromContext(context, context?.SerializerKnownTypeList), 1, false, false); // maxItemsInObjectGraph // ignoreExtensionDataObject // preserveObjectReferences
MemoryStream memoryStream = new MemoryStream();
dataContractSerializer.WriteObject(memoryStream, obj);

View file

@ -143,7 +143,7 @@ namespace System.Runtime.Serialization
XmlDictionary dictionary = new XmlDictionary();
this.Name = dictionary.Add(StableName.Name);
this.Namespace = dictionary.Add(StableName.Namespace);
object[]? xmlRootAttributes = (UnderlyingType == null) ? null : UnderlyingType.GetCustomAttributes(Globals.TypeOfXmlRootAttribute, false).ToArray();
object[]? xmlRootAttributes = UnderlyingType?.GetCustomAttributes(Globals.TypeOfXmlRootAttribute, false).ToArray();
if (xmlRootAttributes == null || xmlRootAttributes.Length == 0)
{
if (hasRoot)

View file

@ -426,7 +426,7 @@ namespace System.Runtime.Serialization
internal virtual Type? GetSerializeType(object? graph)
{
return (graph == null) ? null : graph.GetType();
return graph?.GetType();
}
internal virtual Type? GetDeserializeType()

View file

@ -236,7 +236,7 @@ namespace System.Runtime.Serialization
internal Type? ResolveNameFromKnownTypes(XmlQualifiedName typeName)
{
DataContract? dataContract = ResolveDataContractFromKnownTypes(typeName);
return dataContract == null ? null : dataContract.UnderlyingType;
return dataContract?.UnderlyingType;
}
[RequiresUnreferencedCode(DataContract.SerializerTrimmerWarning)]

View file

@ -117,8 +117,8 @@ namespace System.Runtime.Serialization
dictionaryWriter.WriteStartAttribute(prefix, localName, namespaceUri);
else
writer.WriteStartAttribute(prefix,
(localName == null ? null : localName.Value)!,
(namespaceUri == null ? null : namespaceUri.Value));
localName?.Value!,
namespaceUri?.Value);
}
internal void WriteAttributeString(string? prefix, string localName, string? ns, string value)
@ -230,7 +230,7 @@ namespace System.Runtime.Serialization
if (dictionaryWriter != null)
dictionaryWriter.WriteStartElement(prefix, localName, namespaceUri);
else
writer.WriteStartElement(prefix, (localName == null ? null : localName.Value)!, (namespaceUri == null ? null : namespaceUri.Value));
writer.WriteStartElement(prefix, localName?.Value!, namespaceUri?.Value);
depth++;
_prefixes = 1;
}
@ -240,7 +240,7 @@ namespace System.Runtime.Serialization
if (dictionaryWriter != null)
dictionaryWriter.WriteStartElement(null, localName, namespaceUri);
else
writer.WriteStartElement(null, (localName == null ? null : localName.Value)!, (namespaceUri == null ? null : namespaceUri.Value));
writer.WriteStartElement(null, localName?.Value!, namespaceUri?.Value);
}
internal void WriteEndElementPrimitive()

View file

@ -300,7 +300,7 @@ namespace System.Xml
public override void WriteStartAttribute(string? prefix, XmlDictionaryString localName, XmlDictionaryString? namespaceUri)
{
StartAttribute(ref prefix, (localName != null ? localName.Value : null)!, (namespaceUri != null ? namespaceUri.Value : null), namespaceUri);
StartAttribute(ref prefix, localName?.Value!, namespaceUri?.Value, namespaceUri);
if (!_isXmlnsAttribute)
{
_writer.WriteStartAttribute(prefix, localName!);
@ -604,7 +604,7 @@ namespace System.Xml
public override void WriteStartElement(string? prefix, XmlDictionaryString localName, XmlDictionaryString? namespaceUri)
{
StartElement(ref prefix, localName.Value, (namespaceUri != null ? namespaceUri.Value : null), namespaceUri);
StartElement(ref prefix, localName.Value, namespaceUri?.Value, namespaceUri);
_writer.WriteStartElement(prefix, localName);
}

View file

@ -55,8 +55,7 @@ namespace System.Xml.Linq
{
get
{
XNode? last = LastNode;
return last != null ? last.next : null;
return LastNode?.next;
}
}

View file

@ -215,7 +215,7 @@ namespace System.Xml.Linq
/// </summary>
public XAttribute? FirstAttribute
{
get { return lastAttr != null ? lastAttr.next : null; }
get { return lastAttr?.next; }
}
/// <summary>

View file

@ -505,7 +505,7 @@ namespace System.Xml
internal XmlTextReaderImpl(Stream xmlFragment, XmlNodeType fragType, XmlParserContext? context)
: this((context != null && context.NameTable != null) ? context.NameTable : new NameTable())
{
Encoding? enc = (context != null) ? context.Encoding : null;
Encoding? enc = context?.Encoding;
if (context == null || context.BaseURI == null || context.BaseURI.Length == 0)
{
InitStreamInput(xmlFragment, enc);

View file

@ -1307,7 +1307,7 @@ namespace System.Xml
return prefix;
}
}
return (_predefinedNamespaces != null) ? _predefinedNamespaces.LookupPrefix(ns) : null;
return _predefinedNamespaces?.LookupPrefix(ns);
}
catch
{
@ -2074,7 +2074,7 @@ namespace System.Xml
return _nsStack[i].namespaceUri;
}
}
return (_predefinedNamespaces != null) ? _predefinedNamespaces.LookupNamespace(prefix) : null;
return _predefinedNamespaces?.LookupNamespace(prefix);
}
private string? LookupLocalNamespace(string prefix)

View file

@ -735,10 +735,10 @@ namespace System.Xml
return new XmlParserContext(
nt,
mgr,
(docType == null) ? null : docType.Name,
(docType == null) ? null : docType.PublicId,
(docType == null) ? null : docType.SystemId,
(docType == null) ? null : docType.InternalSubset,
docType?.Name,
docType?.PublicId,
docType?.SystemId,
docType?.InternalSubset,
baseURI,
lang,
spaceMode

View file

@ -3476,7 +3476,7 @@ namespace System.Xml
{
_curPos = curPos;
Uri? baseUri = _readerAdapter.BaseUri;
_readerAdapter.Throw(new XmlException(res, arg, (int)LineNo, (int)LinePos, baseUri == null ? null : baseUri.ToString()));
_readerAdapter.Throw(new XmlException(res, arg, (int)LineNo, (int)LinePos, baseUri?.ToString()));
}
[DoesNotReturn]
@ -3484,14 +3484,14 @@ namespace System.Xml
{
_curPos = curPos;
Uri? baseUri = _readerAdapter.BaseUri;
_readerAdapter.Throw(new XmlException(res, args, (int)LineNo, (int)LinePos, baseUri == null ? null : baseUri.ToString()));
_readerAdapter.Throw(new XmlException(res, args, (int)LineNo, (int)LinePos, baseUri?.ToString()));
}
[DoesNotReturn]
private void Throw(string res, string arg, int lineNo, int linePos)
{
Uri? baseUri = _readerAdapter.BaseUri;
_readerAdapter.Throw(new XmlException(res, arg, (int)lineNo, (int)linePos, baseUri == null ? null : baseUri.ToString()));
_readerAdapter.Throw(new XmlException(res, arg, (int)lineNo, (int)linePos, baseUri?.ToString()));
}
private void ThrowInvalidChar(int pos, string data, int invCharPos)

View file

@ -427,7 +427,7 @@ namespace System.Xml.Schema
public override object? FindId(string name)
{
return _IDs == null ? null : _IDs[name];
return _IDs?[name];
}
private bool GenEntity(XmlQualifiedName qname)

View file

@ -1789,7 +1789,7 @@ namespace System.Xml.Schema
private void CompileLocalAttributes(XmlSchemaComplexType? baseType, XmlSchemaComplexType derivedType, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute? anyAttribute, XmlSchemaDerivationMethod derivedBy)
{
XmlSchemaAnyAttribute? baseAttributeWildcard = baseType != null ? baseType.AttributeWildcard : null;
XmlSchemaAnyAttribute? baseAttributeWildcard = baseType?.AttributeWildcard;
for (int i = 0; i < attributes.Count; ++i)
{
XmlSchemaAttribute? attribute = attributes[i] as XmlSchemaAttribute;

View file

@ -2166,7 +2166,7 @@ namespace System.Xml.Schema
private void CompileLocalAttributes(XmlSchemaComplexType? baseType, XmlSchemaComplexType derivedType, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute? anyAttribute, XmlSchemaDerivationMethod derivedBy)
{
XmlSchemaAnyAttribute? baseAttributeWildcard = baseType != null ? baseType.AttributeWildcard : null;
XmlSchemaAnyAttribute? baseAttributeWildcard = baseType?.AttributeWildcard;
for (int i = 0; i < attributes.Count; ++i)
{
XmlSchemaAttribute? attr = attributes[i] as XmlSchemaAttribute;

View file

@ -651,7 +651,7 @@ namespace System.Xml.Schema
public override object? FindId(string name)
{
return _IDs == null ? null : _IDs[name];
return _IDs?[name];
}
private void Push(XmlQualifiedName elementName)

View file

@ -195,7 +195,7 @@ namespace System.Xml.Schema
get
{
XmlSchemaCollectionNode? node = (XmlSchemaCollectionNode?)_collection[ns ?? string.Empty];
return (node != null) ? node.Schema : null;
return node?.Schema;
}
}
@ -279,7 +279,7 @@ namespace System.Xml.Schema
internal SchemaInfo? GetSchemaInfo(string? ns)
{
XmlSchemaCollectionNode? node = (XmlSchemaCollectionNode?)_collection[ns ?? string.Empty];
return (node != null) ? node.SchemaInfo : null;
return node?.SchemaInfo;
}
internal SchemaNames GetSchemaNames(XmlNameTable nt)

View file

@ -697,7 +697,7 @@ namespace System.Xml.Schema
if (schemaInfo != null)
{
schemaInfo.SchemaAttribute = localAttribute;
schemaInfo.SchemaType = localAttribute == null ? null : localAttribute.AttributeSchemaType;
schemaInfo.SchemaType = localAttribute?.AttributeSchemaType;
schemaInfo.MemberType = localMemberType;
schemaInfo.IsDefault = false;
schemaInfo.Validity = localValidity;
@ -2035,7 +2035,7 @@ namespace System.Xml.Schema
private object? FindId(string name)
{
return _IDs == null ? null : _IDs[name];
return _IDs?[name];
}
private void CheckForwardRefs()

View file

@ -772,7 +772,7 @@ namespace System.Xml.Schema
public override object? FindId(string name)
{
return _IDs == null ? null : _IDs[name];
return _IDs?[name];
}
public bool IsXSDRoot(string localName, string ns)

View file

@ -262,7 +262,7 @@ namespace System.Xml.Serialization
if (root == null)
root = a.XmlRoot;
string? ns = root == null ? null : root.Namespace;
string? ns = root?.Namespace;
if (ns == null) ns = defaultNamespace;
if (ns == null) ns = _defaultNs;

View file

@ -1473,7 +1473,7 @@ namespace System.Xml.Serialization
protected object GetTarget(string id)
{
object? target = _targets != null ? _targets[id] : null;
object? target = _targets?[id];
if (target == null)
{
throw new InvalidOperationException(SR.Format(SR.XmlInvalidHref, id));

View file

@ -78,7 +78,7 @@ namespace System.Xml.Serialization
{
get
{
return _namespaces == null ? null : _namespaces.NamespaceList;
return _namespaces?.NamespaceList;
}
set
{

View file

@ -70,7 +70,7 @@ namespace System.Xml.Xsl.IlGen
public static OptimizerPatterns Read(QilNode nd)
{
XmlILAnnotation? ann = nd.Annotation as XmlILAnnotation;
OptimizerPatterns? optPatt = (ann != null) ? ann.Patterns : null;
OptimizerPatterns? optPatt = ann?.Patterns;
if (optPatt == null)
{

View file

@ -86,7 +86,7 @@ namespace System.Xml.Xsl.IlGen
/// </summary>
public string[]? Names
{
get { return (_uniqueNames != null) ? _uniqueNames.ToArray() : null; }
get { return _uniqueNames?.ToArray(); }
}
/// <summary>
@ -107,7 +107,7 @@ namespace System.Xml.Xsl.IlGen
/// </summary>
public Int32Pair[]? NameFilters
{
get { return (_uniqueFilters != null) ? _uniqueFilters.ToArray() : null; }
get { return _uniqueFilters?.ToArray(); }
}
/// <summary>
@ -143,7 +143,7 @@ namespace System.Xml.Xsl.IlGen
/// </summary>
public StringPair[][]? PrefixMappingsList
{
get { return (_prefixMappingsList != null) ? _prefixMappingsList.ToArray() : null; }
get { return _prefixMappingsList?.ToArray(); }
}
/// <summary>
@ -166,7 +166,7 @@ namespace System.Xml.Xsl.IlGen
/// </summary>
public string[]? GlobalNames
{
get { return (_globalNames != null) ? _globalNames.ToArray() : null; }
get { return _globalNames?.ToArray(); }
}
/// <summary>
@ -213,7 +213,7 @@ namespace System.Xml.Xsl.IlGen
/// </summary>
public XmlQueryType[]? XmlTypes
{
get { return (_uniqueXmlTypes != null) ? _uniqueXmlTypes.ToArray() : null; }
get { return _uniqueXmlTypes?.ToArray(); }
}
/// <summary>
@ -233,7 +233,7 @@ namespace System.Xml.Xsl.IlGen
/// </summary>
public XmlCollation[]? Collations
{
get { return (_uniqueCollations != null) ? _uniqueCollations.ToArray() : null; }
get { return _uniqueCollations?.ToArray(); }
}
}
}

View file

@ -65,7 +65,7 @@ namespace System.Xml.Xsl.IlGen
public static XmlILConstructInfo Read(QilNode nd)
{
XmlILAnnotation? ann = nd.Annotation as XmlILAnnotation;
XmlILConstructInfo? constrInfo = (ann != null) ? ann.ConstructInfo : null;
XmlILConstructInfo? constrInfo = ann?.ConstructInfo;
if (constrInfo == null)
{

View file

@ -38,7 +38,7 @@ namespace System.Xml.Xsl.Qil
for (int i = 0; i < parent.Count; i++)
{
QilNode oldChild = parent[i], newChild;
XmlQueryType? oldChildType = oldChild != null ? oldChild.XmlType : null;
XmlQueryType? oldChildType = oldChild?.XmlType;
// Visit child
if (IsReference(parent, i))

View file

@ -93,7 +93,7 @@ namespace System.Xml.Xsl.Runtime
/// </summary>
public XmlNameTable DefaultNameTable
{
get { return _defaultDataSource != null ? _defaultDataSource.NameTable : null; }
get { return _defaultDataSource?.NameTable; }
}
/// <summary>
@ -170,7 +170,7 @@ namespace System.Xml.Xsl.Runtime
if (stream != null)
{
// Create document from stream
XmlReader reader = _readerSettings.CreateReader(stream, uriResolved != null ? uriResolved.ToString() : null);
XmlReader reader = _readerSettings.CreateReader(stream, uriResolved?.ToString());
try
{
@ -212,7 +212,7 @@ namespace System.Xml.Xsl.Runtime
/// </summary>
public object GetParameter(string localName, string namespaceUri)
{
return (_argList != null) ? _argList.GetParam(localName, namespaceUri) : null;
return _argList?.GetParam(localName, namespaceUri);
}
@ -227,7 +227,7 @@ namespace System.Xml.Xsl.Runtime
Justification = XsltArgumentList.ExtensionObjectSuppresion)]
public object GetLateBoundObject(string namespaceUri)
{
return (_argList != null) ? _argList.GetExtensionObject(namespaceUri) : null;
return _argList?.GetExtensionObject(namespaceUri);
}
/// <summary>
@ -262,7 +262,7 @@ namespace System.Xml.Xsl.Runtime
object objRet;
// Get external object instance from argument list (throw if either the list or the instance doesn't exist)
instance = (_argList != null) ? _argList.GetExtensionObject(namespaceUri) : null;
instance = _argList?.GetExtensionObject(namespaceUri);
if (instance == null)
throw new XslTransformException(SR.XmlIl_UnknownExtObj, namespaceUri);

View file

@ -178,7 +178,7 @@ namespace System.Xml.Xsl
public override string? SourceUri
{
get { return _lineInfo != null ? _lineInfo.Uri : null; }
get { return _lineInfo?.Uri; }
}
public override int LineNumber

View file

@ -1908,7 +1908,7 @@ namespace System.Xml.Xsl.Xslt
QilNode countMatches, fromMatches, A, F, AF;
QilIterator i, j;
countPattern2 = (countPattern != null) ? countPattern.DeepClone(_f.BaseFactory) : null;
countPattern2 = countPattern?.DeepClone(_f.BaseFactory);
countMatches = _f.Filter(i = _f.For(_f.AncestorOrSelf(GetCurrentNode())), MatchCountPattern(countPattern, i));
if (multiple)
{

View file

@ -115,7 +115,7 @@ namespace System.Xml.Xsl.XsltOld
get
{
ActionFrame? frame = (ActionFrame?)_actionStack.Peek();
return frame != null ? frame.Node : null;
return frame?.Node;
}
}

View file

@ -149,7 +149,7 @@ namespace System.Runtime.Caching
{
CacheEntryUpdateArguments args = new CacheEntryUpdateArguments(cache, reason, entry.Key, null);
entry.CacheEntryUpdateCallback(args);
object expensiveObject = (args.UpdatedCacheItem != null) ? args.UpdatedCacheItem.Value : null;
object expensiveObject = args.UpdatedCacheItem?.Value;
CacheItemPolicy policy = args.UpdatedCacheItemPolicy;
// Only update the "expensive" object if the user returns a new object,
// a policy with update callback, and the change monitors haven't changed. (Inserting
@ -446,7 +446,7 @@ namespace System.Runtime.Caching
MemoryCacheKey cacheKey = new MemoryCacheKey(key);
MemoryCacheStore store = GetStore(cacheKey);
MemoryCacheEntry entry = store.AddOrGetExisting(cacheKey, new MemoryCacheEntry(key, value, absExp, slidingExp, priority, changeMonitors, removedCallback, this));
return (entry != null) ? entry.Value : null;
return entry?.Value;
}
public override CacheEntryChangeMonitor CreateCacheEntryChangeMonitor(IEnumerable<string> keys, string regionName = null)
@ -532,7 +532,7 @@ namespace System.Runtime.Caching
throw new ArgumentNullException(nameof(key));
}
MemoryCacheEntry entry = GetEntry(key);
return (entry != null) ? entry.Value : null;
return entry?.Value;
}
internal MemoryCacheEntry GetEntry(string key)
@ -833,7 +833,7 @@ namespace System.Runtime.Caching
return null;
}
MemoryCacheEntry entry = RemoveEntry(key, null, reason);
return (entry != null) ? entry.Value : null;
return entry?.Value;
}
public override long GetCount(string regionName = null)

View file

@ -904,7 +904,7 @@ namespace System.Security.AccessControl
actualFlags |= (ControlFlags.SystemAclPresent);
}
_rawSd = new RawSecurityDescriptor(actualFlags, owner, group, systemAcl == null ? null : systemAcl.RawAcl, discretionaryAcl.RawAcl);
_rawSd = new RawSecurityDescriptor(actualFlags, owner, group, systemAcl?.RawAcl, discretionaryAcl.RawAcl);
}
#endregion

View file

@ -204,7 +204,7 @@ namespace System.Security.Cryptography.Xml
if (cipherData.CipherReference.Uri.Length == 0)
{
// self referenced Uri
string baseUri = (_document == null ? null : _document.BaseURI);
string baseUri = _document?.BaseURI;
TransformChain tc = cipherData.CipherReference.TransformChain;
if (tc == null)
{
@ -222,7 +222,7 @@ namespace System.Security.Cryptography.Xml
throw new CryptographicException(SR.Cryptography_Xml_UriNotSupported);
}
inputStream = new MemoryStream(_encoding.GetBytes(idElem.OuterXml));
string baseUri = (_document == null ? null : _document.BaseURI);
string baseUri = _document?.BaseURI;
TransformChain tc = cipherData.CipherReference.TransformChain;
if (tc == null)
{

View file

@ -112,7 +112,7 @@ namespace System.Security.Cryptography.Xml
private void Initialize(XmlElement element)
{
_containingDocument = (element == null ? null : element.OwnerDocument);
_containingDocument = element?.OwnerDocument;
_context = element;
m_signature = new Signature();
m_signature.SignedXml = this;
@ -784,7 +784,7 @@ namespace System.Security.Cryptography.Xml
bool isKeyedHashAlgorithm = hash is KeyedHashAlgorithm;
if (isKeyedHashAlgorithm || !_bCacheValid || !SignedInfo.CacheValid)
{
string baseUri = (_containingDocument == null ? null : _containingDocument.BaseURI);
string baseUri = _containingDocument?.BaseURI;
XmlResolver resolver = (_bResolverSet ? _xmlResolver : new XmlSecureResolver(new XmlUrlResolver(), baseUri));
XmlDocument doc = Utils.PreProcessElementInput(SignedInfo.GetXml(), resolver, baseUri);

View file

@ -44,7 +44,7 @@ namespace System.Security.Cryptography
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5351", Justification = "This is the implementation of DES")]
public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]? rgbIV)
{
return CreateTransform(rgbKey, rgbIV == null ? null : rgbIV.CloneByteArray(), encrypting: false);
return CreateTransform(rgbKey, rgbIV?.CloneByteArray(), encrypting: false);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5351", Justification = "This is the implementation of DES")]
@ -56,7 +56,7 @@ namespace System.Security.Cryptography
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5351", Justification = "This is the implementation of DES")]
public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[]? rgbIV)
{
return CreateTransform(rgbKey, rgbIV == null ? null : rgbIV.CloneByteArray(), encrypting: true);
return CreateTransform(rgbKey, rgbIV?.CloneByteArray(), encrypting: true);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5351", Justification = "This is the implementation of DES")]

View file

@ -57,13 +57,13 @@ namespace System.Security.Cryptography
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5351", Justification = "This is the implementation of RC2")]
public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[]? rgbIV)
{
return CreateTransform(rgbKey, rgbIV == null ? null : rgbIV.CloneByteArray(), encrypting: true);
return CreateTransform(rgbKey, rgbIV?.CloneByteArray(), encrypting: true);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA5351", Justification = "This is the implementation of RC2")]
public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]? rgbIV)
{
return CreateTransform(rgbKey, rgbIV == null ? null : rgbIV.CloneByteArray(), encrypting: false);
return CreateTransform(rgbKey, rgbIV?.CloneByteArray(), encrypting: false);
}
public override void GenerateKey()

View file

@ -58,7 +58,7 @@ namespace System.ServiceModel.Syndication
_extensions = source._extensions.Clone();
_authors = FeedUtils.ClonePersons(source._authors);
_categories = FeedUtils.CloneCategories(source._categories);
Content = (source.Content != null) ? source.Content.Clone() : null;
Content = source.Content?.Clone();
_contributors = FeedUtils.ClonePersons(source._contributors);
Copyright = FeedUtils.CloneTextContent(source.Copyright);
Id = source.Id;

View file

@ -1590,7 +1590,7 @@ ISpGrammarResourceLoader
sapiGrammar.SetGrammarLoader(_recoThunk);
}
sapiGrammar.LoadCmdFromMemory2(dataPtr, SPLOADOPTIONS.SPLO_STATIC, null, baseUri == null ? null : baseUri.ToString());
sapiGrammar.LoadCmdFromMemory2(dataPtr, SPLOADOPTIONS.SPLO_STATIC, null, baseUri?.ToString());
}
else
{

View file

@ -744,7 +744,7 @@ namespace System.Speech.Recognition
// find the grammar for this rule. If the grammar does not belong to any existing ruleref then
// it must be local.
Grammar ruleRef = grammar != null ? grammar.Find(name) : null;
Grammar ruleRef = grammar?.Find(name);
if (ruleRef != null)
{
grammar = ruleRef;

View file

@ -353,7 +353,7 @@ namespace System.Threading.Tasks.Dataflow
/// <summary>Gets any postponed messages.</summary>
public QueuedMap<ISourceBlock<TInput>, DataflowMessageHeader>? PostponedMessages
{
get { return _defaultDebugInfo != null ? _defaultDebugInfo.PostponedMessages : null; }
get { return _defaultDebugInfo?.PostponedMessages; }
}
/// <summary>Gets the number of outstanding input operations.</summary>

View file

@ -1179,9 +1179,9 @@ namespace System.Threading.Tasks.Dataflow
/// <summary>Gets the messages waiting to be processed.</summary>
public IEnumerable<T> InputQueue { get { return _target._messages.ToList(); } }
/// <summary>Gets the task being used for input processing.</summary>
public Task? TaskForInputProcessing { get { return _target._nonGreedyState != null ? _target._nonGreedyState.TaskForInputProcessing : null; } }
public Task? TaskForInputProcessing { get { return _target._nonGreedyState?.TaskForInputProcessing; } }
/// <summary>Gets the collection of postponed messages.</summary>
public QueuedMap<ISourceBlock<T>, DataflowMessageHeader>? PostponedMessages { get { return _target._nonGreedyState != null ? _target._nonGreedyState.PostponedMessages : null; } }
public QueuedMap<ISourceBlock<T>, DataflowMessageHeader>? PostponedMessages { get { return _target._nonGreedyState?.PostponedMessages; } }
/// <summary>Gets whether the block is declining further messages.</summary>
public bool IsDecliningPermanently { get { return _target._decliningPermanently; } }
/// <summary>Gets the DataflowBlockOptions used to configure this block.</summary>

View file

@ -453,13 +453,13 @@ namespace System.Threading.Tasks.Dataflow
/// <summary>Gets the collection of postponed message headers.</summary>
public QueuedMap<ISourceBlock<T>, DataflowMessageHeader>? PostponedMessages
{
get { return _bufferBlock._boundingState != null ? _bufferBlock._boundingState.PostponedMessages : null; }
get { return _bufferBlock._boundingState?.PostponedMessages; }
}
/// <summary>Gets the messages in the buffer.</summary>
public IEnumerable<T> Queue { get { return _sourceDebuggingInformation.OutputQueue; } }
/// <summary>The task used to process messages.</summary>
public Task? TaskForInputProcessing { get { return _bufferBlock._boundingState != null ? _bufferBlock._boundingState.TaskForInputProcessing : null; } }
public Task? TaskForInputProcessing { get { return _bufferBlock._boundingState?.TaskForInputProcessing; } }
/// <summary>Gets the task being used for output processing.</summary>
public Task? TaskForOutputProcessing { get { return _sourceDebuggingInformation.TaskForOutputProcessing; } }

View file

@ -847,7 +847,7 @@ namespace System.Threading.Tasks.Dataflow.Internal
/// <summary>Gets any postponed messages.</summary>
internal QueuedMap<ISourceBlock<TInput>, DataflowMessageHeader>? PostponedMessages
{
get { return _target._boundingState != null ? _target._boundingState.PostponedMessages : null; }
get { return _target._boundingState?.PostponedMessages; }
}
/// <summary>Gets the current number of outstanding input processing operations.</summary>