Skip to content

Commit

Permalink
Annotate System.ComponentModel.Primitives for nullable (dotnet/corefx…
Browse files Browse the repository at this point in the history
…#41185)

* Annotate System.ComponentModel.Primitives for nullable

Commit migrated from dotnet/corefx@da147ec
  • Loading branch information
buyaa-n authored Sep 24, 2019
1 parent f38db35 commit 2491c6d
Show file tree
Hide file tree
Showing 27 changed files with 126 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -39,9 +39,9 @@ public CategoryAttribute(string category) { }
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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
protected virtual string GetLocalizedString(string value) { throw null; }
protected virtual string? GetLocalizedString(string value) { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
[System.ComponentModel.DesignerCategoryAttribute("Component")]
Expand All @@ -51,28 +51,28 @@ public Component() { }
protected virtual bool CanRaiseEvents { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.ComponentModel.IContainer Container { get { throw null; } }
public System.ComponentModel.IContainer? Container { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
protected bool DesignMode { get { throw null; } }
protected System.ComponentModel.EventHandlerList Events { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual System.ComponentModel.ISite Site { get { throw null; } set { } }
public virtual System.ComponentModel.ISite? Site { get { throw null; } set { } }
[System.ComponentModel.BrowsableAttribute(false)]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public event System.EventHandler Disposed { add { } remove { } }
public event System.EventHandler? Disposed { add { } remove { } }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
~Component() { }
protected virtual object GetService(System.Type service) { throw null; }
protected virtual object? GetService(System.Type service) { throw null; }
public override string ToString() { throw null; }
}
public partial class ComponentCollection : System.Collections.ReadOnlyCollectionBase
{
public ComponentCollection(System.ComponentModel.IComponent[] components) { }
public virtual System.ComponentModel.IComponent this[int index] { get { throw null; } }
public virtual System.ComponentModel.IComponent this[string name] { get { throw null; } }
public virtual System.ComponentModel.IComponent? this[int index] { get { throw null; } }
public virtual System.ComponentModel.IComponent? this[string? name] { get { throw null; } }
public void CopyTo(System.ComponentModel.IComponent[] array, int index) { }
}
[System.AttributeUsageAttribute(System.AttributeTargets.All)]
Expand All @@ -83,7 +83,7 @@ public DescriptionAttribute() { }
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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -98,7 +98,7 @@ public DesignerCategoryAttribute() { }
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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -117,7 +117,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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -129,7 +129,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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -141,30 +141,30 @@ public DisplayNameAttribute() { }
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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
public sealed partial class EventHandlerList : System.IDisposable
{
public EventHandlerList() { }
public System.Delegate this[object key] { get { throw null; } set { } }
public void AddHandler(object key, System.Delegate value) { }
public System.Delegate? this[object key] { get { throw null; } set { } }
public void AddHandler(object key, System.Delegate? value) { }
public void AddHandlers(System.ComponentModel.EventHandlerList listToAddFrom) { }
public void Dispose() { }
public void RemoveHandler(object key, System.Delegate value) { }
public void RemoveHandler(object key, System.Delegate? value) { }
}
public partial interface IComponent : System.IDisposable
{
System.ComponentModel.ISite Site { get; set; }
event System.EventHandler Disposed;
System.ComponentModel.ISite? Site { get; set; }
event System.EventHandler? Disposed;
}
public partial interface IContainer : System.IDisposable
{
System.ComponentModel.ComponentCollection Components { get; }
void Add(System.ComponentModel.IComponent component);
void Add(System.ComponentModel.IComponent component, string name);
void Remove(System.ComponentModel.IComponent component);
void Add(System.ComponentModel.IComponent? component);
void Add(System.ComponentModel.IComponent? component, string? name);
void Remove(System.ComponentModel.IComponent? component);
}
[System.AttributeUsageAttribute(System.AttributeTargets.All)]
public sealed partial class ImmutableObjectAttribute : System.Attribute
Expand All @@ -174,7 +174,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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -188,23 +188,23 @@ public partial class InvalidAsynchronousStateException : System.ArgumentExceptio
{
public InvalidAsynchronousStateException() { }
protected InvalidAsynchronousStateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InvalidAsynchronousStateException(string message) { }
public InvalidAsynchronousStateException(string message, System.Exception innerException) { }
public InvalidAsynchronousStateException(string? message) { }
public InvalidAsynchronousStateException(string? message, System.Exception? innerException) { }
}
public partial class InvalidEnumArgumentException : System.ArgumentException
{
public InvalidEnumArgumentException() { }
protected InvalidEnumArgumentException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public InvalidEnumArgumentException(string message) { }
public InvalidEnumArgumentException(string message, System.Exception innerException) { }
public InvalidEnumArgumentException(string argumentName, int invalidValue, System.Type enumClass) { }
public InvalidEnumArgumentException(string? message) { }
public InvalidEnumArgumentException(string? message, System.Exception? innerException) { }
public InvalidEnumArgumentException(string? argumentName, int invalidValue, System.Type enumClass) { }
}
public partial interface ISite : System.IServiceProvider
{
System.ComponentModel.IComponent Component { get; }
System.ComponentModel.IContainer Container { get; }
bool DesignMode { get; }
string Name { get; set; }
string? Name { get; set; }
}
public partial interface ISupportInitialize
{
Expand All @@ -214,9 +214,9 @@ public partial interface ISupportInitialize
public partial interface ISynchronizeInvoke
{
bool InvokeRequired { get; }
System.IAsyncResult BeginInvoke(System.Delegate method, object[] args);
object EndInvoke(System.IAsyncResult result);
object Invoke(System.Delegate method, object[] args);
System.IAsyncResult BeginInvoke(System.Delegate method, object?[]? args);
object? EndInvoke(System.IAsyncResult result);
object? Invoke(System.Delegate method, object?[]? args);
}
[System.AttributeUsageAttribute(System.AttributeTargets.All)]
public sealed partial class LocalizableAttribute : System.Attribute
Expand All @@ -226,7 +226,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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -238,7 +238,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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -250,7 +250,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(object? obj) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -261,7 +261,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 o) { throw null; }
public override bool Equals(object? o) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -273,7 +273,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(object? value) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand All @@ -291,7 +291,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 value) { throw null; }
public override bool Equals(object? value) { throw null; }
public override int GetHashCode() { throw null; }
public override bool IsDefaultAttribute() { throw null; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release</Configurations>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.ComponentModel.Primitives.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<RootNamespace>System.ComponentModel.Primitives</RootNamespace>
<AssemblyName>System.ComponentModel.Primitives</AssemblyName>
<Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Windows_NT-Debug;uap-Windows_NT-Release</Configurations>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\ComponentModel\ISynchronizeInvoke.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,8 @@ public BrowsableAttribute(bool browsable)
/// </summary>
public bool Browsable { get; }

public override bool Equals(object obj)
{
if (obj == this)
{
return true;
}

BrowsableAttribute other = obj as BrowsableAttribute;
return other?.Browsable == Browsable;
}
public override bool Equals(object? obj) =>
obj is BrowsableAttribute other && other.Browsable == Browsable;

public override int GetHashCode() => Browsable.GetHashCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ namespace System.ComponentModel
[AttributeUsage(AttributeTargets.All)]
public class CategoryAttribute : Attribute
{
private static volatile CategoryAttribute s_action;
private static volatile CategoryAttribute s_appearance;
private static volatile CategoryAttribute s_asynchronous;
private static volatile CategoryAttribute s_behavior;
private static volatile CategoryAttribute s_data;
private static volatile CategoryAttribute s_design;
private static volatile CategoryAttribute s_dragDrop;
private static volatile CategoryAttribute s_defAttr;
private static volatile CategoryAttribute s_focus;
private static volatile CategoryAttribute s_format;
private static volatile CategoryAttribute s_key;
private static volatile CategoryAttribute s_layout;
private static volatile CategoryAttribute s_mouse;
private static volatile CategoryAttribute s_windowStyle;
private static volatile CategoryAttribute? s_action;
private static volatile CategoryAttribute? s_appearance;
private static volatile CategoryAttribute? s_asynchronous;
private static volatile CategoryAttribute? s_behavior;
private static volatile CategoryAttribute? s_data;
private static volatile CategoryAttribute? s_design;
private static volatile CategoryAttribute? s_dragDrop;
private static volatile CategoryAttribute? s_defAttr;
private static volatile CategoryAttribute? s_focus;
private static volatile CategoryAttribute? s_format;
private static volatile CategoryAttribute? s_key;
private static volatile CategoryAttribute? s_layout;
private static volatile CategoryAttribute? s_mouse;
private static volatile CategoryAttribute? s_windowStyle;

private bool _localized;

Expand Down Expand Up @@ -176,7 +176,7 @@ public string Category
{
lock (_locker)
{
string localizedValue = GetLocalizedString(_categoryValue);
string? localizedValue = GetLocalizedString(_categoryValue);
if (localizedValue != null)
{
_categoryValue = localizedValue;
Expand All @@ -190,23 +190,15 @@ public string Category
}
}

public override bool Equals(object obj)
{
if (obj == this)
{
return true;
}

CategoryAttribute other = obj as CategoryAttribute;
return other != null && Category == other.Category;
}
public override bool Equals(object? obj) =>
obj is CategoryAttribute other && other.Category == Category;

public override int GetHashCode() => Category?.GetHashCode() ?? 0;

/// <summary>
/// Looks up the localized name of a given category.
/// </summary>
protected virtual string GetLocalizedString(string value) => SR.GetResourceString("PropertyCategory" + value, null);
protected virtual string? GetLocalizedString(string value) => SR.GetResourceString("PropertyCategory" + value, null);

public override bool IsDefaultAttribute() => Category == Default.Category;
}
Expand Down
Loading

0 comments on commit 2491c6d

Please sign in to comment.