<Rule Id="IDE0038" Action="Hidden" /> <!-- InlineIsTypeWithoutNameCheck -->
<Rule Id="IDE0039" Action="Hidden" /> <!-- UseLocalFunction -->
<Rule Id="IDE0040" Action="Hidden" /> <!-- AddAccessibilityModifiers -->
- <Rule Id="IDE0041" Action="Hidden" /> <!-- UseIsNullCheck -->
+ <Rule Id="IDE0041" Action="Warning" /> <!-- UseIsNullCheck -->
<Rule Id="IDE0042" Action="Hidden" /> <!-- UseDeconstruction -->
- <Rule Id="IDE0043" Action="Hidden" /> <!-- ValidateFormatString -->
+ <Rule Id="IDE0043" Action="Warning" /> <!-- ValidateFormatString -->
<Rule Id="IDE0044" Action="Hidden" /> <!-- MakeFieldReadonly -->
<Rule Id="IDE0045" Action="Hidden" /> <!-- UseConditionalExpressionForAssignment -->
<Rule Id="IDE0046" Action="Hidden" /> <!-- UseConditionalExpressionForReturn -->
<Rule Id="IDE0059" Action="Hidden" /> <!-- ValueAssignedIsUnused -->
<Rule Id="IDE0060" Action="Hidden" /> <!-- UnusedParameter -->
<Rule Id="IDE0061" Action="Hidden" /> <!-- UseExpressionBodyForLocalFunctions -->
- <Rule Id="IDE0062" Action="Hidden" /> <!-- MakeLocalFunctionStatic -->
+ <Rule Id="IDE0062" Action="Warning" /> <!-- MakeLocalFunctionStatic -->
<Rule Id="IDE0063" Action="Hidden" /> <!-- UseSimpleUsingStatement -->
<Rule Id="IDE0064" Action="Hidden" /> <!-- MakeStructFieldsWritable -->
<Rule Id="IDE0065" Action="Hidden" /> <!-- MoveMisplacedUsingDirectives -->
<Rule Id="IDE0076" Action="Hidden" /> <!-- InvalidSuppressMessageAttribute -->
<Rule Id="IDE0077" Action="Hidden" /> <!-- LegacyFormatSuppressMessageAttribute -->
<Rule Id="IDE0078" Action="Hidden" /> <!-- UsePatternCombinators -->
- <Rule Id="IDE0079" Action="Hidden" /> <!-- RemoveUnnecessarySuppression -->
+ <Rule Id="IDE0079" Action="Warning" /> <!-- RemoveUnnecessarySuppression -->
<Rule Id="IDE0080" Action="Hidden" /> <!-- RemoveConfusingSuppressionForIsExpression -->
<Rule Id="IDE0081" Action="Hidden" /> <!-- RemoveUnnecessaryByVal -->
- <Rule Id="IDE0082" Action="Hidden" /> <!-- ConvertTypeOfToNameOf -->
+ <Rule Id="IDE0082" Action="Warning" /> <!-- ConvertTypeOfToNameOf -->
<Rule Id="IDE0083" Action="Hidden" /> <!-- UseNotPattern -->
<Rule Id="IDE0084" Action="Hidden" /> <!-- UseIsNotExpression -->
<Rule Id="IDE1001" Action="Hidden" /> <!-- AnalyzerChanged -->
// to form a new delegate.
protected sealed override Delegate CombineImpl(Delegate? follow)
{
- if ((object?)follow == null) // cast to object for a more efficient test
+ if (follow is null)
return this;
// Verify that the types are the same...
if (Associates.IncludeAccessor(m_setterMethod, nonPublic))
accessorList.Add(m_setterMethod!);
- if ((object?)m_otherMethod != null)
+ if (m_otherMethod is not null)
{
for (int i = 0; i < m_otherMethod.Length; i++)
{
private static bool FilterApplyType(
Type type, BindingFlags bindingFlags, string name, bool prefixLookup, string? ns)
{
- Debug.Assert((object)type != null);
+ Debug.Assert(type is not null);
Debug.Assert(type is RuntimeType);
bool isPublic = type.IsNestedPublic || type.IsPublic;
for (int i = 0; i < parameterInfos.Length; i++)
{
// a null argument type implies a null arg which is always a perfect match
- if ((object)argumentTypes[i] != null && !argumentTypes[i].MatchesParameterTypeExactly(parameterInfos[i]))
+ if (argumentTypes[i] is Type t && !t.MatchesParameterTypeExactly(parameterInfos[i]))
return false;
}
}
{
PropertyInfo firstCandidate = candidates[0];
- if ((object?)returnType != null && !returnType.IsEquivalentTo(firstCandidate.PropertyType))
+ if (returnType is not null && !returnType.IsEquivalentTo(firstCandidate.PropertyType))
return null;
return firstCandidate;
}
catch (Exception e)
{
- throw new ArgumentException(SR.Format(SR.ConvertInvalidPrimitive, text, typeof(int).Name), e);
+ throw new ArgumentException(SR.Format(SR.ConvertInvalidPrimitive, text, nameof(Int32)), e);
}
}
// See if MetadataToken property is available.
PropertyInfo property = memberInfo.GetProperty("MetadataToken", typeof(int), Array.Empty<Type>());
- if ((object)property != null && property.CanRead)
+ if (property is not null && property.CanRead)
{
// (parameter1, parameter2) => parameter1.MetadataToken == parameter2.MetadataToken
var parameter1 = Expression.Parameter(memberInfo);
{
return true;
}
- else if (ReferenceEquals(swt1, null))
+ else if (swt1 is null)
{
return swt2._sym == null;
}
- else if (ReferenceEquals(swt2, null))
+ else if (swt2 is null)
{
return swt1._sym == null;
}
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj)) return false;
+ if (obj is null) return false;
return obj is Dependency && Equals((Dependency) obj);
}
/// <inheritdoc />
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj is null)
{
return false;
}
/// <inheritdoc />
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj is null)
{
return false;
}
(cardinality != ImportCardinality.ZeroOrOne)
)
{
- throw new ArgumentException(SR.Format(SR.ArgumentOutOfRange_InvalidEnum, nameof(cardinality), cardinality, typeof(ImportCardinality).Name), nameof(cardinality));
+ throw new ArgumentException(SR.Format(SR.ArgumentOutOfRange_InvalidEnum, nameof(cardinality), cardinality, nameof(ImportCardinality)), nameof(cardinality));
}
_contractName = contractName ?? EmptyContractName;
return new[] { new ExportDescriptorPromise(
contract,
- typeof(CompositionContext).Name,
+ nameof(CompositionContext),
true,
NoDependencies,
_ => ExportDescriptor.Create((c, o) => c, NoMetadata)) };
// same reference or (null, null) or (DBNull.Value, DBNull.Value)
return true;
}
- if (ReferenceEquals(a, null) || ReferenceEquals(a, DBNull.Value) ||
- ReferenceEquals(b, null) || ReferenceEquals(b, DBNull.Value))
+ if (a is null || ReferenceEquals(a, DBNull.Value) ||
+ b is null || ReferenceEquals(b, DBNull.Value))
{
// (null, non-null) or (null, DBNull.Value) or vice versa
return false;
// same reference or (null, null) or (DBNull.Value, DBNull.Value)
return true;
}
- if (ReferenceEquals(a, null) || ReferenceEquals(a, DBNull.Value) ||
- ReferenceEquals(b, null) || ReferenceEquals(b, DBNull.Value))
+ if (a is null || ReferenceEquals(a, DBNull.Value) ||
+ b is null || ReferenceEquals(b, DBNull.Value))
{
// (null, non-null) or (null, DBNull.Value) or vice versa
return false;
return true;
}
- if (ReferenceEquals(leftRow, null) ||
- ReferenceEquals(rightRow, null))
+ if (leftRow is null ||
+ rightRow is null)
{
return false;
}
if (s_animationThread == null)
{
s_animationThread = new Thread(new ThreadStart(AnimateImages50ms));
- s_animationThread.Name = typeof(ImageAnimator).Name;
+ s_animationThread.Name = nameof(ImageAnimator);
s_animationThread.IsBackground = true;
s_animationThread.Start();
}
}
if (memMappedFileHandle.IsClosed)
{
- throw new ObjectDisposedException(typeof(MemoryMappedFile).Name);
+ throw new ObjectDisposedException(nameof(MemoryMappedFile));
}
if (requestedSize == MemoryMappedFile.DefaultSize)
public void OnCompleted(Action<object?> continuation, object? state, ValueTaskSourceOnCompletedFlags flags, out CompletionData completionData, out bool doubleCompletion)
{
completionData = default;
- doubleCompletion = !ReferenceEquals(_completion, null);
+ doubleCompletion = _completion is not null;
if (IsCompleted || doubleCompletion)
{
public static Type? FindGenericType(Type definition, Type? type)
{
- while ((object?)type != null && type != typeof(object))
+ while (type is not null && type != typeof(object))
{
if (type.IsConstructedGenericType && AreEquivalent(type.GetGenericTypeDefinition(), definition))
{
Debug.Assert(methodBase is MethodInfo || methodBase is ConstructorInfo);
var ctor = methodBase as ConstructorInfo;
- if ((object?)ctor != null)
+ if (ctor is not null)
{
il.Emit(opcode, ctor);
}
private void EmitMemberAddress(MemberInfo member, Type? objectType)
{
FieldInfo? field = member as FieldInfo;
- if ((object?)field != null)
+ if (field is not null)
{
// Verifiable code may not take the address of an init-only field.
// If we are asked to do so then get the value out of the field, stuff it
private WriteBack? AddressOfWriteBack(MemberExpression node)
{
var property = node.Member as PropertyInfo;
- if ((object?)property == null || !property.CanWrite)
+ if (property is null || !property.CanWrite)
{
return null;
}
}
var fld = member as FieldInfo;
- if ((object?)fld != null)
+ if (fld is not null)
{
_ilg.EmitFieldSet((FieldInfo)member);
}
private void EmitMemberGet(MemberInfo member, Type? objectType)
{
var fi = member as FieldInfo;
- if ((object?)fi != null)
+ if (fi is not null)
{
if (fi.IsLiteral)
{
break;
}
- if ((object?)alternativeMethod == null)
+ if (alternativeMethod is null)
{
return new MethodInfoCallInstruction(info, argumentCount);
}
protected static bool TryGetLightLambdaTarget(object? instance, [NotNullWhen(true)] out LightLambda? lightLambda)
{
var del = instance as Delegate;
- if ((object?)del != null)
+ if (del is not null)
{
var thunk = del.Target as Func<object[], object>;
- if ((object?)thunk != null)
+ if (thunk is not null)
{
lightLambda = thunk.Target as LightLambda;
if (lightLambda != null)
if (from == to)
{
- if ((object?)enumTypeTo != null)
+ if (enumTypeTo is not null)
{
// If casting between enums of the same underlying type or to enum from the underlying
// type, there's no need for the numeric conversion, so just include a null-check if
}
}
- if ((object?)enumTypeTo != null)
+ if (enumTypeTo is not null)
{
// Convert from underlying to the enum
_instructions.EmitCastToEnum(enumTypeTo);
public bool Equals(HttpMethod? other)
{
- if ((object?)other == null)
+ if (other is null)
{
return false;
}
public static bool operator ==(HttpMethod? left, HttpMethod? right)
{
- return (object?)left == null || (object?)right == null ?
+ return left is null || right is null ?
ReferenceEquals(left, right) :
left.Equals(right);
}
if (response.Headers.ConnectionClose.GetValueOrDefault())
{
// Server is closing the connection and asking us to authenticate on a new connection.
-#pragma warning disable CS8600 // expression returns null connection on error, was not able to use '!' for the expression
+ // expression returns null connection on error, was not able to use '!' for the expression
+#pragma warning disable CS8600
(connection, response) = await connectionPool.CreateHttp11ConnectionAsync(request, async, cancellationToken).ConfigureAwait(false);
#pragma warning restore CS8600
if (response != null)
{
throw new WebSocketException(WebSocketError.InvalidMessageType,
SR.Format(SR.net_WebSockets_InvalidMessageType,
- typeof(WebSocket).Name + "." + nameof(CloseAsync),
- typeof(WebSocket).Name + "." + nameof(CloseOutputAsync),
+ nameof(WebSocket) + "." + nameof(CloseAsync),
+ nameof(WebSocket) + "." + nameof(CloseOutputAsync),
receiveResult.MessageType));
}
}
private void PublicationOnlyWaitForOtherThreadToPublish()
{
SpinWait spinWait = default;
- while (!ReferenceEquals(_state, null))
+ while (_state is not null)
{
// We get here when PublicationOnly temporarily sets _state to LazyHelper.PublicationOnlyWaitForOtherThreadToPublish.
// This temporary state should be quickly followed by _state being set to null.
// Otherwise, returns the underlying type of the Nullable type
public static Type? GetUnderlyingType(Type nullableType)
{
- if ((object)nullableType == null)
+ if (nullableType is null)
{
throw new ArgumentNullException(nameof(nullableType));
}
[CLSCompliant(false)]
public SerializationInfo(Type type, IFormatterConverter converter)
{
- if ((object)type == null)
+ if (type is null)
{
throw new ArgumentNullException(nameof(type));
}
public void SetType(Type type)
{
- if ((object)type == null)
+ if (type is null)
{
throw new ArgumentNullException(nameof(type));
}
public void AddValue(string name, object? value, Type type)
{
- if (null == name)
+ if (name is null)
{
throw new ArgumentNullException(nameof(name));
}
- if ((object)type == null)
+ if (type is null)
{
throw new ArgumentNullException(nameof(type));
}
{
Debug.Assert(null != name, "[SerializationInfo.UpdateValue]name!=null");
Debug.Assert(null != value, "[SerializationInfo.UpdateValue]value!=null");
- Debug.Assert(null != (object)type, "[SerializationInfo.UpdateValue]type!=null");
+ Debug.Assert(type is not null, "[SerializationInfo.UpdateValue]type!=null");
int index = FindElement(name);
if (index < 0)
Debug.Assert(index < _types.Length, "[SerializationInfo.GetElement]index<_types.Length");
foundType = _types[index];
- Debug.Assert((object)foundType != null, "[SerializationInfo.GetElement]foundType!=null");
+ Debug.Assert(foundType is not null, "[SerializationInfo.GetElement]foundType!=null");
return _values[index];
}
Debug.Assert(index < _types.Length, "[SerializationInfo.GetElement]index<_types.Length");
foundType = _types[index];
- Debug.Assert((object)foundType != null, "[SerializationInfo.GetElement]foundType!=null");
+ Debug.Assert(foundType is not null, "[SerializationInfo.GetElement]foundType!=null");
return _values[index];
}
public object? GetValue(string name, Type type)
{
- if ((object)type == null)
+ if (type is null)
{
throw new ArgumentNullException(nameof(type));
}
internal object? GetValueNoThrow(string name, Type type)
{
- Debug.Assert((object)type != null, "[SerializationInfo.GetValue]type ==null");
+ Debug.Assert(type is not null, "[SerializationInfo.GetValue]type ==null");
Debug.Assert(type.IsRuntimeImplemented(), "[SerializationInfo.GetValue]type is not a runtime type");
object? value = GetElementNoThrow(name, out Type? foundType);
public bool EndsWith(string value, StringComparison comparisonType)
{
- if ((object)value == null)
+ if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
public bool Equals(PrefixHandle? prefix2)
{
- if (ReferenceEquals(prefix2, null))
+ if (prefix2 is null)
return false;
PrefixHandleType type1 = _type;
PrefixHandleType type2 = prefix2._type;
public bool Equals(StringHandle? other)
{
- if (ReferenceEquals(other, null))
+ if (other is null)
return false;
StringHandleType type = other._type;
if (type == StringHandleType.Dictionary)
if (object.ReferenceEquals(id1, id2))
return true;
- if (object.ReferenceEquals(id1, null) || object.ReferenceEquals(id2, null))
+ if (id1 is null || id2 is null)
return false;
#pragma warning suppress 56506 // Microsoft, checks for whether id1 and id2 are null done above.
private bool IsNotAbsoluteUri
{
- get { return (object)_syntax == null; }
+ get { return _syntax is null; }
}
//
//
public Uri(string uriString)
{
- if ((object)uriString == null)
+ if (uriString is null)
throw new ArgumentNullException(nameof(uriString));
CreateThis(uriString, false, UriKind.Absolute);
}
uriString = serializationInfo.GetString("RelativeUri"); // Do not rename (binary serialization)
- if ((object?)uriString == null)
+ if (uriString is null)
throw new ArgumentException(SR.Format(SR.InvalidNullArgument, "RelativeUri"), nameof(serializationInfo));
CreateThis(uriString, false, UriKind.Relative);
//
public static UriHostNameType CheckHostName(string? name)
{
- if ((object?)name == null || name.Length == 0 || name.Length > short.MaxValue)
+ if (string.IsNullOrEmpty(name) || name.Length > short.MaxValue)
{
return UriHostNameType.Unknown;
}
+
int end = name.Length;
unsafe
{
//
public static bool CheckSchemeName(string? schemeName)
{
- if (((object?)schemeName == null)
- || (schemeName.Length == 0)
- || !UriHelper.IsAsciiLetter(schemeName[0]))
+ if (string.IsNullOrEmpty(schemeName) || !UriHelper.IsAsciiLetter(schemeName[0]))
{
return false;
}
+
for (int i = schemeName.Length - 1; i > 0; --i)
{
if (!(UriHelper.IsAsciiLetterOrDigit(schemeName[i])
return false;
}
}
+
return true;
}
public Uri MakeRelativeUri(Uri uri)
{
- if ((object?)uri == null)
+ if (uri is null)
throw new ArgumentNullException(nameof(uri));
if (IsNotAbsoluteUri || uri.IsNotAbsoluteUri)
else if (NotAny(Flags.CanonicalDnsHost))
{
// Check to see if we can take the canonical host string out of _string
- if ((object?)_info.ScopeId != null)
+ if (_info.ScopeId is not null)
{
// IPv6 ScopeId is included when serializing a Uri
flags |= (Flags.HostNotCanonical | Flags.E_HostNotCanonical);
string host = _syntax.InternalGetComponents(this, UriComponents.Host, UriFormat.UriEscaped);
// ATTN: Check on whether recursion has not happened
- if ((object?)_info.Host == null)
+ if (_info.Host is null)
{
if (host.Length >= c_MaxUriBufferSize)
throw GetException(ParsingError.SizeLimit)!;
//
string portStr = _syntax.InternalGetComponents(this, UriComponents.StrongPort, UriFormat.UriEscaped);
int port = 0;
- if ((object)portStr == null || portStr.Length == 0)
+ if (string.IsNullOrEmpty(portStr))
{
// It's like no port
_flags &= ~Flags.NotDefaultPort;
if ((unchecked((ushort)uriParts) & nonCanonical) == 0)
{
string? ret = GetUriPartsFromUserString(uriParts);
- if ((object?)ret != null)
+ if (ret is not null)
{
return ret;
}
if ((unchecked((ushort)uriParts) & nonCanonical) == 0)
{
string? ret = GetUriPartsFromUserString(uriParts);
- if ((object?)ret != null)
+ if (ret is not null)
{
return ret;
}
// A fix up only for SerializationInfo and IpV6 host with a scopeID
if ((parts & UriComponents.SerializationInfoString) != 0 && HostType == Flags.IPv6HostType &&
- (object?)_info.ScopeId != null)
+ _info.ScopeId is not null)
{
_info.ScopeId.CopyTo(0, chars, count - 1, _info.ScopeId.Length);
count += _info.ScopeId.Length;
public UriBuilder(Uri uri)
{
- if ((object?)uri == null)
+ if (uri is null)
throw new ArgumentNullException(nameof(uri));
Init(uri);
public static int Compare(Uri? uri1, Uri? uri2, UriComponents partsToCompare, UriFormat compareFormat,
StringComparison comparisonType)
{
- if ((object?)uri1 == null)
+ if (uri1 is null)
{
- if (uri2 == null)
+ if (uri2 is null)
return 0; // Equal
return -1; // null < non-null
}
- if ((object?)uri2 == null)
+
+ if (uri2 is null)
return 1; // non-null > null
// a relative uri is always less than an absolute one
public static string UnescapeDataString(string stringToUnescape)
{
- if ((object)stringToUnescape == null)
+ if (stringToUnescape is null)
throw new ArgumentNullException(nameof(stringToUnescape));
if (stringToUnescape.Length == 0)
string relativeStr;
- if ((object?)relativeUri != null)
+ if (relativeUri is not null)
{
if (relativeUri.IsAbsoluteUri)
return relativeUri;
userEscaped = relativeUri.UserEscaped;
}
else
+ {
relativeStr = string.Empty;
+ }
// Here we can assert that passed "relativeUri" is indeed a relative one
public bool IsBaseOf(Uri uri)
{
- if ((object)uri == null)
+ if (uri is null)
throw new ArgumentNullException(nameof(uri));
if (!IsAbsoluteUri)
int byteCount = 1;
// lazy initialization of max size, will reuse the array for next sequences
- if ((object?)bytes == null)
- bytes = new byte[end - next];
+ bytes ??= new byte[end - next];
bytes[0] = (byte)ch;
next += 3;
{
// CONSIDER: need the real type name
if (args.Severity == XmlSeverityType.Error)
- throw new InvalidOperationException(SR.Format(SR.XmlSerializableSchemaError, typeof(IXmlSerializable).Name, args.Message));
+ throw new InvalidOperationException(SR.Format(SR.XmlSerializableSchemaError, nameof(IXmlSerializable), args.Message));
}
internal void CheckDuplicateElement(XmlSchemaElement? element, string? elementNs)
}
else
{
- throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaMethodReturnType, _type!.Name, _getSchemaMethod.Name, typeof(XmlSchemaProviderAttribute).Name, typeof(XmlQualifiedName).FullName));
+ throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaMethodReturnType, _type!.Name, _getSchemaMethod.Name, nameof(XmlSchemaProviderAttribute), typeof(XmlQualifiedName).FullName));
}
}
else
private void Write1_XmlSchemaAttribute(XmlSchemaAttribute? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("attribute");
WriteAttribute(@"id", @"", ((string?)o.@Id));
WriteAttributes((XmlAttribute[]?)o.@UnhandledAttributes, o);
private void Write3_XmlSchemaObject(XmlSchemaObject? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
System.Type t = o.GetType();
if (t == typeof(XmlSchemaComplexType))
private void Write5_XmlSchemaAnnotation(XmlSchemaAnnotation? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("annotation");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write6_XmlSchemaDocumentation(XmlSchemaDocumentation o)
{
- if ((object)o == null) return;
+ if (o is null) return;
WriteStartElement("documentation");
WriteAttribute(@"source", @"", ((string?)o.@Source));
private void Write7_XmlSchemaAppInfo(XmlSchemaAppInfo? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("appinfo");
WriteAttribute("source", "", o.Source);
private void Write9_XmlSchemaSimpleType(XmlSchemaSimpleType? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("simpleType");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write12_XmlSchemaSimpleTypeUnion(XmlSchemaSimpleTypeUnion? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("union");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write14_XmlSchemaSimpleTypeList(XmlSchemaSimpleTypeList o)
{
- if ((object)o == null) return;
+ if (o is null) return;
WriteStartElement("list");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write15_XmlSchemaSimpleTypeRestriction(XmlSchemaSimpleTypeRestriction? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("restriction");
WriteAttribute(@"id", @"", ((string?)o.@Id));
WriteAttributes((XmlAttribute[]?)o.@UnhandledAttributes, o);
private void Write_XmlSchemaFacet(string name, XmlSchemaFacet? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement(name);
WriteAttribute("id", "", o.Id);
private void Write31_XmlSchemaAttributeGroup(XmlSchemaAttributeGroup? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("attributeGroup");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write32_XmlSchemaAttributeGroupRef(XmlSchemaAttributeGroupRef? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("attributeGroup");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write33_XmlSchemaAnyAttribute(XmlSchemaAnyAttribute? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("anyAttribute");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write35_XmlSchemaComplexType(XmlSchemaComplexType o)
{
- if ((object)o == null) return;
+ if (o is null) return;
WriteStartElement("complexType");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write36_XmlSchemaSimpleContent(XmlSchemaSimpleContent? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("simpleContent");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write38_XmlSchemaSimpleContentExtension(XmlSchemaSimpleContentExtension o)
{
- if ((object)o == null) return;
+ if (o is null) return;
WriteStartElement("extension");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write40_XmlSchemaSimpleContentRestriction(XmlSchemaSimpleContentRestriction? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("restriction");
WriteAttribute(@"id", @"", ((string?)o.@Id));
WriteAttributes((XmlAttribute[]?)o.@UnhandledAttributes, o);
private void Write41_XmlSchemaComplexContent(XmlSchemaComplexContent? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("complexContent");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write42_XmlSchemaComplexContentExtension(XmlSchemaComplexContentExtension? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("extension");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write43_XmlSchemaAll(XmlSchemaAll o)
{
- if ((object)o == null) return;
+ if (o is null) return;
WriteStartElement("all");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write46_XmlSchemaElement(XmlSchemaElement? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("element");
WriteAttribute(@"id", @"", o.Id);
WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
private void Write47_XmlSchemaKey(XmlSchemaKey? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("key");
WriteAttribute(@"id", @"", ((string?)o.@Id));
WriteAttribute(@"name", @"", ((string?)o.@Name));
private void Write48_XmlSchemaIdentityConstraint(XmlSchemaIdentityConstraint? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
System.Type t = o.GetType();
if (t == typeof(XmlSchemaUnique))
{
private void Write49_XmlSchemaXPath(string name, string ns, XmlSchemaXPath? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement(name);
WriteAttribute(@"id", @"", o.@Id);
WriteAttribute(@"xpath", @"", o.@XPath);
private void Write50_XmlSchemaKeyref(XmlSchemaKeyref? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("keyref");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write51_XmlSchemaUnique(XmlSchemaUnique? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("unique");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write52_XmlSchemaChoice(XmlSchemaChoice? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("choice");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write53_XmlSchemaAny(XmlSchemaAny? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("any");
WriteAttribute(@"id", @"", o.@Id);
private void Write54_XmlSchemaSequence(XmlSchemaSequence? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("sequence");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write55_XmlSchemaGroupRef(XmlSchemaGroupRef? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("group");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write56_XmlSchemaComplexContentRestriction(XmlSchemaComplexContentRestriction? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("restriction");
WriteAttribute(@"id", @"", ((string?)o.@Id));
private void Write57_XmlSchemaGroup(XmlSchemaGroup? o)
{
- if ((object?)o == null) return;
+ if (o is null) return;
WriteStartElement("group");
WriteAttribute(@"id", @"", ((string?)o.@Id));
public static bool operator !=(SourceInfo? a, SourceInfo? b)
{
- if ((object?)a != null)
+ if (a is not null)
return !a.Equals(b);
- return (object?)b != null;
+ return b is not null;
}
public static bool operator ==(SourceInfo? a, SourceInfo? b)
{
- if ((object?)a != null)
+ if (a is not null)
return a.Equals(b);
- return (object?)b == null;
+ return b is null;
}
public override bool Equals(object? obj)
// We allow XmlRoot attribute on IXmlSerializable, but not others
if ((a.XmlFlags & ~XmlAttributeFlags.Root) != 0)
{
- throw new InvalidOperationException(SR.Format(SR.XmlSerializableAttributes, model.TypeDesc.FullName, typeof(XmlSchemaProviderAttribute).Name));
+ throw new InvalidOperationException(SR.Format(SR.XmlSerializableAttributes, model.TypeDesc.FullName, nameof(XmlSchemaProviderAttribute)));
}
}
else
MethodInfo? getMethod = getMethod = type.GetMethod(provider.MethodName, /* BindingFlags.DeclaredOnly | */ BindingFlags.Static | BindingFlags.Public, new Type[] { typeof(XmlSchemaSet) });
if (getMethod == null)
- throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaMethodMissing, provider.MethodName, typeof(XmlSchemaSet).Name, type.FullName));
+ throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaMethodMissing, provider.MethodName, nameof(XmlSchemaSet), type.FullName));
if (!(typeof(XmlQualifiedName).IsAssignableFrom(getMethod.ReturnType)) && !(typeof(XmlSchemaType).IsAssignableFrom(getMethod.ReturnType)))
- throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaMethodReturnType, type.Name, provider.MethodName, typeof(XmlSchemaProviderAttribute).Name, typeof(XmlQualifiedName).FullName, typeof(XmlSchemaType).FullName));
+ throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaMethodReturnType, type.Name, provider.MethodName, nameof(XmlSchemaProviderAttribute), typeof(XmlQualifiedName).FullName, typeof(XmlSchemaType).FullName));
return getMethod;
}
}
if (srcSchemas.Count > 1)
{
- throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaInclude, baseQname.Namespace, typeof(IXmlSerializable).Name, "GetSchema"));
+ throw new InvalidOperationException(SR.Format(SR.XmlGetSchemaInclude, baseQname.Namespace, nameof(IXmlSerializable), "GetSchema"));
}
XmlSchema s = (XmlSchema)srcSchemas[0]!;
{
if (accessor.TypeDesc.ArrayElementTypeDesc.Kind == TypeKind.Serializable)
{
- throw new InvalidOperationException(SR.Format(SR.XmlIllegalAttrOrTextInterface, accessorName, accessor.TypeDesc.ArrayElementTypeDesc.FullName, typeof(IXmlSerializable).Name));
+ throw new InvalidOperationException(SR.Format(SR.XmlIllegalAttrOrTextInterface, accessorName, accessor.TypeDesc.ArrayElementTypeDesc.FullName, nameof(IXmlSerializable)));
}
else
{
{
if (accessor.TypeDesc.Kind == TypeKind.Serializable)
{
- throw new InvalidOperationException(SR.Format(SR.XmlIllegalAttrOrTextInterface, accessorName, accessor.TypeDesc.FullName, typeof(IXmlSerializable).Name));
+ throw new InvalidOperationException(SR.Format(SR.XmlIllegalAttrOrTextInterface, accessorName, accessor.TypeDesc.FullName, nameof(IXmlSerializable)));
}
else
{
if (choiceTypes.Contains(type))
{
// You need to add {0} to the '{1}'.
- throw new InvalidOperationException(SR.Format(SR.XmlChoiceIdentiferMissing, typeof(XmlChoiceIdentifierAttribute).Name, accessorName));
+ throw new InvalidOperationException(SR.Format(SR.XmlChoiceIdentiferMissing, nameof(XmlChoiceIdentifierAttribute), accessorName));
}
else
{
if (choiceTypes.Contains(typeof(XmlElement)) && a.XmlAnyElements.Count > 0)
{
// You need to add {0} to the '{1}'.
- throw new InvalidOperationException(SR.Format(SR.XmlChoiceIdentiferMissing, typeof(XmlChoiceIdentifierAttribute).Name, accessorName));
+ throw new InvalidOperationException(SR.Format(SR.XmlChoiceIdentiferMissing, nameof(XmlChoiceIdentifierAttribute), accessorName));
}
XmlArrayItemAttributes items = a.XmlArrayItems;
XmlArrayItemAttribute? item = (XmlArrayItemAttribute?)arrayTypes[type.FullName, ns];
if (item != null)
{
- throw new InvalidOperationException(SR.Format(SR.XmlArrayItemAmbiguousTypes, accessorName, item.ElementName, items[i]!.ElementName, typeof(XmlElementAttribute).Name, typeof(XmlChoiceIdentifierAttribute).Name, accessorName));
+ throw new InvalidOperationException(SR.Format(SR.XmlArrayItemAmbiguousTypes, accessorName, item.ElementName, items[i]!.ElementName, nameof(XmlElementAttribute), nameof(XmlChoiceIdentifierAttribute), accessorName));
}
else
{
protected Exception CreateMissingIXmlSerializableType(string? name, string? ns, string? clrType)
{
- return new InvalidOperationException(SR.Format(SR.XmlSerializableMissingClrType, name, ns, typeof(XmlIncludeAttribute).Name, clrType));
+ return new InvalidOperationException(SR.Format(SR.XmlSerializableMissingClrType, name, ns, nameof(XmlIncludeAttribute), clrType));
//XmlSerializableMissingClrType= Type '{0}' from namespace '{1}' doesnot have corresponding IXmlSerializable type. Please consider adding {2} to '{3}'.
}
if ((object?)a == (object?)b)
return true;
- if ((object?)a == null || (object?)b == null)
+ if (a is null || b is null)
return false;
return a.Name == b.Name && a.Namespace == b.Namespace;
{
return true;
}
- if ((object?)a == null || (object?)b == null)
+ if (a is null || b is null)
{
return false;
}
/// </summary>
public static bool operator ==(XmlQueryType? left, XmlQueryType? right)
{
- if ((object?)left == null)
- return ((object?)right == null);
+ if (left is null)
+ return right is null;
return left.Equals(right);
}
/// </summary>
public static bool operator !=(XmlQueryType? left, XmlQueryType? right)
{
- if ((object?)left == null)
- return ((object?)right != null);
+ if (left is null)
+ return right is not null;
return !left.Equals(right);
}
// assembly binding unification rules.
public bool Equals(RoAssemblyName? other)
{
- Debug.Assert(other is object);
+ Debug.Assert(other is not null);
if (Name != other.Name)
return false;
if (Version != other.Version)
public bool Equals(RSAEncryptionPadding? other)
{
- return !object.ReferenceEquals(other, null)
+ return other is not null
&& _mode == other._mode
&& _oaepHashAlgorithm == other._oaepHashAlgorithm;
}
public static bool operator ==(RSAEncryptionPadding? left, RSAEncryptionPadding? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return object.ReferenceEquals(right, null);
+ return right is null;
}
return left.Equals(right);
public bool Equals(RSASignaturePadding? other)
{
- return !object.ReferenceEquals(other, null) && _mode == other._mode;
+ return other is not null && _mode == other._mode;
}
public static bool operator ==(RSASignaturePadding? left, RSASignaturePadding? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return object.ReferenceEquals(right, null);
+ return right is null;
}
return left.Equals(right);
public static bool operator ==(CngAlgorithm? left, CngAlgorithm? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return object.ReferenceEquals(right, null);
+ return right is null;
}
return left.Equals(right);
public static bool operator !=(CngAlgorithm? left, CngAlgorithm? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return !object.ReferenceEquals(right, null);
+ return right is not null;
}
return !left.Equals(right);
public bool Equals(CngAlgorithm? other)
{
- if (object.ReferenceEquals(other, null))
+ if (other is null)
{
return false;
}
public static bool operator ==(CngAlgorithmGroup? left, CngAlgorithmGroup? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return object.ReferenceEquals(right, null);
+ return right is null;
}
return left.Equals(right);
public static bool operator !=(CngAlgorithmGroup? left, CngAlgorithmGroup? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return !object.ReferenceEquals(right, null);
+ return right is not null;
}
return !left.Equals(right);
public bool Equals(CngAlgorithmGroup? other)
{
- if (object.ReferenceEquals(other, null))
+ if (other is null)
{
return false;
}
public static bool operator ==(CngKeyBlobFormat? left, CngKeyBlobFormat? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return object.ReferenceEquals(right, null);
+ return right is null;
}
return left.Equals(right);
public static bool operator !=(CngKeyBlobFormat? left, CngKeyBlobFormat? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return !object.ReferenceEquals(right, null);
+ return right is not null;
}
return !left.Equals(right);
public bool Equals(CngKeyBlobFormat? other)
{
- if (object.ReferenceEquals(other, null))
+ if (other is null)
{
return false;
}
public static bool operator ==(CngProvider? left, CngProvider? right)
{
- if (object.ReferenceEquals(left, null))
- return object.ReferenceEquals(right, null);
+ if (left is null)
+ return right is null;
return left.Equals(right);
}
public static bool operator !=(CngProvider? left, CngProvider? right)
{
- if (object.ReferenceEquals(left, null))
+ if (left is null)
{
- return !object.ReferenceEquals(right, null);
+ return right is not null;
}
return !left.Equals(right);
public bool Equals(CngProvider? other)
{
- if (object.ReferenceEquals(other, null))
+ if (other is null)
{
return false;
}
else
{
Type? hashAlgType = hashAlg as Type;
- if ((object?)hashAlgType != null)
+ if (hashAlgType is not null)
{
if (typeof(MD5).IsAssignableFrom(hashAlgType))
return CapiHelper.CALG_MD5;
private static bool FilterApplyType(
Type type, BindingFlags bindingFlags, string? name, bool prefixLookup, string? ns)
{
- Debug.Assert((object)type != null);
Debug.Assert(type is RuntimeType);
bool isPublic = type.IsNestedPublic || type.IsPublic;
for (int i = 0; i < parameterInfos.Length; i++)
{
// a null argument type implies a null arg which is always a perfect match
- if ((object)argumentTypes[i] != null && !argumentTypes[i].MatchesParameterTypeExactly(parameterInfos[i]))
+ if (argumentTypes[i] is not null && !argumentTypes[i].MatchesParameterTypeExactly(parameterInfos[i]))
return false;
}
}
{
PropertyInfo firstCandidate = candidates[0];
- if ((object?)returnType != null && !returnType.IsEquivalentTo(firstCandidate.PropertyType))
+ if (returnType is not null && !returnType.IsEquivalentTo(firstCandidate.PropertyType))
return null;
return firstCandidate;
public override int GetHashCode() => assembly.GetHashCode() ^ document.GetHashCode();
- public static bool operator ==(SourceId a, SourceId b) => ((object)a == null) ? (object)b == null : a.Equals(b);
+ public static bool operator ==(SourceId a, SourceId b) => a is null ? b is null : a.Equals(b);
public static bool operator !=(SourceId a, SourceId b) => !a.Equals(b);
}