diff options
author | Alex Ghiondea <ghiondea.alexandru@microsoft.com> | 2016-10-07 08:11:02 +0300 |
---|---|---|
committer | Alex Ghiondea <ghiondea.alexandru@microsoft.com> | 2016-10-07 08:11:02 +0300 |
commit | e1d0fd9ce066140856df822d94803847cecdb266 (patch) | |
tree | 8c7124ebd44ff344393acda4c7d84f0c7291df35 /src | |
parent | 36c90ac693ff812b168266e6d4e6b2ab1b677615 (diff) |
Implement the remaining members in the System.ComponentModel namespace.
Diffstat (limited to 'src')
47 files changed, 583 insertions, 220 deletions
diff --git a/src/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs b/src/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs index 15bf451a9c..262ec5066b 100644 --- a/src/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs +++ b/src/System.ComponentModel.Primitives/ref/System.ComponentModel.Primitives.cs @@ -17,6 +17,7 @@ namespace System.ComponentModel public bool Browsable { get; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public partial class CategoryAttribute : System.Attribute { @@ -40,6 +41,7 @@ namespace System.ComponentModel public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } protected virtual string GetLocalizedString(string value) { return default(string); } + public override bool IsDefaultAttribute() { throw null; } } [System.ComponentModel.DesignerCategoryAttribute("Component")] public partial class Component : System.MarshalByRefObject, System.ComponentModel.IComponent, System.IDisposable @@ -82,6 +84,7 @@ namespace System.ComponentModel protected string DescriptionValue { get; set; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public sealed partial class DesignerCategoryAttribute : Attribute { @@ -94,6 +97,8 @@ namespace System.ComponentModel public string Category { get; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } + public override object TypeId { get { throw null; } } } public enum DesignerSerializationVisibility { @@ -111,6 +116,7 @@ namespace System.ComponentModel public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } public System.ComponentModel.DesignerSerializationVisibility Visibility { get; } + public override bool IsDefaultAttribute() { throw null; } } public sealed partial class DesignOnlyAttribute : System.Attribute { @@ -121,6 +127,7 @@ namespace System.ComponentModel public bool IsDesignOnly { get; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public partial class DisplayNameAttribute : System.Attribute { @@ -131,6 +138,7 @@ namespace System.ComponentModel protected string DisplayNameValue { get; set; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public sealed partial class EventHandlerList : System.IDisposable { @@ -162,6 +170,7 @@ namespace System.ComponentModel public bool Immutable { get; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public sealed partial class InitializationEventAttribute : System.Attribute { @@ -184,6 +193,7 @@ namespace System.ComponentModel public bool IsLocalizable { get; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public sealed partial class MergablePropertyAttribute : System.Attribute { @@ -194,6 +204,7 @@ namespace System.ComponentModel public bool AllowMerge { get; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public sealed partial class NotifyParentPropertyAttribute : System.Attribute @@ -205,6 +216,7 @@ namespace System.ComponentModel public bool NotifyParent { get; } public override bool Equals(object obj) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public sealed partial class ParenthesizePropertyNameAttribute : System.Attribute { @@ -214,6 +226,7 @@ namespace System.ComponentModel public bool NeedParenthesis { get; } public override bool Equals(object o) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public sealed partial class ReadOnlyAttribute : System.Attribute { @@ -224,6 +237,7 @@ namespace System.ComponentModel public bool IsReadOnly { get; } public override bool Equals(object value) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } public enum RefreshProperties { @@ -240,5 +254,7 @@ namespace System.ComponentModel public System.ComponentModel.RefreshProperties RefreshProperties { get; } public override bool Equals(object value) { return default(bool); } public override int GetHashCode() { return default(int); } + public override bool IsDefaultAttribute() { throw null; } } } + diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/BrowsableAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/BrowsableAttribute.cs index f003e7e615..12ea4f025f 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/BrowsableAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/BrowsableAttribute.cs @@ -71,5 +71,10 @@ namespace System.ComponentModel { return _browsable.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(BrowsableAttribute.Default); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/CategoryAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/CategoryAttribute.cs index 1f2bb057f6..bbb9c5083d 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/CategoryAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/CategoryAttribute.cs @@ -317,5 +317,10 @@ namespace System.ComponentModel { return SR.GetResourceString("PropertyCategory" + value, null); } + + public override bool IsDefaultAttribute() + { + return Category.Equals(CategoryAttribute.Default.Category); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DescriptionAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DescriptionAttribute.cs index 90543d6c83..062c50ce54 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DescriptionAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DescriptionAttribute.cs @@ -59,5 +59,10 @@ namespace System.ComponentModel { return Description.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(DescriptionAttribute.Default); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignOnlyAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignOnlyAttribute.cs index 29d92dc592..a9c3defdcb 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignOnlyAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignOnlyAttribute.cs @@ -70,5 +70,10 @@ namespace System.ComponentModel { return IsDesignOnly.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return IsDesignOnly == DesignOnlyAttribute.Default.IsDesignOnly; + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignerCategoryAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignerCategoryAttribute.cs index d53bd6dc18..e270ea76ab 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignerCategoryAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignerCategoryAttribute.cs @@ -86,5 +86,18 @@ namespace System.ComponentModel { return Category.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Category.Equals(DesignerCategoryAttribute.Default.Category); + } + + public override object TypeId + { + get + { + return base.GetType().FullName + Category; + } + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignerSerializationVisibilityAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignerSerializationVisibilityAttribute.cs index e84a8193dd..d6178c5443 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignerSerializationVisibilityAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DesignerSerializationVisibilityAttribute.cs @@ -98,5 +98,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(DesignerSerializationVisibilityAttribute.Default); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DisplayNameAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DisplayNameAttribute.cs index 123ac3a896..9fc5595620 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/DisplayNameAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/DisplayNameAttribute.cs @@ -59,5 +59,10 @@ namespace System.ComponentModel { return DisplayName.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(DisplayNameAttribute.Default); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/EventHandlerList.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/EventHandlerList.cs index 96eb3abb72..a284ec01e7 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/EventHandlerList.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/EventHandlerList.cs @@ -43,7 +43,7 @@ namespace System.ComponentModel if (e != null) { - return e.handler; + return e.Handler; } else { @@ -55,7 +55,7 @@ namespace System.ComponentModel ListEntry e = Find(key); if (e != null) { - e.handler = value; + e.Handler = value; } else { @@ -72,7 +72,7 @@ namespace System.ComponentModel ListEntry e = Find(key); if (e != null) { - e.handler = Delegate.Combine(e.handler, value); + e.Handler = Delegate.Combine(e.Handler, value); } else { @@ -86,8 +86,8 @@ namespace System.ComponentModel ListEntry currentListEntry = listToAddFrom._head; while (currentListEntry != null) { - AddHandler(currentListEntry.key, currentListEntry.handler); - currentListEntry = currentListEntry.next; + AddHandler(currentListEntry.Key, currentListEntry.Handler); + currentListEntry = currentListEntry.Next; } } @@ -104,11 +104,11 @@ namespace System.ComponentModel ListEntry found = _head; while (found != null) { - if (found.key == key) + if (found.Key == key) { break; } - found = found.next; + found = found.Next; } return found; } @@ -121,7 +121,7 @@ namespace System.ComponentModel ListEntry e = Find(key); if (e != null) { - e.handler = Delegate.Remove(e.handler, value); + e.Handler = Delegate.Remove(e.Handler, value); } // else... no error for removal of non-existant delegate // @@ -129,15 +129,15 @@ namespace System.ComponentModel private sealed class ListEntry { - internal ListEntry next; - internal object key; - internal Delegate handler; + internal ListEntry Next; + internal object Key; + internal Delegate Handler; public ListEntry(object key, Delegate handler, ListEntry next) { - this.next = next; - this.key = key; - this.handler = handler; + Next = next; + Key = key; + Handler = handler; } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/ImmutableObjectAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/ImmutableObjectAttribute.cs index 34cae73634..f569211160 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/ImmutableObjectAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/ImmutableObjectAttribute.cs @@ -69,5 +69,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(ImmutableObjectAttribute.Default); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/LocalizableAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/LocalizableAttribute.cs index e98573418f..e442bfcd21 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/LocalizableAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/LocalizableAttribute.cs @@ -68,5 +68,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return IsLocalizable == LocalizableAttribute.Default.IsLocalizable; + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/MergablePropertyAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/MergablePropertyAttribute.cs index fc6695b037..2a1820ff0d 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/MergablePropertyAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/MergablePropertyAttribute.cs @@ -80,5 +80,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(MergablePropertyAttribute.Default); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/NotifyParentPropertyAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/NotifyParentPropertyAttribute.cs index 683aac5b30..481d455815 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/NotifyParentPropertyAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/NotifyParentPropertyAttribute.cs @@ -75,5 +75,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(NotifyParentPropertyAttribute.Default); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/ParenthesizePropertyNameAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/ParenthesizePropertyNameAttribute.cs index 213132de69..81b90dd48e 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/ParenthesizePropertyNameAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/ParenthesizePropertyNameAttribute.cs @@ -71,5 +71,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(ParenthesizePropertyNameAttribute.Default); + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/ReadOnlyAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/ReadOnlyAttribute.cs index 6d36e56c96..ea5177c700 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/ReadOnlyAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/ReadOnlyAttribute.cs @@ -77,5 +77,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return IsReadOnly == ReadOnlyAttribute.Default.IsReadOnly; + } } } diff --git a/src/System.ComponentModel.Primitives/src/System/ComponentModel/RefreshPropertiesAttribute.cs b/src/System.ComponentModel.Primitives/src/System/ComponentModel/RefreshPropertiesAttribute.cs index 81172a390d..a6eb824e63 100644 --- a/src/System.ComponentModel.Primitives/src/System/ComponentModel/RefreshPropertiesAttribute.cs +++ b/src/System.ComponentModel.Primitives/src/System/ComponentModel/RefreshPropertiesAttribute.cs @@ -79,5 +79,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return Equals(RefreshPropertiesAttribute.Default); + } } } diff --git a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs index 0cc6b901e1..b0c91d2522 100644 --- a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs +++ b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs @@ -5,6 +5,8 @@ // Changes to this file must follow the http://aka.ms/api-review process. // ------------------------------------------------------------------------------ +using System.Runtime.Serialization; + [assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.ComponentModel.Component))] namespace System @@ -16,6 +18,7 @@ namespace System public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { throw null; } public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { throw null; } public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; } + public override bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) { throw null; } } } namespace System.ComponentModel @@ -38,6 +41,7 @@ namespace System.ComponentModel public virtual System.Attribute this[System.Type attributeType] { get { throw null; } } bool System.Collections.ICollection.IsSynchronized { get { throw null; } } object System.Collections.ICollection.SyncRoot { get { throw null; } } + int System.Collections.ICollection.Count { get { throw null; } } public bool Contains(System.Attribute attribute) { throw null; } public bool Contains(System.Attribute[] attributes) { throw null; } public void CopyTo(System.Array array, int index) { } @@ -46,6 +50,7 @@ namespace System.ComponentModel public System.Collections.IEnumerator GetEnumerator() { throw null; } public bool Matches(System.Attribute attribute) { throw null; } public bool Matches(System.Attribute[] attributes) { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } } [System.AttributeUsageAttribute((System.AttributeTargets)(128))] public partial class AttributeProviderAttribute : System.Attribute @@ -226,6 +231,10 @@ namespace System.ComponentModel int System.Collections.IList.IndexOf(object value) { throw null; } void System.Collections.IList.Insert(int index, object value) { } void System.Collections.IList.Remove(object value) { } + int System.Collections.ICollection.Count { get { throw null; } } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + void System.Collections.IList.Clear() { throw null; } + void System.Collections.IList.RemoveAt(int index) { throw null; } } [System.AttributeUsageAttribute((System.AttributeTargets)(32767))] public sealed partial class ExtenderProvidedPropertyAttribute : System.Attribute @@ -236,6 +245,7 @@ namespace System.ComponentModel public System.Type ReceiverType { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } public partial class GuidConverter : System.ComponentModel.TypeConverter { @@ -294,6 +304,7 @@ namespace System.ComponentModel public InvalidAsynchronousStateException() { } public InvalidAsynchronousStateException(string message) { } public InvalidAsynchronousStateException(string message, System.Exception innerException) { } + protected InvalidAsynchronousStateException(SerializationInfo info, StreamingContext context) { } } public partial interface ISupportInitialize { @@ -343,6 +354,7 @@ namespace System.ComponentModel public override int GetHashCode() { throw null; } protected virtual object GetInvocationTarget(System.Type type, object instance) { throw null; } protected static System.ComponentModel.ISite GetSite(object component) { throw null; } + protected static object GetInvokee(Type componentClass, object component) { throw null; } } public partial class MultilineStringConverter : System.ComponentModel.TypeConverter { @@ -446,6 +458,11 @@ namespace System.ComponentModel int System.Collections.IList.IndexOf(object value) { throw null; } void System.Collections.IList.Insert(int index, object value) { } void System.Collections.IList.Remove(object value) { } + int System.Collections.ICollection.Count { get { throw null; } } + void System.Collections.IDictionary.Clear() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + void System.Collections.IList.Clear() { throw null; } + void System.Collections.IList.RemoveAt(int index) { throw null; } } [System.AttributeUsageAttribute((System.AttributeTargets)(4), AllowMultiple = true)] public sealed partial class ProvidePropertyAttribute : System.Attribute @@ -456,6 +473,7 @@ namespace System.ComponentModel public string ReceiverTypeName { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } + public override object TypeId { get { throw null; } } } public partial class RefreshEventArgs : System.EventArgs { @@ -683,6 +701,11 @@ namespace System.ComponentModel [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void RemoveProviderTransparent(System.ComponentModel.TypeDescriptionProvider provider, System.Type type) { } public static void SortDescriptorArray(System.Collections.IList infos) { } + public static Type ComObjectType { get { throw null; } } + public static System.ComponentModel.Design.IDesigner CreateDesigner(IComponent component, Type designerBaseType) { throw null; } +#pragma warning disable 0618 + public static IComNativeDescriptorHandler ComNativeDescriptorHandler { get; set; } +#pragma warning restore 0618 } public abstract partial class TypeListConverter : System.ComponentModel.TypeConverter { diff --git a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.cs b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.cs index 66cc377582..7fa27b0359 100644 --- a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.cs +++ b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.cs @@ -74,7 +74,7 @@ namespace System.ComponentModel public System.ComponentModel.BindingDirection Direction { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } public enum BindableSupport { @@ -210,7 +210,7 @@ namespace System.ComponentModel public bool IsDataObject { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } [System.AttributeUsageAttribute((System.AttributeTargets)(128))] public sealed partial class DataObjectFieldAttribute : System.Attribute @@ -235,7 +235,7 @@ namespace System.ComponentModel public System.ComponentModel.DataObjectMethodType MethodType { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose Match on Attribute public override bool Match(object obj) { throw null; } + public override bool Match(object obj) { throw null; } } public enum DataObjectMethodType { @@ -265,7 +265,7 @@ namespace System.ComponentModel public DesignerAttribute(System.Type designerType, System.Type designerBaseType) { } public string DesignerBaseTypeName { get { throw null; } } public string DesignerTypeName { get { throw null; } } - //TODO - expose TypeID on Attribute public override object TypeId { get { throw null; } } + public override object TypeId { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } } @@ -280,7 +280,7 @@ namespace System.ComponentModel public bool Visible { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } [System.AttributeUsageAttribute((System.AttributeTargets)(32767), AllowMultiple = true, Inherited = true)] public sealed partial class EditorAttribute : System.Attribute @@ -291,7 +291,7 @@ namespace System.ComponentModel public EditorAttribute(System.Type type, System.Type baseType) { } public string EditorBaseTypeName { get { throw null; } } public string EditorTypeName { get { throw null; } } - //TODO - expose TypeID on Attribute public override object TypeId { get { throw null; } } + public override object TypeId { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } } @@ -380,7 +380,7 @@ namespace System.ComponentModel public System.ComponentModel.InheritanceLevel InheritanceLevel { get { throw null; } } public override bool Equals(object value) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } public override string ToString() { throw null; } } public enum InheritanceLevel @@ -473,7 +473,7 @@ namespace System.ComponentModel public LicenseProviderAttribute(string typeName) { } public LicenseProviderAttribute(System.Type type) { } public System.Type LicenseProvider { get { throw null; } } - //TODO - expose TypeID on Attribute public override object TypeId { get { throw null; } } + public override object TypeId { get { throw null; } } public override bool Equals(object value) { throw null; } public override int GetHashCode() { throw null; } } @@ -500,7 +500,7 @@ namespace System.ComponentModel public bool ListBindable { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NEtstandARd2.0 - eXpose isdefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } public partial class ListChangedEventArgs : System.EventArgs { @@ -691,7 +691,7 @@ namespace System.ComponentModel public bool Password { get { throw null; } } public override bool Equals(object o) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } [System.AttributeUsageAttribute((System.AttributeTargets)(32767))] public partial class PropertyTabAttribute : System.Attribute @@ -728,7 +728,7 @@ namespace System.ComponentModel public bool RecommendedAsConfigurable { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } public partial class ReferenceConverter : System.ComponentModel.TypeConverter { @@ -751,7 +751,7 @@ namespace System.ComponentModel public bool RunInstaller { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } public static partial class SyntaxCheck { @@ -771,7 +771,7 @@ namespace System.ComponentModel public string ToolboxItemTypeName { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } [System.AttributeUsageAttribute((System.AttributeTargets)(4), AllowMultiple = true, Inherited = true)] public sealed partial class ToolboxItemFilterAttribute : System.Attribute @@ -780,10 +780,10 @@ namespace System.ComponentModel public ToolboxItemFilterAttribute(string filterString, System.ComponentModel.ToolboxItemFilterType filterType) { } public string FilterString { get { throw null; } } public System.ComponentModel.ToolboxItemFilterType FilterType { get { throw null; } } - //TODO NETSTANDARD2.0- expose TypeID on Attribute public override object TypeId { get { throw null; } } + public override object TypeId { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose Match on Attribute public override bool Match(object obj) { throw null; } + public override bool Match(object obj) { throw null; } public override string ToString() { throw null; } } public enum ToolboxItemFilterType @@ -998,7 +998,7 @@ namespace System.ComponentModel.Design public string HelpKeyword { get { throw null; } } public override bool Equals(object obj) { throw null; } public override int GetHashCode() { throw null; } - //TODO NETSTANDARD2.0 - expose IsDefaultAttribute on Attribute public override bool IsDefaultAttribute() { throw null; } + public override bool IsDefaultAttribute() { throw null; } } public enum HelpKeywordType { @@ -1388,7 +1388,7 @@ namespace System.ComponentModel.Design.Serialization public DesignerSerializerAttribute(System.Type serializerType, System.Type baseSerializerType) { } public string SerializerBaseTypeName { get { throw null; } } public string SerializerTypeName { get { throw null; } } - //TODO - expose TypeID on Attribute public override object TypeId { get { throw null; } } + public override object TypeId { get { throw null; } } } public partial interface IDesignerLoaderHost : System.ComponentModel.Design.IDesignerHost, System.ComponentModel.Design.IServiceContainer, System.IServiceProvider { @@ -1485,7 +1485,7 @@ namespace System.ComponentModel.Design.Serialization public bool Reloadable { get { throw null; } } public string SerializerBaseTypeName { get { throw null; } } public string SerializerTypeName { get { throw null; } } - //TODO - expose TypeID on Attribute public override object TypeId { get { throw null; } } + public override object TypeId { get { throw null; } } } public abstract partial class SerializationStore : System.IDisposable { diff --git a/src/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj b/src/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj index 992d8bccdb..05bc261709 100644 --- a/src/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj +++ b/src/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj @@ -54,7 +54,6 @@ <Compile Include="System\ComponentModel\CollectionChangeAction.cs" /> <Compile Include="System\ComponentModel\CollectionChangeEventArgs.cs" /> <Compile Include="System\ComponentModel\CollectionChangeEventHandler.cs" /> - <Compile Include="System\ComponentModel\ComponentModelExtensions.cs" /> <Compile Include="System\ComponentModel\CustomTypeDescriptor.cs" /> <Compile Include="System\ComponentModel\DefaultEventAttribute.cs" /> <Compile Include="System\ComponentModel\DefaultPropertyAttribute.cs" /> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs index f85be7ac68..c81640d75f 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/AttributeCollection.cs @@ -12,7 +12,7 @@ namespace System.ComponentModel /// <summary> /// Represents a collection of attributes. /// </summary> - public class AttributeCollection : ICollection + public class AttributeCollection : ICollection, IEnumerable { /// <summary> /// An empty AttributeCollection that can used instead of creating a new one. @@ -90,7 +90,7 @@ namespace System.ComponentModel bool match = false; for (int existingIdx = 0; existingIdx < existing.Count; existingIdx++) { - if (newArray[existingIdx].GetTypeId().Equals(newAttributes[idx].GetTypeId())) + if (newArray[existingIdx].TypeId.Equals(newAttributes[idx].TypeId)) { match = true; newArray[existingIdx] = newAttributes[idx]; @@ -378,6 +378,19 @@ namespace System.ComponentModel } } + int ICollection.Count + { + get + { + return Count; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + /// <summary> /// Copies this collection to an array. /// </summary> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BaseNumberConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BaseNumberConverter.cs index 3ecafa3c97..71be45eec5 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BaseNumberConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BaseNumberConverter.cs @@ -51,7 +51,7 @@ namespace System.ComponentModel /// </summary> internal virtual Exception FromStringError(string failedText, Exception innerException) { - return new Exception(SR.Format(SR.ConvertInvalidPrimitive, failedText, this.TargetType.Name), innerException); + return new Exception(SR.Format(SR.ConvertInvalidPrimitive, failedText, TargetType.Name), innerException); } /// <summary> @@ -80,14 +80,14 @@ namespace System.ComponentModel try { - if (this.AllowHex && text[0] == '#') + if (AllowHex && text[0] == '#') { - return this.FromString(text.Substring(1), 16); + return FromString(text.Substring(1), 16); } - else if (this.AllowHex && text.StartsWith("0x", StringComparison.OrdinalIgnoreCase) + else if (AllowHex && text.StartsWith("0x", StringComparison.OrdinalIgnoreCase) || text.StartsWith("&h", StringComparison.OrdinalIgnoreCase)) { - return this.FromString(text.Substring(2), 16); + return FromString(text.Substring(2), 16); } else { @@ -96,7 +96,7 @@ namespace System.ComponentModel culture = CultureInfo.CurrentCulture; } NumberFormatInfo formatInfo = (NumberFormatInfo)culture.GetFormat(typeof(NumberFormatInfo)); - return this.FromString(text, formatInfo); + return FromString(text, formatInfo); } } catch (Exception e) @@ -117,14 +117,14 @@ namespace System.ComponentModel throw new ArgumentNullException(nameof(destinationType)); } - if (destinationType == typeof(string) && value != null && this.TargetType.GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo())) + if (destinationType == typeof(string) && value != null && TargetType.GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo())) { if (culture == null) { culture = CultureInfo.CurrentCulture; } NumberFormatInfo formatInfo = (NumberFormatInfo)culture.GetFormat(typeof(NumberFormatInfo)); - return this.ToString(value, formatInfo); + return ToString(value, formatInfo); } if (destinationType.GetTypeInfo().IsPrimitive) diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindableAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindableAttribute.cs index 3ee966bc39..a51ce380fe 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindableAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindableAttribute.cs @@ -145,7 +145,7 @@ namespace System.ComponentModel /// <internalonly/> public override bool IsDefaultAttribute() { - return (this.Equals(Default) || _isDefault); + return (Equals(Default) || _isDefault); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs index 54c33c44d0..aa7b5ef32d 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/BindingList.cs @@ -75,7 +75,7 @@ namespace System.ComponentModel _raiseItemChangedEvents = true; // Loop thru the items already in the collection and hook their change notification. - foreach (T item in this.Items) + foreach (T item in Items) { HookPropertyChanged(item); } @@ -232,7 +232,7 @@ namespace System.ComponentModel if (_raiseItemChangedEvents) { - foreach (T item in this.Items) + foreach (T item in Items) { UnhookPropertyChanged(item); } @@ -645,7 +645,7 @@ namespace System.ComponentModel private void Child_PropertyChanged(object sender, PropertyChangedEventArgs e) { - if (this.RaiseListChangedEvents) + if (RaiseListChangedEvents) { if (sender == null || e == null || string.IsNullOrEmpty(e.PropertyName)) { @@ -676,7 +676,7 @@ namespace System.ComponentModel if (pos < 0 || pos >= Count || !this[pos].Equals(item)) { - pos = this.IndexOf(item); + pos = IndexOf(item); _lastChangeIndex = pos; } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentModelExtensions.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentModelExtensions.cs deleted file mode 100644 index ce409d2543..0000000000 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ComponentModelExtensions.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Collections.Generic; - -namespace System.ComponentModel -{ - /// <summary> - /// These extension methods are used to mimic behavior from the .NET Framework where System.Attribute - /// had extra methods. For compatibility reasons, they are implemented with interfaces on the attributes - /// that need them, and then exposed via extension methods off of System.Attribute. The only difference - /// is that Attribute.TypeId is now accessed as Attribute.GetTypeId() as extension properties don't exist. - /// </summary> - internal static class ComponentModelExtensions - { - /// <summary> - /// This work around attempts to mimic the known cases where IsDefaultAttribute is true for System.ComponentModel - /// attributes. This does not account for derived attributes, which a few may be (most are sealed). The derived - /// attributes will most likely not be default as they will be overriding the default properties anyway, so this - /// heuristic will cover the majority of cases while allowing correct layering with System.ComponentModel.Primitives - /// </summary> - public static bool IsDefaultAttribute(this Attribute attribute) - { - Func<Attribute, bool> isDefaultAttribute; - return s_defaultAttributes.TryGetValue(attribute.GetType(), out isDefaultAttribute) && isDefaultAttribute(attribute); - } - - /// <summary> - /// This defines a unique ID for this attribute type. It is used by filtering algorithms to identify two attributes that - /// are the same type. For most attributes, this just returns the Type instance for the attribute. DesignerAttribute - /// overrides this to include the name of the category - /// - /// This is a work around as System.Attribute does not contain the property TypeId in .NET Core. This attempts to mimic - /// the known cases where TypeId is is not just the type for System.ComponentModel attributes. There are two cases of this, - /// and both are sealed, so this lookup will cover all cases. - /// </summary> - public static object GetTypeId(this Attribute attribute) - { - Func<Attribute, object> typeId; - return s_typeId.TryGetValue(attribute.GetType(), out typeId) - ? typeId(attribute) - : attribute.GetType(); - } - - /// <summary> - /// System.Attribute in .NET Core does not have a Match method, so this provides an abstraction for it when it is used - /// in the TypeDescriptor classes in case anything ends up needing to customize it similar to GetTypeId or IsDefaultAttribute - /// </summary> - public static bool Match(this Attribute attribute, object obj) - { - return attribute.Equals(obj); - } - - private static readonly Dictionary<Type, Func<Attribute, object>> s_typeId = new Dictionary<Type, Func<Attribute, object>> - { - { typeof(DesignerCategoryAttribute), attr => attr.GetType().FullName + ((DesignerCategoryAttribute)attr).Category }, - { typeof(ProvidePropertyAttribute), attr => attr.GetType().FullName + ((ProvidePropertyAttribute)attr).PropertyName }, - }; - - private static readonly Dictionary<Type, Func<Attribute, bool>> s_defaultAttributes = new Dictionary<Type, Func<Attribute, bool>> - { - { typeof(BrowsableAttribute), attr => attr.Equals(BrowsableAttribute.Default) }, - { typeof(CategoryAttribute), attr => ((CategoryAttribute)attr).Category.Equals(CategoryAttribute.Default.Category) }, - { typeof(DescriptionAttribute), attr => attr.Equals(DescriptionAttribute.Default) }, - { typeof(DesignOnlyAttribute), attr => ((DesignOnlyAttribute)attr).IsDesignOnly == DesignOnlyAttribute.Default.IsDesignOnly }, - { typeof(DisplayNameAttribute), attr => attr.Equals(DisplayNameAttribute.Default) }, - { typeof(ImmutableObjectAttribute), attr => attr.Equals(ImmutableObjectAttribute.Default) }, - { typeof(LocalizableAttribute), attr => ((LocalizableAttribute)attr).IsLocalizable == LocalizableAttribute.Default.IsLocalizable }, - { typeof(MergablePropertyAttribute), attr => attr.Equals(MergablePropertyAttribute.Default) }, - { typeof(NotifyParentPropertyAttribute), attr => attr.Equals(NotifyParentPropertyAttribute.Default) }, - { typeof(ParenthesizePropertyNameAttribute), attr => attr.Equals(ParenthesizePropertyNameAttribute.Default) }, - { typeof(ReadOnlyAttribute), attr => ((ReadOnlyAttribute)attr).IsReadOnly == ReadOnlyAttribute.Default.IsReadOnly }, - { typeof(RefreshPropertiesAttribute), attr => attr.Equals(RefreshPropertiesAttribute.Default) }, - { typeof(DesignerSerializationVisibilityAttribute), attr => attr.Equals(DesignerSerializationVisibilityAttribute.Default) }, - { typeof(ExtenderProvidedPropertyAttribute), attr => ((ExtenderProvidedPropertyAttribute)attr).ReceiverType == null }, - { typeof(DesignerCategoryAttribute), attr => attr.Equals(DesignerCategoryAttribute.Default) } - }; - } -}
\ No newline at end of file diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DataObjectAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DataObjectAttribute.cs index 72eeb6e10d..8ae81e771c 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DataObjectAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DataObjectAttribute.cs @@ -58,7 +58,7 @@ namespace System.ComponentModel /// <internalonly/> public override bool IsDefaultAttribute() { - return (this.Equals(Default)); + return (Equals(Default)); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerVerbCollection.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerVerbCollection.cs index c30c6f2810..8f3bb99371 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerVerbCollection.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/DesignerVerbCollection.cs @@ -62,7 +62,7 @@ namespace System.ComponentModel.Design } for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) { - this.Add(value[i]); + Add(value[i]); } } /// <summary> @@ -77,7 +77,7 @@ namespace System.ComponentModel.Design int currentCount = value.Count; for (int i = 0; i < currentCount; i = ((i) + (1))) { - this.Add(value[i]); + Add(value[i]); } } /// <summary> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/HelpKeywordAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/HelpKeywordAttribute.cs index 03f75c83eb..83aa81633c 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/HelpKeywordAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/HelpKeywordAttribute.cs @@ -126,7 +126,7 @@ namespace System.ComponentModel.Design /// </summary> public override bool IsDefaultAttribute() { - return this.Equals(Default); + return Equals(Default); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/InheritanceAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/InheritanceAttribute.cs index 44efe9360a..36a78c11df 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/InheritanceAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/InheritanceAttribute.cs @@ -119,7 +119,7 @@ namespace System.ComponentModel /// </summary> public override bool IsDefaultAttribute() { - return (this.Equals(Default)); + return (Equals(Default)); } /// <summary> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/ToolboxItemAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/ToolboxItemAttribute.cs index cf02b3589c..32cf7373c4 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/ToolboxItemAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/Design/ToolboxItemAttribute.cs @@ -44,7 +44,7 @@ namespace System.ComponentModel /// </summary> public override bool IsDefaultAttribute() { - return this.Equals(Default); + return Equals(Default); } /// <summary> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DesignTimeVisibleAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DesignTimeVisibleAttribute.cs index bde36be1ff..56adea0c34 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DesignTimeVisibleAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DesignTimeVisibleAttribute.cs @@ -90,7 +90,7 @@ namespace System.ComponentModel /// </summary> public override bool IsDefaultAttribute() { - return (this.Visible == Default.Visible); + return (Visible == Default.Visible); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/EventDescriptorCollection.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/EventDescriptorCollection.cs index f1a7621815..f57edaade9 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/EventDescriptorCollection.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/EventDescriptorCollection.cs @@ -376,7 +376,7 @@ namespace System.ComponentModel return; } - this.InternalSort(_comparer); + InternalSort(_comparer); if (names != null && names.Length > 0) { @@ -454,6 +454,19 @@ namespace System.ComponentModel } } + int ICollection.Count + { + get + { + return Count; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + /// <internalonly/> object IList.this[int index] { @@ -489,6 +502,11 @@ namespace System.ComponentModel return Contains((EventDescriptor)value); } + void IList.Clear() + { + Clear(); + } + /// <internalonly/> int IList.IndexOf(object value) { @@ -507,6 +525,11 @@ namespace System.ComponentModel Remove((EventDescriptor)value); } + void IList.RemoveAt(int index) + { + RemoveAt(index); + } + /// <internalonly/> bool IList.IsReadOnly { diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ExtenderProvidedPropertyAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ExtenderProvidedPropertyAttribute.cs index 3b6c96f1a1..55e69d0f10 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ExtenderProvidedPropertyAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ExtenderProvidedPropertyAttribute.cs @@ -86,5 +86,10 @@ namespace System.ComponentModel { return base.GetHashCode(); } + + public override bool IsDefaultAttribute() + { + return _receiverType == null; + } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidAsynchronousStateException.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidAsynchronousStateException.cs index 258526b9d0..ed67146f86 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidAsynchronousStateException.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/InvalidAsynchronousStateException.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Runtime.Serialization; + namespace System.ComponentModel { /// <summary> @@ -33,5 +35,9 @@ namespace System.ComponentModel : base(message, innerException) { } + + protected InvalidAsynchronousStateException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ListBindableAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ListBindableAttribute.cs index 17e5ecb60e..d3722b5756 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ListBindableAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ListBindableAttribute.cs @@ -91,7 +91,7 @@ namespace System.ComponentModel /// </summary> public override bool IsDefaultAttribute() { - return (this.Equals(Default) || _isDefault); + return (Equals(Default) || _isDefault); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs index 47b5645839..30f3b67c07 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MaskedTextProvider.cs @@ -85,8 +85,8 @@ namespace System.ComponentModel // constructors. public CharDescriptor(int maskPos, CharType charType) { - this.MaskPosition = maskPos; - this.CharType = charType; + MaskPosition = maskPos; + CharType = charType; } public override string ToString() @@ -94,10 +94,10 @@ namespace System.ComponentModel return String.Format( CultureInfo.InvariantCulture, "MaskPosition[{0}] <CaseConversion.{1}><CharType.{2}><IsAssigned: {3}", - this.MaskPosition, - this.CaseConversion, - this.CharType, - this.IsAssigned + MaskPosition, + CaseConversion, + CharType, + IsAssigned ); } } @@ -481,7 +481,7 @@ namespace System.ComponentModel { get { - return this.EditPositionCount - _assignedCharCount; + return EditPositionCount - _assignedCharCount; } } @@ -495,28 +495,28 @@ namespace System.ComponentModel public object Clone() { MaskedTextProvider clonedProvider; - Type providerType = this.GetType(); + Type providerType = GetType(); if (providerType == s_maskTextProviderType) { clonedProvider = new MaskedTextProvider( - this.Mask, - this.Culture, - this.AllowPromptAsInput, - this.PromptChar, - this.PasswordChar, - this.AsciiOnly); + Mask, + Culture, + AllowPromptAsInput, + PromptChar, + PasswordChar, + AsciiOnly); } else // A derived Type instance used. { object[] parameters = new object[] { - this.Mask, - this.Culture, - this.AllowPromptAsInput, - this.PromptChar, - this.PasswordChar, - this.AsciiOnly + Mask, + Culture, + AllowPromptAsInput, + PromptChar, + PasswordChar, + AsciiOnly }; clonedProvider = SecurityUtils.SecureCreateInstance(providerType, parameters) as MaskedTextProvider; @@ -536,11 +536,11 @@ namespace System.ComponentModel } } - clonedProvider.ResetOnPrompt = this.ResetOnPrompt; - clonedProvider.ResetOnSpace = this.ResetOnSpace; - clonedProvider.SkipLiterals = this.SkipLiterals; - clonedProvider.IncludeLiterals = this.IncludeLiterals; - clonedProvider.IncludePrompt = this.IncludePrompt; + clonedProvider.ResetOnPrompt = ResetOnPrompt; + clonedProvider.ResetOnSpace = ResetOnSpace; + clonedProvider.SkipLiterals = SkipLiterals; + clonedProvider.IncludeLiterals = IncludeLiterals; + clonedProvider.IncludePrompt = IncludePrompt; return clonedProvider; } @@ -658,7 +658,7 @@ namespace System.ComponentModel set { - if (this.IsPassword != value) + if (IsPassword != value) { _passwordChar = value ? DefaultPasswordChar : nullPasswordChar; } @@ -730,7 +730,7 @@ namespace System.ComponentModel get { Debug.Assert(_assignedCharCount >= 0, "Invalid count of assigned chars."); - return _assignedCharCount == this.EditPositionCount; + return _assignedCharCount == EditPositionCount; } } @@ -907,7 +907,7 @@ namespace System.ComponentModel /// </summary> public bool Add(char input, out int testPosition, out MaskedTextResultHint resultHint) { - int lastAssignedPos = this.LastAssignedPosition; + int lastAssignedPos = LastAssignedPosition; if (lastAssignedPos == _testString.Length - 1) // at the last edit char position. { @@ -962,7 +962,7 @@ namespace System.ComponentModel throw new ArgumentNullException("input"); } - testPosition = this.LastAssignedPosition + 1; + testPosition = LastAssignedPosition + 1; if (input.Length == 0) // nothing to add. { @@ -1383,7 +1383,7 @@ namespace System.ComponentModel int srcPos = FindEditPositionFrom(position, forward); // source position. bool shiftNeeded = FindAssignedEditPositionInRange(srcPos, testPosition, forward) != invalidIndex; - int lastAssignedPos = this.LastAssignedPosition; + int lastAssignedPos = LastAssignedPosition; if (shiftNeeded && (testPosition == _testString.Length - 1)) // no room for shifting. { @@ -1597,7 +1597,7 @@ namespace System.ComponentModel /// </summary> public bool Remove(out int testPosition, out MaskedTextResultHint resultHint) { - int lastAssignedPos = this.LastAssignedPosition; + int lastAssignedPos = LastAssignedPosition; if (lastAssignedPos == invalidIndex) { @@ -1679,7 +1679,7 @@ namespace System.ComponentModel Debug.Assert(startPosition >= 0 && startPosition <= endPosition && endPosition < _testString.Length, "Out of range input value."); // Check if we need to shift characters left to occupied the positions left by the characters being removed. - int lastAssignedPos = this.LastAssignedPosition; + int lastAssignedPos = LastAssignedPosition; int dstPos = FindEditPositionInRange(startPosition, endPosition, forward); // first edit position in range. resultHint = MaskedTextResultHint.NoEffect; @@ -1717,7 +1717,7 @@ namespace System.ComponentModel CharDescriptor chDex = _stringDescriptor[srcPos]; // if the shifting character is the prompt and it is at an unassigned position we don't need to test it. - if (srcCh != this.PromptChar || chDex.IsAssigned) + if (srcCh != PromptChar || chDex.IsAssigned) { if (!TestChar(srcCh, dstPos, out testHint)) { @@ -1757,7 +1757,7 @@ namespace System.ComponentModel CharDescriptor chDex = _stringDescriptor[srcPos]; // if the shifting character is the prompt and it is at an unassigned position we just reset the destination position. - if (srcCh == this.PromptChar && !chDex.IsAssigned) + if (srcCh == PromptChar && !chDex.IsAssigned) { ResetChar(dstPos); } @@ -2010,7 +2010,7 @@ namespace System.ComponentModel else if (testPosition > endPosition) // Case 3. Replace + Insert. { // Test shifting existing characters to make room for inserting part of the input. - int lastAssignedPos = this.LastAssignedPosition; + int lastAssignedPos = LastAssignedPosition; int dstPos = testPosition + 1; int srcPos = endPosition + 1; @@ -2229,7 +2229,7 @@ namespace System.ComponentModel } } - Debug.Assert(_assignedCharCount <= this.EditPositionCount, "Invalid count of assigned chars."); + Debug.Assert(_assignedCharCount <= EditPositionCount, "Invalid count of assigned chars."); } /// <summary> @@ -2323,7 +2323,7 @@ namespace System.ComponentModel if (IsLiteralPosition(charDex)) { - if (this.SkipLiterals && (input == _testString[position])) + if (SkipLiterals && (input == _testString[position])) { resultHint = MaskedTextResultHint.CharacterEscaped; return true; @@ -2335,7 +2335,7 @@ namespace System.ComponentModel if (input == _promptChar) { - if (this.ResetOnPrompt) + if (ResetOnPrompt) { if (IsEditPosition(charDex) && charDex.IsAssigned) // Position would be reset. { @@ -2349,14 +2349,14 @@ namespace System.ComponentModel } // Escaping precedes AllowPromptAsInput. Now test for it. - if (!this.AllowPromptAsInput) + if (!AllowPromptAsInput) { resultHint = MaskedTextResultHint.PromptCharNotAllowed; return false; } } - if (input == spaceChar && this.ResetOnSpace) + if (input == spaceChar && ResetOnSpace) { if (IsEditPosition(charDex) && charDex.IsAssigned) // Position would be reset. { @@ -2406,7 +2406,7 @@ namespace System.ComponentModel resultHint = MaskedTextResultHint.LetterExpected; return false; } - if (!IsAsciiLetter(input) && this.AsciiOnly) + if (!IsAsciiLetter(input) && AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; @@ -2419,7 +2419,7 @@ namespace System.ComponentModel resultHint = MaskedTextResultHint.LetterExpected; return false; } - if (!IsAsciiLetter(input) && this.AsciiOnly) + if (!IsAsciiLetter(input) && AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; @@ -2427,7 +2427,7 @@ namespace System.ComponentModel break; case '&': // any character required. - if (!IsAscii(input) && this.AsciiOnly) + if (!IsAscii(input) && AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; @@ -2435,7 +2435,7 @@ namespace System.ComponentModel break; case 'C': // any character optional. - if ((!IsAscii(input) && this.AsciiOnly) && input != spaceChar) + if ((!IsAscii(input) && AsciiOnly) && input != spaceChar) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; @@ -2448,7 +2448,7 @@ namespace System.ComponentModel resultHint = MaskedTextResultHint.AlphanumericCharacterExpected; return false; } - if (!IsAciiAlphanumeric(input) && this.AsciiOnly) + if (!IsAciiAlphanumeric(input) && AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; @@ -2461,7 +2461,7 @@ namespace System.ComponentModel resultHint = MaskedTextResultHint.AlphanumericCharacterExpected; return false; } - if (!IsAciiAlphanumeric(input) && this.AsciiOnly) + if (!IsAciiAlphanumeric(input) && AsciiOnly) { resultHint = MaskedTextResultHint.AsciiCharacterExpected; return false; @@ -2503,10 +2503,10 @@ namespace System.ComponentModel // the input value (space, prompt,...). if (IsLiteralPosition(charDex)) { - return this.SkipLiterals && input == _testString[position]; + return SkipLiterals && input == _testString[position]; } - if ((this.ResetOnPrompt && (input == _promptChar)) || (this.ResetOnSpace && (input == spaceChar))) + if ((ResetOnPrompt && (input == _promptChar)) || (ResetOnSpace && (input == spaceChar))) { return true; } @@ -2577,7 +2577,7 @@ namespace System.ComponentModel } // If any char is actually accepted, then the hint is success, otherwise whatever the last character result is. - // Need a temp variable for this. + // Need a temp variable for MaskedTextResultHint tempHint = resultHint; foreach (char ch in input) @@ -2628,7 +2628,7 @@ namespace System.ComponentModel /// </summary> public string ToDisplayString() { - if (!this.IsPassword || _assignedCharCount == 0) // just return the testString since it contains the formatted text. + if (!IsPassword || _assignedCharCount == 0) // just return the testString since it contains the formatted text. { return _testString.ToString(); } @@ -2651,7 +2651,7 @@ namespace System.ComponentModel /// </summary> public override string ToString() { - return ToString(/*ignorePwdChar*/ true, this.IncludePrompt, this.IncludeLiterals, 0, _testString.Length); + return ToString(/*ignorePwdChar*/ true, IncludePrompt, IncludeLiterals, 0, _testString.Length); } /// <summary> @@ -2660,7 +2660,7 @@ namespace System.ComponentModel /// </summary> public string ToString(bool ignorePasswordChar) { - return ToString(ignorePasswordChar, this.IncludePrompt, this.IncludeLiterals, 0, _testString.Length); + return ToString(ignorePasswordChar, IncludePrompt, IncludeLiterals, 0, _testString.Length); } /// <summary> @@ -2670,7 +2670,7 @@ namespace System.ComponentModel /// </summary> public string ToString(int startPosition, int length) { - return ToString(/*ignorePwdChar*/ true, this.IncludePrompt, this.IncludeLiterals, startPosition, length); + return ToString(/*ignorePwdChar*/ true, IncludePrompt, IncludeLiterals, startPosition, length); } /// <summary> @@ -2681,7 +2681,7 @@ namespace System.ComponentModel /// </summary> public string ToString(bool ignorePasswordChar, int startPosition, int length) { - return ToString(ignorePasswordChar, this.IncludePrompt, this.IncludeLiterals, startPosition, length); + return ToString(ignorePasswordChar, IncludePrompt, IncludeLiterals, startPosition, length); } /// <summary> @@ -2735,7 +2735,7 @@ namespace System.ComponentModel //throw new ArgumentOutOfRangeException("length"); } - if (!this.IsPassword || ignorePasswordChar) // we may not need to format the text... + if (!IsPassword || ignorePasswordChar) // we may not need to format the text... { if (includePrompt && includeLiterals) { @@ -2781,7 +2781,7 @@ namespace System.ComponentModel case CharType.EditRequired: if (chDex.IsAssigned) { - if (this.IsPassword && !ignorePasswordChar) + if (IsPassword && !ignorePasswordChar) { st.Append(_passwordChar); // replace edit char with pwd char. break; diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MemberDescriptor.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MemberDescriptor.cs index 03d3654d2a..d27e33c95c 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MemberDescriptor.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MemberDescriptor.cs @@ -428,7 +428,7 @@ namespace System.ComponentModel for (int i = 0; i < list.Count;) { - if (set.Add(list[i].GetTypeId())) + if (set.Add(list[i].TypeId)) { ++i; } @@ -536,5 +536,21 @@ namespace System.ComponentModel return ((IComponent)component).Site; } + + [Obsolete("This method has been deprecated. Use GetInvocationTarget instead. http://go.microsoft.com/fwlink/?linkid=14202")] + protected static object GetInvokee(Type componentClass, object component) { + + if (componentClass == null) + { + throw new ArgumentNullException(nameof(componentClass)); + } + + if (component == null) + { + throw new ArgumentNullException(nameof(component)); + } + + return TypeDescriptor.GetAssociation(componentClass, component); + } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PasswordPropertyTextAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PasswordPropertyTextAttribute.cs index 9a8f468c82..fcfce71c8f 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PasswordPropertyTextAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PasswordPropertyTextAttribute.cs @@ -87,7 +87,7 @@ namespace System.ComponentModel /// </summary> public override bool IsDefaultAttribute() { - return this.Equals(Default); + return Equals(Default); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs index 01f57c4536..b0e200ea32 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs @@ -195,9 +195,9 @@ namespace System.ComponentModel // of an instanceof call. PropertyDescriptor pd = obj as PropertyDescriptor; - if (pd != null && pd.NameHashCode == this.NameHashCode - && pd.PropertyType == this.PropertyType - && pd.Name.Equals(this.Name)) + if (pd != null && pd.NameHashCode == NameHashCode + && pd.PropertyType == PropertyType + && pd.Name.Equals(Name)) { return true; } @@ -374,7 +374,7 @@ namespace System.ComponentModel /// </summary> public override int GetHashCode() { - return this.NameHashCode ^ PropertyType.GetHashCode(); + return NameHashCode ^ PropertyType.GetHashCode(); } /// <summary> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptorCollection.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptorCollection.cs index db5c8b4b1a..bc9da9041d 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptorCollection.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptorCollection.cs @@ -393,7 +393,7 @@ namespace System.ComponentModel return; } - this.InternalSort(_comparer); + InternalSort(_comparer); if (names != null && names.Length > 0) { @@ -489,6 +489,34 @@ namespace System.ComponentModel } } + int ICollection.Count + { + get + { + return Count; + } + } + + void IList.Clear() + { + Clear(); + } + + void IDictionary.Clear() + { + Clear(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + void IList.RemoveAt(int index) + { + RemoveAt(index); + } + /// <internalonly/> void IDictionary.Add(object key, object value) { diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ProvidePropertyAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ProvidePropertyAttribute.cs index 41325a09d2..436a0edf5f 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ProvidePropertyAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ProvidePropertyAttribute.cs @@ -74,6 +74,14 @@ namespace System.ComponentModel { return _propertyName.GetHashCode() ^ _receiverTypeName.GetHashCode(); } + + public override object TypeId + { + get + { + return base.GetType().FullName + _propertyName; + } + } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs index 717963bcaf..e8733e235d 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectPropertyDescriptor.cs @@ -1256,7 +1256,7 @@ namespace System.ComponentModel /// other words, it indicates whether the state of the property is distinct /// from when the component is first instantiated. If there is a default /// value specified in this ReflectPropertyDescriptor, it will be compared against the - /// property's current value to determine this. If there is't, the + /// property's current value to determine this. If there is't, the /// ShouldSerializeXXX method is looked for and invoked if found. If both /// these routes fail, true will be returned. /// diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.ReflectedTypeData.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.ReflectedTypeData.cs index 15871fdf39..843771dc2e 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.ReflectedTypeData.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.ReflectedTypeData.cs @@ -146,9 +146,9 @@ namespace System.ComponentModel } } - if (addAttr && !attrDictionary.Contains(attrArray[idx].GetTypeId())) + if (addAttr && !attrDictionary.Contains(attrArray[idx].TypeId)) { - attrDictionary[attrArray[idx].GetTypeId()] = attrArray[idx]; + attrDictionary[attrArray[idx].TypeId] = attrArray[idx]; } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/RunInstallerAttribute.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/RunInstallerAttribute.cs index e8ab4c8df9..4f1939d26e 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/RunInstallerAttribute.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/RunInstallerAttribute.cs @@ -106,7 +106,7 @@ namespace System.ComponentModel /// </summary> public override bool IsDefaultAttribute() { - return (this.Equals(Default)); + return (Equals(Default)); } } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs index 4d1987d415..cfd31e35d8 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs @@ -344,7 +344,7 @@ namespace System.ComponentModel return; } - // Immediately clear this. If we find a default provider + // Immediately clear this. If we find a default provider // and it starts messing around with type information, // this could infinitely recurse. // @@ -1867,7 +1867,7 @@ namespace System.ComponentModel case PIPELINE_ATTRIBUTES: foreach (Attribute attr in members) { - filterTable[attr.GetTypeId()] = attr; + filterTable[attr.TypeId] = attr; } cacheResults = componentFilter.FilterAttributes(component, filterTable); break; @@ -2435,6 +2435,93 @@ namespace System.ComponentModel } } + [EditorBrowsable(EditorBrowsableState.Advanced)] + public static Type ComObjectType + { + get + { + return typeof(TypeDescriptor.TypeDescriptorComObject); + } + } + + public static IDesigner CreateDesigner(IComponent component, Type designerBaseType) + { + Type type = null; + IDesigner result = null; + AttributeCollection attributes = TypeDescriptor.GetAttributes(component); + for (int i = 0; i < attributes.Count; i++) + { + DesignerAttribute designerAttribute = attributes[i] as DesignerAttribute; + if (designerAttribute != null) + { + Type type2 = Type.GetType(designerAttribute.DesignerBaseTypeName); + if (type2 != null && type2 == designerBaseType) + { + ISite site = component.Site; + bool flag = false; + if (site != null) + { + ITypeResolutionService typeResolutionService = (ITypeResolutionService)site.GetService(typeof(ITypeResolutionService)); + if (typeResolutionService != null) + { + flag = true; + type = typeResolutionService.GetType(designerAttribute.DesignerTypeName); + } + } + if (!flag) + { + type = Type.GetType(designerAttribute.DesignerTypeName); + } + if (type != null) + { + break; + } + } + } + } + if (type != null) + { + result = (IDesigner)SecurityUtils.SecureCreateInstance(type); + } + return result; + } + + [Obsolete("This property has been deprecated. Use a type description provider to supply type information for COM types instead. http://go.microsoft.com/fwlink/?linkid=14202")] + public static IComNativeDescriptorHandler ComNativeDescriptorHandler + { + get + { + TypeDescriptor.TypeDescriptionNode typeDescriptionNode = TypeDescriptor.NodeFor(TypeDescriptor.ComObjectType); + TypeDescriptor.ComNativeDescriptionProvider comNativeDescriptionProvider; + do + { + comNativeDescriptionProvider = (typeDescriptionNode.Provider as TypeDescriptor.ComNativeDescriptionProvider); + typeDescriptionNode = typeDescriptionNode.Next; + } + while (typeDescriptionNode != null && comNativeDescriptionProvider == null); + if (comNativeDescriptionProvider != null) + { + return comNativeDescriptionProvider.Handler; + } + return null; + } + set + { + TypeDescriptor.TypeDescriptionNode typeDescriptionNode = TypeDescriptor.NodeFor(TypeDescriptor.ComObjectType); + while (typeDescriptionNode != null && !(typeDescriptionNode.Provider is TypeDescriptor.ComNativeDescriptionProvider)) + { + typeDescriptionNode = typeDescriptionNode.Next; + } + if (typeDescriptionNode == null) + { + TypeDescriptor.AddProvider(new TypeDescriptor.ComNativeDescriptionProvider(value), TypeDescriptor.ComObjectType); + return; + } + ((TypeDescriptor.ComNativeDescriptionProvider)typeDescriptionNode.Provider).Handler = value; + } + } + + /// <summary> /// The RemoveAssociation method removes an association with an object. /// </summary> @@ -2637,6 +2724,132 @@ namespace System.ComponentModel } /// <summary> + /// This class is a type description provider that works with the IComNativeDescriptorHandler + /// interface. + //// </summary> + private sealed class ComNativeDescriptionProvider : TypeDescriptionProvider + { +#pragma warning disable 618 + internal ComNativeDescriptionProvider(IComNativeDescriptorHandler handler) + { + Handler = handler; + } + + /// <summary> + /// Returns the COM handler object. + //// </summary> + internal IComNativeDescriptorHandler Handler { get; set; } +#pragma warning restore 618 + + /// <summary> + /// Implements GetTypeDescriptor. This creates a custom type + /// descriptor that walks the linked list for each of its calls. + //// </summary> + + [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters")] + public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) + { + if (objectType == null) + { + throw new ArgumentNullException(nameof(objectType)); + } + + if (instance == null) + { + return null; + } + + if (!objectType.IsInstanceOfType(instance)) + { + throw new ArgumentException(SR.Format(SR.ConvertToException, nameof(objectType), instance.GetType()) , nameof(instance)); + } + + return new ComNativeTypeDescriptor(Handler, instance); + } + + /// <summary> + /// This type descriptor sits on top of a native + /// descriptor handler. + //// </summary> + private sealed class ComNativeTypeDescriptor : ICustomTypeDescriptor + { +#pragma warning disable 618 + private readonly IComNativeDescriptorHandler _handler; + private readonly object _instance; + + /// <summary> + /// Creates a new ComNativeTypeDescriptor. + //// </summary> + internal ComNativeTypeDescriptor(IComNativeDescriptorHandler handler, object instance) + { + _handler = handler; + _instance = instance; + } +#pragma warning restore 618 + + AttributeCollection ICustomTypeDescriptor.GetAttributes() + { + return _handler.GetAttributes(_instance); + } + + string ICustomTypeDescriptor.GetClassName() + { + return _handler.GetClassName(_instance); + } + + string ICustomTypeDescriptor.GetComponentName() + { + return null; + } + + TypeConverter ICustomTypeDescriptor.GetConverter() + { + return _handler.GetConverter(_instance); + } + + EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() + { + return _handler.GetDefaultEvent(_instance); + } + + PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty() + { + return _handler.GetDefaultProperty(_instance); + } + + object ICustomTypeDescriptor.GetEditor(Type editorBaseType) + { + return _handler.GetEditor(_instance, editorBaseType); + } + + EventDescriptorCollection ICustomTypeDescriptor.GetEvents() + { + return _handler.GetEvents(_instance); + } + + EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) + { + return _handler.GetEvents(_instance, attributes); + } + + PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties() + { + return _handler.GetProperties(_instance, null); + } + + PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) + { + return _handler.GetProperties(_instance, attributes); + } + + object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd) + { + return _instance; + } + } + } + + /// <summary> /// This is a type description provider that adds the given /// array of attributes to a class or instance, preserving the rest /// of the metadata in the process. @@ -2701,7 +2914,7 @@ namespace System.ComponentModel bool match = false; for (int existingIdx = 0; existingIdx < existing.Count; existingIdx++) { - if (newArray[existingIdx].GetTypeId().Equals(newAttrs[idx].GetTypeId())) + if (newArray[existingIdx].TypeId.Equals(newAttrs[idx].TypeId)) { match = true; newArray[existingIdx] = newAttrs[idx]; @@ -2817,6 +3030,10 @@ namespace System.ComponentModel } } + private sealed class TypeDescriptorComObject + { + } + /// <summary> /// This is a merged type descriptor that can merge the output of /// a primary and secondary type descriptor. If the primary doesn't diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/UriTypeConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/UriTypeConverter.cs index 803bac803b..45cf4cf84d 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/UriTypeConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/UriTypeConverter.cs @@ -81,5 +81,16 @@ namespace System throw GetConvertToException(value, destinationType); } + + public override bool IsValid(ITypeDescriptorContext context, object value) + { + string text = value as string; + if (text != null) + { + Uri uri; + return Uri.TryCreate(text, UriKind.RelativeOrAbsolute, out uri); + } + return value is Uri; + } } } diff --git a/src/System.ComponentModel.TypeConverter/tests/SampleClasses.cs b/src/System.ComponentModel.TypeConverter/tests/SampleClasses.cs index b10717d690..f1a56418cb 100644 --- a/src/System.ComponentModel.TypeConverter/tests/SampleClasses.cs +++ b/src/System.ComponentModel.TypeConverter/tests/SampleClasses.cs @@ -102,7 +102,7 @@ namespace System.ComponentModel.Tests { return false; } - if (otherBaseClass.BaseProperty == this.BaseProperty) + if (otherBaseClass.BaseProperty == BaseProperty) { return true; } @@ -165,12 +165,12 @@ namespace System.ComponentModel.Tests public DerivedClass() : base() { - this.DerivedProperty = 2; + DerivedProperty = 2; } public DerivedClass(int i) : base() { - this.DerivedProperty = i; + DerivedProperty = i; } public override bool Equals(object other) { @@ -179,7 +179,7 @@ namespace System.ComponentModel.Tests { return false; } - if (otherDerivedClass.DerivedProperty != this.DerivedProperty) + if (otherDerivedClass.DerivedProperty != DerivedProperty) { return false; } @@ -252,7 +252,7 @@ namespace System.ComponentModel.Tests { public ClassIBase() { - this.InterfaceProperty = 10; + InterfaceProperty = 10; } public int InterfaceProperty { get; set; } } @@ -261,8 +261,8 @@ namespace System.ComponentModel.Tests { public ClassIDerived() { - this.InterfaceProperty = 20; - this.DerivedInterfaceProperty = this.InterfaceProperty / 2; + InterfaceProperty = 20; + DerivedInterfaceProperty = InterfaceProperty / 2; } public int InterfaceProperty { get; set; } public int DerivedInterfaceProperty { get; set; } diff --git a/src/System.ComponentModel.TypeConverter/tests/TypeConverterTests.cs b/src/System.ComponentModel.TypeConverter/tests/TypeConverterTests.cs index 21303789cf..1f5133fdca 100644 --- a/src/System.ComponentModel.TypeConverter/tests/TypeConverterTests.cs +++ b/src/System.ComponentModel.TypeConverter/tests/TypeConverterTests.cs @@ -138,12 +138,12 @@ namespace System.ComponentModel.Tests private void RunProtectedMethods() { - Assert.Throws<NotSupportedException>(() => this.GetConvertFromException(null)); - Assert.Throws<NotSupportedException>(() => this.GetConvertFromException("1")); - Assert.Throws<NotSupportedException>(() => this.GetConvertFromException(new BaseClass())); - Assert.Throws<NotSupportedException>(() => this.GetConvertToException(null, typeof(int))); - Assert.Throws<NotSupportedException>(() => this.GetConvertToException("1", typeof(int))); - Assert.Throws<NotSupportedException>(() => this.GetConvertToException(new BaseClass(), typeof(BaseClass))); + Assert.Throws<NotSupportedException>(() => GetConvertFromException(null)); + Assert.Throws<NotSupportedException>(() => GetConvertFromException("1")); + Assert.Throws<NotSupportedException>(() => GetConvertFromException(new BaseClass())); + Assert.Throws<NotSupportedException>(() => GetConvertToException(null, typeof(int))); + Assert.Throws<NotSupportedException>(() => GetConvertToException("1", typeof(int))); + Assert.Throws<NotSupportedException>(() => GetConvertToException(new BaseClass(), typeof(BaseClass))); } private static void VerifyConversionToString(object o) |