未验证 提交 4a23f535 编写于 作者: H hrrrrustic 提交者: GitHub

System.ComponentModel.* missed Equals nullable annotations (#52163)

* add NotNullWhen attribute

* add usings
上级 e7a500a8
......@@ -174,7 +174,7 @@ public sealed partial class FilterUIHintAttribute : System.Attribute
public System.Collections.Generic.IDictionary<string, object?> ControlParameters { get { throw null; } }
public string FilterUIHint { get { throw null; } }
public string? PresentationLayer { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
}
public partial interface IValidatableObject
......@@ -280,7 +280,7 @@ public partial class UIHintAttribute : System.Attribute
public System.Collections.Generic.IDictionary<string, object?> ControlParameters { get { throw null; } }
public string? PresentationLayer { get { throw null; } }
public string UIHint { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false)]
......
......@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel.DataAnnotations
{
......@@ -82,7 +83,7 @@ public FilterUIHintAttribute(string filterUIHint, string? presentationLayer)
/// <param name="obj">An System.Object.</param>
/// <returns>true if obj is a FilterUIHintAttribute and its value is the same
/// as this instance; otherwise, false.</returns>
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is FilterUIHintAttribute otherAttribute && _implementation.Equals(otherAttribute._implementation);
}
}
......@@ -5,6 +5,7 @@
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel.DataAnnotations
{
......@@ -65,7 +66,7 @@ public UIHintAttribute(string uiHint, string? presentationLayer, params object?[
public override int GetHashCode() => _implementation.GetHashCode();
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is UIHintAttribute otherAttribute && _implementation.Equals(otherAttribute._implementation);
internal sealed class UIHintImplementation
......@@ -118,7 +119,7 @@ public override int GetHashCode()
/// </summary>
/// <param name="obj">An System.Object.</param>
/// <returns>true if obj is a UIHintAttribute and its value is the same as this instance; otherwise, false.</returns>
public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
var otherImplementation = obj as UIHintImplementation;
......
......@@ -550,7 +550,7 @@ public string DisplayName
get { return _originalPartCreationInfo.Origin; }
}
public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is GenericSpecializationPartCreationInfo that && (_originalPartCreationInfo.Equals(that._originalPartCreationInfo)) &&
(_specialization.IsArrayEqual(that._specialization));
......
......@@ -14,7 +14,7 @@ public sealed partial class BrowsableAttribute : System.Attribute
public static readonly System.ComponentModel.BrowsableAttribute Yes;
public BrowsableAttribute(bool browsable) { }
public bool Browsable { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -38,7 +38,7 @@ public partial class CategoryAttribute : System.Attribute
public static System.ComponentModel.CategoryAttribute Layout { get { throw null; } }
public static System.ComponentModel.CategoryAttribute Mouse { get { throw null; } }
public static System.ComponentModel.CategoryAttribute WindowStyle { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
protected virtual string? GetLocalizedString(string value) { throw null; }
public override bool IsDefaultAttribute() { throw null; }
......@@ -82,7 +82,7 @@ public partial class DescriptionAttribute : System.Attribute
public DescriptionAttribute(string description) { }
public virtual string Description { get { throw null; } }
protected string DescriptionValue { get { throw null; } set { } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -113,7 +113,7 @@ public sealed partial class DesignerCategoryAttribute : System.Attribute
public DesignerCategoryAttribute(string category) { }
public string Category { get { throw null; } }
public override object TypeId { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -132,7 +132,7 @@ public sealed partial class DesignerSerializationVisibilityAttribute : System.At
public static readonly System.ComponentModel.DesignerSerializationVisibilityAttribute Visible;
public DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility visibility) { }
public System.ComponentModel.DesignerSerializationVisibility Visibility { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -144,7 +144,7 @@ public sealed partial class DesignOnlyAttribute : System.Attribute
public static readonly System.ComponentModel.DesignOnlyAttribute Yes;
public DesignOnlyAttribute(bool isDesignOnly) { }
public bool IsDesignOnly { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -156,7 +156,7 @@ public partial class DisplayNameAttribute : System.Attribute
public DisplayNameAttribute(string displayName) { }
public virtual string DisplayName { get { throw null; } }
protected string DisplayNameValue { get { throw null; } set { } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -208,7 +208,7 @@ public sealed partial class ImmutableObjectAttribute : System.Attribute
public static readonly System.ComponentModel.ImmutableObjectAttribute Yes;
public ImmutableObjectAttribute(bool immutable) { }
public bool Immutable { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -260,7 +260,7 @@ public sealed partial class LocalizableAttribute : System.Attribute
public static readonly System.ComponentModel.LocalizableAttribute Yes;
public LocalizableAttribute(bool isLocalizable) { }
public bool IsLocalizable { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -272,7 +272,7 @@ public sealed partial class MergablePropertyAttribute : System.Attribute
public static readonly System.ComponentModel.MergablePropertyAttribute Yes;
public MergablePropertyAttribute(bool allowMerge) { }
public bool AllowMerge { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -284,7 +284,7 @@ public sealed partial class NotifyParentPropertyAttribute : System.Attribute
public static readonly System.ComponentModel.NotifyParentPropertyAttribute Yes;
public NotifyParentPropertyAttribute(bool notifyParent) { }
public bool NotifyParent { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -295,7 +295,7 @@ public sealed partial class ParenthesizePropertyNameAttribute : System.Attribute
public ParenthesizePropertyNameAttribute() { }
public ParenthesizePropertyNameAttribute(bool needParenthesis) { }
public bool NeedParenthesis { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -307,7 +307,7 @@ public sealed partial class ReadOnlyAttribute : System.Attribute
public static readonly System.ComponentModel.ReadOnlyAttribute Yes;
public ReadOnlyAttribute(bool isReadOnly) { }
public bool IsReadOnly { get { throw null; } }
public override bool Equals(object? value) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......@@ -325,7 +325,7 @@ public sealed partial class RefreshPropertiesAttribute : System.Attribute
public static readonly System.ComponentModel.RefreshPropertiesAttribute Repaint;
public RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties refresh) { }
public System.ComponentModel.RefreshProperties RefreshProperties { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -42,7 +44,7 @@ public BrowsableAttribute(bool browsable)
/// </summary>
public bool Browsable { get; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is BrowsableAttribute other && other.Browsable == Browsable;
public override int GetHashCode() => Browsable.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -189,7 +191,7 @@ public string Category
}
}
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is CategoryAttribute other && other.Category == Category;
public override int GetHashCode() => Category?.GetHashCode() ?? 0;
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -39,7 +41,7 @@ public DescriptionAttribute(string description)
/// </summary>
protected string DescriptionValue { get; set; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is DescriptionAttribute other && other.Description == Description;
public override int GetHashCode() => Description?.GetHashCode() ?? 0;
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -41,7 +43,7 @@ public DesignOnlyAttribute(bool isDesignOnly)
/// </summary>
public bool IsDesignOnly { get; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is DesignOnlyAttribute other && other.IsDesignOnly == IsDesignOnly;
public override int GetHashCode() => IsDesignOnly.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -55,7 +57,7 @@ public DesignerCategoryAttribute(string category)
/// </summary>
public string Category { get; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is DesignerCategoryAttribute other && other.Category == Category;
public override int GetHashCode() => Category?.GetHashCode() ?? 0;
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -51,7 +53,7 @@ public DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility
/// </summary>
public DesignerSerializationVisibility Visibility { get; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is DesignerSerializationVisibilityAttribute other && other.Visibility == Visibility;
public override int GetHashCode() => base.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -38,7 +40,7 @@ public DisplayNameAttribute(string displayName)
/// </summary>
protected string DisplayNameValue { get; set; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is DisplayNameAttribute other && other.DisplayName == DisplayName;
public override int GetHashCode() => DisplayName?.GetHashCode() ?? 0;
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -41,7 +43,7 @@ public ImmutableObjectAttribute(bool immutable)
public bool Immutable { get; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is ImmutableObjectAttribute other && other.Immutable == Immutable;
public override int GetHashCode() => base.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -41,7 +43,7 @@ public LocalizableAttribute(bool isLocalizable)
/// </summary>
public static readonly LocalizableAttribute Default = No;
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is LocalizableAttribute other && other.IsLocalizable == IsLocalizable;
public override int GetHashCode() => base.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -47,7 +49,7 @@ public MergablePropertyAttribute(bool allowMerge)
/// </summary>
public bool AllowMerge { get; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is MergablePropertyAttribute other && other.AllowMerge == AllowMerge;
public override int GetHashCode() => base.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -49,7 +51,7 @@ public NotifyParentPropertyAttribute(bool notifyParent)
/// <summary>
/// Tests whether the specified object is the same as the current object.
/// </summary>
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is NotifyParentPropertyAttribute other && other.NotifyParent == NotifyParent;
public override int GetHashCode() => base.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -39,7 +41,7 @@ public ParenthesizePropertyNameAttribute(bool needParenthesis)
/// <summary>
/// Compares the specified object to this object and tests for equality.
/// </summary>
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is ParenthesizePropertyNameAttribute other && other.NeedParenthesis == NeedParenthesis;
public override int GetHashCode() => base.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -42,7 +44,7 @@ public sealed class ReadOnlyAttribute : Attribute
/// </summary>
public bool IsReadOnly { get; }
public override bool Equals(object? value) =>
public override bool Equals([NotNullWhen(true)] object? value) =>
value is ReadOnlyAttribute other && other.IsReadOnly == IsReadOnly;
public override int GetHashCode() => base.GetHashCode();
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace System.ComponentModel
{
/// <summary>
......@@ -37,7 +39,7 @@ public RefreshPropertiesAttribute(RefreshProperties refresh)
/// </summary>
public RefreshProperties RefreshProperties { get; }
public override bool Equals(object? obj) =>
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is RefreshPropertiesAttribute other && other.RefreshProperties == RefreshProperties;
public override int GetHashCode() => base.GetHashCode();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册