diff options
author | Alex Perovich <alperovi@microsoft.com> | 2016-09-22 21:49:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-22 21:49:37 +0300 |
commit | 93470c7590b38a509f0bcdd75ec2d7114da5f819 (patch) | |
tree | fcc20e3013c311db8ca4bb5924a83aeb8c92f6e2 /src | |
parent | f3d245ac4107c6da8c907808de674a7e1fcdd64a (diff) |
Port S.Drawing types and converters. (#11731)
* Port S.Drawing types and converters.
Fixes #11545
* Update dependencies
* Address nits.
* Update Dependencies
* Address Review feedback
Diffstat (limited to 'src')
59 files changed, 5913 insertions, 1161 deletions
diff --git a/src/Common/src/System/Drawing/ColorTable.cs b/src/Common/src/System/Drawing/ColorTable.cs new file mode 100644 index 0000000000..a6e5d0ef97 --- /dev/null +++ b/src/Common/src/System/Drawing/ColorTable.cs @@ -0,0 +1,54 @@ +// 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; +using System.Reflection; + +namespace System.Drawing +{ + internal static class ColorTable + { + private static readonly Lazy<Dictionary<string, Color>> s_colorConstants = new Lazy<Dictionary<string, Color>>(GetColors); + private static readonly Lazy<Dictionary<string, Color>> s_systemColorConstants = new Lazy<Dictionary<string, Color>>(GetSystemColors); + + private static Dictionary<string, Color> GetColors() + { + var dict = new Dictionary<string, Color>(StringComparer.OrdinalIgnoreCase); + FillConstants(dict, typeof(Color)); + return dict; + } + + private static Dictionary<string, Color> GetSystemColors() + { + var dict = new Dictionary<string, Color>(StringComparer.OrdinalIgnoreCase); + FillConstants(dict, typeof(SystemColors)); + return dict; + } + + internal static Dictionary<string, Color> Colors => s_colorConstants.Value; + + internal static Dictionary<string, Color> SystemColors => s_systemColorConstants.Value; + + private static void FillConstants(Dictionary<string, Color> colors, Type enumType) + { + const MethodAttributes attrs = MethodAttributes.Public | MethodAttributes.Static; + PropertyInfo[] props = enumType.GetProperties(); + + foreach (PropertyInfo prop in props) + { + if (prop.PropertyType == typeof(Color)) + { + MethodInfo method = prop.GetGetMethod(); + if (method != null && (method.Attributes & attrs) == attrs) + { + colors[prop.Name] = (Color) prop.GetValue(null, null); + } + } + } + } + + internal static bool TryGetNamedColor(string name, out Color result) => + Colors.TryGetValue(name, out result) || SystemColors.TryGetValue(name, out result); + } +}
\ No newline at end of file diff --git a/src/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.sln b/src/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.sln index 4b9e5d1366..44377c11d0 100644 --- a/src/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.sln +++ b/src/System.ComponentModel.TypeConverter/System.ComponentModel.TypeConverter.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.ComponentModel.TypeConverter", "src\System.ComponentModel.TypeConverter.csproj", "{AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}" EndProject @@ -15,16 +15,16 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Release|Any CPU.Build.0 = Release|Any CPU - {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Release|Any CPU.Build.0 = Release|Any CPU - {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Debug|Any CPU.ActiveCfg = netstandard1.7_Debug|Any CPU + {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Debug|Any CPU.Build.0 = netstandard1.7_Debug|Any CPU + {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Release|Any CPU.ActiveCfg = netstandard1.7_Release|Any CPU + {AF3EBF3B-526A-4B51-9F3D-62B0113CD01F}.Release|Any CPU.Build.0 = netstandard1.7_Release|Any CPU + {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Debug|Any CPU.ActiveCfg = netstandard1.7_Debug|Any CPU + {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Debug|Any CPU.Build.0 = netstandard1.7_Debug|Any CPU + {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Release|Any CPU.ActiveCfg = netstandard1.7_Release|Any CPU + {3F0326A1-9E19-4A6C-95CE-63E65C9D2030}.Release|Any CPU.Build.0 = netstandard1.7_Release|Any CPU + {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Debug|Any CPU.ActiveCfg = netstandard1.7_Debug|Any CPU + {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Debug|Any CPU.Build.0 = netstandard1.7_Debug|Any CPU {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Release|Any CPU.ActiveCfg = Release|Any CPU {89C76728-ECAF-4905-A33F-BD6BFED5E91D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.Manual.cs b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.Manual.cs deleted file mode 100644 index 657e2a7bda..0000000000 --- a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.Manual.cs +++ /dev/null @@ -1,35 +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. - -// Stub to unblock explosing System.Timers - -namespace System.ComponentModel -{ - public partial interface ISynchronizeInvoke - { - IAsyncResult BeginInvoke(Delegate method, object[] args); - object EndInvoke(IAsyncResult result); - object Invoke(Delegate method, object[] args); - bool InvokeRequired { get; } - } - - public partial interface ISupportInitialize - { - void BeginInit(); - void EndInit(); - } - - public partial class Component : IDisposable - { - public Component() { } - public void Dispose() { } - protected virtual void Dispose(bool disposing) { } - ~Component() { } - protected virtual object GetService(Type service) { return default(object); } - public override string ToString() { return default(string); } - protected virtual bool CanRaiseEvents { get { return default(bool); } } - protected bool DesignMode { get { return default(bool); } } - public virtual ISite Site { get { return default(ISite); } set { } } - } -} diff --git a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs index 236858a187..5e280d04e9 100644 --- a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs +++ b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.cs @@ -5,59 +5,71 @@ // Changes to this file must follow the http://aka.ms/api-review process. // ------------------------------------------------------------------------------ +namespace System +{ + public partial class UriTypeConverter : System.ComponentModel.TypeConverter + { + public UriTypeConverter() { } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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; } + } +} namespace System.ComponentModel { public partial class ArrayConverter : System.ComponentModel.CollectionConverter { public ArrayConverter() { } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } - public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; } + public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } } public partial class AttributeCollection : System.Collections.ICollection, System.Collections.IEnumerable { public static readonly System.ComponentModel.AttributeCollection Empty; protected AttributeCollection() { } public AttributeCollection(params System.Attribute[] attributes) { } - protected virtual System.Attribute[] Attributes { get; } - public bool Contains(System.Attribute attribute) { return default(bool); } - public bool Contains(System.Attribute[] attributes) { return default(bool); } + protected virtual System.Attribute[] Attributes { get { throw null; } } + public int Count { get { throw null; } } + public virtual System.Attribute this[int index] { get { throw null; } } + 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; } } + public bool Contains(System.Attribute attribute) { throw null; } + public bool Contains(System.Attribute[] attributes) { throw null; } public void CopyTo(System.Array array, int index) { } - public int Count { get; } - public static System.ComponentModel.AttributeCollection FromExisting(System.ComponentModel.AttributeCollection existing, params System.Attribute[] newAttributes) { return default(System.ComponentModel.AttributeCollection); } - protected System.Attribute GetDefaultAttribute(System.Type attributeType) { return default(System.Attribute); } - public System.Collections.IEnumerator GetEnumerator() { return default(System.Collections.IEnumerator); } - bool System.Collections.ICollection.IsSynchronized { get; } - public bool Matches(System.Attribute attribute) { return default(bool); } - public bool Matches(System.Attribute[] attributes) { return default(bool); } - object System.Collections.ICollection.SyncRoot { get; } - public virtual System.Attribute this[int index] { get { return default(System.Attribute); } } - public virtual System.Attribute this[System.Type attributeType] { get { return default(System.Attribute); } } + public static System.ComponentModel.AttributeCollection FromExisting(System.ComponentModel.AttributeCollection existing, params System.Attribute[] newAttributes) { throw null; } + protected System.Attribute GetDefaultAttribute(System.Type attributeType) { throw null; } + public System.Collections.IEnumerator GetEnumerator() { throw null; } + public bool Matches(System.Attribute attribute) { throw null; } + public bool Matches(System.Attribute[] attributes) { throw null; } } + [System.AttributeUsageAttribute((System.AttributeTargets)(128))] public partial class AttributeProviderAttribute : System.Attribute { public AttributeProviderAttribute(string typeName) { } public AttributeProviderAttribute(string typeName, string propertyName) { } public AttributeProviderAttribute(System.Type type) { } - public string PropertyName { get; } - public string TypeName { get; } + public string PropertyName { get { throw null; } } + public string TypeName { get { throw null; } } } public abstract partial class BaseNumberConverter : System.ComponentModel.TypeConverter { protected BaseNumberConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type t) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 partial class BooleanConverter : System.ComponentModel.TypeConverter { public BooleanConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return default(System.ComponentModel.TypeConverter.StandardValuesCollection); } - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { throw null; } + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } } public partial class ByteConverter : System.ComponentModel.BaseNumberConverter { @@ -67,9 +79,9 @@ namespace System.ComponentModel public partial class CharConverter : System.ComponentModel.TypeConverter { public CharConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { 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 enum CollectionChangeAction { @@ -80,71 +92,85 @@ namespace System.ComponentModel public partial class CollectionChangeEventArgs : System.EventArgs { public CollectionChangeEventArgs(System.ComponentModel.CollectionChangeAction action, object element) { } - public virtual System.ComponentModel.CollectionChangeAction Action { get; } - public virtual object Element { get; } + public virtual System.ComponentModel.CollectionChangeAction Action { get { throw null; } } + public virtual object Element { get { throw null; } } } public delegate void CollectionChangeEventHandler(object sender, System.ComponentModel.CollectionChangeEventArgs e); public partial class CollectionConverter : System.ComponentModel.TypeConverter { public CollectionConverter() { } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } - public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; } + public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + } + public partial class Component : System.IDisposable + { + public Component() { } + protected virtual bool CanRaiseEvents { get { throw null; } } + protected bool DesignMode { get { throw null; } } + public virtual System.ComponentModel.ISite Site { get { throw null; } set { } } + public void Dispose() { } + protected virtual void Dispose(bool disposing) { } + ~Component() { } + protected virtual object GetService(System.Type service) { throw null; } + public override string ToString() { throw null; } } public abstract partial class CustomTypeDescriptor : System.ComponentModel.ICustomTypeDescriptor { protected CustomTypeDescriptor() { } protected CustomTypeDescriptor(System.ComponentModel.ICustomTypeDescriptor parent) { } - public virtual System.ComponentModel.AttributeCollection GetAttributes() { return default(System.ComponentModel.AttributeCollection); } - public virtual string GetClassName() { return default(string); } - public virtual string GetComponentName() { return default(string); } - public virtual System.ComponentModel.TypeConverter GetConverter() { return default(System.ComponentModel.TypeConverter); } - public virtual System.ComponentModel.EventDescriptor GetDefaultEvent() { return default(System.ComponentModel.EventDescriptor); } - public virtual System.ComponentModel.PropertyDescriptor GetDefaultProperty() { return default(System.ComponentModel.PropertyDescriptor); } - public virtual object GetEditor(System.Type editorBaseType) { return default(object); } - public virtual System.ComponentModel.EventDescriptorCollection GetEvents() { return default(System.ComponentModel.EventDescriptorCollection); } - public virtual System.ComponentModel.EventDescriptorCollection GetEvents(System.Attribute[] attributes) { return default(System.ComponentModel.EventDescriptorCollection); } - public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties() { return default(System.ComponentModel.PropertyDescriptorCollection); } - public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public virtual object GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd) { return default(object); } + public virtual System.ComponentModel.AttributeCollection GetAttributes() { throw null; } + public virtual string GetClassName() { throw null; } + public virtual string GetComponentName() { throw null; } + public virtual System.ComponentModel.TypeConverter GetConverter() { throw null; } + public virtual System.ComponentModel.EventDescriptor GetDefaultEvent() { throw null; } + public virtual System.ComponentModel.PropertyDescriptor GetDefaultProperty() { throw null; } + public virtual object GetEditor(System.Type editorBaseType) { throw null; } + public virtual System.ComponentModel.EventDescriptorCollection GetEvents() { throw null; } + public virtual System.ComponentModel.EventDescriptorCollection GetEvents(System.Attribute[] attributes) { throw null; } + public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties() { throw null; } + public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Attribute[] attributes) { throw null; } + public virtual object GetPropertyOwner(System.ComponentModel.PropertyDescriptor pd) { throw null; } } public partial class DateTimeConverter : System.ComponentModel.TypeConverter { public DateTimeConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 partial class DateTimeOffsetConverter : System.ComponentModel.TypeConverter { public DateTimeOffsetConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 partial class DecimalConverter : System.ComponentModel.BaseNumberConverter { public DecimalConverter() { } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } + public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { throw null; } + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; } } + [System.AttributeUsageAttribute((System.AttributeTargets)(4))] public sealed partial class DefaultEventAttribute : System.Attribute { public static readonly System.ComponentModel.DefaultEventAttribute Default; public DefaultEventAttribute(string name) { } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } - public string Name { get; } + public string Name { get { throw null; } } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } } + [System.AttributeUsageAttribute((System.AttributeTargets)(4))] public sealed partial class DefaultPropertyAttribute : System.Attribute { public static readonly System.ComponentModel.DefaultPropertyAttribute Default; public DefaultPropertyAttribute(string name) { } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } - public string Name { get; } + public string Name { get { throw null; } } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } } public partial class DoubleConverter : System.ComponentModel.BaseNumberConverter { @@ -153,27 +179,27 @@ namespace System.ComponentModel public partial class EnumConverter : System.ComponentModel.TypeConverter { public EnumConverter(System.Type type) { } - protected System.Type EnumType { get { return default(System.Type); } } - protected virtual System.Collections.IComparer Comparer { get; } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return default(System.ComponentModel.TypeConverter.StandardValuesCollection); } - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public override bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) { return default(bool); } - protected System.ComponentModel.TypeConverter.StandardValuesCollection Values { get; set; } + protected virtual System.Collections.IComparer Comparer { get { throw null; } } + protected System.Type EnumType { get { throw null; } } + protected System.ComponentModel.TypeConverter.StandardValuesCollection Values { get { throw null; } set { } } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) { throw null; } } public abstract partial class EventDescriptor : System.ComponentModel.MemberDescriptor { - protected EventDescriptor(System.ComponentModel.MemberDescriptor descr) : base(default(System.ComponentModel.MemberDescriptor)) { } - protected EventDescriptor(System.ComponentModel.MemberDescriptor descr, System.Attribute[] attrs) : base(default(System.ComponentModel.MemberDescriptor), default(System.Attribute[])) { } - protected EventDescriptor(string name, System.Attribute[] attrs) : base(default(string), default(System.Attribute[])) { } - public abstract void AddEventHandler(object component, System.Delegate value); + protected EventDescriptor(System.ComponentModel.MemberDescriptor descr) : base (default(string)) { } + protected EventDescriptor(System.ComponentModel.MemberDescriptor descr, System.Attribute[] attrs) : base (default(string)) { } + protected EventDescriptor(string name, System.Attribute[] attrs) : base (default(string)) { } public abstract System.Type ComponentType { get; } public abstract System.Type EventType { get; } public abstract bool IsMulticast { get; } + public abstract void AddEventHandler(object component, System.Delegate value); public abstract void RemoveEventHandler(object component, System.Delegate value); } public partial class EventDescriptorCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList @@ -181,58 +207,59 @@ namespace System.ComponentModel public static readonly System.ComponentModel.EventDescriptorCollection Empty; public EventDescriptorCollection(System.ComponentModel.EventDescriptor[] events) { } public EventDescriptorCollection(System.ComponentModel.EventDescriptor[] events, bool readOnly) { } - int System.Collections.IList.Add(object value) { return default(int); } - bool System.Collections.IList.Contains(object value) { return default(bool); } - public int Count { get; } - int System.Collections.IList.IndexOf(object value) { return default(int); } - void System.Collections.IList.Insert(int index, object value) { } - bool System.Collections.ICollection.IsSynchronized { get; } - object System.Collections.ICollection.SyncRoot { get; } - bool System.Collections.IList.IsFixedSize { get; } - bool System.Collections.IList.IsReadOnly { get; } - void System.Collections.IList.Remove(object value) { } - object System.Collections.IList.this[int index] { get { return default(object); } set { } } - public virtual System.ComponentModel.EventDescriptor this[int index] { get { return default(System.ComponentModel.EventDescriptor); } } - public virtual System.ComponentModel.EventDescriptor this[string name] { get { return default(System.ComponentModel.EventDescriptor); } } - public int Add(System.ComponentModel.EventDescriptor value) { return default(int); } + public int Count { get { throw null; } } + public virtual System.ComponentModel.EventDescriptor this[int index] { get { throw null; } } + public virtual System.ComponentModel.EventDescriptor this[string name] { get { throw null; } } + bool System.Collections.ICollection.IsSynchronized { get { throw null; } } + object System.Collections.ICollection.SyncRoot { get { throw null; } } + bool System.Collections.IList.IsFixedSize { get { throw null; } } + bool System.Collections.IList.IsReadOnly { get { throw null; } } + object System.Collections.IList.this[int index] { get { throw null; } set { } } + public int Add(System.ComponentModel.EventDescriptor value) { throw null; } public void Clear() { } - public bool Contains(System.ComponentModel.EventDescriptor value) { return default(bool); } - public virtual System.ComponentModel.EventDescriptor Find(string name, bool ignoreCase) { return default(System.ComponentModel.EventDescriptor); } - public System.Collections.IEnumerator GetEnumerator() { return default(System.Collections.IEnumerator); } - public int IndexOf(System.ComponentModel.EventDescriptor value) { return default(int); } + public bool Contains(System.ComponentModel.EventDescriptor value) { throw null; } + public virtual System.ComponentModel.EventDescriptor Find(string name, bool ignoreCase) { throw null; } + public System.Collections.IEnumerator GetEnumerator() { throw null; } + public int IndexOf(System.ComponentModel.EventDescriptor value) { throw null; } public void Insert(int index, System.ComponentModel.EventDescriptor value) { } protected void InternalSort(System.Collections.IComparer sorter) { } protected void InternalSort(string[] names) { } public void Remove(System.ComponentModel.EventDescriptor value) { } public void RemoveAt(int index) { } - public virtual System.ComponentModel.EventDescriptorCollection Sort() { return default(System.ComponentModel.EventDescriptorCollection); } - public virtual System.ComponentModel.EventDescriptorCollection Sort(System.Collections.IComparer comparer) { return default(System.ComponentModel.EventDescriptorCollection); } - public virtual System.ComponentModel.EventDescriptorCollection Sort(string[] names) { return default(System.ComponentModel.EventDescriptorCollection); } - public virtual System.ComponentModel.EventDescriptorCollection Sort(string[] names, System.Collections.IComparer comparer) { return default(System.ComponentModel.EventDescriptorCollection); } + public virtual System.ComponentModel.EventDescriptorCollection Sort() { throw null; } + public virtual System.ComponentModel.EventDescriptorCollection Sort(System.Collections.IComparer comparer) { throw null; } + public virtual System.ComponentModel.EventDescriptorCollection Sort(string[] names) { throw null; } + public virtual System.ComponentModel.EventDescriptorCollection Sort(string[] names, System.Collections.IComparer comparer) { throw null; } void System.Collections.ICollection.CopyTo(System.Array array, int index) { } + int System.Collections.IList.Add(object value) { throw null; } + bool System.Collections.IList.Contains(object value) { throw null; } + 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) { } } + [System.AttributeUsageAttribute((System.AttributeTargets)(32767))] public sealed partial class ExtenderProvidedPropertyAttribute : System.Attribute { public ExtenderProvidedPropertyAttribute() { } - public System.ComponentModel.PropertyDescriptor ExtenderProperty { get; } - public System.ComponentModel.IExtenderProvider Provider { get; } - public System.Type ReceiverType { get; } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } + public System.ComponentModel.PropertyDescriptor ExtenderProperty { get { throw null; } } + public System.ComponentModel.IExtenderProvider Provider { get { throw null; } } + public System.Type ReceiverType { get { throw null; } } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } } public partial class GuidConverter : System.ComponentModel.TypeConverter { public GuidConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 partial class HandledEventArgs : System.EventArgs { public HandledEventArgs() { } public HandledEventArgs(bool defaultHandledValue) { } - public bool Handled { get; set; } + public bool Handled { get { throw null; } set { } } } public delegate void HandledEventHandler(object sender, System.ComponentModel.HandledEventArgs e); public partial interface ICustomTypeDescriptor @@ -254,6 +281,7 @@ namespace System.ComponentModel { bool CanExtend(object extendee); } + [System.ComponentModel.MergablePropertyAttribute(false)] public partial interface IListSource { bool ContainsListCollection { get; } @@ -277,6 +305,18 @@ namespace System.ComponentModel public InvalidAsynchronousStateException(string message) { } public InvalidAsynchronousStateException(string message, System.Exception innerException) { } } + public partial interface ISupportInitialize + { + void BeginInit(); + void EndInit(); + } + 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); + } public partial interface ITypeDescriptorContext : System.IServiceProvider { System.ComponentModel.IContainer Container { get; } @@ -296,142 +336,143 @@ namespace System.ComponentModel protected MemberDescriptor(System.ComponentModel.MemberDescriptor oldMemberDescriptor, System.Attribute[] newAttributes) { } protected MemberDescriptor(string name) { } protected MemberDescriptor(string name, System.Attribute[] attributes) { } - protected virtual System.Attribute[] AttributeArray { get; set; } - public virtual System.ComponentModel.AttributeCollection Attributes { get; } - public virtual string Category { get; } - public virtual string Description { get; } - public virtual bool DesignTimeOnly { get; } - public virtual string DisplayName { get; } - public virtual bool IsBrowsable { get; } - public virtual string Name { get; } - protected virtual int NameHashCode { get; } - protected virtual System.ComponentModel.AttributeCollection CreateAttributeCollection() { return default(System.ComponentModel.AttributeCollection); } - public override bool Equals(object obj) { return default(bool); } + protected virtual System.Attribute[] AttributeArray { get { throw null; } set { } } + public virtual System.ComponentModel.AttributeCollection Attributes { get { throw null; } } + public virtual string Category { get { throw null; } } + public virtual string Description { get { throw null; } } + public virtual bool DesignTimeOnly { get { throw null; } } + public virtual string DisplayName { get { throw null; } } + public virtual bool IsBrowsable { get { throw null; } } + public virtual string Name { get { throw null; } } + protected virtual int NameHashCode { get { throw null; } } + protected virtual System.ComponentModel.AttributeCollection CreateAttributeCollection() { throw null; } + public override bool Equals(object obj) { throw null; } protected virtual void FillAttributes(System.Collections.IList attributeList) { } - protected static System.Reflection.MethodInfo FindMethod(System.Type componentClass, string name, System.Type[] args, System.Type returnType) { return default(System.Reflection.MethodInfo); } - protected static System.Reflection.MethodInfo FindMethod(System.Type componentClass, string name, System.Type[] args, System.Type returnType, bool publicOnly) { return default(System.Reflection.MethodInfo); } - public override int GetHashCode() { return default(int); } - protected virtual object GetInvocationTarget(System.Type type, object instance) { return default(object); } - protected static System.ComponentModel.ISite GetSite(object component) { return default(System.ComponentModel.ISite); } + protected static System.Reflection.MethodInfo FindMethod(System.Type componentClass, string name, System.Type[] args, System.Type returnType) { throw null; } + protected static System.Reflection.MethodInfo FindMethod(System.Type componentClass, string name, System.Type[] args, System.Type returnType, bool publicOnly) { throw null; } + 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; } } public partial class MultilineStringConverter : System.ComponentModel.TypeConverter { public MultilineStringConverter() { } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } - public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; } + public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } } public partial class NullableConverter : System.ComponentModel.TypeConverter { public NullableConverter(System.Type type) { } - public System.Type NullableType { get { return default(System.Type); } } - public System.Type UnderlyingType { get { return default(System.Type); } } - public System.ComponentModel.TypeConverter UnderlyingTypeConverter { get { return default(System.ComponentModel.TypeConverter); } } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } - public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return default(object); } - public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return default(System.ComponentModel.TypeConverter.StandardValuesCollection); } - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public override bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) { return default(bool); } + public System.Type NullableType { get { throw null; } } + public System.Type UnderlyingType { get { throw null; } } + public System.ComponentModel.TypeConverter UnderlyingTypeConverter { get { throw null; } } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; } + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) { throw null; } } public abstract partial class PropertyDescriptor : System.ComponentModel.MemberDescriptor { - protected PropertyDescriptor(System.ComponentModel.MemberDescriptor descr) : base(default(System.ComponentModel.MemberDescriptor)) { } - protected PropertyDescriptor(System.ComponentModel.MemberDescriptor descr, System.Attribute[] attrs) : base(default(System.ComponentModel.MemberDescriptor), default(System.Attribute[])) { } - protected PropertyDescriptor(string name, System.Attribute[] attrs) : base(default(string), default(System.Attribute[])) { } + protected PropertyDescriptor(System.ComponentModel.MemberDescriptor descr) : base (default(string)) { } + protected PropertyDescriptor(System.ComponentModel.MemberDescriptor descr, System.Attribute[] attrs) : base (default(string)) { } + protected PropertyDescriptor(string name, System.Attribute[] attrs) : base (default(string)) { } public abstract System.Type ComponentType { get; } - public virtual System.ComponentModel.TypeConverter Converter { get; } - public virtual bool IsLocalizable { get; } + public virtual System.ComponentModel.TypeConverter Converter { get { throw null; } } + public virtual bool IsLocalizable { get { throw null; } } public abstract bool IsReadOnly { get; } public abstract System.Type PropertyType { get; } - public virtual bool SupportsChangeEvents { get; } + public System.ComponentModel.DesignerSerializationVisibility SerializationVisibility { get { throw null; } } + public virtual bool SupportsChangeEvents { get { throw null; } } public virtual void AddValueChanged(object component, System.EventHandler handler) { } public abstract bool CanResetValue(object component); - protected object CreateInstance(System.Type type) { return default(object); } - public override bool Equals(object obj) { return default(bool); } + protected object CreateInstance(System.Type type) { throw null; } + public override bool Equals(object obj) { throw null; } protected override void FillAttributes(System.Collections.IList attributeList) { } - public System.ComponentModel.PropertyDescriptorCollection GetChildProperties() { return default(System.ComponentModel.PropertyDescriptorCollection); } - public System.ComponentModel.PropertyDescriptorCollection GetChildProperties(System.Attribute[] filter) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public System.ComponentModel.PropertyDescriptorCollection GetChildProperties(object instance) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public virtual System.ComponentModel.PropertyDescriptorCollection GetChildProperties(object instance, System.Attribute[] filter) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public virtual object GetEditor(System.Type editorBaseType) { return default(object);} - public override int GetHashCode() { return default(int); } - protected override object GetInvocationTarget(System.Type type, object instance) { return default(object); } - protected System.Type GetTypeFromName(string typeName) { return default(System.Type); } + public System.ComponentModel.PropertyDescriptorCollection GetChildProperties() { throw null; } + public System.ComponentModel.PropertyDescriptorCollection GetChildProperties(System.Attribute[] filter) { throw null; } + public System.ComponentModel.PropertyDescriptorCollection GetChildProperties(object instance) { throw null; } + public virtual System.ComponentModel.PropertyDescriptorCollection GetChildProperties(object instance, System.Attribute[] filter) { throw null; } + public virtual object GetEditor(System.Type editorBaseType) { throw null; } + public override int GetHashCode() { throw null; } + protected override object GetInvocationTarget(System.Type type, object instance) { throw null; } + protected System.Type GetTypeFromName(string typeName) { throw null; } public abstract object GetValue(object component); - protected internal System.EventHandler GetValueChangedHandler(object component) { return default(System.EventHandler); } + protected internal System.EventHandler GetValueChangedHandler(object component) { throw null; } protected virtual void OnValueChanged(object component, System.EventArgs e) { } public virtual void RemoveValueChanged(object component, System.EventHandler handler) { } public abstract void ResetValue(object component); - public System.ComponentModel.DesignerSerializationVisibility SerializationVisibility { get { return default(System.ComponentModel.DesignerSerializationVisibility); } } public abstract void SetValue(object component, object value); public abstract bool ShouldSerializeValue(object component); } - public partial class PropertyDescriptorCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IDictionary, System.Collections.IList + public partial class PropertyDescriptorCollection : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable, System.Collections.IList { public static readonly System.ComponentModel.PropertyDescriptorCollection Empty; public PropertyDescriptorCollection(System.ComponentModel.PropertyDescriptor[] properties) { } public PropertyDescriptorCollection(System.ComponentModel.PropertyDescriptor[] properties, bool readOnly) { } - public int Count { get; } - bool System.Collections.ICollection.IsSynchronized { get; } - object System.Collections.ICollection.SyncRoot { get; } - bool System.Collections.IDictionary.IsFixedSize { get; } - void System.Collections.IDictionary.Add(object key, object value) { } - bool System.Collections.IDictionary.Contains(object key) { return default(bool); } - object System.Collections.IDictionary.this[object key] { get { return default(object); } set { } } - void System.Collections.IDictionary.Remove(object key) { } - bool System.Collections.IDictionary.IsReadOnly { get; } - System.Collections.IDictionaryEnumerator System.Collections.IDictionary.GetEnumerator() { return default(System.Collections.IDictionaryEnumerator); } - System.Collections.ICollection System.Collections.IDictionary.Keys { get; } - System.Collections.ICollection System.Collections.IDictionary.Values { get; } - bool System.Collections.IList.IsFixedSize { get; } - bool System.Collections.IList.IsReadOnly { get; } - int System.Collections.IList.Add(object value) { return default(int); } - void System.Collections.IList.Remove(object value) { } - bool System.Collections.IList.Contains(object value) { return default(bool); } - int System.Collections.IList.IndexOf(object value) { return default(int); } - void System.Collections.IList.Insert(int index, object value) { } - object System.Collections.IList.this[int index] { get { return default(object); } set { } } - public virtual System.ComponentModel.PropertyDescriptor this[int index] { get { return default(System.ComponentModel.PropertyDescriptor); } } - public virtual System.ComponentModel.PropertyDescriptor this[string name] { get { return default(System.ComponentModel.PropertyDescriptor); } } - public int Add(System.ComponentModel.PropertyDescriptor value) { return default(int); } + public int Count { get { throw null; } } + public virtual System.ComponentModel.PropertyDescriptor this[int index] { get { throw null; } } + public virtual System.ComponentModel.PropertyDescriptor this[string name] { get { throw null; } } + bool System.Collections.ICollection.IsSynchronized { get { throw null; } } + object System.Collections.ICollection.SyncRoot { get { throw null; } } + bool System.Collections.IDictionary.IsFixedSize { get { throw null; } } + bool System.Collections.IDictionary.IsReadOnly { get { throw null; } } + object System.Collections.IDictionary.this[object key] { get { throw null; } set { } } + System.Collections.ICollection System.Collections.IDictionary.Keys { get { throw null; } } + System.Collections.ICollection System.Collections.IDictionary.Values { get { throw null; } } + bool System.Collections.IList.IsFixedSize { get { throw null; } } + bool System.Collections.IList.IsReadOnly { get { throw null; } } + object System.Collections.IList.this[int index] { get { throw null; } set { } } + public int Add(System.ComponentModel.PropertyDescriptor value) { throw null; } public void Clear() { } - public bool Contains(System.ComponentModel.PropertyDescriptor value) { return default(bool); } + public bool Contains(System.ComponentModel.PropertyDescriptor value) { throw null; } public void CopyTo(System.Array array, int index) { } - public virtual System.ComponentModel.PropertyDescriptor Find(string name, bool ignoreCase) { return default(System.ComponentModel.PropertyDescriptor); } - public virtual System.Collections.IEnumerator GetEnumerator() { return default(System.Collections.IEnumerator); } - public int IndexOf(System.ComponentModel.PropertyDescriptor value) { return default(int); } + public virtual System.ComponentModel.PropertyDescriptor Find(string name, bool ignoreCase) { throw null; } + public virtual System.Collections.IEnumerator GetEnumerator() { throw null; } + public int IndexOf(System.ComponentModel.PropertyDescriptor value) { throw null; } public void Insert(int index, System.ComponentModel.PropertyDescriptor value) { } protected void InternalSort(System.Collections.IComparer sorter) { } protected void InternalSort(string[] names) { } public void Remove(System.ComponentModel.PropertyDescriptor value) { } public void RemoveAt(int index) { } - public virtual System.ComponentModel.PropertyDescriptorCollection Sort() { return default(System.ComponentModel.PropertyDescriptorCollection); } - public virtual System.ComponentModel.PropertyDescriptorCollection Sort(System.Collections.IComparer comparer) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public virtual System.ComponentModel.PropertyDescriptorCollection Sort(string[] names) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public virtual System.ComponentModel.PropertyDescriptorCollection Sort(string[] names, System.Collections.IComparer comparer) { return default(System.ComponentModel.PropertyDescriptorCollection); } + public virtual System.ComponentModel.PropertyDescriptorCollection Sort() { throw null; } + public virtual System.ComponentModel.PropertyDescriptorCollection Sort(System.Collections.IComparer comparer) { throw null; } + public virtual System.ComponentModel.PropertyDescriptorCollection Sort(string[] names) { throw null; } + public virtual System.ComponentModel.PropertyDescriptorCollection Sort(string[] names, System.Collections.IComparer comparer) { throw null; } + void System.Collections.IDictionary.Add(object key, object value) { } + bool System.Collections.IDictionary.Contains(object key) { throw null; } + System.Collections.IDictionaryEnumerator System.Collections.IDictionary.GetEnumerator() { throw null; } + void System.Collections.IDictionary.Remove(object key) { } + int System.Collections.IList.Add(object value) { throw null; } + bool System.Collections.IList.Contains(object value) { throw null; } + 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) { } } + [System.AttributeUsageAttribute((System.AttributeTargets)(4), AllowMultiple=true)] public sealed partial class ProvidePropertyAttribute : System.Attribute { public ProvidePropertyAttribute(string propertyName, string receiverTypeName) { } public ProvidePropertyAttribute(string propertyName, System.Type receiverType) { } - public string PropertyName { get; } - public string ReceiverTypeName { get; } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } + public string PropertyName { get { throw null; } } + public string ReceiverTypeName { get { throw null; } } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } } public partial class RefreshEventArgs : System.EventArgs { public RefreshEventArgs(object componentChanged) { } public RefreshEventArgs(System.Type typeChanged) { } - public object ComponentChanged { get; } - public System.Type TypeChanged { get; } + public object ComponentChanged { get { throw null; } } + public System.Type TypeChanged { get { throw null; } } } public delegate void RefreshEventHandler(System.ComponentModel.RefreshEventArgs e); public partial class SByteConverter : System.ComponentModel.BaseNumberConverter @@ -445,78 +486,78 @@ namespace System.ComponentModel public partial class StringConverter : System.ComponentModel.TypeConverter { public StringConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { throw null; } } public partial class TimeSpanConverter : System.ComponentModel.TypeConverter { public TimeSpanConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 partial class TypeConverter { public TypeConverter() { } - public virtual bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public bool CanConvertFrom(System.Type sourceType) { return default(bool); } - public virtual bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public bool CanConvertTo(System.Type destinationType) { return default(bool); } - public virtual object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public object ConvertFrom(object value) { return default(object); } - public object ConvertFromInvariantString(System.ComponentModel.ITypeDescriptorContext context, string text) { return default(object); } - public object ConvertFromInvariantString(string text) { return default(object); } - public object ConvertFromString(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, string text) { return default(object); } - public object ConvertFromString(System.ComponentModel.ITypeDescriptorContext context, string text) { return default(object); } - public object ConvertFromString(string text) { return default(object); } - public virtual object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } - public object ConvertTo(object value, System.Type destinationType) { return default(object); } - public string ConvertToInvariantString(System.ComponentModel.ITypeDescriptorContext context, object value) { return default(string); } - public string ConvertToInvariantString(object value) { return default(string); } - public string ConvertToString(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(string); } - public string ConvertToString(System.ComponentModel.ITypeDescriptorContext context, object value) { return default(string); } - public string ConvertToString(object value) { return default(string); } - public object CreateInstance(System.Collections.IDictionary propertyValues) { return default(object); } - public virtual object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { return default(object); } - protected System.Exception GetConvertFromException(object value) { return default(System.Exception); } - protected System.Exception GetConvertToException(object value, System.Type destinationType) { return default(System.Exception); } - public bool GetCreateInstanceSupported() { return default(bool); } - public virtual bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public System.ComponentModel.PropertyDescriptorCollection GetProperties(object value) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public bool GetPropertiesSupported() { return default(bool); } - public virtual bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public System.Collections.ICollection GetStandardValues() { return default(System.Collections.ICollection); } - public virtual System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return default(System.ComponentModel.TypeConverter.StandardValuesCollection); } - public bool GetStandardValuesExclusive() { return default(bool); } - public virtual bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public bool GetStandardValuesSupported() { return default(bool); } - public virtual bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public virtual bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) { return default(bool); } - public bool IsValid(object value) { return default(bool); } - protected System.ComponentModel.PropertyDescriptorCollection SortProperties(System.ComponentModel.PropertyDescriptorCollection props, string[] names) { return default(System.ComponentModel.PropertyDescriptorCollection); } + public virtual bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + public bool CanConvertFrom(System.Type sourceType) { throw null; } + public virtual bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { throw null; } + public bool CanConvertTo(System.Type destinationType) { throw null; } + public virtual object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { throw null; } + public object ConvertFrom(object value) { throw null; } + public object ConvertFromInvariantString(System.ComponentModel.ITypeDescriptorContext context, string text) { throw null; } + public object ConvertFromInvariantString(string text) { throw null; } + public object ConvertFromString(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, string text) { throw null; } + public object ConvertFromString(System.ComponentModel.ITypeDescriptorContext context, string text) { throw null; } + public object ConvertFromString(string text) { throw null; } + public virtual object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { throw null; } + public object ConvertTo(object value, System.Type destinationType) { throw null; } + public string ConvertToInvariantString(System.ComponentModel.ITypeDescriptorContext context, object value) { throw null; } + public string ConvertToInvariantString(object value) { throw null; } + public string ConvertToString(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { throw null; } + public string ConvertToString(System.ComponentModel.ITypeDescriptorContext context, object value) { throw null; } + public string ConvertToString(object value) { throw null; } + public object CreateInstance(System.Collections.IDictionary propertyValues) { throw null; } + public virtual object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; } + protected System.Exception GetConvertFromException(object value) { throw null; } + protected System.Exception GetConvertToException(object value, System.Type destinationType) { throw null; } + public bool GetCreateInstanceSupported() { throw null; } + public virtual bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value) { throw null; } + public virtual System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public System.ComponentModel.PropertyDescriptorCollection GetProperties(object value) { throw null; } + public bool GetPropertiesSupported() { throw null; } + public virtual bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public System.Collections.ICollection GetStandardValues() { throw null; } + public virtual System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public bool GetStandardValuesExclusive() { throw null; } + public virtual bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public bool GetStandardValuesSupported() { throw null; } + public virtual bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public virtual bool IsValid(System.ComponentModel.ITypeDescriptorContext context, object value) { throw null; } + public bool IsValid(object value) { throw null; } + protected System.ComponentModel.PropertyDescriptorCollection SortProperties(System.ComponentModel.PropertyDescriptorCollection props, string[] names) { throw null; } protected abstract partial class SimplePropertyDescriptor : System.ComponentModel.PropertyDescriptor { - protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType) : base(default(System.ComponentModel.MemberDescriptor)) { } - protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType, System.Attribute[] attributes) : base(default(System.ComponentModel.MemberDescriptor)) { } - public override System.Type ComponentType { get; } - public override bool IsReadOnly { get; } - public override System.Type PropertyType { get; } - public override bool CanResetValue(object component) { return default(bool); } + protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType) : base (default(string), default(System.Attribute[])) { } + protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType, System.Attribute[] attributes) : base (default(string), default(System.Attribute[])) { } + public override System.Type ComponentType { get { throw null; } } + public override bool IsReadOnly { get { throw null; } } + public override System.Type PropertyType { get { throw null; } } + public override bool CanResetValue(object component) { throw null; } public override void ResetValue(object component) { } - public override bool ShouldSerializeValue(object component) { return default(bool); } + public override bool ShouldSerializeValue(object component) { throw null; } } public partial class StandardValuesCollection : System.Collections.ICollection, System.Collections.IEnumerable { public StandardValuesCollection(System.Collections.ICollection values) { } - public int Count { get; } - bool System.Collections.ICollection.IsSynchronized { get; } - object System.Collections.ICollection.SyncRoot { get; } - public object this[int index] { get { return default(object); } } + public int Count { get { throw null; } } + public object this[int index] { get { throw null; } } + bool System.Collections.ICollection.IsSynchronized { get { throw null; } } + object System.Collections.ICollection.SyncRoot { get { throw null; } } public void CopyTo(System.Array array, int index) { } - public System.Collections.IEnumerator GetEnumerator() { return default(System.Collections.IEnumerator); } + public System.Collections.IEnumerator GetEnumerator() { throw null; } } } [System.AttributeUsageAttribute((System.AttributeTargets)(32767))] @@ -526,112 +567,143 @@ namespace System.ComponentModel public TypeConverterAttribute() { } public TypeConverterAttribute(string typeName) { } public TypeConverterAttribute(System.Type type) { } - public string ConverterTypeName { get { return default(string); } } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } + public string ConverterTypeName { get { throw null; } } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } } public abstract partial class TypeDescriptionProvider { protected TypeDescriptionProvider() { } protected TypeDescriptionProvider(System.ComponentModel.TypeDescriptionProvider parent) { } - public virtual object CreateInstance(System.IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { return default(object); } - public virtual System.Collections.IDictionary GetCache(object instance) { return default(System.Collections.IDictionary); } - public virtual System.ComponentModel.ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance) { return default(System.ComponentModel.ICustomTypeDescriptor); } - protected internal virtual System.ComponentModel.IExtenderProvider[] GetExtenderProviders(object instance) { return default(System.ComponentModel.IExtenderProvider[]); } - public virtual string GetFullComponentName(object component) { return default(string); } - public System.Type GetReflectionType(object instance) { return default(System.Type); } - public System.Type GetReflectionType(System.Type objectType) { return default(System.Type); } - public virtual System.Type GetReflectionType(System.Type objectType, object instance) { return default(System.Type); } - public virtual System.Type GetRuntimeType(System.Type reflectionType) { return default(System.Type); } - public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(object instance) { return default(System.ComponentModel.ICustomTypeDescriptor); } - public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(System.Type objectType) { return default(System.ComponentModel.ICustomTypeDescriptor); } - public virtual System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(System.Type objectType, object instance) { return default(System.ComponentModel.ICustomTypeDescriptor); } - public virtual bool IsSupportedType(System.Type type) { return default(bool); } - } + public virtual object CreateInstance(System.IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { throw null; } + public virtual System.Collections.IDictionary GetCache(object instance) { throw null; } + public virtual System.ComponentModel.ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance) { throw null; } + protected internal virtual System.ComponentModel.IExtenderProvider[] GetExtenderProviders(object instance) { throw null; } + public virtual string GetFullComponentName(object component) { throw null; } + public System.Type GetReflectionType(object instance) { throw null; } + public System.Type GetReflectionType(System.Type objectType) { throw null; } + public virtual System.Type GetReflectionType(System.Type objectType, object instance) { throw null; } + public virtual System.Type GetRuntimeType(System.Type reflectionType) { throw null; } + public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(object instance) { throw null; } + public System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(System.Type objectType) { throw null; } + public virtual System.ComponentModel.ICustomTypeDescriptor GetTypeDescriptor(System.Type objectType, object instance) { throw null; } + public virtual bool IsSupportedType(System.Type type) { throw null; } + } + [System.AttributeUsageAttribute((System.AttributeTargets)(4), Inherited=true)] public sealed partial class TypeDescriptionProviderAttribute : System.Attribute { public TypeDescriptionProviderAttribute(string typeName) { } public TypeDescriptionProviderAttribute(System.Type type) { } - public string TypeName { get; } + public string TypeName { get { throw null; } } } public sealed partial class TypeDescriptor { internal TypeDescriptor() { } - public static System.Type InterfaceType { get; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.Type InterfaceType { get { throw null; } } public static event System.ComponentModel.RefreshEventHandler Refreshed { add { } remove { } } - public static System.ComponentModel.TypeDescriptionProvider AddAttributes(object instance, params System.Attribute[] attributes) { return default(System.ComponentModel.TypeDescriptionProvider); } - public static System.ComponentModel.TypeDescriptionProvider AddAttributes(System.Type type, params System.Attribute[] attributes) { return default(System.ComponentModel.TypeDescriptionProvider); } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.TypeDescriptionProvider AddAttributes(object instance, params System.Attribute[] attributes) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.TypeDescriptionProvider AddAttributes(System.Type type, params System.Attribute[] attributes) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void AddEditorTable(System.Type editorBaseType, System.Collections.Hashtable table) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void AddProvider(System.ComponentModel.TypeDescriptionProvider provider, object instance) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void AddProvider(System.ComponentModel.TypeDescriptionProvider provider, System.Type type) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void AddProviderTransparent(System.ComponentModel.TypeDescriptionProvider provider, object instance) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void AddProviderTransparent(System.ComponentModel.TypeDescriptionProvider provider, System.Type type) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void CreateAssociation(object primary, object secondary) { } - public static System.ComponentModel.EventDescriptor CreateEvent(System.Type componentType, System.ComponentModel.EventDescriptor oldEventDescriptor, params System.Attribute[] attributes) { return default(System.ComponentModel.EventDescriptor); } - public static System.ComponentModel.EventDescriptor CreateEvent(System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { return default(System.ComponentModel.EventDescriptor); } - public static object CreateInstance(System.IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { return default(object); } - public static System.ComponentModel.PropertyDescriptor CreateProperty(System.Type componentType, System.ComponentModel.PropertyDescriptor oldPropertyDescriptor, params System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptor); } - public static System.ComponentModel.PropertyDescriptor CreateProperty(System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptor); } - public static object GetAssociation(System.Type type, object primary) { return default(object); } - public static System.ComponentModel.AttributeCollection GetAttributes(object component) { return default(System.ComponentModel.AttributeCollection); } - public static System.ComponentModel.AttributeCollection GetAttributes(object component, bool noCustomTypeDesc) { return default(System.ComponentModel.AttributeCollection); } - public static System.ComponentModel.AttributeCollection GetAttributes(System.Type componentType) { return default(System.ComponentModel.AttributeCollection); } - public static string GetClassName(object component) { return default(string); } - public static string GetClassName(object component, bool noCustomTypeDesc) { return default(string); } - public static string GetClassName(System.Type componentType) { return default(string); } - public static string GetComponentName(object component) { return default(string); } - public static string GetComponentName(object component, bool noCustomTypeDesc) { return default(string); } - public static System.ComponentModel.TypeConverter GetConverter(object component) { return default(System.ComponentModel.TypeConverter); } - public static System.ComponentModel.TypeConverter GetConverter(object component, bool noCustomTypeDesc) { return default(System.ComponentModel.TypeConverter); } - public static System.ComponentModel.TypeConverter GetConverter(System.Type type) { return default(System.ComponentModel.TypeConverter); } - public static System.ComponentModel.EventDescriptor GetDefaultEvent(object component) { return default(System.ComponentModel.EventDescriptor); } - public static System.ComponentModel.EventDescriptor GetDefaultEvent(object component, bool noCustomTypeDesc) { return default(System.ComponentModel.EventDescriptor); } - public static System.ComponentModel.EventDescriptor GetDefaultEvent(System.Type componentType) { return default(System.ComponentModel.EventDescriptor); } - public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(object component) { return default(System.ComponentModel.PropertyDescriptor); } - public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(object component, bool noCustomTypeDesc) { return default(System.ComponentModel.PropertyDescriptor); } - public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(System.Type componentType) { return default(System.ComponentModel.PropertyDescriptor); } - public static object GetEditor(object component, System.Type editorBaseType) { return default(object); } - public static object GetEditor(object component, System.Type editorBaseType, bool noCustomTypeDesc) { return default(object); } - public static object GetEditor(System.Type type, System.Type editorBaseType) { return default(object); } - public static System.ComponentModel.EventDescriptorCollection GetEvents(object component) { return default(System.ComponentModel.EventDescriptorCollection); } - public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, System.Attribute[] attributes) { return default(System.ComponentModel.EventDescriptorCollection); } - public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, System.Attribute[] attributes, bool noCustomTypeDesc) { return default(System.ComponentModel.EventDescriptorCollection); } - public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, bool noCustomTypeDesc) { return default(System.ComponentModel.EventDescriptorCollection); } - public static System.ComponentModel.EventDescriptorCollection GetEvents(System.Type componentType) { return default(System.ComponentModel.EventDescriptorCollection); } - public static System.ComponentModel.EventDescriptorCollection GetEvents(System.Type componentType, System.Attribute[] attributes) { return default(System.ComponentModel.EventDescriptorCollection); } - public static string GetFullComponentName(object component) { return default(string); } - public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes, bool noCustomTypeDesc) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, bool noCustomTypeDesc) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public static System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Type componentType) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public static System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Type componentType, System.Attribute[] attributes) { return default(System.ComponentModel.PropertyDescriptorCollection); } - public static System.ComponentModel.TypeDescriptionProvider GetProvider(object instance) { return default(System.ComponentModel.TypeDescriptionProvider); } - public static System.ComponentModel.TypeDescriptionProvider GetProvider(System.Type type) { return default(System.ComponentModel.TypeDescriptionProvider); } - public static System.Type GetReflectionType(object instance) { return default(System.Type); } - public static System.Type GetReflectionType(System.Type type) { return default(System.Type); } + public static System.ComponentModel.EventDescriptor CreateEvent(System.Type componentType, System.ComponentModel.EventDescriptor oldEventDescriptor, params System.Attribute[] attributes) { throw null; } + public static System.ComponentModel.EventDescriptor CreateEvent(System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { throw null; } + public static object CreateInstance(System.IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { throw null; } + public static System.ComponentModel.PropertyDescriptor CreateProperty(System.Type componentType, System.ComponentModel.PropertyDescriptor oldPropertyDescriptor, params System.Attribute[] attributes) { throw null; } + public static System.ComponentModel.PropertyDescriptor CreateProperty(System.Type componentType, string name, System.Type type, params System.Attribute[] attributes) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static object GetAssociation(System.Type type, object primary) { throw null; } + public static System.ComponentModel.AttributeCollection GetAttributes(object component) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.AttributeCollection GetAttributes(object component, bool noCustomTypeDesc) { throw null; } + public static System.ComponentModel.AttributeCollection GetAttributes(System.Type componentType) { throw null; } + public static string GetClassName(object component) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static string GetClassName(object component, bool noCustomTypeDesc) { throw null; } + public static string GetClassName(System.Type componentType) { throw null; } + public static string GetComponentName(object component) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static string GetComponentName(object component, bool noCustomTypeDesc) { throw null; } + public static System.ComponentModel.TypeConverter GetConverter(object component) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.TypeConverter GetConverter(object component, bool noCustomTypeDesc) { throw null; } + public static System.ComponentModel.TypeConverter GetConverter(System.Type type) { throw null; } + public static System.ComponentModel.EventDescriptor GetDefaultEvent(object component) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.EventDescriptor GetDefaultEvent(object component, bool noCustomTypeDesc) { throw null; } + public static System.ComponentModel.EventDescriptor GetDefaultEvent(System.Type componentType) { throw null; } + public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(object component) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(object component, bool noCustomTypeDesc) { throw null; } + public static System.ComponentModel.PropertyDescriptor GetDefaultProperty(System.Type componentType) { throw null; } + public static object GetEditor(object component, System.Type editorBaseType) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static object GetEditor(object component, System.Type editorBaseType, bool noCustomTypeDesc) { throw null; } + public static object GetEditor(System.Type type, System.Type editorBaseType) { throw null; } + public static System.ComponentModel.EventDescriptorCollection GetEvents(object component) { throw null; } + public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, System.Attribute[] attributes) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, System.Attribute[] attributes, bool noCustomTypeDesc) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.EventDescriptorCollection GetEvents(object component, bool noCustomTypeDesc) { throw null; } + public static System.ComponentModel.EventDescriptorCollection GetEvents(System.Type componentType) { throw null; } + public static System.ComponentModel.EventDescriptorCollection GetEvents(System.Type componentType, System.Attribute[] attributes) { throw null; } + public static string GetFullComponentName(object component) { throw null; } + public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component) { throw null; } + public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes) { throw null; } + public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, System.Attribute[] attributes, bool noCustomTypeDesc) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.PropertyDescriptorCollection GetProperties(object component, bool noCustomTypeDesc) { throw null; } + public static System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Type componentType) { throw null; } + public static System.ComponentModel.PropertyDescriptorCollection GetProperties(System.Type componentType, System.Attribute[] attributes) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.TypeDescriptionProvider GetProvider(object instance) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.ComponentModel.TypeDescriptionProvider GetProvider(System.Type type) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.Type GetReflectionType(object instance) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] + public static System.Type GetReflectionType(System.Type type) { throw null; } public static void Refresh(object component) { } public static void Refresh(System.Reflection.Assembly assembly) { } public static void Refresh(System.Reflection.Module module) { } public static void Refresh(System.Type type) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void RemoveAssociation(object primary, object secondary) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void RemoveAssociations(object primary) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void RemoveProvider(System.ComponentModel.TypeDescriptionProvider provider, object instance) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void RemoveProvider(System.ComponentModel.TypeDescriptionProvider provider, System.Type type) { } + [System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(2))] public static void RemoveProviderTransparent(System.ComponentModel.TypeDescriptionProvider provider, object instance) { } + [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 abstract partial class TypeListConverter : System.ComponentModel.TypeConverter { protected TypeListConverter(System.Type[] types) { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } - public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { return default(System.ComponentModel.TypeConverter.StandardValuesCollection); } - public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } - public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { return default(bool); } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } } public partial class UInt16Converter : System.ComponentModel.BaseNumberConverter { @@ -646,50 +718,96 @@ namespace System.ComponentModel public UInt64Converter() { } } } - +namespace System.Drawing +{ + public partial class ColorConverter : System.ComponentModel.TypeConverter + { + public ColorConverter() { } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + } + public partial class PointConverter : System.ComponentModel.TypeConverter + { + public PointConverter() { } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; } + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + } + public partial class RectangleConverter : System.ComponentModel.TypeConverter + { + public RectangleConverter() { } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; } + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + } + public partial class SizeConverter : System.ComponentModel.TypeConverter + { + public SizeConverter() { } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; } + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + } + public partial class SizeFConverter : System.ComponentModel.TypeConverter + { + public SizeFConverter() { } + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { throw null; } + 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 object CreateInstance(System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues) { throw null; } + public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext context, object value, System.Attribute[] attributes) { throw null; } + public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext context) { throw null; } + } +} namespace System.Timers { + public partial class ElapsedEventArgs : System.EventArgs + { + internal ElapsedEventArgs() { } + public System.DateTime SignalTime { get { throw null; } } + } + public delegate void ElapsedEventHandler(object sender, System.Timers.ElapsedEventArgs e); public partial class Timer : System.ComponentModel.Component, System.ComponentModel.ISupportInitialize { public Timer() { } public Timer(double interval) { } + public bool AutoReset { get { throw null; } set { } } + public bool Enabled { get { throw null; } set { } } + public double Interval { get { throw null; } set { } } + public override System.ComponentModel.ISite Site { get { throw null; } set { } } + public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get { throw null; } set { } } + public event System.Timers.ElapsedEventHandler Elapsed { add { } remove { } } public void BeginInit() { } public void Close() { } protected override void Dispose(bool disposing) { } public void EndInit() { } public void Start() { } public void Stop() { } - public bool AutoReset { get { return default(bool); } set { } } - public bool Enabled { get { return default(bool); } set { } } - public double Interval { get { return default(double); } set { } } - public override System.ComponentModel.ISite Site { get { return default(System.ComponentModel.ISite); } set { } } - public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { get { return default(System.ComponentModel.ISynchronizeInvoke); } set { } } - public event ElapsedEventHandler Elapsed { add { } remove { } } } - + [System.AttributeUsageAttribute((System.AttributeTargets)(32767))] public partial class TimersDescriptionAttribute : System.ComponentModel.DescriptionAttribute { public TimersDescriptionAttribute(string description) { } - public override string Description { get { return default(string); } } - } - - public delegate void ElapsedEventHandler(object sender, ElapsedEventArgs e); - - public partial class ElapsedEventArgs : EventArgs - { - internal ElapsedEventArgs(long fileTime) { } - public DateTime SignalTime { get { return default(DateTime); } } - } -} - -namespace System -{ - public partial class UriTypeConverter : System.ComponentModel.TypeConverter - { - public UriTypeConverter() { } - public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Type sourceType) { return default(bool); } - public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Type destinationType) { return default(bool); } - public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { return default(object); } - public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType) { return default(object); } + public override string Description { get { throw null; } } } } diff --git a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.csproj b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.csproj index c75d3aaaf1..afb2b17511 100644 --- a/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.csproj +++ b/src/System.ComponentModel.TypeConverter/ref/System.ComponentModel.TypeConverter.csproj @@ -7,10 +7,13 @@ </PropertyGroup> <ItemGroup> <Compile Include="System.ComponentModel.TypeConverter.cs" /> - <Compile Include="System.ComponentModel.Manual.cs" /> </ItemGroup> <ItemGroup> <None Include="project.json" /> </ItemGroup> + <!-- TODO: Replace this with a package reference. --> + <ItemGroup> + <ProjectReference Include="..\..\System.Drawing.Primitives\pkg\System.Drawing.Primitives.pkgproj"/> + </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/src/System.ComponentModel.TypeConverter/ref/project.json b/src/System.ComponentModel.TypeConverter/ref/project.json index 0ea2b2490c..7343cb1680 100644 --- a/src/System.ComponentModel.TypeConverter/ref/project.json +++ b/src/System.ComponentModel.TypeConverter/ref/project.json @@ -1,17 +1,14 @@ { "dependencies": { - "System.Collections.NonGeneric": "4.0.0", - "System.ComponentModel": "4.0.0", - "System.ComponentModel.Primitives": "4.1.0", - "System.Globalization": "4.0.0", - "System.Reflection": "4.0.0", - "System.Runtime": "4.0.0" + "System.Collections.NonGeneric": "4.3.0-beta-24520-06", + "System.ComponentModel": "4.3.0-beta-24520-06", + "System.ComponentModel.Primitives": "4.3.0-beta-24520-06", + "System.Globalization": "4.3.0-beta-24520-06", + "System.Reflection": "4.3.0-beta-24520-06", + "System.Runtime": "4.3.0-beta-24520-06", + "System.Security.Permissions": "4.3.0-beta-24520-06" }, "frameworks": { - "netstandard1.7": { - "imports": [ - "dotnet5.8" - ] - } + "netstandard1.7": {} } } diff --git a/src/System.ComponentModel.TypeConverter/src/Resources/Strings.resx b/src/System.ComponentModel.TypeConverter/src/Resources/Strings.resx index f316fab3b3..63f9f7dea8 100644 --- a/src/System.ComponentModel.TypeConverter/src/Resources/Strings.resx +++ b/src/System.ComponentModel.TypeConverter/src/Resources/Strings.resx @@ -192,6 +192,18 @@ <data name="TypeDescriptorSameAssociation" xml:space="preserve"> <value>Cannot create an association when the primary and secondary objects are the same.</value> </data> + <data name="InvalidEx2BoundArgument" xml:space="preserve"> + <value>Value of '{1}' is not valid for '{0}'. '{0}' should be greater than or equal to {2} and less than or equal to {3}.</value> + </data> + <data name="InvalidColor" xml:space="preserve"> + <value>Color '{0}' is not valid.</value> + </data> + <data name="TextParseFailedFormat" xml:space="preserve"> + <value>Text "{0}" cannot be parsed. The expected text format is "{1}".</value> + </data> + <data name="PropertyValueInvalidEntry" xml:space="preserve"> + <value>IDictionary parameter contains at least one entry that is not valid. Ensure all values are consistent with the object's properties.</value> + </data> <data name="InvalidParameter" xml:space="preserve"> <value>Invalid value '{1}' for parameter '{0}'.</value> </data> diff --git a/src/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj b/src/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj index cc4be9940c..b63e5dd032 100644 --- a/src/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj +++ b/src/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj @@ -9,18 +9,11 @@ <NuGetTargetMoniker Condition="'$(TargetGroup)' == ''">.NETStandard,Version=v1.7</NuGetTargetMoniker> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net45_Debug|AnyCPU'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net45_Release|AnyCPU'" /> - <PropertyGroup Condition="'$(TargetGroup)'=='netstandard1.0'"> - <DefineConstants>NETSTANDARD10</DefineConstants> - </PropertyGroup> - <ItemGroup Condition="'$(TargetGroup)'=='netstandard1.0'"> - <Compile Include="System\ComponentModel\ReflectTypeDescriptionProvider.NetStandard10.cs" /> - <Compile Include="System\ComponentModel\TypeDescriptor.NetStandard10.cs" /> - </ItemGroup> - <ItemGroup Condition="'$(TargetGroup)'=='' OR '$(TargetGroup)'=='netstandard1.0'"> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.7_Debug|AnyCPU'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.7_Release|AnyCPU'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net463_Debug|AnyCPU'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net463_Release|AnyCPU'" /> + <ItemGroup Condition="'$(TargetGroup)'==''"> <Compile Include="System\ComponentModel\ArrayConverter.cs" /> <Compile Include="System\ComponentModel\BaseNumberConverter.cs" /> <Compile Include="System\ComponentModel\BooleanConverter.cs" /> @@ -51,8 +44,6 @@ <Compile Include="System\ComponentModel\UInt32Converter.cs" /> <Compile Include="System\ComponentModel\UInt64Converter.cs" /> <Compile Include="System\ComponentModel\UriTypeConverter.cs" /> - </ItemGroup> - <ItemGroup Condition="'$(TargetGroup)'==''"> <Compile Include="System\Timers\ElapsedEventArgs.cs" /> <Compile Include="System\Timers\ElapsedEventHandler.cs" /> <Compile Include="System\Timers\System.ComponentModel.cs" /> @@ -97,16 +88,27 @@ <Compile Include="System\ComponentModel\Design\IDictionaryService.cs" /> <Compile Include="System\ComponentModel\Design\IExtenderListService.cs" /> <Compile Include="System\ComponentModel\Design\ITypeDescriptorFilterService.cs" /> - </ItemGroup> - <ItemGroup Condition="'$(TargetGroup)'==''"> + <Compile Include="$(CommonPath)/System/Drawing/ColorTable.cs"> + <Link>System\Drawing\ColorTable.cs</Link> + </Compile> + <Compile Include="System\Drawing\ColorConverter.cs" /> + <Compile Include="System\Drawing\PointConverter.cs" /> + <Compile Include="System\Drawing\RectangleConverter.cs" /> + <Compile Include="System\Drawing\SizeConverter.cs" /> + <Compile Include="System\Drawing\SizeFConverter.cs" /> <EmbeddedResource Include="$(MsBuildThisFileDirectory)Resources\$(AssemblyName).rd.xml" /> </ItemGroup> <ItemGroup Condition="'$(TargetGroup)'=='net463'"> <TargetingPackReference Include="mscorlib" /> <TargetingPackReference Include="System" /> + <TargetingPackReference Include="System.Drawing" /> </ItemGroup> <ItemGroup> <None Include="project.json" /> </ItemGroup> + <!-- TODO: Replace this with a package reference. --> + <ItemGroup Condition="'$(TargetGroup)'==''"> + <ProjectReference Include="..\..\System.Drawing.Primitives\pkg\System.Drawing.Primitives.pkgproj"/> + </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ArrayConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ArrayConverter.cs index 6d39152842..7936a39c50 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ArrayConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ArrayConverter.cs @@ -30,7 +30,6 @@ namespace System.ComponentModel return base.ConvertTo(context, culture, value, destinationType); } -#if !NETSTANDARD10 /// <summary> /// <para>Gets a collection of properties for the type of array specified by the value parameter.</para> /// </summary> @@ -60,7 +59,6 @@ namespace System.ComponentModel return new PropertyDescriptorCollection(props); } -#endif // !NETSTANDARD10 /// <summary> /// <para>Gets a value indicating whether this object supports properties.</para> @@ -70,7 +68,6 @@ namespace System.ComponentModel return true; } -#if !NETSTANDARD10 private class ArrayPropertyDescriptor : SimplePropertyDescriptor { private readonly int _index; @@ -106,6 +103,5 @@ namespace System.ComponentModel } } } -#endif // !NETSTANDARD10 } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/CollectionConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/CollectionConverter.cs index d6dd22c32b..0bc4b6f448 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/CollectionConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/CollectionConverter.cs @@ -33,7 +33,6 @@ namespace System.ComponentModel return base.ConvertTo(context, culture, value, destinationType); } -#if !NETSTANDARD10 /// <summary> /// <para> /// Gets a collection of properties for the type of array specified by the value parameter using @@ -44,7 +43,6 @@ namespace System.ComponentModel { return new PropertyDescriptorCollection(null); } -#endif // !NETSTANDARD10 /// <summary> /// <para>Gets a value indicating whether this object supports properties.</para> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DateTimeOffsetConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DateTimeOffsetConverter.cs index e7c0385b84..4bd4fd4afa 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DateTimeOffsetConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/DateTimeOffsetConverter.cs @@ -22,7 +22,7 @@ namespace System.ComponentModel /// </summary> public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { - return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); + return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType); } /// <summary> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs index 5e5c1db596..e3e1b62f5f 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs @@ -99,7 +99,6 @@ namespace System.ComponentModel return base.CanConvertTo(context, destinationType); } -#if !NETSTANDARD10 /// <summary> /// <para> /// Gets an <see cref='System.Collections.IComparer'/> interface that can @@ -113,7 +112,6 @@ namespace System.ComponentModel return InvariantComparer.Default; } } -#endif // !NETSTANDARD10 /// <internalonly/> /// <summary> @@ -235,7 +233,6 @@ namespace System.ComponentModel return base.ConvertTo(context, culture, value, destinationType); } -#if !NETSTANDARD10 /// <internalonly/> /// <summary> /// <para>Gets a collection of standard values for the data type this validator is @@ -340,6 +337,5 @@ namespace System.ComponentModel { return Enum.IsDefined(_type, value); } -#endif // !NETSTANDARD10 } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MultilineStringConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MultilineStringConverter.cs index 07a5dae79a..e1364241e3 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MultilineStringConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/MultilineStringConverter.cs @@ -33,7 +33,6 @@ namespace System.ComponentModel return base.ConvertTo(context, culture, value, destinationType); } -#if !NETSTANDARD10 /// <summary> /// Gets a collection of properties for the type of array specified by the value /// parameter using the specified context and attributes. @@ -42,7 +41,6 @@ namespace System.ComponentModel { return null; } -#endif // !NETSTANDARD10 /// <summary> /// Gets a value indicating whether this object supports properties. diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs index ed587bf473..e12d6ef595 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/NullableConverter.cs @@ -155,7 +155,6 @@ namespace System.ComponentModel return base.GetCreateInstanceSupported(context); } -#if !NETSTANDARD10 /// <summary> /// <para> /// Gets a collection of properties for the type of array specified by the value @@ -172,7 +171,6 @@ namespace System.ComponentModel return base.GetProperties(context, value, attributes); } -#endif // !NETSTANDARD10 /// <summary> /// <para>Gets a value indicating whether this object supports properties using the specified context.</para> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs index 7f68e0b103..01f57c4536 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/PropertyDescriptor.cs @@ -10,13 +10,8 @@ namespace System.ComponentModel /// <summary> /// <para>Provides a description of a property.</para> /// </summary> -#if NETSTANDARD10 - public abstract class PropertyDescriptor -#else public abstract class PropertyDescriptor : MemberDescriptor -#endif { -#if !NETSTANDARD10 private TypeConverter _converter = null; private Hashtable _valueChangedHandlers; private object[] _editors; @@ -531,6 +526,5 @@ namespace System.ComponentModel return false; } } -#endif // NETSTANDARD10 } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.NetStandard10.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.NetStandard10.cs deleted file mode 100644 index 8d7ff44bfa..0000000000 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.NetStandard10.cs +++ /dev/null @@ -1,401 +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.Diagnostics; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; - -namespace System.ComponentModel -{ - /// <summary> - /// This type description provider provides type information through - /// reflection. Unless someone has provided a custom type description - /// provider for a type or instance, or unless an instance implements - /// ICustomTypeDescriptor, any query for type information will go through - /// this class. There should be a single instance of this class associated - /// with "object", as it can provide all type information for any type. - /// </summary> - internal sealed class ReflectTypeDescriptionProvider - { - // This is where we store the various converters for the intrinsic types. - // - private static volatile Dictionary<object, object> s_intrinsicConverters; - - // For converters, etc that are bound to class attribute data, rather than a class - // type, we have special key sentinel values that we put into the hash table. - // - private static object s_intrinsicNullableKey = new object(); - - private static object s_syncObject = new object(); - - /// <summary> - /// Creates a new ReflectTypeDescriptionProvider. The type is the - /// type we will obtain type information for. - /// </summary> - internal ReflectTypeDescriptionProvider() - { - } - - /// <summary> - /// This is a table we create for intrinsic types. - /// There should be entries here ONLY for intrinsic - /// types, as all other types we should be able to - /// add attributes directly as metadata. - /// </summary> - private static Dictionary<object, object> IntrinsicTypeConverters - { - get - { - Debug.Assert(Monitor.IsEntered(s_syncObject)); - - // It is not worth taking a lock for this -- worst case of a collision - // would build two tables, one that garbage collects very quickly. - // - if (ReflectTypeDescriptionProvider.s_intrinsicConverters == null) - { - Dictionary<object, object> temp = new Dictionary<object, object>(); - - // Add the intrinsics - // - temp[typeof(bool)] = typeof(BooleanConverter); - temp[typeof(byte)] = typeof(ByteConverter); - temp[typeof(SByte)] = typeof(SByteConverter); - temp[typeof(char)] = typeof(CharConverter); - temp[typeof(double)] = typeof(DoubleConverter); - temp[typeof(string)] = typeof(StringConverter); - temp[typeof(int)] = typeof(Int32Converter); - temp[typeof(short)] = typeof(Int16Converter); - temp[typeof(long)] = typeof(Int64Converter); - temp[typeof(float)] = typeof(SingleConverter); - temp[typeof(UInt16)] = typeof(UInt16Converter); - temp[typeof(UInt32)] = typeof(UInt32Converter); - temp[typeof(UInt64)] = typeof(UInt64Converter); - temp[typeof(object)] = typeof(TypeConverter); - temp[typeof(void)] = typeof(TypeConverter); - temp[typeof(DateTime)] = typeof(DateTimeConverter); - temp[typeof(DateTimeOffset)] = typeof(DateTimeOffsetConverter); - temp[typeof(Decimal)] = typeof(DecimalConverter); - temp[typeof(TimeSpan)] = typeof(TimeSpanConverter); - temp[typeof(Guid)] = typeof(GuidConverter); - temp[typeof(Array)] = typeof(ArrayConverter); - temp[typeof(ICollection)] = typeof(CollectionConverter); - temp[typeof(Enum)] = typeof(EnumConverter); - - // Special cases for things that are not bound to a specific type - // - temp[ReflectTypeDescriptionProvider.s_intrinsicNullableKey] = typeof(NullableConverter); - - ReflectTypeDescriptionProvider.s_intrinsicConverters = temp; - } - return ReflectTypeDescriptionProvider.s_intrinsicConverters; - } - } - - /// <summary> - /// Helper method to create type converters. This checks to see if the - /// type implements a Type constructor, and if it does it invokes that ctor. - /// Otherwise, it just tries to create the type. - /// </summary> - private static object CreateInstance(Type objectType, Type parameterType, ref bool noTypeConstructor) - { - ConstructorInfo typeConstructor = null; - noTypeConstructor = true; - - foreach (ConstructorInfo constructor in objectType.GetTypeInfo().DeclaredConstructors) - { - if (!constructor.IsPublic) - { - continue; - } - - // This is the signature we look for when creating types that are generic, but - // want to know what type they are dealing with. Enums are a good example of this; - // there is one enum converter that can work with all enums, but it needs to know - // the type of enum it is dealing with. - // - ParameterInfo[] parameters = constructor.GetParameters(); - if (parameters.Length != 1 || !parameters[0].ParameterType.Equals(typeof(Type))) - { - continue; - } - typeConstructor = constructor; - break; - } - - if (typeConstructor != null) - { - noTypeConstructor = false; - return typeConstructor.Invoke(new object[] { parameterType }); - } - - return Activator.CreateInstance(objectType); - } - - private static TypeConverterAttribute GetTypeConverterAttributeIfAny(Type type) - { - foreach (TypeConverterAttribute attribute in type.GetTypeInfo().GetCustomAttributes<TypeConverterAttribute>(false)) - { - return attribute; - } - return null; - } - - /// <summary> - /// Gets a type converter for the specified type. - /// </summary> - internal static TypeConverter GetConverter(Type type) - { - if (type == null) - { - throw new ArgumentNullException(nameof(type)); - } - - // Check the cached TypeConverter dictionary for an exact match of the given type. - object ans = SearchIntrinsicTable_ExactTypeMatch(type); - if (ans != null) - return (TypeConverter)ans; - - // Obtaining attributes follows a very critical order: we must take care that - // we merge attributes the right way. Consider this: - // - // [A4] - // interface IBase; - // - // [A3] - // interface IDerived; - // - // [A2] - // class Base : IBase; - // - // [A1] - // class Derived : Base, IDerived - // - // We are retrieving attributes in the following order: A1 - A4. - // Interfaces always lose to types, and interfaces and types - // must be looked up in the same order. - TypeConverterAttribute converterAttribute = ReflectTypeDescriptionProvider.GetTypeConverterAttributeIfAny(type); - if (converterAttribute == null) - { - Type baseType = type.GetTypeInfo().BaseType; - - while (baseType != null && baseType != typeof(object)) - { - converterAttribute = ReflectTypeDescriptionProvider.GetTypeConverterAttributeIfAny(baseType); - if (converterAttribute != null) - { - break; - } - baseType = baseType.GetTypeInfo().BaseType; - } - } - - if (converterAttribute == null) - { - IEnumerable<Type> interfaces = type.GetTypeInfo().ImplementedInterfaces; - foreach (Type iface in interfaces) - { - // only do this for public interfaces. - // - if ((iface.GetTypeInfo().Attributes & (TypeAttributes.Public | TypeAttributes.NestedPublic)) != 0) - { - converterAttribute = GetTypeConverterAttributeIfAny(iface); - if (converterAttribute != null) - { - break; - } - } - } - } - - if (converterAttribute != null) - { - Type converterType = ReflectTypeDescriptionProvider.GetTypeFromName(converterAttribute.ConverterTypeName, type); - if (converterType != null && typeof(TypeConverter).GetTypeInfo().IsAssignableFrom(converterType.GetTypeInfo())) - { - bool noTypeConstructor = true; - object instance = (TypeConverter)ReflectTypeDescriptionProvider.CreateInstance(converterType, type, ref noTypeConstructor); - if (noTypeConstructor) - { - lock (s_syncObject) - { - ReflectTypeDescriptionProvider.IntrinsicTypeConverters[type] = instance; - } - } - return (TypeConverter)instance; - } - } - - // We did not get a converter. Traverse up the base class chain until - // we find one in the stock hashtable. - // - return (TypeConverter)ReflectTypeDescriptionProvider.SearchIntrinsicTable(type); - } - - /// <summary> - /// Retrieve a type from a name, if the name is not a fully qualified assembly name, then - /// look for this type name in the same assembly as the "type" parameter is defined in. - /// </summary> - private static Type GetTypeFromName(string typeName, Type type) - { - if (string.IsNullOrEmpty(typeName)) - { - return null; - } - - int commaIndex = typeName.IndexOf(','); - Type t = null; - - if (commaIndex == -1) - { - t = type.GetTypeInfo().Assembly.GetType(typeName); - } - - if (t == null) - { - t = Type.GetType(typeName); - } - - return t; - } - - /// <summary> - /// Searches the provided intrinsic hashtable for a match with the object type. - /// At the beginning, the hashtable contains types for the various converters. - /// As this table is searched, the types for these objects - /// are replaced with instances, so we only create as needed. This method - /// does the search up the base class hierarchy and will create instances - /// for types as needed. These instances are stored back into the table - /// for the base type, and for the original component type, for fast access. - /// </summary> - private static object SearchIntrinsicTable(Type callingType) - { - object hashEntry = null; - - // We take a lock on this table. Nothing in this code calls out to - // other methods that lock, so it should be fairly safe to grab this - // lock. Also, this allows multiple intrinsic tables to be searched - // at once. - // - lock (ReflectTypeDescriptionProvider.s_syncObject) - { - Type baseType = callingType; - while (baseType != null && baseType != typeof(object)) - { - if (ReflectTypeDescriptionProvider.IntrinsicTypeConverters.TryGetValue(baseType, out hashEntry) && hashEntry != null) - { - break; - } - - baseType = baseType.GetTypeInfo().BaseType; - } - - TypeInfo callingTypeInfo = callingType.GetTypeInfo(); - - // Now make a scan through each value in the table, looking for interfaces. - // If we find one, see if the object implements the interface. - // - if (hashEntry == null) - { - foreach (object key in ReflectTypeDescriptionProvider.IntrinsicTypeConverters.Keys) - { - Type keyType = key as Type; - - if (keyType != null) - { - TypeInfo keyTypeInfo = keyType.GetTypeInfo(); - if (keyTypeInfo.IsInterface && keyTypeInfo.IsAssignableFrom(callingTypeInfo)) - { - ReflectTypeDescriptionProvider.IntrinsicTypeConverters.TryGetValue(key, out hashEntry); - string converterTypeString = hashEntry as string; - - if (converterTypeString != null) - { - hashEntry = Type.GetType(converterTypeString); - if (hashEntry != null) - { - ReflectTypeDescriptionProvider.IntrinsicTypeConverters[callingType] = hashEntry; - } - } - - if (hashEntry != null) - { - break; - } - } - } - } - } - - // Special case converter - // - if (hashEntry == null) - { - if (callingTypeInfo.IsGenericType && callingTypeInfo.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - // Check if it is a nullable value - ReflectTypeDescriptionProvider.IntrinsicTypeConverters.TryGetValue(ReflectTypeDescriptionProvider.s_intrinsicNullableKey, out hashEntry); - } - } - - // Interfaces do not derive from object, so we - // must handle the case of no hash entry here. - // - if (hashEntry == null) - { - ReflectTypeDescriptionProvider.IntrinsicTypeConverters.TryGetValue(typeof(object), out hashEntry); - } - - // If the entry is a type, create an instance of it and then - // replace the entry. This way we only need to create once. - // We can only do this if the object doesn't want a type - // in its constructor. - // - Type type = hashEntry as Type; - - if (type != null) - { - bool noTypeConstructor = true; - hashEntry = ReflectTypeDescriptionProvider.CreateInstance(type, callingType, ref noTypeConstructor); - if (noTypeConstructor) - { - ReflectTypeDescriptionProvider.IntrinsicTypeConverters[callingType] = hashEntry; - } - } - } - return hashEntry; - } - - private static object SearchIntrinsicTable_ExactTypeMatch(Type callingType) - { - object hashEntry = null; - - // We take a lock on this table. Nothing in this code calls out to - // other methods that lock, so it should be fairly safe to grab this - // lock. Also, this allows multiple intrinsic tables to be searched - // at once. - // - lock (s_syncObject) - { - if (callingType != null && !IntrinsicTypeConverters.TryGetValue(callingType, out hashEntry)) - return null; - - // If the entry is a type, create an instance of it and then - // replace the entry. This way we only need to create once. - // We can only do this if the object doesn't want a type - // in its constructor. - Type type = hashEntry as Type; - if (type != null) - { - bool noTypeConstructor = true; - hashEntry = CreateInstance(type, callingType, ref noTypeConstructor); - if (noTypeConstructor) - IntrinsicTypeConverters[callingType] = hashEntry; - } - } - return hashEntry; - } - } -} 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 dab3048c88..15871fdf39 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.ReflectedTypeData.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.ReflectedTypeData.cs @@ -22,7 +22,7 @@ namespace System.ComponentModel private EventDescriptorCollection _events; private PropertyDescriptorCollection _properties; private TypeConverter _converter; -#if FEATURE_EDITOR +#if FEATURE_EDITORATTRIBUTE private object[] _editors; private Type[] _editorTypes; private int _editorCount; @@ -321,7 +321,7 @@ namespace System.ComponentModel return null; } -#if FEATURE_EDITOR +#if FEATURE_EDITORATTRIBUTE /// <summary> /// Retrieves the editor for the given base type. /// </summary> @@ -577,7 +577,7 @@ namespace System.ComponentModel _events = null; _properties = null; _converter = null; -#if FEATURE_EDITOR +#if FEATURE_EDITORATTRIBUTE _editors = null; _editorTypes = null; _editorCount = 0; diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs index 98f182580a..349afc2845 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/ReflectTypeDescriptionProvider.cs @@ -7,6 +7,7 @@ using System.ComponentModel.Design; using System.Diagnostics; using System.Linq; using System.Reflection; +using System.Drawing; namespace System.ComponentModel { @@ -110,38 +111,44 @@ namespace System.ComponentModel // if (s_intrinsicTypeConverters == null) { - Hashtable temp = new Hashtable(); - // Add the intrinsics // - temp[typeof(bool)] = typeof(BooleanConverter); - temp[typeof(byte)] = typeof(ByteConverter); - temp[typeof(SByte)] = typeof(SByteConverter); - temp[typeof(char)] = typeof(CharConverter); - temp[typeof(double)] = typeof(DoubleConverter); - temp[typeof(string)] = typeof(StringConverter); - temp[typeof(int)] = typeof(Int32Converter); - temp[typeof(short)] = typeof(Int16Converter); - temp[typeof(long)] = typeof(Int64Converter); - temp[typeof(float)] = typeof(SingleConverter); - temp[typeof(UInt16)] = typeof(UInt16Converter); - temp[typeof(UInt32)] = typeof(UInt32Converter); - temp[typeof(UInt64)] = typeof(UInt64Converter); - temp[typeof(object)] = typeof(TypeConverter); - temp[typeof(void)] = typeof(TypeConverter); - temp[typeof(DateTime)] = typeof(DateTimeConverter); - temp[typeof(DateTimeOffset)] = typeof(DateTimeOffsetConverter); - temp[typeof(Decimal)] = typeof(DecimalConverter); - temp[typeof(TimeSpan)] = typeof(TimeSpanConverter); - temp[typeof(Guid)] = typeof(GuidConverter); - temp[typeof(Array)] = typeof(ArrayConverter); - temp[typeof(ICollection)] = typeof(CollectionConverter); - temp[typeof(Enum)] = typeof(EnumConverter); - temp[typeof(Uri)] = typeof(UriTypeConverter); - - // Special cases for things that are not bound to a specific type - // - temp[s_intrinsicNullableKey] = typeof(NullableConverter); + Hashtable temp = new Hashtable + { + [typeof(bool)] = typeof(BooleanConverter), + [typeof(byte)] = typeof(ByteConverter), + [typeof(SByte)] = typeof(SByteConverter), + [typeof(char)] = typeof(CharConverter), + [typeof(double)] = typeof(DoubleConverter), + [typeof(string)] = typeof(StringConverter), + [typeof(int)] = typeof(Int32Converter), + [typeof(short)] = typeof(Int16Converter), + [typeof(long)] = typeof(Int64Converter), + [typeof(float)] = typeof(SingleConverter), + [typeof(UInt16)] = typeof(UInt16Converter), + [typeof(UInt32)] = typeof(UInt32Converter), + [typeof(UInt64)] = typeof(UInt64Converter), + [typeof(object)] = typeof(TypeConverter), + [typeof(void)] = typeof(TypeConverter), + [typeof(DateTime)] = typeof(DateTimeConverter), + [typeof(DateTimeOffset)] = typeof(DateTimeOffsetConverter), + [typeof(Decimal)] = typeof(DecimalConverter), + [typeof(TimeSpan)] = typeof(TimeSpanConverter), + [typeof(Guid)] = typeof(GuidConverter), + [typeof(Uri)] = typeof(UriTypeConverter), + [typeof(Color)] = typeof(ColorConverter), + [typeof(Point)] = typeof(PointConverter), + [typeof(Rectangle)] = typeof(RectangleConverter), + [typeof(Size)] = typeof(SizeConverter), + [typeof(SizeF)] = typeof(SizeFConverter), + // Special cases for things that are not bound to a specific type + // + [typeof(Array)] = typeof(ArrayConverter), + [typeof(ICollection)] = typeof(CollectionConverter), + [typeof(Enum)] = typeof(EnumConverter), + [s_intrinsicNullableKey] = typeof(NullableConverter), + }; + s_intrinsicTypeConverters = temp; } @@ -957,7 +964,7 @@ namespace System.ComponentModel { // Get the type's attributes. // - attrs = type.GetTypeInfo().GetCustomAttributes(typeof(Attribute), false).ToArray(); + attrs = type.GetTypeInfo().GetCustomAttributes(typeof(Attribute), false).OfType<Attribute>().ToArray(); s_attributeCache[type] = attrs; } } @@ -995,7 +1002,7 @@ namespace System.ComponentModel { // Get the member's attributes. // - attrs = member.GetCustomAttributes(typeof(Attribute), false).ToArray(); + attrs = member.GetCustomAttributes(typeof(Attribute), false).OfType<Attribute>().ToArray(); s_attributeCache[member] = attrs; } } diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeConverter.cs index 1fa14acb59..48abd26d8c 100644 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeConverter.cs +++ b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeConverter.cs @@ -266,7 +266,6 @@ namespace System.ComponentModel return false; } -#if !NETSTANDARD10 /// <summary> /// <para>Gets a collection of properties for the type of array specified by the value parameter.</para> /// </summary> @@ -296,7 +295,6 @@ namespace System.ComponentModel { return null; } -#endif // !NETSTANDARD10 /// <summary> /// <para>Gets a value indicating whether this object supports properties.</para> @@ -411,7 +409,6 @@ namespace System.ComponentModel return isValid; } -#if !NETSTANDARD10 /// <summary> /// <para>Sorts a collection of properties.</para> /// </summary> @@ -519,7 +516,6 @@ namespace System.ComponentModel return false; } } -#endif // !NETSTANDARD10 /// <summary> /// <para>Represents a collection of values.</para> diff --git a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.NetStandard10.cs b/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.NetStandard10.cs deleted file mode 100644 index 4456b035d0..0000000000 --- a/src/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.NetStandard10.cs +++ /dev/null @@ -1,27 +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. - -namespace System.ComponentModel -{ - /// <summary> - /// Provides information about the properties and events - /// for a component. This class cannot be inherited. - /// - /// This is only a stub to support the TypeConverter scenario. - /// </summary> - public sealed class TypeDescriptor - { - private TypeDescriptor() - { - } - - /// <summary> - /// Gets a type converter for the specified type. - /// </summary> - public static TypeConverter GetConverter(Type type) - { - return ReflectTypeDescriptionProvider.GetConverter(type); - } - } -} diff --git a/src/System.ComponentModel.TypeConverter/src/System/Drawing/ColorConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/Drawing/ColorConverter.cs new file mode 100644 index 0000000000..eec3773dd8 --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/src/System/Drawing/ColorConverter.cs @@ -0,0 +1,299 @@ +// 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.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Reflection; +using System.Threading; + +namespace System.Drawing +{ + public class ColorConverter : TypeConverter + { + private static object s_valuesLock = new object(); + private static StandardValuesCollection s_values; + + public ColorConverter() + { + } + + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + { + return true; + } + return base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + return true; + } +#endif + return base.CanConvertTo(context, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + string strValue = value as string; + if (strValue != null) + { + string text = strValue.Trim(); + + if (text.Length == 0) + { + return Color.Empty; + } + + { + Color c; + // First, check to see if this is a standard name. + // + if (ColorTable.TryGetNamedColor(text, out c)) + { + return c; + } + } + + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + + char sep = culture.TextInfo.ListSeparator[0]; + + TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); + + // If the value is a 6 digit hex number only, then + // we want to treat the Alpha as 255, not 0 + // + if (text.IndexOf(sep) == -1) + { + // text can be '' (empty quoted string) + if (text.Length >= 2 && (text[0] == '\'' || text[0] == '"') && text[0] == text[text.Length - 1]) + { + // In quotes means a named value + string colorName = text.Substring(1, text.Length - 2); + return Color.FromName(colorName); + } + else if ((text.Length == 7 && text[0] == '#') || + (text.Length == 8 && (text.StartsWith("0x") || text.StartsWith("0X"))) || + (text.Length == 8 && (text.StartsWith("&h") || text.StartsWith("&H")))) + { + // Note: ConvertFromString will raise exception if value cannot be converted. + return PossibleKnownColor(Color.FromArgb(unchecked((int)(0xFF000000 | (uint)(int)intConverter.ConvertFromString(context, culture, text))))); + } + } + + // Nope. Parse the RGBA from the text. + // + string[] tokens = text.Split(sep); + int[] values = new int[tokens.Length]; + for (int i = 0; i < values.Length; i++) + { + values[i] = unchecked((int)intConverter.ConvertFromString(context, culture, tokens[i])); + } + + // We should now have a number of parsed integer values. + // We support 1, 3, or 4 arguments: + // + // 1 -- full ARGB encoded + // 3 -- RGB + // 4 -- ARGB + // + switch (values.Length) + { + case 1: + return PossibleKnownColor(Color.FromArgb(values[0])); + + case 3: + return PossibleKnownColor(Color.FromArgb(values[0], values[1], values[2])); + + case 4: + return PossibleKnownColor(Color.FromArgb(values[0], values[1], values[2], values[3])); + } + + throw new ArgumentException(SR.Format(SR.InvalidColor, text)); + } + return base.ConvertFrom(context, culture, value); + } + + private Color PossibleKnownColor(Color color) + { + // Now check to see if this color matches one of our known colors. + // If it does, then substitute it. We can only do this for "Colors" + // because system colors morph with user settings. + // + int targetARGB = color.ToArgb(); + + foreach (Color c in ColorTable.Colors.Values) + { + if (c.ToArgb() == targetARGB) + { + return c; + } + } + return color; + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == null) + { + throw new ArgumentNullException(nameof(destinationType)); + } + + if (value is Color) + { + if (destinationType == typeof(string)) + { + Color c = (Color)value; + + if (c == Color.Empty) + { + return string.Empty; + } + else + { + // If this is a known color, then Color can provide its own + // name. Otherwise, we fabricate an ARGB value for it. + // + if (c.IsKnownColor) + { + return c.Name; + } + else if (c.IsNamedColor) + { + return "'" + c.Name + "'"; + } + else + { + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + string sep = culture.TextInfo.ListSeparator + " "; + TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); + string[] args; + int nArg = 0; + + if (c.A < 255) + { + args = new string[4]; + args[nArg++] = intConverter.ConvertToString(context, culture, (object)c.A); + } + else + { + args = new string[3]; + } + + // Note: ConvertToString will raise exception if value cannot be converted. + args[nArg++] = intConverter.ConvertToString(context, culture, (object)c.R); + args[nArg++] = intConverter.ConvertToString(context, culture, (object)c.G); + args[nArg++] = intConverter.ConvertToString(context, culture, (object)c.B); + + // Now slam all of these together with the fantastic Join + // method. + // + return string.Join(sep, args); + } + } + } +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + MemberInfo member = null; + object[] args = null; + + Color c = (Color)value; + + if (c.IsEmpty) + { + member = typeof(Color).GetField("Empty"); + } + else if (c.IsSystemColor) + { + member = typeof(SystemColors).GetProperty(c.Name); + } + else if (c.IsKnownColor) + { + member = typeof(Color).GetProperty(c.Name); + } + else if (c.A != 255) + { + member = typeof(Color).GetMethod("FromArgb", new Type[] { typeof(int), typeof(int), typeof(int), typeof(int) }); + args = new object[] { c.A, c.R, c.G, c.B }; + } + else if (c.IsNamedColor) + { + member = typeof(Color).GetMethod("FromName", new Type[] { typeof(string) }); + args = new object[] { c.Name }; + } + else + { + member = typeof(Color).GetMethod("FromArgb", new Type[] { typeof(int), typeof(int), typeof(int) }); + args = new object[] { c.R, c.G, c.B }; + } + + Debug.Assert(member != null, "Could not convert color to member. Did someone change method name / signature and not update Colorconverter?"); + if (member != null) + { + return new InstanceDescriptor(member, args); + } + else + { + return null; + } + } +#endif + } + + return base.ConvertTo(context, culture, value, destinationType); + } + + public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + { + if (s_values == null) + { + lock (s_valuesLock) + { + if (s_values == null) + { + // We must take the value from each hashtable and combine them. + // + HashSet<Color> set = + new HashSet<Color>(ColorTable.Colors.Values.Concat(ColorTable.SystemColors.Values)); + + s_values = new StandardValuesCollection(set.OrderBy(c => c, new ColorComparer()).ToList()); + } + } + } + + return s_values; + } + + public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + { + return true; + } + + private class ColorComparer : IComparer<Color> + { + public int Compare(Color left, Color right) + { + return string.CompareOrdinal(left.Name, right.Name); + } + } + } +} diff --git a/src/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs new file mode 100644 index 0000000000..a7ca372585 --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/src/System/Drawing/PointConverter.cs @@ -0,0 +1,168 @@ +// 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.Diagnostics.CodeAnalysis; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; + +namespace System.Drawing +{ + public class PointConverter : TypeConverter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + { + return true; + } + return base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + return true; + } +#endif + return base.CanConvertTo(context, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + string strValue = value as string; + + if (strValue != null) + { + string text = strValue.Trim(); + + if (text.Length == 0) + { + return null; + } + else + { + // Parse 2 integer values. + // + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + char sep = culture.TextInfo.ListSeparator[0]; + string[] tokens = text.Split(sep); + int[] values = new int[tokens.Length]; + TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); + for (int i = 0; i < values.Length; i++) + { + // Note: ConvertFromString will raise exception if value cannot be converted. + values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i]); + } + + if (values.Length == 2) + { + return new Point(values[0], values[1]); + } + else + { + throw new ArgumentException(SR.Format(SR.TextParseFailedFormat, + text, + "x, y")); + } + } + } + + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == null) + { + throw new ArgumentNullException(nameof(destinationType)); + } + + if (value is Point) + { + if (destinationType == typeof(string)) + { + Point pt = (Point)value; + + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + string sep = culture.TextInfo.ListSeparator + " "; + TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); + string[] args = new string[2]; + int nArg = 0; + + // Note: ConvertToString will raise exception if value cannot be converted. + args[nArg++] = intConverter.ConvertToString(context, culture, pt.X); + args[nArg++] = intConverter.ConvertToString(context, culture, pt.Y); + + return string.Join(sep, args); + } +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + Point pt = (Point)value; + + ConstructorInfo ctor = typeof(Point).GetConstructor(new Type[] { typeof(int), typeof(int) }); + if (ctor != null) + { + return new InstanceDescriptor(ctor, new object[] { pt.X, pt.Y }); + } + } +#endif + } + + return base.ConvertTo(context, culture, value, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + [SuppressMessage("Microsoft.Security", "CA2102:CatchNonClsCompliantExceptionsInGeneralHandlers")] + public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) + { + if (propertyValues == null) + { + throw new ArgumentNullException(nameof(propertyValues)); + } + + object x = propertyValues["X"]; + object y = propertyValues["Y"]; + + if (x == null || y == null || + !(x is int) || !(y is int)) + { + throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry)); + } + + + return new Point((int)x, (int)y); + } + + public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) + { + return true; + } + + private static readonly string[] s_propertySort = {"X", "Y"}; + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Point), attributes); + return props.Sort(s_propertySort); + } + + + public override bool GetPropertiesSupported(ITypeDescriptorContext context) + { + return true; + } + } +}
\ No newline at end of file diff --git a/src/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs new file mode 100644 index 0000000000..02847fb8bb --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/src/System/Drawing/RectangleConverter.cs @@ -0,0 +1,171 @@ +// 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.Diagnostics.CodeAnalysis; +using System.Collections; +using System.ComponentModel; +using System.Globalization; + +namespace System.Drawing +{ + public class RectangleConverter : TypeConverter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + { + return true; + } + return base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + return true; + } +#endif + return base.CanConvertTo(context, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + string strValue = value as string; + + if (strValue != null) + { + string text = strValue.Trim(); + + if (text.Length == 0) + { + return null; + } + else + { + // Parse 4 integer values. + // + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + char sep = culture.TextInfo.ListSeparator[0]; + string[] tokens = text.Split(new char[] { sep }); + int[] values = new int[tokens.Length]; + TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); + for (int i = 0; i < values.Length; i++) + { + // Note: ConvertFromString will raise exception if value cannot be converted. + values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i]); + } + + if (values.Length == 4) + { + return new Rectangle(values[0], values[1], values[2], values[3]); + } + else + { + throw new ArgumentException(SR.Format(SR.TextParseFailedFormat, + "text", + text, + "x, y, width, height")); + } + } + } + + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == null) + { + throw new ArgumentNullException(nameof(destinationType)); + } + + if (value is Rectangle) + { + if (destinationType == typeof(string)) + { + Rectangle rect = (Rectangle)value; + + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + string sep = culture.TextInfo.ListSeparator + " "; + TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); + string[] args = new string[4]; + int nArg = 0; + + // Note: ConvertToString will raise exception if value cannot be converted. + args[nArg++] = intConverter.ConvertToString(context, culture, rect.X); + args[nArg++] = intConverter.ConvertToString(context, culture, rect.Y); + args[nArg++] = intConverter.ConvertToString(context, culture, rect.Width); + args[nArg++] = intConverter.ConvertToString(context, culture, rect.Height); + + return string.Join(sep, args); + } +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + Rectangle rect = (Rectangle)value; + ConstructorInfo ctor = typeof(Rectangle).GetConstructor(new Type[] { + typeof(int), typeof(int), typeof(int), typeof(int)}); + + if (ctor != null) + { + return new InstanceDescriptor(ctor, new object[] { + rect.X, rect.Y, rect.Width, rect.Height}); + } + } +#endif + } + + return base.ConvertTo(context, culture, value, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + [SuppressMessage("Microsoft.Security", "CA2102:CatchNonClsCompliantExceptionsInGeneralHandlers")] + public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) + { + if (propertyValues == null) + { + throw new ArgumentNullException(nameof(propertyValues)); + } + + object x = propertyValues["X"]; + object y = propertyValues["Y"]; + object width = propertyValues["Width"]; + object height = propertyValues["Height"]; + + if (x == null || y == null || width == null || height == null || + !(x is int) || !(y is int) || !(width is int) || !(height is int)) + { + throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry)); + } + return new Rectangle((int)x, (int)y, (int)width, (int)height); + } + + public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) + { + return true; + } + + private static readonly string[] s_propertySort = {"X", "Y", "Width", "Height"}; + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Rectangle), attributes); + return props.Sort(s_propertySort); + } + + public override bool GetPropertiesSupported(ITypeDescriptorContext context) + { + return true; + } + } +}
\ No newline at end of file diff --git a/src/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs new file mode 100644 index 0000000000..2e9a79a07f --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/src/System/Drawing/SizeConverter.cs @@ -0,0 +1,166 @@ +// 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; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; + +namespace System.Drawing +{ + public class SizeConverter : TypeConverter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + { + return true; + } + return base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + return true; + } +#endif + return base.CanConvertTo(context, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + string strValue = value as string; + + if (strValue != null) + { + string text = strValue.Trim(); + + if (text.Length == 0) + { + return null; + } + else + { + // Parse 2 integer values. + // + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + char sep = culture.TextInfo.ListSeparator[0]; + string[] tokens = text.Split(sep); + int[] values = new int[tokens.Length]; + TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); + for (int i = 0; i < values.Length; i++) + { + // Note: ConvertFromString will raise exception if value cannot be converted. + values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i]); + } + + if (values.Length == 2) + { + return new Size(values[0], values[1]); + } + else + { + throw new ArgumentException(SR.Format(SR.TextParseFailedFormat, + text, + "Width,Height")); + } + } + } + + return base.ConvertFrom(context, culture, value); + } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == null) + { + throw new ArgumentNullException(nameof(destinationType)); + } + + if (value is Size) + { + if (destinationType == typeof(string)) + { + Size size = (Size)value; + + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + string sep = culture.TextInfo.ListSeparator + " "; + TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int)); + string[] args = new string[2]; + int nArg = 0; + + // Note: ConvertToString will raise exception if value cannot be converted. + args[nArg++] = intConverter.ConvertToString(context, culture, size.Width); + args[nArg++] = intConverter.ConvertToString(context, culture, size.Height); + + return string.Join(sep, args); + } +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + Size size = (Size)value; + + ConstructorInfo ctor = typeof(Size).GetConstructor(new Type[] { typeof(int), typeof(int) }); + if (ctor != null) + { + return new InstanceDescriptor(ctor, new object[] { size.Width, size.Height }); + } + } +#endif + } + + return base.ConvertTo(context, culture, value, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + [SuppressMessage("Microsoft.Security", "CA2102:CatchNonClsCompliantExceptionsInGeneralHandlers")] + public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) + { + if (propertyValues == null) + { + throw new ArgumentNullException(nameof(propertyValues)); + } + + + object width = propertyValues["Width"]; + object height = propertyValues["Height"]; + + if (width == null || height == null || + !(width is int) || !(height is int)) + { + throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry)); + } + return new Size((int)width, (int)height); + } + + public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) + { + return true; + } + + private static readonly string[] s_propertySort = {"Width", "Height"}; + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Size), attributes); + return props.Sort(s_propertySort); + } + + + public override bool GetPropertiesSupported(ITypeDescriptorContext context) + { + return true; + } + } +}
\ No newline at end of file diff --git a/src/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs b/src/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs new file mode 100644 index 0000000000..725546e330 --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/src/System/Drawing/SizeFConverter.cs @@ -0,0 +1,160 @@ +// 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; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Reflection; + +namespace System.Drawing +{ + public class SizeFConverter : TypeConverter + { + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + { + return true; + } + return base.CanConvertFrom(context, sourceType); + } + + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + { +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor)) + { + return true; + } +#endif + return base.CanConvertTo(context, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + string strValue = value as string; + + if (strValue != null) + { + string text = strValue.Trim(); + + if (text.Length == 0) + { + return null; + } + else + { + // Parse 2 integer values. + // + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + char sep = culture.TextInfo.ListSeparator[0]; + string[] tokens = text.Split(sep); + float[] values = new float[tokens.Length]; + TypeConverter floatConverter = TypeDescriptor.GetConverter(typeof(float)); + for (int i = 0; i < values.Length; i++) + { + values[i] = (float)floatConverter.ConvertFromString(context, culture, tokens[i]); + } + + if (values.Length == 2) + { + return new SizeF(values[0], values[1]); + } + else + { + throw new ArgumentException(SR.Format(SR.TextParseFailedFormat, text, "Width,Height")); + } + } + } + + return base.ConvertFrom(context, culture, value); + } + + [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == null) + { + throw new ArgumentNullException(nameof(destinationType)); + } + + if (destinationType == typeof(string) && value is SizeF) + { + SizeF size = (SizeF)value; + + if (culture == null) + { + culture = CultureInfo.CurrentCulture; + } + string sep = culture.TextInfo.ListSeparator + " "; + TypeConverter floatConverter = TypeDescriptor.GetConverter(typeof(float)); + string[] args = new string[2]; + int nArg = 0; + + args[nArg++] = floatConverter.ConvertToString(context, culture, size.Width); + args[nArg++] = floatConverter.ConvertToString(context, culture, size.Height); + + return string.Join(sep, args); + } +#if FEATURE_INSTANCEDESCRIPTOR + if (destinationType == typeof(InstanceDescriptor) && value is SizeF) + { + SizeF size = (SizeF)value; + + ConstructorInfo ctor = typeof(SizeF).GetConstructor(new Type[] { typeof(float), typeof(float) }); + if (ctor != null) + { + return new InstanceDescriptor(ctor, new object[] { size.Width, size.Height }); + } + } +#endif + + return base.ConvertTo(context, culture, value, destinationType); + } + + [SuppressMessage("Microsoft.Performance", "CA1808:AvoidCallsThatBoxValueTypes")] + public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) + { + if (propertyValues == null) + { + throw new ArgumentNullException(nameof(propertyValues)); + } + + + object width = propertyValues["Width"]; + object height = propertyValues["Height"]; + + if (width == null || height == null || + !(width is float) || !(height is float)) + { + throw new ArgumentException(SR.Format(SR.PropertyValueInvalidEntry)); + } + return new SizeF((float)width, (float)height); + } + + public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) + { + return true; + } + + private static readonly string[] s_propertySort = {"Width", "Height"}; + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(SizeF), attributes); + return props.Sort(s_propertySort); + } + + + public override bool GetPropertiesSupported(ITypeDescriptorContext context) + { + return true; + } + } +}
\ No newline at end of file diff --git a/src/System.ComponentModel.TypeConverter/src/project.json b/src/System.ComponentModel.TypeConverter/src/project.json index e4f73019f7..95127ca98f 100644 --- a/src/System.ComponentModel.TypeConverter/src/project.json +++ b/src/System.ComponentModel.TypeConverter/src/project.json @@ -2,29 +2,27 @@ "frameworks": { "netstandard1.7": { "dependencies": { - "System.Collections": "4.0.0", - "System.Collections.NonGeneric": "4.0.0", - "System.Collections.Specialized": "4.0.0", - "System.ComponentModel": "4.0.0", - "System.ComponentModel.Primitives": "4.1.0", - "System.Diagnostics.Contracts": "4.0.0", - "System.Diagnostics.Debug": "4.0.10", - "System.Diagnostics.Tools": "4.0.0", - "System.Globalization": "4.0.0", - "System.Linq": "4.0.0", - "System.Reflection": "4.1.0", - "System.Reflection.Extensions": "4.0.0", - "System.Reflection.TypeExtensions": "4.1.0", - "System.Resources.ResourceManager": "4.0.0", - "System.Runtime": "4.0.20", - "System.Runtime.Extensions": "4.0.0", + "System.Collections": "4.3.0-beta-24520-06", + "System.Collections.NonGeneric": "4.3.0-beta-24520-06", + "System.Collections.Specialized": "4.3.0-beta-24520-06", + "System.ComponentModel": "4.3.0-beta-24520-06", + "System.ComponentModel.Primitives": "4.3.0-beta-24520-06", + "System.Diagnostics.Contracts": "4.3.0-beta-24520-06", + "System.Diagnostics.Debug": "4.3.0-beta-24520-06", + "System.Diagnostics.Tools": "4.3.0-beta-24520-06", + "System.Globalization": "4.3.0-beta-24520-06", + "System.Linq": "4.3.0-beta-24520-06", + "System.Reflection": "4.3.0-beta-24520-06", + "System.Reflection.Extensions": "4.3.0-beta-24520-06", + "System.Reflection.TypeExtensions": "4.3.0-beta-24520-06", + "System.Resources.ResourceManager": "4.3.0-beta-24520-06", + "System.Runtime": "4.3.0-beta-24520-06", + "System.Runtime.Extensions": "4.3.0-beta-24520-06", "System.Security.Permissions": "4.3.0-beta-24520-06", - "System.Threading": "4.0.10", - "System.Threading.Timer": "4.0.0" - }, - "imports": [ - "dotnet5.8" - ] + "System.Threading": "4.3.0-beta-24520-06", + "System.Threading.Tasks": "4.3.0-beta-24520-06", + "System.Threading.Timer": "4.3.0-beta-24520-06" + } }, "net463": { "dependencies": { diff --git a/src/System.ComponentModel.TypeConverter/tests/Drawing/ColorConverterTests.cs b/src/System.ComponentModel.TypeConverter/tests/Drawing/ColorConverterTests.cs new file mode 100644 index 0000000000..d0e017acce --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/tests/Drawing/ColorConverterTests.cs @@ -0,0 +1,450 @@ +// 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; +using System.Drawing; +using System.Globalization; +using System.Linq; +using Xunit; + +namespace System.ComponentModel.TypeConverterTests +{ + public class ColorConverterTests + { + [Theory] + [InlineData(typeof(string))] + public void CanConvertFromTrue(Type type) + { + var conv = new ColorConverter(); + Assert.True(conv.CanConvertFrom(type)); + Assert.True(conv.CanConvertFrom(null, type)); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertFromFalse(Type type) + { + var conv = new ColorConverter(); + Assert.False(conv.CanConvertFrom(type)); + Assert.False(conv.CanConvertFrom(null, type)); + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertToTrue(Type type) + { + var conv = new ColorConverter(); + Assert.True(conv.CanConvertTo(type)); + Assert.True(conv.CanConvertTo(null, type)); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertToFalse(Type type) + { + var conv = new ColorConverter(); + Assert.False(conv.CanConvertTo(type)); + Assert.False(conv.CanConvertTo(null, type)); + } + + public static IEnumerable<object[]> ColorData + { + get + { + for (int a = 0; a < 256; a += 53) + { + for (int r = 0; r < 256; r += 59) + { + for (int g = 0; g < 256; g += 61) + { + for (int b = 0; b < 256; b += 67) + { + yield return new object[] {a, r, g, b}; + } + } + } + } + } + } + + public static IEnumerable<object[]> ColorNames => + Enum.GetNames(typeof(KnownColor)).Select(n => new object[] {n}); + + [Theory] + [MemberData(nameof(ColorData))] + public void ConvertFrom(int a, int r, int g, int b) + { + var conv = new ColorConverter(); + Color color = (Color) conv.ConvertFrom(null, CultureInfo.InvariantCulture, $"#0x{a:x2}{r:x2}{g:x2}{b:x2}"); + Assert.Equal(a, color.A); + Assert.Equal(r, color.R); + Assert.Equal(g, color.G); + Assert.Equal(b, color.B); + + Assert.Equal(color, + (Color) conv.ConvertFrom(null, CultureInfo.InvariantCulture, $"#0X{a:x2}{r:x2}{g:x2}{b:x2}")); + Assert.Equal(color, + (Color) conv.ConvertFrom(null, CultureInfo.InvariantCulture, $"0x{a:x2}{r:x2}{g:x2}{b:x2}")); + Assert.Equal(color, + (Color) conv.ConvertFrom(null, CultureInfo.InvariantCulture, $"0X{a:x2}{r:x2}{g:x2}{b:x2}")); + } + + [Theory] + [MemberData(nameof(ColorData))] + public void ConvertFrom_InvariantSeparator(int a, int r, int g, int b) + { + var conv = new ColorConverter(); + var color = + (Color) + conv.ConvertFrom(null, CultureInfo.InvariantCulture, + string.Format("{0}{4} {1}{4} {2}{4} {3}", a, r, g, b, + CultureInfo.InvariantCulture.TextInfo.ListSeparator)); + Assert.Equal(a, color.A); + Assert.Equal(r, color.R); + Assert.Equal(g, color.G); + Assert.Equal(b, color.B); + } + + [Theory] + [MemberData(nameof(ColorData))] + public void ConvertFrom_FrFrSeparator(int a, int r, int g, int b) + { + var conv = new ColorConverter(); + var culture = new CultureInfo("fr-FR"); + var color = + (Color) + conv.ConvertFrom(null, culture, + string.Format("{0}{4} {1}{4} {2}{4} {3}", a, r, g, b, + culture.TextInfo.ListSeparator)); + Assert.Equal(a, color.A); + Assert.Equal(r, color.R); + Assert.Equal(g, color.G); + Assert.Equal(b, color.B); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void ConvertFrom_Name(string name) + { + var conv = new ColorConverter(); + var color = Color.FromName(name); + Assert.Equal(color, (Color) conv.ConvertFrom(name)); + Assert.Equal(color, (Color) conv.ConvertFrom(" " + name + " ")); + } + + [Fact] + public void ConvertFrom_Empty() + { + var conv = new ColorConverter(); + var color = Color.Empty; + Assert.Equal(color, (Color) conv.ConvertFrom(string.Empty)); + Assert.Equal(color, (Color) conv.ConvertFrom(" ")); + } + + [Theory] + [InlineData("10, 20")] + [InlineData("-10, 20, 30")] + [InlineData("1, 1, 1, 1, 1")] + public void ConvertFrom_ArgumentException(string value) + { + var conv = new ColorConverter(); + Assert.Throws<ArgumentException>(() => + { + conv.ConvertFrom(null, CultureInfo.InvariantCulture, value); + }); + } + + [Theory] + [InlineData("*1, 1")] + public void ConvertFrom_Exception(string value) + { + var conv = new ColorConverter(); + Assert.Throws<Exception>(() => + { + conv.ConvertFrom(null, CultureInfo.InvariantCulture, value); + }); + } + + public static IEnumerable<object[]> ConvertFrom_NotsupportedExceptionData => + new[] + { + new object[] {new Point(10, 10)}, + new object[] {new PointF(10, 10)}, + new object[] {new Size(10, 10)}, + new object[] {new SizeF(10, 10)}, + new object[] {0x10}, + }; + + [Theory] + [MemberData(nameof(ConvertFrom_NotsupportedExceptionData))] + public void ConvertFrom_NotSupportedException(object value) + { + var conv = new ColorConverter(); + Assert.Throws<NotSupportedException>(() => + { + conv.ConvertFrom(null, CultureInfo.InvariantCulture, value); + }); + } + + [Fact] + public void ConvertFrom_NullCulture() + { + var conv = new ColorConverter(); + var color = (Color) conv.ConvertFrom(null, null, "#0x23190A44"); + Assert.Equal(35, color.A); + Assert.Equal(25, color.R); + Assert.Equal(10, color.G); + Assert.Equal(68, color.B); + } + + [Theory] + [MemberData(nameof(ColorData))] + public void ConvertTo(int a, int r, int g, int b) + { + var conv = new ColorConverter(); + Assert.Equal($"{a}, {r}, {g}, {b}", + (string) conv.ConvertTo(null, CultureInfo.InvariantCulture, Color.FromArgb(a, r, g, b), typeof(string))); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void ConvertTo_Named(string name) + { + var conv = new ColorConverter(); + Assert.Equal(name, + (string) conv.ConvertTo(null, CultureInfo.InvariantCulture, Color.FromName(name), typeof(string))); + } + + [Fact] + public void ConvertTo_Empty() + { + var conv = new ColorConverter(); + Assert.Equal(string.Empty, + (string) conv.ConvertTo(null, CultureInfo.InvariantCulture, Color.Empty, typeof(string))); + } + + [Theory] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(int))] + public void ConvertTo_NotSupported(Type type) + { + var conv = new ColorConverter(); + var col = Color.Red; + Assert.Throws<NotSupportedException>(() => + { + conv.ConvertTo(null, CultureInfo.InvariantCulture, col, type); + }); + } + + [Fact] + public void GetCreateInstanceSupported() + { + var conv = new ColorConverter(); + Assert.False(conv.GetCreateInstanceSupported()); + Assert.False(conv.GetCreateInstanceSupported(null)); + } + + [Fact] + public void CreateInstance() + { + var conv = new ColorConverter(); + Assert.Null(conv.CreateInstance(new Dictionary<string, object> + { + ["R"] = 10, + ["G"] = 20, + ["B"] = 30, + })); + + Assert.Null(conv.CreateInstance(new Dictionary<string, object> + { + ["Name"] = "ForestGreen", + })); + } + + [Fact] + public void GetPropertiesSupported() + { + var conv = new ColorConverter(); + Assert.False(conv.GetPropertiesSupported()); + Assert.False(conv.GetPropertiesSupported(null)); + } + + [Fact] + public void GetProperties() + { + var conv = new ColorConverter(); + Assert.Null(conv.GetProperties(Color.Red)); + Assert.Null(conv.GetProperties(null, Color.Red, null)); + Assert.Null(conv.GetProperties(null, Color.Red, + typeof(Color).GetCustomAttributes(true).OfType<Attribute>().ToArray())); + } + + [Theory] + [MemberData(nameof(ColorData))] + public void ConvertFromInvariantString(int a, int r, int g, int b) + { + var conv = new ColorConverter(); + var color = (Color) conv.ConvertFromInvariantString($"{a}, {r}, {g}, {b}"); + Assert.Equal(a, color.A); + Assert.Equal(r, color.R); + Assert.Equal(g, color.G); + Assert.Equal(b, color.B); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void ConvertFromInvariantString_Name(string name) + { + var conv = new ColorConverter(); + var color = Color.FromName(name); + Assert.Equal(color, (Color) conv.ConvertFromInvariantString(name)); + } + + [Fact] + public void ConvertFromInvariantString_Invalid() + { + var conv = new ColorConverter(); + Assert.Throws<ArgumentException>(() => + { + conv.ConvertFromInvariantString("1, 2, 3, 4, 5"); + }); + } + + [Fact] + public void ConvertFromInvariantString_NotNumber() + { + var conv = new ColorConverter(); + var ex = Assert.Throws<Exception>(() => + { + conv.ConvertFromInvariantString("hello"); + }); + Assert.NotNull(ex.InnerException); + Assert.IsType<FormatException>(ex.InnerException); + } + + [Theory] + [MemberData(nameof(ColorData))] + public void ConvertFromString(int a, int r, int g, int b) + { + var conv = new ColorConverter(); + var color = + (Color) + conv.ConvertFromString(string.Format("{0}{4} {1}{4} {2}{4} {3}", a, r, g, b, + CultureInfo.CurrentCulture.TextInfo.ListSeparator)); + Assert.Equal(a, color.A); + Assert.Equal(r, color.R); + Assert.Equal(g, color.G); + Assert.Equal(b, color.B); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void ConvertFromString_Name(string name) + { + var conv = new ColorConverter(); + var color = Color.FromName(name); + Assert.Equal(color, (Color) conv.ConvertFromString(name)); + } + + [Fact] + public void ConvertFromString_Invalid() + { + var conv = new ColorConverter(); + Assert.Throws<ArgumentException>(() => + { + conv.ConvertFromString(string.Format("1{0} 2{0} 3{0} 4{0} 5", CultureInfo.CurrentCulture.TextInfo.ListSeparator)); + }); + } + + [Fact] + public void ConvertFromString_NotNumber() + { + var conv = new ColorConverter(); + var ex = Assert.Throws<Exception>(() => + { + conv.ConvertFromString("hello"); + }); + Assert.NotNull(ex.InnerException); + Assert.IsType<FormatException>(ex.InnerException); + } + + [Theory] + [MemberData(nameof(ColorData))] + public void ConvertToInvariantString(int a, int r, int g, int b) + { + var conv = new ColorConverter(); + var str = conv.ConvertToInvariantString(Color.FromArgb(a, r, g, b)); + Assert.Equal($"{a}, {r}, {g}, {b}", str); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void ConvertToInvariantString_Name(string name) + { + var conv = new ColorConverter(); + Assert.Equal(name, conv.ConvertToInvariantString(Color.FromName(name))); + } + + [Theory] + [MemberData(nameof(ColorData))] + public void ConvertToString(int a, int r, int g, int b) + { + var conv = new ColorConverter(); + var str = conv.ConvertToString(Color.FromArgb(a, r, g, b)); + Assert.Equal(string.Format("{0}{4} {1}{4} {2}{4} {3}", a, r, g, b, CultureInfo.CurrentCulture.TextInfo.ListSeparator), str); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void ConvertToString_Name(string name) + { + var conv = new ColorConverter(); + Assert.Equal(name, conv.ConvertToString(Color.FromName(name))); + } + + [Fact] + public void GetStandardValuesSupported() + { + var conv = new ColorConverter(); + Assert.True(conv.GetStandardValuesSupported()); + Assert.True(conv.GetStandardValuesSupported(null)); + } + + [Fact] + public void GetStandardValues() + { + var conv = new ColorConverter(); + + Assert.Equal((int) KnownColor.MenuHighlight, conv.GetStandardValues().Count); + Assert.Equal((int) KnownColor.MenuHighlight, conv.GetStandardValues(null).Count); + } + + [Fact] + public void GetStandardValuesExclusive() + { + var conv = new ColorConverter(); + Assert.False(conv.GetStandardValuesExclusive()); + } + } +} diff --git a/src/System.ComponentModel.TypeConverter/tests/Drawing/PointConverterTests.cs b/src/System.ComponentModel.TypeConverter/tests/Drawing/PointConverterTests.cs new file mode 100644 index 0000000000..b85ecdc28e --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/tests/Drawing/PointConverterTests.cs @@ -0,0 +1,262 @@ +// 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; +using System.Drawing; +using System.Globalization; +using System.Linq; +using Xunit; + +namespace System.ComponentModel.TypeConverterTests +{ + public class PointConverterTests : StringTypeConverterTestBase<Point> + { + protected override TypeConverter Converter { get; } = new PointConverter(); + protected override bool StandardValuesSupported { get; } = false; + protected override bool StandardValuesExclusive { get; } = false; + protected override Point Default => new Point(1, 1); + protected override bool CreateInstanceSupported { get; } = true; + protected override bool IsGetPropertiesSupported { get; } = true; + + protected override IEnumerable<Tuple<Point, Dictionary<string, object>>> CreateInstancePairs + { + get + { + yield return Tuple.Create(new Point(10, 20), new Dictionary<string, object> + { + ["X"] = 10, + ["Y"] = 20, + }); + yield return Tuple.Create(new Point(-2, 3), new Dictionary<string, object> + { + ["X"] = -2, + ["Y"] = 3, + }); + } + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertFromTrue(Type type) + { + CanConvertFrom(type); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertFromFalse(Type type) + { + CannotConvertFrom(type); + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertToTrue(Type type) + { + CanConvertTo(type); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertToFalse(Type type) + { + CannotConvertTo(type); + } + + public static IEnumerable<object[]> PointData => + new[] + { + new object[] {0, 0}, + new object[] {1, 1}, + new object[] {-1, 1}, + new object[] {1, -1}, + new object[] {-1, -1}, + new object[] {int.MaxValue, int.MaxValue}, + new object[] {int.MinValue, int.MaxValue}, + new object[] {int.MaxValue, int.MinValue}, + new object[] {int.MinValue, int.MinValue}, + }; + + [Theory] + [MemberData(nameof(PointData))] + public void ConvertFrom(int x, int y) + { + TestConvertFromString(new Point(x, y), $"{x}, {y}"); + } + + [Theory] + [InlineData("1")] + [InlineData("1, 1, 1")] + public void ConvertFrom_ArgumentException(string value) + { + ConvertFromThrowsArgumentExceptionForString(value); + } + + [Fact] + public void ConvertFrom_Invalid() + { + ConvertFromThrowsFormatInnerExceptionForString("*1, 1"); + } + + public static IEnumerable<object[]> ConvertFrom_NotSupportedData => + new[] + { + new object[] {new Point(1, 1)}, + new object[] {new PointF(1, 1)}, + new object[] {new Size(1, 1)}, + new object[] {new SizeF(1, 1)}, + new object[] {0x10}, + }; + + [Theory] + [MemberData(nameof(ConvertFrom_NotSupportedData))] + public void ConvertFrom_NotSupported(object value) + { + ConvertFromThrowsNotSupportedFor(value); + } + + [Theory] + [MemberData(nameof(PointData))] + public void ConvertTo(int x, int y) + { + TestConvertToString(new Point(x, y), $"{x}, {y}"); + } + + [Theory] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(int))] + public void ConvertTo_NotSupportedException(Type type) + { + ConvertToThrowsNotSupportedForType(type); + } + + [Fact] + public void ConvertTo_NullCulture() + { + Assert.Equal("1, 1", Converter.ConvertTo(null, null, new Point(1, 1), typeof(string))); + } + + [Fact] + public void CreateInstance_CaseSensitive() + { + Assert.Throws<ArgumentException>(() => + { + Converter.CreateInstance(null, new Dictionary<string, object> + { + ["x"] = 1, + ["y"] = -1, + }); + }); + } + + [Fact] + public void GetProperties() + { + var pt = new Point(1, 1); + var props = Converter.GetProperties(new Point(1, 1)); + Assert.Equal(3, props.Count); + Assert.Equal(1, props["X"].GetValue(pt)); + Assert.Equal(1, props["Y"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new Point(1, 1)); + Assert.Equal(3, props.Count); + Assert.Equal(1, props["X"].GetValue(pt)); + Assert.Equal(1, props["Y"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new Point(1, 1), null); + Assert.Equal(3, props.Count); + Assert.Equal(1, props["X"].GetValue(pt)); + Assert.Equal(1, props["Y"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new Point(1, 1), + typeof(Point).GetCustomAttributes(true).OfType<Attribute>().ToArray()); + Assert.Equal(3, props.Count); + Assert.Equal(1, props["X"].GetValue(pt)); + Assert.Equal(1, props["Y"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + } + + [Theory] + [MemberData(nameof(PointData))] + public void ConvertFromInvariantString(int x, int y) + { + var point = (Point)Converter.ConvertFromInvariantString($"{x}, {y}"); + Assert.Equal(x, point.X); + Assert.Equal(y, point.Y); + } + + [Fact] + public void ConvertFromInvariantString_ArgumentException() + { + ConvertFromInvariantStringThrowsArgumentException("1"); + } + + [Fact] + public void ConvertFromInvariantString_FormatException() + { + ConvertFromInvariantStringThrowsFormatInnerException("hello"); + } + + [Theory] + [MemberData(nameof(PointData))] + public void ConvertFromString(int x, int y) + { + var point = + (Point)Converter.ConvertFromString(string.Format("{0}{2} {1}", x, y, + CultureInfo.CurrentCulture.TextInfo.ListSeparator)); + Assert.Equal(x, point.X); + Assert.Equal(y, point.Y); + } + + [Fact] + public void ConvertFromString_ArgumentException() + { + ConvertFromStringThrowsArgumentException("1"); + } + + [Fact] + public void ConvertFromString_FormatException() + { + ConvertFromStringThrowsFormatInnerException("hello"); + } + + [Theory] + [MemberData(nameof(PointData))] + public void ConvertToInvariantString(int x, int y) + { + var str = Converter.ConvertToInvariantString(new Point(x, y)); + Assert.Equal($"{x}, {y}", str); + } + + [Theory] + [MemberData(nameof(PointData))] + public void ConvertToString(int x, int y) + { + var str = Converter.ConvertToString(new Point(x, y)); + Assert.Equal(string.Format("{0}{2} {1}", x, y, CultureInfo.CurrentCulture.TextInfo.ListSeparator), str); + } + } +} diff --git a/src/System.ComponentModel.TypeConverter/tests/Drawing/RectangleConverterTests.cs b/src/System.ComponentModel.TypeConverter/tests/Drawing/RectangleConverterTests.cs new file mode 100644 index 0000000000..b149ec4c7e --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/tests/Drawing/RectangleConverterTests.cs @@ -0,0 +1,276 @@ +// 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; +using System.Drawing; +using System.Globalization; +using System.Linq; +using Xunit; + +namespace System.ComponentModel.TypeConverterTests +{ + public class RectangleConverterTests : StringTypeConverterTestBase<Rectangle> + { + protected override TypeConverter Converter { get; } = new RectangleConverter(); + protected override bool StandardValuesSupported { get; } = false; + protected override bool StandardValuesExclusive { get; } = false; + protected override Rectangle Default => new Rectangle(0, 0, 100, 100); + protected override bool CreateInstanceSupported { get; } = true; + protected override bool IsGetPropertiesSupported { get; } = true; + + protected override IEnumerable<Tuple<Rectangle, Dictionary<string, object>>> CreateInstancePairs { + get + { + yield return Tuple.Create(new Rectangle(10, 10, 20, 30), new Dictionary<string, object> + { + ["X"] = 10, + ["Y"] = 10, + ["Width"] = 20, + ["Height"] = 30, + }); + yield return Tuple.Create(new Rectangle(-10, -10, 20, 30), new Dictionary<string, object> + { + ["X"] = -10, + ["Y"] = -10, + ["Width"] = 20, + ["Height"] = 30, + }); + } + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertFromTrue(Type type) + { + CanConvertFrom(type); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertFromFalse(Type type) + { + CannotConvertFrom(type); + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertToTrue(Type type) + { + CanConvertTo(type); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertToFalse(Type type) + { + CannotConvertTo(type); + } + + public static IEnumerable<object[]> RectangleData => + new[] + { + new object[] {0, 0, 0, 0}, + new object[] {1, 1, 1, 1}, + new object[] {-1, 1, 1, 1}, + new object[] {1, -1, 1, 1}, + new object[] {-1, -1, 1, 1}, + new object[] {int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue}, + new object[] {int.MinValue, int.MaxValue, int.MaxValue, int.MaxValue}, + new object[] {int.MaxValue, int.MinValue, int.MaxValue, int.MaxValue}, + new object[] {int.MinValue, int.MinValue, int.MaxValue, int.MaxValue}, + }; + + [Theory] + [MemberData(nameof(RectangleData))] + public void ConvertFrom(int x, int y, int width, int height) + { + TestConvertFromString(new Rectangle(x, y, width, height), $"{x}, {y}, {width}, {height}"); + } + + [Theory] + [InlineData("10, 10")] + [InlineData("1, 1, 1, 1, 1")] + public void ConvertFrom_ArgumentException(string value) + { + ConvertFromThrowsArgumentExceptionForString(value); + } + + [Fact] + public void ConvertFrom_Invalid() + { + ConvertFromThrowsFormatInnerExceptionForString("*1, 1, 1, 1"); + } + + public static IEnumerable<object[]> ConvertFrom_NotSupportedData => + new[] + { + new object[] {new Point(10, 10)}, + new object[] {new PointF(10, 10)}, + new object[] {new Size(10, 10)}, + new object[] {new SizeF(10, 10)}, + new object[] {new object()}, + new object[] {1001}, + }; + + [Theory] + [MemberData(nameof(ConvertFrom_NotSupportedData))] + public void ConvertFrom_NotSupported(object value) + { + ConvertFromThrowsNotSupportedFor(value); + } + + [Theory] + [MemberData(nameof(RectangleData))] + public void ConvertTo(int x, int y, int width, int height) + { + TestConvertToString(new Rectangle(x, y, width, height), $"{x}, {y}, {width}, {height}"); + } + + [Theory] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void ConvertTo_NotSupportedException(Type type) + { + ConvertToThrowsNotSupportedForType(type); + } + + [Fact] + public void CreateInstance_CaseSensitive() + { + Assert.Throws<ArgumentException>(() => + { + Converter.CreateInstance(null, new Dictionary<string, object> + { + ["x"] = -10, + ["Y"] = -10, + ["Width"] = 20, + ["Height"] = 30, + }); + }); + } + + [Fact] + public void TestGetProperties() + { + var rect = new Rectangle(10, 10, 20, 30); + var propsColl = Converter.GetProperties(rect); + Assert.Equal(11, propsColl.Count); + Assert.Equal(rect.X, propsColl["X"].GetValue(rect)); + Assert.Equal(rect.Y, propsColl["Y"].GetValue(rect)); + Assert.Equal(rect.Width, propsColl["Width"].GetValue(rect)); + Assert.Equal(rect.Height, propsColl["Height"].GetValue(rect)); + + rect = new Rectangle(-10, -10, 20, 30); + propsColl = Converter.GetProperties(null, rect); + Assert.Equal(11, propsColl.Count); + Assert.Equal(rect.X, propsColl["X"].GetValue(rect)); + Assert.Equal(rect.Y, propsColl["Y"].GetValue(rect)); + Assert.Equal(rect.Width, propsColl["Width"].GetValue(rect)); + Assert.Equal(rect.Height, propsColl["Height"].GetValue(rect)); + + rect = new Rectangle(10, 10, 20, 30); + propsColl = Converter.GetProperties(null, rect, null); + Assert.Equal(11, propsColl.Count); + Assert.Equal(rect.X, propsColl["X"].GetValue(rect)); + Assert.Equal(rect.Y, propsColl["Y"].GetValue(rect)); + Assert.Equal(rect.Width, propsColl["Width"].GetValue(rect)); + Assert.Equal(rect.Height, propsColl["Height"].GetValue(rect)); + + Assert.Equal(rect.Top, propsColl["Top"].GetValue(rect)); + Assert.Equal(rect.Bottom, propsColl["Bottom"].GetValue(rect)); + Assert.Equal(rect.Left, propsColl["Left"].GetValue(rect)); + Assert.Equal(rect.Right, propsColl["Right"].GetValue(rect)); + Assert.Equal(rect.Location, propsColl["Location"].GetValue(rect)); + Assert.Equal(rect.Size, propsColl["Size"].GetValue(rect)); + Assert.Equal(rect.IsEmpty, propsColl["IsEmpty"].GetValue(rect)); + } + + [Theory] + [MemberData(nameof(RectangleData))] + public void ConvertFromInvariantString(int x, int y, int width, int height) + { + var rect = (Rectangle)Converter.ConvertFromInvariantString($"{x}, {y}, {width}, {height}"); + Assert.Equal(x, rect.X); + Assert.Equal(y, rect.Y); + Assert.Equal(width, rect.Width); + Assert.Equal(height, rect.Height); + } + + [Fact] + public void ConvertFromInvariantString_ArgumentException() + { + ConvertFromInvariantStringThrowsArgumentException("1, 2, 3"); + } + + [Fact] + public void ConvertFromInvariantString_FormatException() + { + ConvertFromInvariantStringThrowsFormatInnerException("hello"); + } + + [Theory] + [MemberData(nameof(RectangleData))] + public void ConvertFromString(int x, int y, int width, int height) + { + var rect = + (Rectangle)Converter.ConvertFromString(string.Format("{0}{4} {1}{4} {2}{4} {3}", x, y, width, height, + CultureInfo.CurrentCulture.TextInfo.ListSeparator)); + Assert.Equal(x, rect.X); + Assert.Equal(y, rect.Y); + Assert.Equal(width, rect.Width); + Assert.Equal(height, rect.Height); + } + + [Fact] + public void ConvertFromString_ArgumentException() + { + ConvertFromStringThrowsArgumentException(string.Format("1{0} 1{0} 1{0} 1{0} 1", + CultureInfo.CurrentCulture.TextInfo.ListSeparator)); + } + + [Fact] + public void ConvertFromString_FormatException() + { + ConvertFromStringThrowsFormatInnerException("hello"); + } + + [Theory] + [MemberData(nameof(RectangleData))] + public void ConvertToInvariantString(int x, int y, int width, int height) + { + var str = Converter.ConvertToInvariantString(new Rectangle(x, y, width, height)); + Assert.Equal($"{x}, {y}, {width}, {height}", str); + } + + [Theory] + [MemberData(nameof(RectangleData))] + public void ConvertToString(int x, int y, int width, int height) + { + var str = Converter.ConvertToString(new Rectangle(x, y, width, height)); + Assert.Equal( + string.Format("{0}{4} {1}{4} {2}{4} {3}", x, y, width, height, + CultureInfo.CurrentCulture.TextInfo.ListSeparator), str); + } + } +}
\ No newline at end of file diff --git a/src/System.ComponentModel.TypeConverter/tests/Drawing/SizeConverterTests.cs b/src/System.ComponentModel.TypeConverter/tests/Drawing/SizeConverterTests.cs new file mode 100644 index 0000000000..3c15435aae --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/tests/Drawing/SizeConverterTests.cs @@ -0,0 +1,262 @@ +// 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; +using System.Drawing; +using System.Globalization; +using System.Linq; +using Xunit; + +namespace System.ComponentModel.TypeConverterTests +{ + public class SizeConverterTests : StringTypeConverterTestBase<Size> + { + protected override TypeConverter Converter { get; } = new SizeConverter(); + protected override bool StandardValuesSupported { get; } = false; + protected override bool StandardValuesExclusive { get; } = false; + protected override Size Default => new Size(1, 1); + protected override bool CreateInstanceSupported { get; } = true; + protected override bool IsGetPropertiesSupported { get; } = true; + + protected override IEnumerable<Tuple<Size, Dictionary<string, object>>> CreateInstancePairs + { + get + { + yield return Tuple.Create(new Size(10, 20), new Dictionary<string, object> + { + ["Width"] = 10, + ["Height"] = 20, + }); + yield return Tuple.Create(new Size(-2, 3), new Dictionary<string, object> + { + ["Width"] = -2, + ["Height"] = 3, + }); + } + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertFromTrue(Type type) + { + CanConvertFrom(type); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertFromFalse(Type type) + { + CannotConvertFrom(type); + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertToTrue(Type type) + { + CanConvertTo(type); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertToFalse(Type type) + { + CannotConvertTo(type); + } + + public static IEnumerable<object[]> SizeData => + new[] + { + new object[] {0, 0}, + new object[] {1, 1}, + new object[] {-1, 1}, + new object[] {1, -1}, + new object[] {-1, -1}, + new object[] {int.MaxValue, int.MaxValue}, + new object[] {int.MinValue, int.MaxValue}, + new object[] {int.MaxValue, int.MinValue}, + new object[] {int.MinValue, int.MinValue}, + }; + + [Theory] + [MemberData(nameof(SizeData))] + public void ConvertFrom(int width, int height) + { + TestConvertFromString(new Size(width, height), $"{width}, {height}"); + } + + [Theory] + [InlineData("1")] + [InlineData("1, 1, 1")] + public void ConvertFrom_ArgumentException(string value) + { + ConvertFromThrowsArgumentExceptionForString(value); + } + + [Fact] + public void ConvertFrom_Invalid() + { + ConvertFromThrowsFormatInnerExceptionForString("*1, 1"); + } + + public static IEnumerable<object[]> ConvertFrom_NotSupportedData => + new[] + { + new object[] {new Point(1, 1)}, + new object[] {new PointF(1, 1)}, + new object[] {new Size(1, 1)}, + new object[] {new SizeF(1, 1)}, + new object[] {0x10}, + }; + + [Theory] + [MemberData(nameof(ConvertFrom_NotSupportedData))] + public void ConvertFrom_NotSupported(object value) + { + ConvertFromThrowsNotSupportedFor(value); + } + + [Theory] + [MemberData(nameof(SizeData))] + public void ConvertTo(int width, int height) + { + TestConvertToString(new Size(width, height), $"{width}, {height}"); + } + + [Theory] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(int))] + public void ConvertTo_NotSupportedException(Type type) + { + ConvertToThrowsNotSupportedForType(type); + } + + [Fact] + public void ConvertTo_NullCulture() + { + Assert.Equal("1, 1", Converter.ConvertTo(null, null, new Size(1, 1), typeof(string))); + } + + [Fact] + public void CreateInstance_CaseSensitive() + { + Assert.Throws<ArgumentException>(() => + { + Converter.CreateInstance(null, new Dictionary<string, object> + { + ["width"] = 1, + ["Height"] = 1, + }); + }); + } + + [Fact] + public void GetProperties() + { + var pt = new Size(1, 1); + var props = Converter.GetProperties(new Size(1, 1)); + Assert.Equal(3, props.Count); + Assert.Equal(1, props["Width"].GetValue(pt)); + Assert.Equal(1, props["Height"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new Size(1, 1)); + Assert.Equal(3, props.Count); + Assert.Equal(1, props["Width"].GetValue(pt)); + Assert.Equal(1, props["Height"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new Size(1, 1), null); + Assert.Equal(3, props.Count); + Assert.Equal(1, props["Width"].GetValue(pt)); + Assert.Equal(1, props["Height"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new Size(1, 1), + typeof(Size).GetCustomAttributes(true).OfType<Attribute>().ToArray()); + Assert.Equal(3, props.Count); + Assert.Equal(1, props["Width"].GetValue(pt)); + Assert.Equal(1, props["Height"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + } + + [Theory] + [MemberData(nameof(SizeData))] + public void ConvertFromInvariantString(int width, int height) + { + var point = (Size)Converter.ConvertFromInvariantString($"{width}, {height}"); + Assert.Equal(width, point.Width); + Assert.Equal(height, point.Height); + } + + [Fact] + public void ConvertFromInvariantString_ArgumentException() + { + ConvertFromInvariantStringThrowsArgumentException("1"); + } + + [Fact] + public void ConvertFromInvariantString_FormatException() + { + ConvertFromInvariantStringThrowsFormatInnerException("hello"); + } + + [Theory] + [MemberData(nameof(SizeData))] + public void ConvertFromString(int width, int height) + { + var point = + (Size)Converter.ConvertFromString(string.Format("{0}{2} {1}", width, height, + CultureInfo.CurrentCulture.TextInfo.ListSeparator)); + Assert.Equal(width, point.Width); + Assert.Equal(height, point.Height); + } + + [Fact] + public void ConvertFromString_ArgumentException() + { + ConvertFromStringThrowsArgumentException("1"); + } + + [Fact] + public void ConvertFromString_FormatException() + { + ConvertFromStringThrowsFormatInnerException("hello"); + } + + [Theory] + [MemberData(nameof(SizeData))] + public void ConvertToInvariantString(int width, int height) + { + var str = Converter.ConvertToInvariantString(new Size(width, height)); + Assert.Equal($"{width}, {height}", str); + } + + [Theory] + [MemberData(nameof(SizeData))] + public void ConvertToString(int width, int height) + { + var str = Converter.ConvertToString(new Size(width, height)); + Assert.Equal(string.Format("{0}{2} {1}", width, height, CultureInfo.CurrentCulture.TextInfo.ListSeparator), str); + } + } +} diff --git a/src/System.ComponentModel.TypeConverter/tests/Drawing/SizeFConverterTests.cs b/src/System.ComponentModel.TypeConverter/tests/Drawing/SizeFConverterTests.cs new file mode 100644 index 0000000000..2db538fec7 --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/tests/Drawing/SizeFConverterTests.cs @@ -0,0 +1,262 @@ +// 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; +using System.Drawing; +using System.Globalization; +using System.Linq; +using Xunit; + +namespace System.ComponentModel.TypeConverterTests +{ + public class SizeFConverterTests : StringTypeConverterTestBase<SizeF> + { + protected override TypeConverter Converter { get; } = new SizeFConverter(); + protected override bool StandardValuesSupported { get; } = false; + protected override bool StandardValuesExclusive { get; } = false; + protected override SizeF Default => new SizeF(1, 1); + protected override bool CreateInstanceSupported { get; } = true; + protected override bool IsGetPropertiesSupported { get; } = true; + + protected override IEnumerable<Tuple<SizeF, Dictionary<string, object>>> CreateInstancePairs + { + get + { + yield return Tuple.Create(new SizeF(10, 20), new Dictionary<string, object> + { + ["Width"] = 10f, + ["Height"] = 20f, + }); + yield return Tuple.Create(new SizeF(-2, 3), new Dictionary<string, object> + { + ["Width"] = -2f, + ["Height"] = 3f, + }); + } + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertFromTrue(Type type) + { + CanConvertFrom(type); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertFromFalse(Type type) + { + CannotConvertFrom(type); + } + + [Theory] + [InlineData(typeof(string))] + public void CanConvertToTrue(Type type) + { + CanConvertTo(type); + } + + [Theory] + [InlineData(typeof(Rectangle))] + [InlineData(typeof(RectangleF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(Color))] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(object))] + [InlineData(typeof(int))] + public void CanConvertToFalse(Type type) + { + CannotConvertTo(type); + } + + public static IEnumerable<object[]> SizeFData => + new[] + { + new object[] {0, 0}, + new object[] {1, 1}, + new object[] {-1, 1}, + new object[] {1, -1}, + new object[] {-1, -1}, + new object[] {float.MaxValue, float.MaxValue}, + new object[] {float.MinValue, float.MaxValue}, + new object[] {float.MaxValue, float.MinValue}, + new object[] {float.MinValue, float.MinValue}, + }; + + [Theory] + [MemberData(nameof(SizeFData))] + public void ConvertFrom(float width, float height) + { + TestConvertFromString(new SizeF(width, height), $"{width:G9}, {height:G9}"); + } + + [Theory] + [InlineData("1")] + [InlineData("1, 1, 1")] + public void ConvertFrom_ArgumentException(string value) + { + ConvertFromThrowsArgumentExceptionForString(value); + } + + [Fact] + public void ConvertFrom_Invalid() + { + ConvertFromThrowsFormatInnerExceptionForString("*1, 1"); + } + + public static IEnumerable<object[]> ConvertFrom_NotSupportedData => + new[] + { + new object[] {new Point(1, 1)}, + new object[] {new PointF(1, 1)}, + new object[] {new SizeF(1, 1)}, + new object[] {new SizeF(1, 1)}, + new object[] {0x10}, + }; + + [Theory] + [MemberData(nameof(ConvertFrom_NotSupportedData))] + public void ConvertFrom_NotSupported(object value) + { + ConvertFromThrowsNotSupportedFor(value); + } + + [Theory] + [MemberData(nameof(SizeFData))] + public void ConvertTo(float width, float height) + { + TestConvertToString(new SizeF(width, height), $"{width:G9}, {height:G9}"); + } + + [Theory] + [InlineData(typeof(Size))] + [InlineData(typeof(SizeF))] + [InlineData(typeof(Point))] + [InlineData(typeof(PointF))] + [InlineData(typeof(int))] + public void ConvertTo_NotSupportedException(Type type) + { + ConvertToThrowsNotSupportedForType(type); + } + + [Fact] + public void ConvertTo_NullCulture() + { + Assert.Equal("1, 1", Converter.ConvertTo(null, null, new SizeF(1, 1), typeof(string))); + } + + [Fact] + public void CreateInstance_CaseSensitive() + { + Assert.Throws<ArgumentException>(() => + { + Converter.CreateInstance(null, new Dictionary<string, object> + { + ["width"] = 1, + ["Height"] = 1, + }); + }); + } + + [Fact] + public void GetProperties() + { + var pt = new SizeF(1, 1); + var props = Converter.GetProperties(new SizeF(1, 1)); + Assert.Equal(3, props.Count); + Assert.Equal(1f, props["Width"].GetValue(pt)); + Assert.Equal(1f, props["Height"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new SizeF(1, 1)); + Assert.Equal(3, props.Count); + Assert.Equal(1f, props["Width"].GetValue(pt)); + Assert.Equal(1f, props["Height"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new SizeF(1, 1), null); + Assert.Equal(3, props.Count); + Assert.Equal(1f, props["Width"].GetValue(pt)); + Assert.Equal(1f, props["Height"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + + props = Converter.GetProperties(null, new SizeF(1, 1), + typeof(SizeF).GetCustomAttributes(true).OfType<Attribute>().ToArray()); + Assert.Equal(3, props.Count); + Assert.Equal(1f, props["Width"].GetValue(pt)); + Assert.Equal(1f, props["Height"].GetValue(pt)); + Assert.Equal(false, props["IsEmpty"].GetValue(pt)); + } + + [Theory] + [MemberData(nameof(SizeFData))] + public void ConvertFromInvariantString(float width, float height) + { + var point = (SizeF)Converter.ConvertFromInvariantString($"{width:G9}, {height:G9}"); + Assert.Equal(width, point.Width); + Assert.Equal(height, point.Height); + } + + [Fact] + public void ConvertFromInvariantString_ArgumentException() + { + ConvertFromInvariantStringThrowsArgumentException("1"); + } + + [Fact] + public void ConvertFromInvariantString_FormatException() + { + ConvertFromInvariantStringThrowsFormatInnerException("hello"); + } + + [Theory] + [MemberData(nameof(SizeFData))] + public void ConvertFromString(float width, float height) + { + var point = + (SizeF)Converter.ConvertFromString(string.Format(CultureInfo.CurrentCulture, "{0:g9}{2} {1:g9}", width, height, + CultureInfo.CurrentCulture.TextInfo.ListSeparator)); + Assert.Equal(width, point.Width); + Assert.Equal(height, point.Height); + } + + [Fact] + public void ConvertFromString_ArgumentException() + { + ConvertFromStringThrowsArgumentException("1"); + } + + [Fact] + public void ConvertFromString_FormatException() + { + ConvertFromStringThrowsFormatInnerException("hello"); + } + + [Theory] + [MemberData(nameof(SizeFData))] + public void ConvertToInvariantString(float width, float height) + { + var str = Converter.ConvertToInvariantString(new SizeF(width, height)); + Assert.Equal($"{width:G9}, {height:G9}", str); + } + + [Theory] + [MemberData(nameof(SizeFData))] + public void ConvertToString(float width, float height) + { + var str = Converter.ConvertToString(new SizeF(width, height)); + Assert.Equal(string.Format(CultureInfo.CurrentCulture, "{0:G9}{2} {1:G9}", width, height, CultureInfo.CurrentCulture.TextInfo.ListSeparator), str); + } + } +} diff --git a/src/System.ComponentModel.TypeConverter/tests/Drawing/StringTypeConverterTestBase.cs b/src/System.ComponentModel.TypeConverter/tests/Drawing/StringTypeConverterTestBase.cs new file mode 100644 index 0000000000..6895a2e4e3 --- /dev/null +++ b/src/System.ComponentModel.TypeConverter/tests/Drawing/StringTypeConverterTestBase.cs @@ -0,0 +1,174 @@ +// 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; +using System.Globalization; +using Xunit; + +namespace System.ComponentModel.TypeConverterTests +{ + public abstract class StringTypeConverterTestBase<T> + { + protected abstract T Default { get; } + protected abstract TypeConverter Converter { get; } + protected abstract bool StandardValuesSupported { get; } + protected abstract bool StandardValuesExclusive { get; } + protected abstract bool CreateInstanceSupported { get; } + protected abstract bool IsGetPropertiesSupported { get; } + + protected virtual IEnumerable<Tuple<T, Dictionary<string, object>>> CreateInstancePairs + { + get { yield break; } + } + + [Fact] + public void GetStandardValuesSupported() + { + Assert.Equal(StandardValuesSupported, Converter.GetStandardValuesSupported()); + Assert.Equal(StandardValuesSupported, Converter.GetStandardValuesSupported(null)); + } + + [Fact] + public void GetStandardValues() + { + if (!StandardValuesSupported) + { + Assert.Null(Converter.GetStandardValues()); + } + } + + [Fact] + public void GetStandardValuesExclusive() + { + Assert.Equal(StandardValuesExclusive, Converter.GetStandardValuesExclusive()); + } + + protected void CanConvertFrom(Type type) + { + Assert.True(Converter.CanConvertFrom(type)); + Assert.True(Converter.CanConvertFrom(null, type)); + } + + protected void CannotConvertFrom(Type type) + { + Assert.False(Converter.CanConvertFrom(type)); + Assert.False(Converter.CanConvertFrom(null, type)); + } + + protected void CanConvertTo(Type type) + { + Assert.True(Converter.CanConvertTo(type)); + Assert.True(Converter.CanConvertTo(null, type)); + } + + protected void CannotConvertTo(Type type) + { + Assert.False(Converter.CanConvertTo(type)); + Assert.False(Converter.CanConvertTo(null, type)); + } + + protected void TestConvertFromString(T value, string str) + { + Assert.Equal(value, (T)Converter.ConvertFrom(null, CultureInfo.InvariantCulture, str)); + } + + protected void TestConvertToString(T value, string str) + { + Assert.Equal(str, (string)Converter.ConvertTo(null, CultureInfo.InvariantCulture, value, typeof(string))); + } + + protected void ConvertFromThrowsArgumentExceptionForString(string value) + { + Assert.Throws<ArgumentException>(() => + { + Converter.ConvertFrom(null, CultureInfo.InvariantCulture, value); + }); + } + + protected void ConvertFromThrowsFormatInnerExceptionForString(string value) + { + var ex = Assert.Throws<Exception>(() => + { + Converter.ConvertFrom(null, CultureInfo.InvariantCulture, value); + }); + Assert.NotNull(ex.InnerException); + Assert.IsType<FormatException>(ex.InnerException); + } + + protected void ConvertFromThrowsNotSupportedFor(object value) + { + Assert.Throws<NotSupportedException>(() => + { + Converter.ConvertFrom(null, CultureInfo.InvariantCulture, value); + }); + } + + protected void ConvertToThrowsNotSupportedForType(Type type) + { + Assert.Throws<NotSupportedException>(() => + { + Converter.ConvertTo(null, CultureInfo.InvariantCulture, Default, type); + }); + } + + [Fact] + public void GetCreateInstanceSupported() + { + Assert.Equal(CreateInstanceSupported, Converter.GetCreateInstanceSupported()); + Assert.Equal(CreateInstanceSupported, Converter.GetCreateInstanceSupported(null)); + } + + [Fact] + public void CreateInstance() + { + foreach (var pair in CreateInstancePairs) + { + Assert.Equal(pair.Item1, Converter.CreateInstance(pair.Item2)); + } + } + + [Fact] + public void GetPropertiesSupported() + { + Assert.Equal(IsGetPropertiesSupported, Converter.GetPropertiesSupported()); + Assert.Equal(IsGetPropertiesSupported, Converter.GetPropertiesSupported(null)); + } + + protected void ConvertFromInvariantStringThrowsArgumentException(string str) + { + Assert.Throws<ArgumentException>(() => + { + Converter.ConvertFromInvariantString(str); + }); + } + + protected void ConvertFromInvariantStringThrowsFormatInnerException(string str) + { + var ex = Assert.Throws<Exception>(() => + { + Converter.ConvertFromInvariantString(str); + }); + Assert.NotNull(ex.InnerException); + Assert.IsType<FormatException>(ex.InnerException); + } + + protected void ConvertFromStringThrowsArgumentException(string str) + { + Assert.Throws<ArgumentException>(() => + { + Converter.ConvertFromString(str); + }); + } + + protected void ConvertFromStringThrowsFormatInnerException(string str) + { + var ex = Assert.Throws<Exception>(() => + { + Converter.ConvertFromString(str); + }); + Assert.NotNull(ex.InnerException); + Assert.IsType<FormatException>(ex.InnerException); + } + } +}
\ No newline at end of file diff --git a/src/System.ComponentModel.TypeConverter/tests/Performance/System.ComponentModel.TypeConverter.Performance.Tests.csproj b/src/System.ComponentModel.TypeConverter/tests/Performance/System.ComponentModel.TypeConverter.Performance.Tests.csproj index b5ff4861b3..bb436508ba 100644 --- a/src/System.ComponentModel.TypeConverter/tests/Performance/System.ComponentModel.TypeConverter.Performance.Tests.csproj +++ b/src/System.ComponentModel.TypeConverter/tests/Performance/System.ComponentModel.TypeConverter.Performance.Tests.csproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> @@ -7,6 +7,7 @@ <IncludePerformanceTests>true</IncludePerformanceTests> <NugetTargetMoniker>.NETStandard,Version=v1.5</NugetTargetMoniker> <DefineConstants>$(DefineConstants);PERFORMANCE_TESTS</DefineConstants> + <ProjectGuid>{89C76728-ECAF-4905-A33F-BD6BFED5E91D}</ProjectGuid> </PropertyGroup> <PropertyGroup> <DebugEngines>{2E36F1D4-B23C-435D-AB41-18E608940038}</DebugEngines> @@ -14,6 +15,9 @@ <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.7_Debug|AnyCPU'"> + <OutputPath>bin\netstandard1.7_Debug\</OutputPath> + </PropertyGroup> <ItemGroup> <Compile Include="..\SampleClasses.cs" /> <Compile Include="Perf.TypeDescriptorTests.cs" /> diff --git a/src/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.builds b/src/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.builds index 764e1e03cc..fcf01f276b 100644 --- a/src/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.builds +++ b/src/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.builds @@ -2,9 +2,18 @@ <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <ItemGroup> + <Project Include="System.ComponentModel.TypeConverter.Tests.csproj"> + <TargetGroup>netstandard1.7</TargetGroup> + <TestTFMs>netcoreapp1.1</TestTFMs> + </Project> + <Project Include="System.ComponentModel.TypeConverter.Tests.csproj"> + <TargetGroup>netstandard1.7</TargetGroup> + <TestTFMs>net463</TestTFMs> + <OSGroup>Windows_NT</OSGroup> + </Project> <Project Include="System.ComponentModel.TypeConverter.Tests.csproj"/> <Project Include="System.ComponentModel.TypeConverter.Tests.csproj"> - <TestTFMs>net462;net463</TestTFMs> + <TestTFMs>net462</TestTFMs> <OSGroup>Windows_NT</OSGroup> </Project> <Project Include="System.ComponentModel.TypeConverter.Tests.csproj"> diff --git a/src/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj b/src/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj index 6fa5a96b71..cadd3c6f17 100644 --- a/src/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj +++ b/src/System.ComponentModel.TypeConverter/tests/System.ComponentModel.TypeConverter.Tests.csproj @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -8,16 +8,20 @@ <ProjectGuid>{3F0326A1-9E19-4A6C-95CE-63E65C9D2030}</ProjectGuid> <RootNamespace>System.ComponentModel.TypeConverter.Tests</RootNamespace> <AssemblyName>System.ComponentModel.TypeConverter.Tests</AssemblyName> - <NugetTargetMoniker Condition="'$(NugetTargetMoniker)'==''">.NETStandard,Version=v1.5</NugetTargetMoniker> + <NugetTargetMoniker Condition=" '$(TargetGroup)' == '' ">.NETStandard,Version=v1.5</NugetTargetMoniker> <DefineConstants>$(DefineConstants);FUNCTIONAL_TESTS</DefineConstants> </PropertyGroup> <PropertyGroup> <DebugEngines>{2E36F1D4-B23C-435D-AB41-18E608940038}</DebugEngines> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.7_Debug|AnyCPU' "> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.7_Release|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.5_Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.5_Release|AnyCPU' "> </PropertyGroup> <ItemGroup> <Compile Include="ArrayConverterTests.cs" /> @@ -67,6 +71,14 @@ <Compile Include="UInt64ConverterTests.cs" /> <Compile Include="UriTypeConverterTests.cs" /> </ItemGroup> + <ItemGroup Condition=" '$(TargetGroup)' == 'netstandard1.7'"> + <Compile Include="Drawing\ColorConverterTests.cs" /> + <Compile Include="Drawing\PointConverterTests.cs" /> + <Compile Include="Drawing\RectangleConverterTests.cs" /> + <Compile Include="Drawing\SizeConverterTests.cs" /> + <Compile Include="Drawing\SizeFConverterTests.cs" /> + <Compile Include="Drawing\StringTypeConverterTestBase.cs" /> + </ItemGroup> <ItemGroup Condition="'$(TargetGroup)'=='netstandard1.7'"> <Compile Include="TimerTests.cs" /> </ItemGroup> @@ -74,8 +86,12 @@ <ProjectReference Include="..\pkg\System.ComponentModel.TypeConverter.pkgproj"> </ProjectReference> </ItemGroup> + <!-- TODO: Replace this with a package reference. --> + <ItemGroup Condition="'$(TargetGroup)'=='netstandard1.7'"> + <ProjectReference Include="..\..\System.Drawing.Primitives\pkg\System.Drawing.Primitives.pkgproj" /> + </ItemGroup> <ItemGroup> <None Include="project.json" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/src/System.ComponentModel.TypeConverter/tests/project.json b/src/System.ComponentModel.TypeConverter/tests/project.json index 501c7d6233..7dc4e69d48 100644 --- a/src/System.ComponentModel.TypeConverter/tests/project.json +++ b/src/System.ComponentModel.TypeConverter/tests/project.json @@ -5,6 +5,7 @@ "System.Collections.Specialized": "4.3.0-beta-24520-06", "System.ComponentModel.Primitives": "4.3.0-beta-24520-06", "System.Globalization": "4.3.0-beta-24520-06", + "System.Linq": "4.3.0-beta-24520-06", "System.Linq.Expressions": "4.3.0-beta-24520-06", "System.ObjectModel": "4.3.0-beta-24520-06", "System.Reflection": "4.3.0-beta-24520-06", diff --git a/src/System.Drawing.Primitives/System.Drawing.Primitives.sln b/src/System.Drawing.Primitives/System.Drawing.Primitives.sln index bbcd2a4145..20143d53b4 100644 --- a/src/System.Drawing.Primitives/System.Drawing.Primitives.sln +++ b/src/System.Drawing.Primitives/System.Drawing.Primitives.sln @@ -1,7 +1,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Drawing.Primitives", "src\System.Drawing.Primitives.csproj", "{F9DF2357-81B4-4317-908E-512DA9395583}" EndProject @@ -9,18 +9,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Drawing.Primitives.T EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU + netstandard1.7_Debug|Any CPU = netstandard1.7_Debug|Any CPU + netstandard1.7_Release|Any CPU = netstandard1.7_Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F9DF2357-81B4-4317-908E-512DA9395583}.Debug|Any CPU.ActiveCfg = Release|Any CPU - {F9DF2357-81B4-4317-908E-512DA9395583}.Debug|Any CPU.Build.0 = Release|Any CPU - {F9DF2357-81B4-4317-908E-512DA9395583}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9DF2357-81B4-4317-908E-512DA9395583}.Release|Any CPU.Build.0 = Release|Any CPU - {297A9116-1005-499D-A895-2063D03E4C94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {297A9116-1005-499D-A895-2063D03E4C94}.Debug|Any CPU.Build.0 = Debug|Any CPU - {297A9116-1005-499D-A895-2063D03E4C94}.Release|Any CPU.ActiveCfg = Release|Any CPU - {297A9116-1005-499D-A895-2063D03E4C94}.Release|Any CPU.Build.0 = Release|Any CPU + {F9DF2357-81B4-4317-908E-512DA9395583}.netstandard1.7_Debug|Any CPU.ActiveCfg = netstandard1.7_Debug|Any CPU + {F9DF2357-81B4-4317-908E-512DA9395583}.netstandard1.7_Debug|Any CPU.Build.0 = netstandard1.7_Debug|Any CPU + {F9DF2357-81B4-4317-908E-512DA9395583}.netstandard1.7_Release|Any CPU.ActiveCfg = netstandard1.7_Release|Any CPU + {F9DF2357-81B4-4317-908E-512DA9395583}.netstandard1.7_Release|Any CPU.Build.0 = netstandard1.7_Release|Any CPU + {297A9116-1005-499D-A895-2063D03E4C94}.netstandard1.7_Debug|Any CPU.ActiveCfg = netstandard1.7_Debug|Any CPU + {297A9116-1005-499D-A895-2063D03E4C94}.netstandard1.7_Debug|Any CPU.Build.0 = netstandard1.7_Debug|Any CPU + {297A9116-1005-499D-A895-2063D03E4C94}.netstandard1.7_Release|Any CPU.ActiveCfg = netstandard1.7_Release|Any CPU + {297A9116-1005-499D-A895-2063D03E4C94}.netstandard1.7_Release|Any CPU.Build.0 = netstandard1.7_Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/System.Drawing.Primitives/dir.props b/src/System.Drawing.Primitives/dir.props index 38aaf93ed7..e8201d60ba 100644 --- a/src/System.Drawing.Primitives/dir.props +++ b/src/System.Drawing.Primitives/dir.props @@ -1,7 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="..\dir.props" /> <PropertyGroup> - <AssemblyVersion>4.0.1.0</AssemblyVersion> + <AssemblyVersion>4.1.0.0</AssemblyVersion> </PropertyGroup> </Project> - diff --git a/src/System.Drawing.Primitives/pkg/System.Drawing.Primitives.pkgproj b/src/System.Drawing.Primitives/pkg/System.Drawing.Primitives.pkgproj index fbdbdbcb47..1a38bbee4a 100644 --- a/src/System.Drawing.Primitives/pkg/System.Drawing.Primitives.pkgproj +++ b/src/System.Drawing.Primitives/pkg/System.Drawing.Primitives.pkgproj @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <ItemGroup> <ProjectReference Include="..\ref\System.Drawing.Primitives.csproj"> - <SupportedFramework>netcore45;net45;netcoreapp1.0;wpa81;$(AllXamarinFrameworks)</SupportedFramework> + <SupportedFramework>net463;netcoreapp1.1;$(AllXamarinFrameworks)</SupportedFramework> </ProjectReference> <ProjectReference Include="..\src\System.Drawing.Primitives.builds"> </ProjectReference> - <InboxOnTargetFramework Include="$(AllXamarinFrameworks)" /> + <InboxOnTargetFramework Include="$(AllXamarinFrameworks)" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs b/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs index a49b5b65a6..d3c00d57dd 100644 --- a/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs +++ b/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.cs @@ -7,175 +7,554 @@ namespace System.Drawing { + [System.SerializableAttribute] + public partial struct Color + { + public static readonly System.Drawing.Color Empty; + public byte A { get { throw null; } } + public static System.Drawing.Color AliceBlue { get { throw null; } } + public static System.Drawing.Color AntiqueWhite { get { throw null; } } + public static System.Drawing.Color Aqua { get { throw null; } } + public static System.Drawing.Color Aquamarine { get { throw null; } } + public static System.Drawing.Color Azure { get { throw null; } } + public byte B { get { throw null; } } + public static System.Drawing.Color Beige { get { throw null; } } + public static System.Drawing.Color Bisque { get { throw null; } } + public static System.Drawing.Color Black { get { throw null; } } + public static System.Drawing.Color BlanchedAlmond { get { throw null; } } + public static System.Drawing.Color Blue { get { throw null; } } + public static System.Drawing.Color BlueViolet { get { throw null; } } + public static System.Drawing.Color Brown { get { throw null; } } + public static System.Drawing.Color BurlyWood { get { throw null; } } + public static System.Drawing.Color CadetBlue { get { throw null; } } + public static System.Drawing.Color Chartreuse { get { throw null; } } + public static System.Drawing.Color Chocolate { get { throw null; } } + public static System.Drawing.Color Coral { get { throw null; } } + public static System.Drawing.Color CornflowerBlue { get { throw null; } } + public static System.Drawing.Color Cornsilk { get { throw null; } } + public static System.Drawing.Color Crimson { get { throw null; } } + public static System.Drawing.Color Cyan { get { throw null; } } + public static System.Drawing.Color DarkBlue { get { throw null; } } + public static System.Drawing.Color DarkCyan { get { throw null; } } + public static System.Drawing.Color DarkGoldenrod { get { throw null; } } + public static System.Drawing.Color DarkGray { get { throw null; } } + public static System.Drawing.Color DarkGreen { get { throw null; } } + public static System.Drawing.Color DarkKhaki { get { throw null; } } + public static System.Drawing.Color DarkMagenta { get { throw null; } } + public static System.Drawing.Color DarkOliveGreen { get { throw null; } } + public static System.Drawing.Color DarkOrange { get { throw null; } } + public static System.Drawing.Color DarkOrchid { get { throw null; } } + public static System.Drawing.Color DarkRed { get { throw null; } } + public static System.Drawing.Color DarkSalmon { get { throw null; } } + public static System.Drawing.Color DarkSeaGreen { get { throw null; } } + public static System.Drawing.Color DarkSlateBlue { get { throw null; } } + public static System.Drawing.Color DarkSlateGray { get { throw null; } } + public static System.Drawing.Color DarkTurquoise { get { throw null; } } + public static System.Drawing.Color DarkViolet { get { throw null; } } + public static System.Drawing.Color DeepPink { get { throw null; } } + public static System.Drawing.Color DeepSkyBlue { get { throw null; } } + public static System.Drawing.Color DimGray { get { throw null; } } + public static System.Drawing.Color DodgerBlue { get { throw null; } } + public static System.Drawing.Color Firebrick { get { throw null; } } + public static System.Drawing.Color FloralWhite { get { throw null; } } + public static System.Drawing.Color ForestGreen { get { throw null; } } + public static System.Drawing.Color Fuchsia { get { throw null; } } + public byte G { get { throw null; } } + public static System.Drawing.Color Gainsboro { get { throw null; } } + public static System.Drawing.Color GhostWhite { get { throw null; } } + public static System.Drawing.Color Gold { get { throw null; } } + public static System.Drawing.Color Goldenrod { get { throw null; } } + public static System.Drawing.Color Gray { get { throw null; } } + public static System.Drawing.Color Green { get { throw null; } } + public static System.Drawing.Color GreenYellow { get { throw null; } } + public static System.Drawing.Color Honeydew { get { throw null; } } + public static System.Drawing.Color HotPink { get { throw null; } } + public static System.Drawing.Color IndianRed { get { throw null; } } + public static System.Drawing.Color Indigo { get { throw null; } } + public bool IsEmpty { get { throw null; } } + public bool IsKnownColor { get { throw null; } } + public bool IsNamedColor { get { throw null; } } + public bool IsSystemColor { get { throw null; } } + public static System.Drawing.Color Ivory { get { throw null; } } + public static System.Drawing.Color Khaki { get { throw null; } } + public static System.Drawing.Color Lavender { get { throw null; } } + public static System.Drawing.Color LavenderBlush { get { throw null; } } + public static System.Drawing.Color LawnGreen { get { throw null; } } + public static System.Drawing.Color LemonChiffon { get { throw null; } } + public static System.Drawing.Color LightBlue { get { throw null; } } + public static System.Drawing.Color LightCoral { get { throw null; } } + public static System.Drawing.Color LightCyan { get { throw null; } } + public static System.Drawing.Color LightGoldenrodYellow { get { throw null; } } + public static System.Drawing.Color LightGray { get { throw null; } } + public static System.Drawing.Color LightGreen { get { throw null; } } + public static System.Drawing.Color LightPink { get { throw null; } } + public static System.Drawing.Color LightSalmon { get { throw null; } } + public static System.Drawing.Color LightSeaGreen { get { throw null; } } + public static System.Drawing.Color LightSkyBlue { get { throw null; } } + public static System.Drawing.Color LightSlateGray { get { throw null; } } + public static System.Drawing.Color LightSteelBlue { get { throw null; } } + public static System.Drawing.Color LightYellow { get { throw null; } } + public static System.Drawing.Color Lime { get { throw null; } } + public static System.Drawing.Color LimeGreen { get { throw null; } } + public static System.Drawing.Color Linen { get { throw null; } } + public static System.Drawing.Color Magenta { get { throw null; } } + public static System.Drawing.Color Maroon { get { throw null; } } + public static System.Drawing.Color MediumAquamarine { get { throw null; } } + public static System.Drawing.Color MediumBlue { get { throw null; } } + public static System.Drawing.Color MediumOrchid { get { throw null; } } + public static System.Drawing.Color MediumPurple { get { throw null; } } + public static System.Drawing.Color MediumSeaGreen { get { throw null; } } + public static System.Drawing.Color MediumSlateBlue { get { throw null; } } + public static System.Drawing.Color MediumSpringGreen { get { throw null; } } + public static System.Drawing.Color MediumTurquoise { get { throw null; } } + public static System.Drawing.Color MediumVioletRed { get { throw null; } } + public static System.Drawing.Color MidnightBlue { get { throw null; } } + public static System.Drawing.Color MintCream { get { throw null; } } + public static System.Drawing.Color MistyRose { get { throw null; } } + public static System.Drawing.Color Moccasin { get { throw null; } } + public string Name { get { throw null; } } + public static System.Drawing.Color NavajoWhite { get { throw null; } } + public static System.Drawing.Color Navy { get { throw null; } } + public static System.Drawing.Color OldLace { get { throw null; } } + public static System.Drawing.Color Olive { get { throw null; } } + public static System.Drawing.Color OliveDrab { get { throw null; } } + public static System.Drawing.Color Orange { get { throw null; } } + public static System.Drawing.Color OrangeRed { get { throw null; } } + public static System.Drawing.Color Orchid { get { throw null; } } + public static System.Drawing.Color PaleGoldenrod { get { throw null; } } + public static System.Drawing.Color PaleGreen { get { throw null; } } + public static System.Drawing.Color PaleTurquoise { get { throw null; } } + public static System.Drawing.Color PaleVioletRed { get { throw null; } } + public static System.Drawing.Color PapayaWhip { get { throw null; } } + public static System.Drawing.Color PeachPuff { get { throw null; } } + public static System.Drawing.Color Peru { get { throw null; } } + public static System.Drawing.Color Pink { get { throw null; } } + public static System.Drawing.Color Plum { get { throw null; } } + public static System.Drawing.Color PowderBlue { get { throw null; } } + public static System.Drawing.Color Purple { get { throw null; } } + public byte R { get { throw null; } } + public static System.Drawing.Color Red { get { throw null; } } + public static System.Drawing.Color RosyBrown { get { throw null; } } + public static System.Drawing.Color RoyalBlue { get { throw null; } } + public static System.Drawing.Color SaddleBrown { get { throw null; } } + public static System.Drawing.Color Salmon { get { throw null; } } + public static System.Drawing.Color SandyBrown { get { throw null; } } + public static System.Drawing.Color SeaGreen { get { throw null; } } + public static System.Drawing.Color SeaShell { get { throw null; } } + public static System.Drawing.Color Sienna { get { throw null; } } + public static System.Drawing.Color Silver { get { throw null; } } + public static System.Drawing.Color SkyBlue { get { throw null; } } + public static System.Drawing.Color SlateBlue { get { throw null; } } + public static System.Drawing.Color SlateGray { get { throw null; } } + public static System.Drawing.Color Snow { get { throw null; } } + public static System.Drawing.Color SpringGreen { get { throw null; } } + public static System.Drawing.Color SteelBlue { get { throw null; } } + public static System.Drawing.Color Tan { get { throw null; } } + public static System.Drawing.Color Teal { get { throw null; } } + public static System.Drawing.Color Thistle { get { throw null; } } + public static System.Drawing.Color Tomato { get { throw null; } } + public static System.Drawing.Color Transparent { get { throw null; } } + public static System.Drawing.Color Turquoise { get { throw null; } } + public static System.Drawing.Color Violet { get { throw null; } } + public static System.Drawing.Color Wheat { get { throw null; } } + public static System.Drawing.Color White { get { throw null; } } + public static System.Drawing.Color WhiteSmoke { get { throw null; } } + public static System.Drawing.Color Yellow { get { throw null; } } + public static System.Drawing.Color YellowGreen { get { throw null; } } + public override bool Equals(object obj) { throw null; } + public static System.Drawing.Color FromArgb(int argb) { throw null; } + public static System.Drawing.Color FromArgb(int alpha, System.Drawing.Color baseColor) { throw null; } + public static System.Drawing.Color FromArgb(int red, int green, int blue) { throw null; } + public static System.Drawing.Color FromArgb(int alpha, int red, int green, int blue) { throw null; } + public static System.Drawing.Color FromKnownColor(System.Drawing.KnownColor color) { throw null; } + public static System.Drawing.Color FromName(string name) { throw null; } + public float GetBrightness() { throw null; } + public override int GetHashCode() { throw null; } + public float GetHue() { throw null; } + public float GetSaturation() { throw null; } + public static bool operator ==(System.Drawing.Color left, System.Drawing.Color right) { throw null; } + public static bool operator !=(System.Drawing.Color left, System.Drawing.Color right) { throw null; } + public int ToArgb() { throw null; } + public System.Drawing.KnownColor ToKnownColor() { throw null; } + public override string ToString() { throw null; } + } + public enum KnownColor + { + ActiveBorder = 1, + ActiveCaption = 2, + ActiveCaptionText = 3, + AliceBlue = 28, + AntiqueWhite = 29, + AppWorkspace = 4, + Aqua = 30, + Aquamarine = 31, + Azure = 32, + Beige = 33, + Bisque = 34, + Black = 35, + BlanchedAlmond = 36, + Blue = 37, + BlueViolet = 38, + Brown = 39, + BurlyWood = 40, + ButtonFace = 168, + ButtonHighlight = 169, + ButtonShadow = 170, + CadetBlue = 41, + Chartreuse = 42, + Chocolate = 43, + Control = 5, + ControlDark = 6, + ControlDarkDark = 7, + ControlLight = 8, + ControlLightLight = 9, + ControlText = 10, + Coral = 44, + CornflowerBlue = 45, + Cornsilk = 46, + Crimson = 47, + Cyan = 48, + DarkBlue = 49, + DarkCyan = 50, + DarkGoldenrod = 51, + DarkGray = 52, + DarkGreen = 53, + DarkKhaki = 54, + DarkMagenta = 55, + DarkOliveGreen = 56, + DarkOrange = 57, + DarkOrchid = 58, + DarkRed = 59, + DarkSalmon = 60, + DarkSeaGreen = 61, + DarkSlateBlue = 62, + DarkSlateGray = 63, + DarkTurquoise = 64, + DarkViolet = 65, + DeepPink = 66, + DeepSkyBlue = 67, + Desktop = 11, + DimGray = 68, + DodgerBlue = 69, + Firebrick = 70, + FloralWhite = 71, + ForestGreen = 72, + Fuchsia = 73, + Gainsboro = 74, + GhostWhite = 75, + Gold = 76, + Goldenrod = 77, + GradientActiveCaption = 171, + GradientInactiveCaption = 172, + Gray = 78, + GrayText = 12, + Green = 79, + GreenYellow = 80, + Highlight = 13, + HighlightText = 14, + Honeydew = 81, + HotPink = 82, + HotTrack = 15, + InactiveBorder = 16, + InactiveCaption = 17, + InactiveCaptionText = 18, + IndianRed = 83, + Indigo = 84, + Info = 19, + InfoText = 20, + Ivory = 85, + Khaki = 86, + Lavender = 87, + LavenderBlush = 88, + LawnGreen = 89, + LemonChiffon = 90, + LightBlue = 91, + LightCoral = 92, + LightCyan = 93, + LightGoldenrodYellow = 94, + LightGray = 95, + LightGreen = 96, + LightPink = 97, + LightSalmon = 98, + LightSeaGreen = 99, + LightSkyBlue = 100, + LightSlateGray = 101, + LightSteelBlue = 102, + LightYellow = 103, + Lime = 104, + LimeGreen = 105, + Linen = 106, + Magenta = 107, + Maroon = 108, + MediumAquamarine = 109, + MediumBlue = 110, + MediumOrchid = 111, + MediumPurple = 112, + MediumSeaGreen = 113, + MediumSlateBlue = 114, + MediumSpringGreen = 115, + MediumTurquoise = 116, + MediumVioletRed = 117, + Menu = 21, + MenuBar = 173, + MenuHighlight = 174, + MenuText = 22, + MidnightBlue = 118, + MintCream = 119, + MistyRose = 120, + Moccasin = 121, + NavajoWhite = 122, + Navy = 123, + OldLace = 124, + Olive = 125, + OliveDrab = 126, + Orange = 127, + OrangeRed = 128, + Orchid = 129, + PaleGoldenrod = 130, + PaleGreen = 131, + PaleTurquoise = 132, + PaleVioletRed = 133, + PapayaWhip = 134, + PeachPuff = 135, + Peru = 136, + Pink = 137, + Plum = 138, + PowderBlue = 139, + Purple = 140, + Red = 141, + RosyBrown = 142, + RoyalBlue = 143, + SaddleBrown = 144, + Salmon = 145, + SandyBrown = 146, + ScrollBar = 23, + SeaGreen = 147, + SeaShell = 148, + Sienna = 149, + Silver = 150, + SkyBlue = 151, + SlateBlue = 152, + SlateGray = 153, + Snow = 154, + SpringGreen = 155, + SteelBlue = 156, + Tan = 157, + Teal = 158, + Thistle = 159, + Tomato = 160, + Transparent = 27, + Turquoise = 161, + Violet = 162, + Wheat = 163, + White = 164, + WhiteSmoke = 165, + Window = 24, + WindowFrame = 25, + WindowText = 26, + Yellow = 166, + YellowGreen = 167, + } public partial struct Point { - public static readonly Point Empty; - public Point(Size sz) { } - public Point(int dw) { } - public Point(int x, int y) { } - public bool IsEmpty { get { return default(bool); } } - public int X { get { return default(int); } set { } } - public int Y { get { return default(int); } set { } } - public static Point Add(Point pt, Size sz) { return default(Point); } - public static Point Ceiling(PointF value) { return default(Point); } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } - public void Offset(Point p) { } + public static readonly System.Drawing.Point Empty; + public Point(System.Drawing.Size sz) { throw null;} + public Point(int dw) { throw null;} + public Point(int x, int y) { throw null;} + public bool IsEmpty { get { throw null; } } + public int X { get { throw null; } set { } } + public int Y { get { throw null; } set { } } + public static System.Drawing.Point Add(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; } + public static System.Drawing.Point Ceiling(System.Drawing.PointF value) { throw null; } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } + public void Offset(System.Drawing.Point p) { } public void Offset(int dx, int dy) { } - public static Point operator +(Point pt, Size sz) { return default(Point); } - public static bool operator ==(Point left, Point right) { return default(bool); } - public static explicit operator Size(Point p) { return default(Size); } - public static implicit operator PointF(Point p) { return default(PointF); } - public static bool operator !=(Point left, Point right) { return default(bool); } - public static Point operator -(Point pt, Size sz) { return default(Point); } - public static Point Round(PointF value) { return default(Point); } - public static Point Subtract(Point pt, Size sz) { return default(Point); } - public override string ToString() { return default(string); } - public static Point Truncate(PointF value) { return default(Point); } + public static System.Drawing.Point operator +(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; } + public static bool operator ==(System.Drawing.Point left, System.Drawing.Point right) { throw null; } + public static explicit operator System.Drawing.Size (System.Drawing.Point p) { throw null; } + public static implicit operator System.Drawing.PointF (System.Drawing.Point p) { throw null; } + public static bool operator !=(System.Drawing.Point left, System.Drawing.Point right) { throw null; } + public static System.Drawing.Point operator -(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; } + public static System.Drawing.Point Round(System.Drawing.PointF value) { throw null; } + public static System.Drawing.Point Subtract(System.Drawing.Point pt, System.Drawing.Size sz) { throw null; } + public override string ToString() { throw null; } + public static System.Drawing.Point Truncate(System.Drawing.PointF value) { throw null; } } - public partial struct PointF { - public static readonly PointF Empty; - public PointF(float x, float y) { } - public bool IsEmpty { get { return default(bool); } } - public float X { get { return default(float); } set { } } - public float Y { get { return default(float); } set { } } - public static PointF Add(PointF pt, Size sz) { return default(PointF); } - public static PointF Add(PointF pt, SizeF sz) { return default(PointF); } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } - public static PointF operator +(PointF pt, Size sz) { return default(PointF); } - public static PointF operator +(PointF pt, SizeF sz) { return default(PointF); } - public static bool operator ==(PointF left, PointF right) { return default(bool); } - public static bool operator !=(PointF left, PointF right) { return default(bool); } - public static PointF operator -(PointF pt, Size sz) { return default(PointF); } - public static PointF operator -(PointF pt, SizeF sz) { return default(PointF); } - public static PointF Subtract(PointF pt, Size sz) { return default(PointF); } - public static PointF Subtract(PointF pt, SizeF sz) { return default(PointF); } - public override string ToString() { return default(string); } + public static readonly System.Drawing.PointF Empty; + public PointF(float x, float y) { throw null;} + public bool IsEmpty { get { throw null; } } + public float X { get { throw null; } set { } } + public float Y { get { throw null; } set { } } + public static System.Drawing.PointF Add(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; } + public static System.Drawing.PointF Add(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } + public static System.Drawing.PointF operator +(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; } + public static System.Drawing.PointF operator +(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; } + public static bool operator ==(System.Drawing.PointF left, System.Drawing.PointF right) { throw null; } + public static bool operator !=(System.Drawing.PointF left, System.Drawing.PointF right) { throw null; } + public static System.Drawing.PointF operator -(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; } + public static System.Drawing.PointF operator -(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; } + public static System.Drawing.PointF Subtract(System.Drawing.PointF pt, System.Drawing.Size sz) { throw null; } + public static System.Drawing.PointF Subtract(System.Drawing.PointF pt, System.Drawing.SizeF sz) { throw null; } + public override string ToString() { throw null; } } - public partial struct Rectangle { - public static readonly Rectangle Empty; - public Rectangle(Point location, Size size) { } - public Rectangle(int x, int y, int width, int height) { } - public int Bottom { get { return default(int); } } - public int Height { get { return default(int); } set { } } - public bool IsEmpty { get { return default(bool); } } - public int Left { get { return default(int); } } - public Point Location { get { return default(Point); } set { } } - public int Right { get { return default(int); } } - public Size Size { get { return default(Size); } set { } } - public int Top { get { return default(int); } } - public int Width { get { return default(int); } set { } } - public int X { get { return default(int); } set { } } - public int Y { get { return default(int); } set { } } - public static Rectangle Ceiling(RectangleF value) { return default(Rectangle); } - public bool Contains(Point pt) { return default(bool); } - public bool Contains(Rectangle rect) { return default(bool); } - public bool Contains(int x, int y) { return default(bool); } - public override bool Equals(object obj) { return default(bool); } - public static Rectangle FromLTRB(int left, int top, int right, int bottom) { return default(Rectangle); } - public override int GetHashCode() { return default(int); } - public static Rectangle Inflate(Rectangle rect, int x, int y) { return default(Rectangle); } - public void Inflate(Size size) { } + public static readonly System.Drawing.Rectangle Empty; + public Rectangle(System.Drawing.Point location, System.Drawing.Size size) { throw null;} + public Rectangle(int x, int y, int width, int height) { throw null;} + public int Bottom { get { throw null; } } + public int Height { get { throw null; } set { } } + public bool IsEmpty { get { throw null; } } + public int Left { get { throw null; } } + public System.Drawing.Point Location { get { throw null; } set { } } + public int Right { get { throw null; } } + public System.Drawing.Size Size { get { throw null; } set { } } + public int Top { get { throw null; } } + public int Width { get { throw null; } set { } } + public int X { get { throw null; } set { } } + public int Y { get { throw null; } set { } } + public static System.Drawing.Rectangle Ceiling(System.Drawing.RectangleF value) { throw null; } + public bool Contains(System.Drawing.Point pt) { throw null; } + public bool Contains(System.Drawing.Rectangle rect) { throw null; } + public bool Contains(int x, int y) { throw null; } + public override bool Equals(object obj) { throw null; } + public static System.Drawing.Rectangle FromLTRB(int left, int top, int right, int bottom) { throw null; } + public override int GetHashCode() { throw null; } + public static System.Drawing.Rectangle Inflate(System.Drawing.Rectangle rect, int x, int y) { throw null; } + public void Inflate(System.Drawing.Size size) { } public void Inflate(int width, int height) { } - public void Intersect(Rectangle rect) { } - public static Rectangle Intersect(Rectangle a, Rectangle b) { return default(Rectangle); } - public bool IntersectsWith(Rectangle rect) { return default(bool); } - public void Offset(Point pos) { } + public void Intersect(System.Drawing.Rectangle rect) { } + public static System.Drawing.Rectangle Intersect(System.Drawing.Rectangle a, System.Drawing.Rectangle b) { throw null; } + public bool IntersectsWith(System.Drawing.Rectangle rect) { throw null; } + public void Offset(System.Drawing.Point pos) { } public void Offset(int x, int y) { } - public static bool operator ==(Rectangle left, Rectangle right) { return default(bool); } - public static bool operator !=(Rectangle left, Rectangle right) { return default(bool); } - public static Rectangle Round(RectangleF value) { return default(Rectangle); } - public override string ToString() { return default(string); } - public static Rectangle Truncate(RectangleF value) { return default(Rectangle); } - public static Rectangle Union(Rectangle a, Rectangle b) { return default(Rectangle); } + public static bool operator ==(System.Drawing.Rectangle left, System.Drawing.Rectangle right) { throw null; } + public static bool operator !=(System.Drawing.Rectangle left, System.Drawing.Rectangle right) { throw null; } + public static System.Drawing.Rectangle Round(System.Drawing.RectangleF value) { throw null; } + public override string ToString() { throw null; } + public static System.Drawing.Rectangle Truncate(System.Drawing.RectangleF value) { throw null; } + public static System.Drawing.Rectangle Union(System.Drawing.Rectangle a, System.Drawing.Rectangle b) { throw null; } } - public partial struct RectangleF { - public static readonly RectangleF Empty; - public RectangleF(PointF location, SizeF size) { } - public RectangleF(float x, float y, float width, float height) { } - public float Bottom { get { return default(float); } } - public float Height { get { return default(float); } set { } } - public bool IsEmpty { get { return default(bool); } } - public float Left { get { return default(float); } } - public PointF Location { get { { return default(PointF); } } set { } } - public float Right { get { return default(float); } } - public SizeF Size { get { return default(SizeF); } set { } } - public float Top { get { return default(float); } } - public float Width { get { return default(float); } set { } } - public float X { get { return default(float); } set { } } - public float Y { get { return default(float); } set { } } - public bool Contains(PointF pt) { return default(bool); } - public bool Contains(RectangleF rect) { return default(bool); } - public bool Contains(float x, float y) { return default(bool); } - public override bool Equals(object obj) { return default(bool); } - public static RectangleF FromLTRB(float left, float top, float right, float bottom) { return default(RectangleF); } - public override int GetHashCode() { return default(int); } - public static RectangleF Inflate(RectangleF rect, float x, float y) { return default(RectangleF); } - public void Inflate(SizeF size) { } + public static readonly System.Drawing.RectangleF Empty; + public RectangleF(System.Drawing.PointF location, System.Drawing.SizeF size) { throw null;} + public RectangleF(float x, float y, float width, float height) { throw null;} + public float Bottom { get { throw null; } } + public float Height { get { throw null; } set { } } + public bool IsEmpty { get { throw null; } } + public float Left { get { throw null; } } + public System.Drawing.PointF Location { get { throw null; } set { } } + public float Right { get { throw null; } } + public System.Drawing.SizeF Size { get { throw null; } set { } } + public float Top { get { throw null; } } + public float Width { get { throw null; } set { } } + public float X { get { throw null; } set { } } + public float Y { get { throw null; } set { } } + public bool Contains(System.Drawing.PointF pt) { throw null; } + public bool Contains(System.Drawing.RectangleF rect) { throw null; } + public bool Contains(float x, float y) { throw null; } + public override bool Equals(object obj) { throw null; } + public static System.Drawing.RectangleF FromLTRB(float left, float top, float right, float bottom) { throw null; } + public override int GetHashCode() { throw null; } + public static System.Drawing.RectangleF Inflate(System.Drawing.RectangleF rect, float x, float y) { throw null; } + public void Inflate(System.Drawing.SizeF size) { } public void Inflate(float x, float y) { } - public void Intersect(RectangleF rect) { } - public static RectangleF Intersect(RectangleF a, RectangleF b) { return default(RectangleF); } - public bool IntersectsWith(RectangleF rect) { return default(bool); } - public void Offset(PointF pos) { } + public void Intersect(System.Drawing.RectangleF rect) { } + public static System.Drawing.RectangleF Intersect(System.Drawing.RectangleF a, System.Drawing.RectangleF b) { throw null; } + public bool IntersectsWith(System.Drawing.RectangleF rect) { throw null; } + public void Offset(System.Drawing.PointF pos) { } public void Offset(float x, float y) { } - public static bool operator ==(RectangleF left, RectangleF right) { return default(bool); } - public static implicit operator RectangleF(Rectangle r) { return default(Rectangle); } - public static bool operator !=(RectangleF left, RectangleF right) { return default(bool); } - public override string ToString() { return default(string); } - public static RectangleF Union(RectangleF a, RectangleF b) { return default(RectangleF); } + public static bool operator ==(System.Drawing.RectangleF left, System.Drawing.RectangleF right) { throw null; } + public static implicit operator System.Drawing.RectangleF (System.Drawing.Rectangle r) { throw null; } + public static bool operator !=(System.Drawing.RectangleF left, System.Drawing.RectangleF right) { throw null; } + public override string ToString() { throw null; } + public static System.Drawing.RectangleF Union(System.Drawing.RectangleF a, System.Drawing.RectangleF b) { throw null; } } - public partial struct Size { - public static readonly Size Empty; - public Size(Point pt) { } - public Size(int width, int height) { } - public int Height { get { return default(int); } set { } } - public bool IsEmpty { get { return default(bool); } } - public int Width { get { return default(int); } set { } } - public static Size Add(Size sz1, Size sz2) { return default(Size); } - public static Size Ceiling(SizeF value) { return default(Size); } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } - public static Size operator +(Size sz1, Size sz2) { return default(Size); } - public static bool operator ==(Size sz1, Size sz2) { return default(bool); } - public static explicit operator Point(Size size) { return default(Point); } - public static implicit operator SizeF(Size p) { return default(Size); } - public static bool operator !=(Size sz1, Size sz2) { return default(bool); } - public static Size operator -(Size sz1, Size sz2) { return default(Size); } - public static Size Round(SizeF value) { return default(Size); } - public static Size Subtract(Size sz1, Size sz2) { return default(Size); } - public override string ToString() { return default(string); } - public static Size Truncate(SizeF value) { return default(Size); } + public static readonly System.Drawing.Size Empty; + public Size(System.Drawing.Point pt) { throw null;} + public Size(int width, int height) { throw null;} + public int Height { get { throw null; } set { } } + public bool IsEmpty { get { throw null; } } + public int Width { get { throw null; } set { } } + public static System.Drawing.Size Add(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; } + public static System.Drawing.Size Ceiling(System.Drawing.SizeF value) { throw null; } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } + public static System.Drawing.Size operator +(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; } + public static bool operator ==(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; } + public static explicit operator System.Drawing.Point (System.Drawing.Size size) { throw null; } + public static implicit operator System.Drawing.SizeF (System.Drawing.Size p) { throw null; } + public static bool operator !=(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; } + public static System.Drawing.Size operator -(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; } + public static System.Drawing.Size Round(System.Drawing.SizeF value) { throw null; } + public static System.Drawing.Size Subtract(System.Drawing.Size sz1, System.Drawing.Size sz2) { throw null; } + public override string ToString() { throw null; } + public static System.Drawing.Size Truncate(System.Drawing.SizeF value) { throw null; } } - public partial struct SizeF { - public static readonly SizeF Empty; - public SizeF(PointF pt) { } - public SizeF(SizeF size) { } - public SizeF(float width, float height) { } - public float Height { get { return default(float); } set { } } - public bool IsEmpty { get { return default(bool); } } - public float Width { get { return default(float); } set { } } - public static SizeF Add(SizeF sz1, SizeF sz2) { return default(SizeF); } - public override bool Equals(object obj) { return default(bool); } - public override int GetHashCode() { return default(int); } - public static SizeF operator +(SizeF sz1, SizeF sz2) { return default(SizeF); } - public static bool operator ==(SizeF sz1, SizeF sz2) { return default(bool); } - public static explicit operator PointF(SizeF size) { return default(PointF); } - public static bool operator !=(SizeF sz1, SizeF sz2) { return default(bool); } - public static SizeF operator -(SizeF sz1, SizeF sz2) { return default(SizeF); } - public static SizeF Subtract(SizeF sz1, SizeF sz2) { return default(SizeF); } - public PointF ToPointF() { return default(PointF); } - public Size ToSize() { return default(Size); } - public override string ToString() { return default(string); } + public static readonly System.Drawing.SizeF Empty; + public SizeF(System.Drawing.PointF pt) { throw null;} + public SizeF(System.Drawing.SizeF size) { throw null;} + public SizeF(float width, float height) { throw null;} + public float Height { get { throw null; } set { } } + public bool IsEmpty { get { throw null; } } + public float Width { get { throw null; } set { } } + public static System.Drawing.SizeF Add(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; } + public override bool Equals(object obj) { throw null; } + public override int GetHashCode() { throw null; } + public static System.Drawing.SizeF operator +(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; } + public static bool operator ==(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; } + public static explicit operator System.Drawing.PointF (System.Drawing.SizeF size) { throw null; } + public static bool operator !=(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; } + public static System.Drawing.SizeF operator -(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; } + public static System.Drawing.SizeF Subtract(System.Drawing.SizeF sz1, System.Drawing.SizeF sz2) { throw null; } + public System.Drawing.PointF ToPointF() { throw null; } + public System.Drawing.Size ToSize() { throw null; } + public override string ToString() { throw null; } + } + public static partial class SystemColors + { + public static System.Drawing.Color ActiveBorder { get { throw null; } } + public static System.Drawing.Color ActiveCaption { get { throw null; } } + public static System.Drawing.Color ActiveCaptionText { get { throw null; } } + public static System.Drawing.Color AppWorkspace { get { throw null; } } + public static System.Drawing.Color ButtonFace { get { throw null; } } + public static System.Drawing.Color ButtonHighlight { get { throw null; } } + public static System.Drawing.Color ButtonShadow { get { throw null; } } + public static System.Drawing.Color Control { get { throw null; } } + public static System.Drawing.Color ControlDark { get { throw null; } } + public static System.Drawing.Color ControlDarkDark { get { throw null; } } + public static System.Drawing.Color ControlLight { get { throw null; } } + public static System.Drawing.Color ControlLightLight { get { throw null; } } + public static System.Drawing.Color ControlText { get { throw null; } } + public static System.Drawing.Color Desktop { get { throw null; } } + public static System.Drawing.Color GradientActiveCaption { get { throw null; } } + public static System.Drawing.Color GradientInactiveCaption { get { throw null; } } + public static System.Drawing.Color GrayText { get { throw null; } } + public static System.Drawing.Color Highlight { get { throw null; } } + public static System.Drawing.Color HighlightText { get { throw null; } } + public static System.Drawing.Color HotTrack { get { throw null; } } + public static System.Drawing.Color InactiveBorder { get { throw null; } } + public static System.Drawing.Color InactiveCaption { get { throw null; } } + public static System.Drawing.Color InactiveCaptionText { get { throw null; } } + public static System.Drawing.Color Info { get { throw null; } } + public static System.Drawing.Color InfoText { get { throw null; } } + public static System.Drawing.Color Menu { get { throw null; } } + public static System.Drawing.Color MenuBar { get { throw null; } } + public static System.Drawing.Color MenuHighlight { get { throw null; } } + public static System.Drawing.Color MenuText { get { throw null; } } + public static System.Drawing.Color ScrollBar { get { throw null; } } + public static System.Drawing.Color Window { get { throw null; } } + public static System.Drawing.Color WindowFrame { get { throw null; } } + public static System.Drawing.Color WindowText { get { throw null; } } } } diff --git a/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.csproj b/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.csproj index ebc9ce4a4d..897ad625b1 100644 --- a/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.csproj +++ b/src/System.Drawing.Primitives/ref/System.Drawing.Primitives.csproj @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <OutputType>Library</OutputType> - <NuGetTargetMoniker>.NETStandard,Version=v1.1</NuGetTargetMoniker> + <NuGetTargetMoniker>.NETStandard,Version=v1.7</NuGetTargetMoniker> </PropertyGroup> <ItemGroup> <Compile Include="System.Drawing.Primitives.cs" /> @@ -12,4 +12,4 @@ <None Include="project.json" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/src/System.Drawing.Primitives/ref/project.json b/src/System.Drawing.Primitives/ref/project.json index 0c5f83e6e8..986e149de5 100644 --- a/src/System.Drawing.Primitives/ref/project.json +++ b/src/System.Drawing.Primitives/ref/project.json @@ -1,11 +1,11 @@ { "dependencies": { - "System.Runtime": "4.0.0" + "System.Runtime": "4.3.0-beta-24520-06" }, "frameworks": { - "netstandard1.1": { + "netstandard1.7": { "imports": [ - "dotnet5.2" + "dotnet5.6" ] } } diff --git a/src/System.Drawing.Primitives/src/Resources/Strings.resx b/src/System.Drawing.Primitives/src/Resources/Strings.resx new file mode 100644 index 0000000000..b33753a5d6 --- /dev/null +++ b/src/System.Drawing.Primitives/src/Resources/Strings.resx @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <data name="InvalidEx2BoundArgument" xml:space="preserve"> + <value>Value of '{1}' is not valid for '{0}'. '{0}' should be greater than or equal to {2} and less than or equal to {3}.</value> + </data> +</root> diff --git a/src/System.Drawing.Primitives/src/System.Drawing.Primitives.builds b/src/System.Drawing.Primitives/src/System.Drawing.Primitives.builds index b9b052fb5d..8e73b72c59 100644 --- a/src/System.Drawing.Primitives/src/System.Drawing.Primitives.builds +++ b/src/System.Drawing.Primitives/src/System.Drawing.Primitives.builds @@ -4,7 +4,7 @@ <ItemGroup> <Project Include="System.Drawing.Primitives.csproj" /> <Project Include="System.Drawing.Primitives.csproj"> - <TargetGroup>net45</TargetGroup> + <TargetGroup>net463</TargetGroup> </Project> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" /> diff --git a/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj b/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj index 021a31476e..1cea90d4c0 100644 --- a/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj +++ b/src/System.Drawing.Primitives/src/System.Drawing.Primitives.csproj @@ -1,34 +1,41 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Windows_Debug</Configuration> + <Configuration Condition=" '$(Configuration)' == '' ">netstandard1.7_Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <OutputType>Library</OutputType> <RootNamespace>System.Drawing</RootNamespace> <AssemblyName>System.Drawing.Primitives</AssemblyName> - <IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'net45'">true</IsPartialFacadeAssembly> <ProjectGuid>{F9DF2357-81B4-4317-908E-512DA9395583}</ProjectGuid> - <NuGetTargetMoniker Condition="'$(TargetGroup)' == ''">.NETStandard,Version=v1.1</NuGetTargetMoniker> + <IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'net463'">true</IsPartialFacadeAssembly> + <NuGetTargetMoniker Condition="'$(TargetGroup)' == ''">.NETStandard,Version=v1.7</NuGetTargetMoniker> </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net45_Debug|AnyCPU'" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net45_Release|AnyCPU'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.7_Debug|AnyCPU'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard1.7_Release|AnyCPU'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net463_Debug|AnyCPU'" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'net463_Release|AnyCPU'" /> <ItemGroup> <None Include="project.json" /> </ItemGroup> - <ItemGroup Condition="'$(TargetGroup)' != 'net45'"> + <ItemGroup Condition="'$(TargetGroup)' != 'net463'"> <Compile Include="System\Drawing\Point.cs" /> <Compile Include="System\Drawing\PointF.cs" /> <Compile Include="System\Drawing\Rectangle.cs" /> <Compile Include="System\Drawing\RectangleF.cs" /> <Compile Include="System\Drawing\Size.cs" /> <Compile Include="System\Drawing\SizeF.cs" /> + <Compile Include="System\Drawing\Color.cs" /> + <Compile Include="$(CommonPath)\System\Drawing\ColorTable.cs"> + <Link>System\Drawing\ColorTable.cs</Link> + </Compile> + <Compile Include="System\Drawing\KnownColor.cs" /> + <Compile Include="System\Drawing\KnownColorTable.cs" /> + <Compile Include="System\Drawing\SystemColors.cs" /> </ItemGroup> - <ItemGroup Condition="'$(TargetGroup)' == 'net45'"> + <ItemGroup Condition="'$(TargetGroup)' == 'net463'"> <TargetingPackReference Include="mscorlib" /> <TargetingPackReference Include="System.Drawing" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> -</Project>
\ No newline at end of file +</Project> diff --git a/src/System.Drawing.Primitives/src/System/Drawing/Color.cs b/src/System.Drawing.Primitives/src/System/Drawing/Color.cs new file mode 100644 index 0000000000..a68f84aa12 --- /dev/null +++ b/src/System.Drawing.Primitives/src/System/Drawing/Color.cs @@ -0,0 +1,693 @@ +// 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; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Text; + +namespace System.Drawing +{ + [DebuggerDisplay("{NameAndARGBValue}")] + [Serializable] + public struct Color + { + public static readonly Color Empty = new Color(); + + // ------------------------------------------------------------------- + // static list of "web" colors... + // + public static Color Transparent => new Color(KnownColor.Transparent); + + public static Color AliceBlue => new Color(KnownColor.AliceBlue); + + public static Color AntiqueWhite => new Color(KnownColor.AntiqueWhite); + + public static Color Aqua => new Color(KnownColor.Aqua); + + public static Color Aquamarine => new Color(KnownColor.Aquamarine); + + public static Color Azure => new Color(KnownColor.Azure); + + public static Color Beige => new Color(KnownColor.Beige); + + public static Color Bisque => new Color(KnownColor.Bisque); + + public static Color Black => new Color(KnownColor.Black); + + public static Color BlanchedAlmond => new Color(KnownColor.BlanchedAlmond); + + public static Color Blue => new Color(KnownColor.Blue); + + public static Color BlueViolet => new Color(KnownColor.BlueViolet); + + public static Color Brown => new Color(KnownColor.Brown); + + public static Color BurlyWood => new Color(KnownColor.BurlyWood); + + public static Color CadetBlue => new Color(KnownColor.CadetBlue); + + public static Color Chartreuse => new Color(KnownColor.Chartreuse); + + public static Color Chocolate => new Color(KnownColor.Chocolate); + + public static Color Coral => new Color(KnownColor.Coral); + + public static Color CornflowerBlue => new Color(KnownColor.CornflowerBlue); + + public static Color Cornsilk => new Color(KnownColor.Cornsilk); + + public static Color Crimson => new Color(KnownColor.Crimson); + + public static Color Cyan => new Color(KnownColor.Cyan); + + public static Color DarkBlue => new Color(KnownColor.DarkBlue); + + public static Color DarkCyan => new Color(KnownColor.DarkCyan); + + public static Color DarkGoldenrod => new Color(KnownColor.DarkGoldenrod); + + public static Color DarkGray => new Color(KnownColor.DarkGray); + + public static Color DarkGreen => new Color(KnownColor.DarkGreen); + + public static Color DarkKhaki => new Color(KnownColor.DarkKhaki); + + public static Color DarkMagenta => new Color(KnownColor.DarkMagenta); + + public static Color DarkOliveGreen => new Color(KnownColor.DarkOliveGreen); + + public static Color DarkOrange => new Color(KnownColor.DarkOrange); + + public static Color DarkOrchid => new Color(KnownColor.DarkOrchid); + + public static Color DarkRed => new Color(KnownColor.DarkRed); + + public static Color DarkSalmon => new Color(KnownColor.DarkSalmon); + + public static Color DarkSeaGreen => new Color(KnownColor.DarkSeaGreen); + + public static Color DarkSlateBlue => new Color(KnownColor.DarkSlateBlue); + + public static Color DarkSlateGray => new Color(KnownColor.DarkSlateGray); + + public static Color DarkTurquoise => new Color(KnownColor.DarkTurquoise); + + public static Color DarkViolet => new Color(KnownColor.DarkViolet); + + public static Color DeepPink => new Color(KnownColor.DeepPink); + + public static Color DeepSkyBlue => new Color(KnownColor.DeepSkyBlue); + + public static Color DimGray => new Color(KnownColor.DimGray); + + public static Color DodgerBlue => new Color(KnownColor.DodgerBlue); + + public static Color Firebrick => new Color(KnownColor.Firebrick); + + public static Color FloralWhite => new Color(KnownColor.FloralWhite); + + public static Color ForestGreen => new Color(KnownColor.ForestGreen); + + public static Color Fuchsia => new Color(KnownColor.Fuchsia); + + public static Color Gainsboro => new Color(KnownColor.Gainsboro); + + public static Color GhostWhite => new Color(KnownColor.GhostWhite); + + public static Color Gold => new Color(KnownColor.Gold); + + public static Color Goldenrod => new Color(KnownColor.Goldenrod); + + public static Color Gray => new Color(KnownColor.Gray); + + public static Color Green => new Color(KnownColor.Green); + + public static Color GreenYellow => new Color(KnownColor.GreenYellow); + + public static Color Honeydew => new Color(KnownColor.Honeydew); + + public static Color HotPink => new Color(KnownColor.HotPink); + + public static Color IndianRed => new Color(KnownColor.IndianRed); + + public static Color Indigo => new Color(KnownColor.Indigo); + + public static Color Ivory => new Color(KnownColor.Ivory); + + public static Color Khaki => new Color(KnownColor.Khaki); + + public static Color Lavender => new Color(KnownColor.Lavender); + + public static Color LavenderBlush => new Color(KnownColor.LavenderBlush); + + public static Color LawnGreen => new Color(KnownColor.LawnGreen); + + public static Color LemonChiffon => new Color(KnownColor.LemonChiffon); + + public static Color LightBlue => new Color(KnownColor.LightBlue); + + public static Color LightCoral => new Color(KnownColor.LightCoral); + + public static Color LightCyan => new Color(KnownColor.LightCyan); + + public static Color LightGoldenrodYellow => new Color(KnownColor.LightGoldenrodYellow); + + public static Color LightGreen => new Color(KnownColor.LightGreen); + + public static Color LightGray => new Color(KnownColor.LightGray); + + public static Color LightPink => new Color(KnownColor.LightPink); + + public static Color LightSalmon => new Color(KnownColor.LightSalmon); + + public static Color LightSeaGreen => new Color(KnownColor.LightSeaGreen); + + public static Color LightSkyBlue => new Color(KnownColor.LightSkyBlue); + + public static Color LightSlateGray => new Color(KnownColor.LightSlateGray); + + public static Color LightSteelBlue => new Color(KnownColor.LightSteelBlue); + + public static Color LightYellow => new Color(KnownColor.LightYellow); + + public static Color Lime => new Color(KnownColor.Lime); + + public static Color LimeGreen => new Color(KnownColor.LimeGreen); + + public static Color Linen => new Color(KnownColor.Linen); + + public static Color Magenta => new Color(KnownColor.Magenta); + + public static Color Maroon => new Color(KnownColor.Maroon); + + public static Color MediumAquamarine => new Color(KnownColor.MediumAquamarine); + + public static Color MediumBlue => new Color(KnownColor.MediumBlue); + + public static Color MediumOrchid => new Color(KnownColor.MediumOrchid); + + public static Color MediumPurple => new Color(KnownColor.MediumPurple); + + public static Color MediumSeaGreen => new Color(KnownColor.MediumSeaGreen); + + public static Color MediumSlateBlue => new Color(KnownColor.MediumSlateBlue); + + public static Color MediumSpringGreen => new Color(KnownColor.MediumSpringGreen); + + public static Color MediumTurquoise => new Color(KnownColor.MediumTurquoise); + + public static Color MediumVioletRed => new Color(KnownColor.MediumVioletRed); + + public static Color MidnightBlue => new Color(KnownColor.MidnightBlue); + + public static Color MintCream => new Color(KnownColor.MintCream); + + public static Color MistyRose => new Color(KnownColor.MistyRose); + + public static Color Moccasin => new Color(KnownColor.Moccasin); + + public static Color NavajoWhite => new Color(KnownColor.NavajoWhite); + + public static Color Navy => new Color(KnownColor.Navy); + + public static Color OldLace => new Color(KnownColor.OldLace); + + public static Color Olive => new Color(KnownColor.Olive); + + public static Color OliveDrab => new Color(KnownColor.OliveDrab); + + public static Color Orange => new Color(KnownColor.Orange); + + public static Color OrangeRed => new Color(KnownColor.OrangeRed); + + public static Color Orchid => new Color(KnownColor.Orchid); + + public static Color PaleGoldenrod => new Color(KnownColor.PaleGoldenrod); + + public static Color PaleGreen => new Color(KnownColor.PaleGreen); + + public static Color PaleTurquoise => new Color(KnownColor.PaleTurquoise); + + public static Color PaleVioletRed => new Color(KnownColor.PaleVioletRed); + + public static Color PapayaWhip => new Color(KnownColor.PapayaWhip); + + public static Color PeachPuff => new Color(KnownColor.PeachPuff); + + public static Color Peru => new Color(KnownColor.Peru); + + public static Color Pink => new Color(KnownColor.Pink); + + public static Color Plum => new Color(KnownColor.Plum); + + public static Color PowderBlue => new Color(KnownColor.PowderBlue); + + public static Color Purple => new Color(KnownColor.Purple); + + public static Color Red => new Color(KnownColor.Red); + + public static Color RosyBrown => new Color(KnownColor.RosyBrown); + + public static Color RoyalBlue => new Color(KnownColor.RoyalBlue); + + public static Color SaddleBrown => new Color(KnownColor.SaddleBrown); + + public static Color Salmon => new Color(KnownColor.Salmon); + + public static Color SandyBrown => new Color(KnownColor.SandyBrown); + + public static Color SeaGreen => new Color(KnownColor.SeaGreen); + + public static Color SeaShell => new Color(KnownColor.SeaShell); + + public static Color Sienna => new Color(KnownColor.Sienna); + + public static Color Silver => new Color(KnownColor.Silver); + + public static Color SkyBlue => new Color(KnownColor.SkyBlue); + + public static Color SlateBlue => new Color(KnownColor.SlateBlue); + + public static Color SlateGray => new Color(KnownColor.SlateGray); + + public static Color Snow => new Color(KnownColor.Snow); + + public static Color SpringGreen => new Color(KnownColor.SpringGreen); + + public static Color SteelBlue => new Color(KnownColor.SteelBlue); + + public static Color Tan => new Color(KnownColor.Tan); + + public static Color Teal => new Color(KnownColor.Teal); + + public static Color Thistle => new Color(KnownColor.Thistle); + + public static Color Tomato => new Color(KnownColor.Tomato); + + public static Color Turquoise => new Color(KnownColor.Turquoise); + + public static Color Violet => new Color(KnownColor.Violet); + + public static Color Wheat => new Color(KnownColor.Wheat); + + public static Color White => new Color(KnownColor.White); + + public static Color WhiteSmoke => new Color(KnownColor.WhiteSmoke); + + public static Color Yellow => new Color(KnownColor.Yellow); + + public static Color YellowGreen => new Color(KnownColor.YellowGreen); + + // + // end "web" colors + // ------------------------------------------------------------------- + + // NOTE : The "zero" pattern (all members being 0) must represent + // : "not set". This allows "Color c;" to be correct. + + private static short s_stateKnownColorValid = 0x0001; + private static short s_stateARGBValueValid = 0x0002; + private static short s_stateValueMask = (short)(s_stateARGBValueValid); + private static short s_stateNameValid = 0x0008; + private static long s_notDefinedValue = 0; + + /** + * Shift count and bit mask for A, R, G, B components in ARGB mode! + */ + private const int ARGBAlphaShift = 24; + private const int ARGBRedShift = 16; + private const int ARGBGreenShift = 8; + private const int ARGBBlueShift = 0; + + + // user supplied name of color. Will not be filled in if + // we map to a "knowncolor" + // + private readonly string name; + + // will contain standard 32bit sRGB (ARGB) + // + private readonly long value; + + // ignored, unless "state" says it is valid + // + private readonly short knownColor; + + // implementation specific information + // + private readonly short state; + + + internal Color(KnownColor knownColor) + { + value = 0; + state = s_stateKnownColorValid; + name = null; + this.knownColor = unchecked((short)knownColor); + } + + private Color(long value, short state, string name, KnownColor knownColor) + { + this.value = value; + this.state = state; + this.name = name; + this.knownColor = unchecked((short)knownColor); + } + + public byte R => (byte)((Value >> ARGBRedShift) & 0xFF); + + public byte G => (byte)((Value >> ARGBGreenShift) & 0xFF); + + public byte B => (byte)((Value >> ARGBBlueShift) & 0xFF); + + public byte A => (byte)((Value >> ARGBAlphaShift) & 0xFF); + + public bool IsKnownColor => ((state & s_stateKnownColorValid) != 0); + + public bool IsEmpty => state == 0; + + public bool IsNamedColor => ((state & s_stateNameValid) != 0) || IsKnownColor; + + public bool IsSystemColor => IsKnownColor && ((((KnownColor)knownColor) <= KnownColor.WindowText) || (((KnownColor)knownColor) > KnownColor.YellowGreen)); + + // Not localized because it's only used for the DebuggerDisplayAttribute, and the values are + // programmatic items. + // Also, don't inline into the attribute for performance reasons. This way means the debugger + // does 1 func-eval instead of 5. + [SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters")] + private string NameAndARGBValue => $"{{Name={Name}, ARGB=({A}, {R}, {G}, {B})}}"; + + public string Name + { + get + { + if ((state & s_stateNameValid) != 0) + { + return name; + } + + if (IsKnownColor) + { + // first try the table so we can avoid the (slow!) .ToString() + string tablename = KnownColorTable.KnownColorToName((KnownColor)knownColor); + if (tablename != null) + return tablename; + + Debug.Assert(false, "Could not find known color '" + ((KnownColor)knownColor) + "' in the KnownColorTable"); + + return ((KnownColor)knownColor).ToString(); + } + + // if we reached here, just encode the value + // + return Convert.ToString(value, 16); + } + } + + private long Value + { + get + { + if ((state & s_stateValueMask) != 0) + { + return value; + } + if (IsKnownColor) + { + return unchecked((int)KnownColorTable.KnownColorToArgb((KnownColor)knownColor)); + } + + return s_notDefinedValue; + } + } + + private static void CheckByte(int value, string name) + { + if (value < 0 || value > 255) + throw new ArgumentException(SR.Format(SR.InvalidEx2BoundArgument, name, value, 0, 255)); + } + + private static long MakeArgb(byte alpha, byte red, byte green, byte blue) + { + return (long)(unchecked((uint)(red << ARGBRedShift | + green << ARGBGreenShift | + blue << ARGBBlueShift | + alpha << ARGBAlphaShift))) & 0xffffffff; + } + + public static Color FromArgb(int argb) + { + return new Color((long)argb & 0xffffffff, s_stateARGBValueValid, null, (KnownColor)0); + } + + public static Color FromArgb(int alpha, int red, int green, int blue) + { + CheckByte(alpha, "alpha"); + CheckByte(red, "red"); + CheckByte(green, "green"); + CheckByte(blue, "blue"); + return new Color(MakeArgb((byte)alpha, (byte)red, (byte)green, (byte)blue), s_stateARGBValueValid, null, (KnownColor)0); + } + + public static Color FromArgb(int alpha, Color baseColor) + { + CheckByte(alpha, "alpha"); + // unchecked - because we already checked that alpha is a byte in CheckByte above + return new Color(MakeArgb(unchecked((byte)alpha), baseColor.R, baseColor.G, baseColor.B), s_stateARGBValueValid, null, (KnownColor)0); + } + + public static Color FromArgb(int red, int green, int blue) + { + return FromArgb(255, red, green, blue); + } + + public static Color FromKnownColor(KnownColor color) + { + var value = (int)color; + if (value < (int)KnownColor.ActiveBorder || value > (int)KnownColor.MenuHighlight) + { + return Color.FromName(color.ToString()); + } + return new Color(color); + } + + public static Color FromName(string name) + { + // try to get a known color first + Color color; + if (ColorTable.TryGetNamedColor(name, out color)) + { + return color; + } + // otherwise treat it as a named color + return new Color(s_notDefinedValue, s_stateNameValid, name, (KnownColor)0); + } + + public float GetBrightness() + { + float r = (float)R / 255.0f; + float g = (float)G / 255.0f; + float b = (float)B / 255.0f; + + float max, min; + + max = r; min = r; + + if (g > max) max = g; + if (b > max) max = b; + + if (g < min) min = g; + if (b < min) min = b; + + return (max + min) / 2; + } + + + public Single GetHue() + { + if (R == G && G == B) + return 0; // 0 makes as good an UNDEFINED value as any + + float r = (float)R / 255.0f; + float g = (float)G / 255.0f; + float b = (float)B / 255.0f; + + float max, min; + float delta; + float hue = 0.0f; + + max = r; min = r; + + if (g > max) max = g; + if (b > max) max = b; + + if (g < min) min = g; + if (b < min) min = b; + + delta = max - min; + + if (r == max) + { + hue = (g - b) / delta; + } + else if (g == max) + { + hue = 2 + (b - r) / delta; + } + else if (b == max) + { + hue = 4 + (r - g) / delta; + } + hue *= 60; + + if (hue < 0.0f) + { + hue += 360.0f; + } + return hue; + } + + public float GetSaturation() + { + float r = (float)R / 255.0f; + float g = (float)G / 255.0f; + float b = (float)B / 255.0f; + + float max, min; + float l, s = 0; + + max = r; min = r; + + if (g > max) max = g; + if (b > max) max = b; + + if (g < min) min = g; + if (b < min) min = b; + + // if max == min, then there is no color and + // the saturation is zero. + // + if (max != min) + { + l = (max + min) / 2; + + if (l <= .5) + { + s = (max - min) / (max + min); + } + else + { + s = (max - min) / (2 - max - min); + } + } + return s; + } + + public int ToArgb() + { + return unchecked((int)Value); + } + + public KnownColor ToKnownColor() + { + return (KnownColor)knownColor; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(32); + sb.Append(nameof(Color)); + sb.Append(" ["); + + if ((state & s_stateNameValid) != 0) + { + sb.Append(Name); + } + else if ((state & s_stateKnownColorValid) != 0) + { + sb.Append(Name); + } + else if ((state & s_stateValueMask) != 0) + { + sb.Append("A="); + sb.Append(A); + sb.Append(", R="); + sb.Append(R); + sb.Append(", G="); + sb.Append(G); + sb.Append(", B="); + sb.Append(B); + } + else + { + sb.Append("Empty"); + } + + + sb.Append(']'); + + return sb.ToString(); + } + + public static bool operator ==(Color left, Color right) + { + if (left.value == right.value + && left.state == right.state + && left.knownColor == right.knownColor) + { + if (left.name == right.name) + { + return true; + } + + if (ReferenceEquals(left.name, null) || ReferenceEquals(right.name, null)) + { + return false; + } + + return left.name.Equals(right.name); + } + + return false; + } + + public static bool operator !=(Color left, Color right) + { + return !(left == right); + } + + public override bool Equals(object obj) + { + if (obj is Color) + { + Color right = (Color)obj; + if (value == right.value + && state == right.state + && knownColor == right.knownColor) + { + if (name == right.name) + { + return true; + } + + if (ReferenceEquals(name, null) || ReferenceEquals(right.name, null)) + { + return false; + } + + return name.Equals(name); + } + } + return false; + } + + public override int GetHashCode() + { + return unchecked(value.GetHashCode() ^ + state.GetHashCode() ^ + knownColor.GetHashCode()); + } + } +} diff --git a/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs b/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs new file mode 100644 index 0000000000..2385fa9fdc --- /dev/null +++ b/src/System.Drawing.Primitives/src/System/Drawing/KnownColor.cs @@ -0,0 +1,202 @@ +// 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.Diagnostics.CodeAnalysis; + +namespace System.Drawing +{ + [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] + public enum KnownColor + { + // This enum is order dependant!!! + // + // The value of these known colors are indexes into a color array. + // Do not modify this enum without updating KnownColorTable. + // + + + // 0 - reserved for "not a known color" + + // "System" colors + ActiveBorder = 1, + ActiveCaption, + ActiveCaptionText, + AppWorkspace, + Control, + ControlDark, + ControlDarkDark, + ControlLight, + ControlLightLight, + ControlText, + Desktop, + GrayText, + Highlight, + HighlightText, + HotTrack, + InactiveBorder, + InactiveCaption, + InactiveCaptionText, + Info, + InfoText, + Menu, + MenuText, + ScrollBar, + Window, + WindowFrame, + WindowText, + + // "Web" Colors + Transparent, + AliceBlue, + AntiqueWhite, + Aqua, + Aquamarine, + Azure, + Beige, + Bisque, + Black, + BlanchedAlmond, + Blue, + BlueViolet, + Brown, + BurlyWood, + CadetBlue, + Chartreuse, + Chocolate, + Coral, + CornflowerBlue, + Cornsilk, + Crimson, + Cyan, + DarkBlue, + DarkCyan, + DarkGoldenrod, + DarkGray, + DarkGreen, + DarkKhaki, + DarkMagenta, + DarkOliveGreen, + DarkOrange, + DarkOrchid, + DarkRed, + DarkSalmon, + DarkSeaGreen, + DarkSlateBlue, + DarkSlateGray, + DarkTurquoise, + DarkViolet, + DeepPink, + DeepSkyBlue, + DimGray, + DodgerBlue, + Firebrick, + FloralWhite, + ForestGreen, + Fuchsia, + Gainsboro, + GhostWhite, + Gold, + Goldenrod, + Gray, + Green, + GreenYellow, + Honeydew, + HotPink, + IndianRed, + Indigo, + Ivory, + Khaki, + Lavender, + LavenderBlush, + LawnGreen, + LemonChiffon, + LightBlue, + LightCoral, + LightCyan, + LightGoldenrodYellow, + LightGray, + LightGreen, + LightPink, + LightSalmon, + LightSeaGreen, + LightSkyBlue, + LightSlateGray, + LightSteelBlue, + LightYellow, + Lime, + LimeGreen, + Linen, + Magenta, + Maroon, + MediumAquamarine, + MediumBlue, + MediumOrchid, + MediumPurple, + MediumSeaGreen, + MediumSlateBlue, + MediumSpringGreen, + MediumTurquoise, + MediumVioletRed, + MidnightBlue, + MintCream, + MistyRose, + Moccasin, + NavajoWhite, + Navy, + OldLace, + Olive, + OliveDrab, + Orange, + OrangeRed, + Orchid, + PaleGoldenrod, + PaleGreen, + PaleTurquoise, + PaleVioletRed, + PapayaWhip, + PeachPuff, + Peru, + Pink, + Plum, + PowderBlue, + Purple, + Red, + RosyBrown, + RoyalBlue, + SaddleBrown, + Salmon, + SandyBrown, + SeaGreen, + SeaShell, + Sienna, + Silver, + SkyBlue, + SlateBlue, + SlateGray, + Snow, + SpringGreen, + SteelBlue, + Tan, + Teal, + Thistle, + Tomato, + Turquoise, + Violet, + Wheat, + White, + WhiteSmoke, + Yellow, + YellowGreen, + + // NEW ADDITIONS IN WHIDBEY - DO NOT MOVE THESE UP OR IT WILL BE A BREAKING CHANGE + + ButtonFace, + ButtonHighlight, + ButtonShadow, + GradientActiveCaption, + GradientInactiveCaption, + MenuBar, + MenuHighlight, + } +}
\ No newline at end of file diff --git a/src/System.Drawing.Primitives/src/System/Drawing/KnownColorTable.cs b/src/System.Drawing.Primitives/src/System/Drawing/KnownColorTable.cs new file mode 100644 index 0000000000..eaf3766722 --- /dev/null +++ b/src/System.Drawing.Primitives/src/System/Drawing/KnownColorTable.cs @@ -0,0 +1,463 @@ +// 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. + +namespace System.Drawing +{ + internal static class KnownColorTable + { + private static int[] s_colorTable; + private static string[] s_colorNameTable; + + /** + * Shift count and bit mask for A, R, G, B components + */ + private const int AlphaShift = 24; + private const int RedShift = 16; + private const int GreenShift = 8; + private const int BlueShift = 0; + + private const int Win32RedShift = 0; + private const int Win32GreenShift = 8; + private const int Win32BlueShift = 16; + + public static Color ArgbToKnownColor(int targetARGB) + { + EnsureColorTable(); + for (int index = 0; index < s_colorTable.Length; ++index) + { + int argb = s_colorTable[index]; + if (argb == targetARGB) + { + Color color = Color.FromKnownColor((KnownColor)index); + if (!color.IsSystemColor) + return color; + } + } + + return Color.FromArgb(targetARGB); + } + + private static void EnsureColorTable() + { + // no need to lock... worse case is a double create of the table... + // + if (s_colorTable == null) + { + InitColorTable(); + } + } + + private static void InitColorTable() + { + int[] values = new int[(unchecked((int)KnownColor.MenuHighlight)) + 1]; + + // system + // + UpdateSystemColors(values); + + // just consts... + // + values[(int)KnownColor.Transparent] = 0x00FFFFFF; + values[(int)KnownColor.AliceBlue] = unchecked((int)0xFFF0F8FF); + values[(int)KnownColor.AntiqueWhite] = unchecked((int)0xFFFAEBD7); + values[(int)KnownColor.Aqua] = unchecked((int)0xFF00FFFF); + values[(int)KnownColor.Aquamarine] = unchecked((int)0xFF7FFFD4); + values[(int)KnownColor.Azure] = unchecked((int)0xFFF0FFFF); + values[(int)KnownColor.Beige] = unchecked((int)0xFFF5F5DC); + values[(int)KnownColor.Bisque] = unchecked(unchecked((int)0xFFFFE4C4)); + values[(int)KnownColor.Black] = unchecked((int)0xFF000000); + values[(int)KnownColor.BlanchedAlmond] = unchecked((int)0xFFFFEBCD); + values[(int)KnownColor.Blue] = unchecked((int)0xFF0000FF); + values[(int)KnownColor.BlueViolet] = unchecked((int)0xFF8A2BE2); + values[(int)KnownColor.Brown] = unchecked((int)0xFFA52A2A); + values[(int)KnownColor.BurlyWood] = unchecked((int)0xFFDEB887); + values[(int)KnownColor.CadetBlue] = unchecked((int)0xFF5F9EA0); + values[(int)KnownColor.Chartreuse] = unchecked((int)0xFF7FFF00); + values[(int)KnownColor.Chocolate] = unchecked((int)0xFFD2691E); + values[(int)KnownColor.Coral] = unchecked((int)0xFFFF7F50); + values[(int)KnownColor.CornflowerBlue] = unchecked((int)0xFF6495ED); + values[(int)KnownColor.Cornsilk] = unchecked((int)0xFFFFF8DC); + values[(int)KnownColor.Crimson] = unchecked((int)0xFFDC143C); + values[(int)KnownColor.Cyan] = unchecked((int)0xFF00FFFF); + values[(int)KnownColor.DarkBlue] = unchecked((int)0xFF00008B); + values[(int)KnownColor.DarkCyan] = unchecked((int)0xFF008B8B); + values[(int)KnownColor.DarkGoldenrod] = unchecked((int)0xFFB8860B); + values[(int)KnownColor.DarkGray] = unchecked((int)0xFFA9A9A9); + values[(int)KnownColor.DarkGreen] = unchecked((int)0xFF006400); + values[(int)KnownColor.DarkKhaki] = unchecked((int)0xFFBDB76B); + values[(int)KnownColor.DarkMagenta] = unchecked((int)0xFF8B008B); + values[(int)KnownColor.DarkOliveGreen] = unchecked((int)0xFF556B2F); + values[(int)KnownColor.DarkOrange] = unchecked((int)0xFFFF8C00); + values[(int)KnownColor.DarkOrchid] = unchecked((int)0xFF9932CC); + values[(int)KnownColor.DarkRed] = unchecked((int)0xFF8B0000); + values[(int)KnownColor.DarkSalmon] = unchecked((int)0xFFE9967A); + values[(int)KnownColor.DarkSeaGreen] = unchecked((int)0xFF8FBC8B); + values[(int)KnownColor.DarkSlateBlue] = unchecked((int)0xFF483D8B); + values[(int)KnownColor.DarkSlateGray] = unchecked((int)0xFF2F4F4F); + values[(int)KnownColor.DarkTurquoise] = unchecked((int)0xFF00CED1); + values[(int)KnownColor.DarkViolet] = unchecked((int)0xFF9400D3); + values[(int)KnownColor.DeepPink] = unchecked((int)0xFFFF1493); + values[(int)KnownColor.DeepSkyBlue] = unchecked((int)0xFF00BFFF); + values[(int)KnownColor.DimGray] = unchecked((int)0xFF696969); + values[(int)KnownColor.DodgerBlue] = unchecked((int)0xFF1E90FF); + values[(int)KnownColor.Firebrick] = unchecked((int)0xFFB22222); + values[(int)KnownColor.FloralWhite] = unchecked((int)0xFFFFFAF0); + values[(int)KnownColor.ForestGreen] = unchecked((int)0xFF228B22); + values[(int)KnownColor.Fuchsia] = unchecked((int)0xFFFF00FF); + values[(int)KnownColor.Gainsboro] = unchecked((int)0xFFDCDCDC); + values[(int)KnownColor.GhostWhite] = unchecked((int)0xFFF8F8FF); + values[(int)KnownColor.Gold] = unchecked((int)0xFFFFD700); + values[(int)KnownColor.Goldenrod] = unchecked((int)0xFFDAA520); + values[(int)KnownColor.Gray] = unchecked((int)0xFF808080); + values[(int)KnownColor.Green] = unchecked((int)0xFF008000); + values[(int)KnownColor.GreenYellow] = unchecked((int)0xFFADFF2F); + values[(int)KnownColor.Honeydew] = unchecked((int)0xFFF0FFF0); + values[(int)KnownColor.HotPink] = unchecked((int)0xFFFF69B4); + values[(int)KnownColor.IndianRed] = unchecked((int)0xFFCD5C5C); + values[(int)KnownColor.Indigo] = unchecked((int)0xFF4B0082); + values[(int)KnownColor.Ivory] = unchecked((int)0xFFFFFFF0); + values[(int)KnownColor.Khaki] = unchecked((int)0xFFF0E68C); + values[(int)KnownColor.Lavender] = unchecked((int)0xFFE6E6FA); + values[(int)KnownColor.LavenderBlush] = unchecked((int)0xFFFFF0F5); + values[(int)KnownColor.LawnGreen] = unchecked((int)0xFF7CFC00); + values[(int)KnownColor.LemonChiffon] = unchecked((int)0xFFFFFACD); + values[(int)KnownColor.LightBlue] = unchecked((int)0xFFADD8E6); + values[(int)KnownColor.LightCoral] = unchecked((int)0xFFF08080); + values[(int)KnownColor.LightCyan] = unchecked((int)0xFFE0FFFF); + values[(int)KnownColor.LightGoldenrodYellow] = unchecked((int)0xFFFAFAD2); + values[(int)KnownColor.LightGray] = unchecked((int)0xFFD3D3D3); + values[(int)KnownColor.LightGreen] = unchecked((int)0xFF90EE90); + values[(int)KnownColor.LightPink] = unchecked((int)0xFFFFB6C1); + values[(int)KnownColor.LightSalmon] = unchecked((int)0xFFFFA07A); + values[(int)KnownColor.LightSeaGreen] = unchecked((int)0xFF20B2AA); + values[(int)KnownColor.LightSkyBlue] = unchecked((int)0xFF87CEFA); + values[(int)KnownColor.LightSlateGray] = unchecked((int)0xFF778899); + values[(int)KnownColor.LightSteelBlue] = unchecked((int)0xFFB0C4DE); + values[(int)KnownColor.LightYellow] = unchecked((int)0xFFFFFFE0); + values[(int)KnownColor.Lime] = unchecked((int)0xFF00FF00); + values[(int)KnownColor.LimeGreen] = unchecked((int)0xFF32CD32); + values[(int)KnownColor.Linen] = unchecked((int)0xFFFAF0E6); + values[(int)KnownColor.Magenta] = unchecked((int)0xFFFF00FF); + values[(int)KnownColor.Maroon] = unchecked((int)0xFF800000); + values[(int)KnownColor.MediumAquamarine] = unchecked((int)0xFF66CDAA); + values[(int)KnownColor.MediumBlue] = unchecked((int)0xFF0000CD); + values[(int)KnownColor.MediumOrchid] = unchecked((int)0xFFBA55D3); + values[(int)KnownColor.MediumPurple] = unchecked((int)0xFF9370DB); + values[(int)KnownColor.MediumSeaGreen] = unchecked((int)0xFF3CB371); + values[(int)KnownColor.MediumSlateBlue] = unchecked((int)0xFF7B68EE); + values[(int)KnownColor.MediumSpringGreen] = unchecked((int)0xFF00FA9A); + values[(int)KnownColor.MediumTurquoise] = unchecked((int)0xFF48D1CC); + values[(int)KnownColor.MediumVioletRed] = unchecked((int)0xFFC71585); + values[(int)KnownColor.MidnightBlue] = unchecked((int)0xFF191970); + values[(int)KnownColor.MintCream] = unchecked((int)0xFFF5FFFA); + values[(int)KnownColor.MistyRose] = unchecked((int)0xFFFFE4E1); + values[(int)KnownColor.Moccasin] = unchecked((int)0xFFFFE4B5); + values[(int)KnownColor.NavajoWhite] = unchecked((int)0xFFFFDEAD); + values[(int)KnownColor.Navy] = unchecked((int)0xFF000080); + values[(int)KnownColor.OldLace] = unchecked((int)0xFFFDF5E6); + values[(int)KnownColor.Olive] = unchecked((int)0xFF808000); + values[(int)KnownColor.OliveDrab] = unchecked((int)0xFF6B8E23); + values[(int)KnownColor.Orange] = unchecked((int)0xFFFFA500); + values[(int)KnownColor.OrangeRed] = unchecked((int)0xFFFF4500); + values[(int)KnownColor.Orchid] = unchecked((int)0xFFDA70D6); + values[(int)KnownColor.PaleGoldenrod] = unchecked((int)0xFFEEE8AA); + values[(int)KnownColor.PaleGreen] = unchecked((int)0xFF98FB98); + values[(int)KnownColor.PaleTurquoise] = unchecked((int)0xFFAFEEEE); + values[(int)KnownColor.PaleVioletRed] = unchecked((int)0xFFDB7093); + values[(int)KnownColor.PapayaWhip] = unchecked((int)0xFFFFEFD5); + values[(int)KnownColor.PeachPuff] = unchecked((int)0xFFFFDAB9); + values[(int)KnownColor.Peru] = unchecked((int)0xFFCD853F); + values[(int)KnownColor.Pink] = unchecked((int)0xFFFFC0CB); + values[(int)KnownColor.Plum] = unchecked((int)0xFFDDA0DD); + values[(int)KnownColor.PowderBlue] = unchecked((int)0xFFB0E0E6); + values[(int)KnownColor.Purple] = unchecked((int)0xFF800080); + values[(int)KnownColor.Red] = unchecked((int)0xFFFF0000); + values[(int)KnownColor.RosyBrown] = unchecked((int)0xFFBC8F8F); + values[(int)KnownColor.RoyalBlue] = unchecked((int)0xFF4169E1); + values[(int)KnownColor.SaddleBrown] = unchecked((int)0xFF8B4513); + values[(int)KnownColor.Salmon] = unchecked((int)0xFFFA8072); + values[(int)KnownColor.SandyBrown] = unchecked((int)0xFFF4A460); + values[(int)KnownColor.SeaGreen] = unchecked((int)0xFF2E8B57); + values[(int)KnownColor.SeaShell] = unchecked((int)0xFFFFF5EE); + values[(int)KnownColor.Sienna] = unchecked((int)0xFFA0522D); + values[(int)KnownColor.Silver] = unchecked((int)0xFFC0C0C0); + values[(int)KnownColor.SkyBlue] = unchecked((int)0xFF87CEEB); + values[(int)KnownColor.SlateBlue] = unchecked((int)0xFF6A5ACD); + values[(int)KnownColor.SlateGray] = unchecked((int)0xFF708090); + values[(int)KnownColor.Snow] = unchecked((int)0xFFFFFAFA); + values[(int)KnownColor.SpringGreen] = unchecked((int)0xFF00FF7F); + values[(int)KnownColor.SteelBlue] = unchecked((int)0xFF4682B4); + values[(int)KnownColor.Tan] = unchecked((int)0xFFD2B48C); + values[(int)KnownColor.Teal] = unchecked((int)0xFF008080); + values[(int)KnownColor.Thistle] = unchecked((int)0xFFD8BFD8); + values[(int)KnownColor.Tomato] = unchecked((int)0xFFFF6347); + values[(int)KnownColor.Turquoise] = unchecked((int)0xFF40E0D0); + values[(int)KnownColor.Violet] = unchecked((int)0xFFEE82EE); + values[(int)KnownColor.Wheat] = unchecked((int)0xFFF5DEB3); + values[(int)KnownColor.White] = unchecked((int)0xFFFFFFFF); + values[(int)KnownColor.WhiteSmoke] = unchecked((int)0xFFF5F5F5); + values[(int)KnownColor.Yellow] = unchecked((int)0xFFFFFF00); + values[(int)KnownColor.YellowGreen] = unchecked((int)0xFF9ACD32); + s_colorTable = values; + } + + private static void EnsureColorNameTable() + { + // no need to lock... worse case is a double create of the table... + // + if (s_colorNameTable == null) + { + InitColorNameTable(); + } + } + + private static void InitColorNameTable() + { + string[] values = new string[((int)KnownColor.MenuHighlight) + 1]; + + // just consts... + // + values[(int)KnownColor.ActiveBorder] = "ActiveBorder"; + values[(int)KnownColor.ActiveCaption] = "ActiveCaption"; + values[(int)KnownColor.ActiveCaptionText] = "ActiveCaptionText"; + values[(int)KnownColor.AppWorkspace] = "AppWorkspace"; + values[(int)KnownColor.ButtonFace] = "ButtonFace"; + values[(int)KnownColor.ButtonHighlight] = "ButtonHighlight"; + values[(int)KnownColor.ButtonShadow] = "ButtonShadow"; + values[(int)KnownColor.Control] = "Control"; + values[(int)KnownColor.ControlDark] = "ControlDark"; + values[(int)KnownColor.ControlDarkDark] = "ControlDarkDark"; + values[(int)KnownColor.ControlLight] = "ControlLight"; + values[(int)KnownColor.ControlLightLight] = "ControlLightLight"; + values[(int)KnownColor.ControlText] = "ControlText"; + values[(int)KnownColor.Desktop] = "Desktop"; + values[(int)KnownColor.GradientActiveCaption] = "GradientActiveCaption"; + values[(int)KnownColor.GradientInactiveCaption] = "GradientInactiveCaption"; + values[(int)KnownColor.GrayText] = "GrayText"; + values[(int)KnownColor.Highlight] = "Highlight"; + values[(int)KnownColor.HighlightText] = "HighlightText"; + values[(int)KnownColor.HotTrack] = "HotTrack"; + values[(int)KnownColor.InactiveBorder] = "InactiveBorder"; + values[(int)KnownColor.InactiveCaption] = "InactiveCaption"; + values[(int)KnownColor.InactiveCaptionText] = "InactiveCaptionText"; + values[(int)KnownColor.Info] = "Info"; + values[(int)KnownColor.InfoText] = "InfoText"; + values[(int)KnownColor.Menu] = "Menu"; + values[(int)KnownColor.MenuBar] = "MenuBar"; + values[(int)KnownColor.MenuHighlight] = "MenuHighlight"; + values[(int)KnownColor.MenuText] = "MenuText"; + values[(int)KnownColor.ScrollBar] = "ScrollBar"; + values[(int)KnownColor.Window] = "Window"; + values[(int)KnownColor.WindowFrame] = "WindowFrame"; + values[(int)KnownColor.WindowText] = "WindowText"; + + values[(int)KnownColor.Transparent] = "Transparent"; + values[(int)KnownColor.AliceBlue] = "AliceBlue"; + values[(int)KnownColor.AntiqueWhite] = "AntiqueWhite"; + values[(int)KnownColor.Aqua] = "Aqua"; + values[(int)KnownColor.Aquamarine] = "Aquamarine"; + values[(int)KnownColor.Azure] = "Azure"; + values[(int)KnownColor.Beige] = "Beige"; + values[(int)KnownColor.Bisque] = "Bisque"; + values[(int)KnownColor.Black] = "Black"; + values[(int)KnownColor.BlanchedAlmond] = "BlanchedAlmond"; + values[(int)KnownColor.Blue] = "Blue"; + values[(int)KnownColor.BlueViolet] = "BlueViolet"; + values[(int)KnownColor.Brown] = "Brown"; + values[(int)KnownColor.BurlyWood] = "BurlyWood"; + values[(int)KnownColor.CadetBlue] = "CadetBlue"; + values[(int)KnownColor.Chartreuse] = "Chartreuse"; + values[(int)KnownColor.Chocolate] = "Chocolate"; + values[(int)KnownColor.Coral] = "Coral"; + values[(int)KnownColor.CornflowerBlue] = "CornflowerBlue"; + values[(int)KnownColor.Cornsilk] = "Cornsilk"; + values[(int)KnownColor.Crimson] = "Crimson"; + values[(int)KnownColor.Cyan] = "Cyan"; + values[(int)KnownColor.DarkBlue] = "DarkBlue"; + values[(int)KnownColor.DarkCyan] = "DarkCyan"; + values[(int)KnownColor.DarkGoldenrod] = "DarkGoldenrod"; + values[(int)KnownColor.DarkGray] = "DarkGray"; + values[(int)KnownColor.DarkGreen] = "DarkGreen"; + values[(int)KnownColor.DarkKhaki] = "DarkKhaki"; + values[(int)KnownColor.DarkMagenta] = "DarkMagenta"; + values[(int)KnownColor.DarkOliveGreen] = "DarkOliveGreen"; + values[(int)KnownColor.DarkOrange] = "DarkOrange"; + values[(int)KnownColor.DarkOrchid] = "DarkOrchid"; + values[(int)KnownColor.DarkRed] = "DarkRed"; + values[(int)KnownColor.DarkSalmon] = "DarkSalmon"; + values[(int)KnownColor.DarkSeaGreen] = "DarkSeaGreen"; + values[(int)KnownColor.DarkSlateBlue] = "DarkSlateBlue"; + values[(int)KnownColor.DarkSlateGray] = "DarkSlateGray"; + values[(int)KnownColor.DarkTurquoise] = "DarkTurquoise"; + values[(int)KnownColor.DarkViolet] = "DarkViolet"; + values[(int)KnownColor.DeepPink] = "DeepPink"; + values[(int)KnownColor.DeepSkyBlue] = "DeepSkyBlue"; + values[(int)KnownColor.DimGray] = "DimGray"; + values[(int)KnownColor.DodgerBlue] = "DodgerBlue"; + values[(int)KnownColor.Firebrick] = "Firebrick"; + values[(int)KnownColor.FloralWhite] = "FloralWhite"; + values[(int)KnownColor.ForestGreen] = "ForestGreen"; + values[(int)KnownColor.Fuchsia] = "Fuchsia"; + values[(int)KnownColor.Gainsboro] = "Gainsboro"; + values[(int)KnownColor.GhostWhite] = "GhostWhite"; + values[(int)KnownColor.Gold] = "Gold"; + values[(int)KnownColor.Goldenrod] = "Goldenrod"; + values[(int)KnownColor.Gray] = "Gray"; + values[(int)KnownColor.Green] = "Green"; + values[(int)KnownColor.GreenYellow] = "GreenYellow"; + values[(int)KnownColor.Honeydew] = "Honeydew"; + values[(int)KnownColor.HotPink] = "HotPink"; + values[(int)KnownColor.IndianRed] = "IndianRed"; + values[(int)KnownColor.Indigo] = "Indigo"; + values[(int)KnownColor.Ivory] = "Ivory"; + values[(int)KnownColor.Khaki] = "Khaki"; + values[(int)KnownColor.Lavender] = "Lavender"; + values[(int)KnownColor.LavenderBlush] = "LavenderBlush"; + values[(int)KnownColor.LawnGreen] = "LawnGreen"; + values[(int)KnownColor.LemonChiffon] = "LemonChiffon"; + values[(int)KnownColor.LightBlue] = "LightBlue"; + values[(int)KnownColor.LightCoral] = "LightCoral"; + values[(int)KnownColor.LightCyan] = "LightCyan"; + values[(int)KnownColor.LightGoldenrodYellow] = "LightGoldenrodYellow"; + values[(int)KnownColor.LightGray] = "LightGray"; + values[(int)KnownColor.LightGreen] = "LightGreen"; + values[(int)KnownColor.LightPink] = "LightPink"; + values[(int)KnownColor.LightSalmon] = "LightSalmon"; + values[(int)KnownColor.LightSeaGreen] = "LightSeaGreen"; + values[(int)KnownColor.LightSkyBlue] = "LightSkyBlue"; + values[(int)KnownColor.LightSlateGray] = "LightSlateGray"; + values[(int)KnownColor.LightSteelBlue] = "LightSteelBlue"; + values[(int)KnownColor.LightYellow] = "LightYellow"; + values[(int)KnownColor.Lime] = "Lime"; + values[(int)KnownColor.LimeGreen] = "LimeGreen"; + values[(int)KnownColor.Linen] = "Linen"; + values[(int)KnownColor.Magenta] = "Magenta"; + values[(int)KnownColor.Maroon] = "Maroon"; + values[(int)KnownColor.MediumAquamarine] = "MediumAquamarine"; + values[(int)KnownColor.MediumBlue] = "MediumBlue"; + values[(int)KnownColor.MediumOrchid] = "MediumOrchid"; + values[(int)KnownColor.MediumPurple] = "MediumPurple"; + values[(int)KnownColor.MediumSeaGreen] = "MediumSeaGreen"; + values[(int)KnownColor.MediumSlateBlue] = "MediumSlateBlue"; + values[(int)KnownColor.MediumSpringGreen] = "MediumSpringGreen"; + values[(int)KnownColor.MediumTurquoise] = "MediumTurquoise"; + values[(int)KnownColor.MediumVioletRed] = "MediumVioletRed"; + values[(int)KnownColor.MidnightBlue] = "MidnightBlue"; + values[(int)KnownColor.MintCream] = "MintCream"; + values[(int)KnownColor.MistyRose] = "MistyRose"; + values[(int)KnownColor.Moccasin] = "Moccasin"; + values[(int)KnownColor.NavajoWhite] = "NavajoWhite"; + values[(int)KnownColor.Navy] = "Navy"; + values[(int)KnownColor.OldLace] = "OldLace"; + values[(int)KnownColor.Olive] = "Olive"; + values[(int)KnownColor.OliveDrab] = "OliveDrab"; + values[(int)KnownColor.Orange] = "Orange"; + values[(int)KnownColor.OrangeRed] = "OrangeRed"; + values[(int)KnownColor.Orchid] = "Orchid"; + values[(int)KnownColor.PaleGoldenrod] = "PaleGoldenrod"; + values[(int)KnownColor.PaleGreen] = "PaleGreen"; + values[(int)KnownColor.PaleTurquoise] = "PaleTurquoise"; + values[(int)KnownColor.PaleVioletRed] = "PaleVioletRed"; + values[(int)KnownColor.PapayaWhip] = "PapayaWhip"; + values[(int)KnownColor.PeachPuff] = "PeachPuff"; + values[(int)KnownColor.Peru] = "Peru"; + values[(int)KnownColor.Pink] = "Pink"; + values[(int)KnownColor.Plum] = "Plum"; + values[(int)KnownColor.PowderBlue] = "PowderBlue"; + values[(int)KnownColor.Purple] = "Purple"; + values[(int)KnownColor.Red] = "Red"; + values[(int)KnownColor.RosyBrown] = "RosyBrown"; + values[(int)KnownColor.RoyalBlue] = "RoyalBlue"; + values[(int)KnownColor.SaddleBrown] = "SaddleBrown"; + values[(int)KnownColor.Salmon] = "Salmon"; + values[(int)KnownColor.SandyBrown] = "SandyBrown"; + values[(int)KnownColor.SeaGreen] = "SeaGreen"; + values[(int)KnownColor.SeaShell] = "SeaShell"; + values[(int)KnownColor.Sienna] = "Sienna"; + values[(int)KnownColor.Silver] = "Silver"; + values[(int)KnownColor.SkyBlue] = "SkyBlue"; + values[(int)KnownColor.SlateBlue] = "SlateBlue"; + values[(int)KnownColor.SlateGray] = "SlateGray"; + values[(int)KnownColor.Snow] = "Snow"; + values[(int)KnownColor.SpringGreen] = "SpringGreen"; + values[(int)KnownColor.SteelBlue] = "SteelBlue"; + values[(int)KnownColor.Tan] = "Tan"; + values[(int)KnownColor.Teal] = "Teal"; + values[(int)KnownColor.Thistle] = "Thistle"; + values[(int)KnownColor.Tomato] = "Tomato"; + values[(int)KnownColor.Turquoise] = "Turquoise"; + values[(int)KnownColor.Violet] = "Violet"; + values[(int)KnownColor.Wheat] = "Wheat"; + values[(int)KnownColor.White] = "White"; + values[(int)KnownColor.WhiteSmoke] = "WhiteSmoke"; + values[(int)KnownColor.Yellow] = "Yellow"; + values[(int)KnownColor.YellowGreen] = "YellowGreen"; + s_colorNameTable = values; + } + + public static int KnownColorToArgb(KnownColor color) + { + EnsureColorTable(); + if (color <= KnownColor.MenuHighlight) + { + return s_colorTable[unchecked((int)color)]; + } + else + { + return 0; + } + } + + public static string KnownColorToName(KnownColor color) + { + EnsureColorNameTable(); + if (color <= KnownColor.MenuHighlight) + { + return s_colorNameTable[unchecked((int)color)]; + } + else + { + return null; + } + } + + private static void UpdateSystemColors(int[] colorTable) + { + // Colors from a default XP desktop for use by UI designers in ASP.NET: <EMAIL>mcartwri</EMAIL> + colorTable[(int)KnownColor.ActiveBorder] = unchecked((int)0xffd4d0c8); + colorTable[(int)KnownColor.ActiveCaption] = unchecked((int)0xff0054e3); + colorTable[(int)KnownColor.ActiveCaptionText] = unchecked((int)0xffffffff); + colorTable[(int)KnownColor.AppWorkspace] = unchecked((int)0xff808080); + colorTable[(int)KnownColor.ButtonFace] = unchecked((int)0x0); + colorTable[(int)KnownColor.ButtonHighlight] = unchecked((int)0x0); + colorTable[(int)KnownColor.ButtonShadow] = unchecked((int)0x0); + colorTable[(int)KnownColor.Control] = unchecked((int)0xffece9d8); + colorTable[(int)KnownColor.ControlDark] = unchecked((int)0xffaca899); + colorTable[(int)KnownColor.ControlDarkDark] = unchecked((int)0xff716f64); + colorTable[(int)KnownColor.ControlLight] = unchecked((int)0xfff1efe2); + colorTable[(int)KnownColor.ControlLightLight] = unchecked((int)0xffffffff); + colorTable[(int)KnownColor.ControlText] = unchecked((int)0xff000000); + colorTable[(int)KnownColor.Desktop] = unchecked((int)0xff004e98); + colorTable[(int)KnownColor.GradientActiveCaption] = unchecked((int)0x0); + colorTable[(int)KnownColor.GradientInactiveCaption] = unchecked((int)0x0); + colorTable[(int)KnownColor.GrayText] = unchecked((int)0xffaca899); + colorTable[(int)KnownColor.Highlight] = unchecked((int)0xff316ac5); + colorTable[(int)KnownColor.HighlightText] = unchecked((int)0xffffffff); + colorTable[(int)KnownColor.HotTrack] = unchecked((int)0xff000080); + colorTable[(int)KnownColor.InactiveBorder] = unchecked((int)0xffd4d0c8); + colorTable[(int)KnownColor.InactiveCaption] = unchecked((int)0xff7a96df); + colorTable[(int)KnownColor.InactiveCaptionText] = unchecked((int)0xffd8e4f8); + colorTable[(int)KnownColor.Info] = unchecked((int)0xffffffe1); + colorTable[(int)KnownColor.InfoText] = unchecked((int)0xff000000); + colorTable[(int)KnownColor.Menu] = unchecked((int)0xffffffff); + colorTable[(int)KnownColor.MenuBar] = unchecked((int)0x0); + colorTable[(int)KnownColor.MenuHighlight] = unchecked((int)0x0); + colorTable[(int)KnownColor.MenuText] = unchecked((int)0xff000000); + colorTable[(int)KnownColor.ScrollBar] = unchecked((int)0xffd4d0c8); + colorTable[(int)KnownColor.Window] = unchecked((int)0xffffffff); + colorTable[(int)KnownColor.WindowFrame] = unchecked((int)0xff000000); + colorTable[(int)KnownColor.WindowText] = unchecked((int)0xff000000); + } + } +} diff --git a/src/System.Drawing.Primitives/src/System/Drawing/Size.cs b/src/System.Drawing.Primitives/src/System/Drawing/Size.cs index 1078484840..8659535478 100644 --- a/src/System.Drawing.Primitives/src/System/Drawing/Size.cs +++ b/src/System.Drawing.Primitives/src/System/Drawing/Size.cs @@ -242,5 +242,4 @@ namespace System.Drawing return "{Width=" + _width.ToString() + ", Height=" + _height.ToString() + "}"; } } - } diff --git a/src/System.Drawing.Primitives/src/System/Drawing/SystemColors.cs b/src/System.Drawing.Primitives/src/System/Drawing/SystemColors.cs new file mode 100644 index 0000000000..6f8e4ad98f --- /dev/null +++ b/src/System.Drawing.Primitives/src/System/Drawing/SystemColors.cs @@ -0,0 +1,75 @@ +// 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. + +namespace System.Drawing +{ + public static class SystemColors + { + public static Color ActiveBorder => new Color(KnownColor.ActiveBorder); + + public static Color ActiveCaption => new Color(KnownColor.ActiveCaption); + + public static Color ActiveCaptionText => new Color(KnownColor.ActiveCaptionText); + + public static Color AppWorkspace => new Color(KnownColor.AppWorkspace); + + public static Color ButtonFace => new Color(KnownColor.ButtonFace); + + public static Color ButtonHighlight => new Color(KnownColor.ButtonHighlight); + + public static Color ButtonShadow => new Color(KnownColor.ButtonShadow); + + public static Color Control => new Color(KnownColor.Control); + + public static Color ControlDark => new Color(KnownColor.ControlDark); + + public static Color ControlDarkDark => new Color(KnownColor.ControlDarkDark); + + public static Color ControlLight => new Color(KnownColor.ControlLight); + + public static Color ControlLightLight => new Color(KnownColor.ControlLightLight); + + public static Color ControlText => new Color(KnownColor.ControlText); + + public static Color Desktop => new Color(KnownColor.Desktop); + + public static Color GradientActiveCaption => new Color(KnownColor.GradientActiveCaption); + + public static Color GradientInactiveCaption => new Color(KnownColor.GradientInactiveCaption); + + public static Color GrayText => new Color(KnownColor.GrayText); + + public static Color Highlight => new Color(KnownColor.Highlight); + + public static Color HighlightText => new Color(KnownColor.HighlightText); + + public static Color HotTrack => new Color(KnownColor.HotTrack); + + public static Color InactiveBorder => new Color(KnownColor.InactiveBorder); + + public static Color InactiveCaption => new Color(KnownColor.InactiveCaption); + + public static Color InactiveCaptionText => new Color(KnownColor.InactiveCaptionText); + + public static Color Info => new Color(KnownColor.Info); + + public static Color InfoText => new Color(KnownColor.InfoText); + + public static Color Menu => new Color(KnownColor.Menu); + + public static Color MenuBar => new Color(KnownColor.MenuBar); + + public static Color MenuHighlight => new Color(KnownColor.MenuHighlight); + + public static Color MenuText => new Color(KnownColor.MenuText); + + public static Color ScrollBar => new Color(KnownColor.ScrollBar); + + public static Color Window => new Color(KnownColor.Window); + + public static Color WindowFrame => new Color(KnownColor.WindowFrame); + + public static Color WindowText => new Color(KnownColor.WindowText); + } +}
\ No newline at end of file diff --git a/src/System.Drawing.Primitives/src/project.json b/src/System.Drawing.Primitives/src/project.json index 3aa9c80f49..1d93ddf677 100644 --- a/src/System.Drawing.Primitives/src/project.json +++ b/src/System.Drawing.Primitives/src/project.json @@ -1,19 +1,23 @@ { "frameworks": { - "netstandard1.1": { + "netstandard1.7": { "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1", + "System.Collections": "4.0.11", "System.Diagnostics.Contracts": "4.0.1", - "System.Runtime": "4.0.0", - "System.Runtime.Extensions": "4.0.0" - }, - "imports": [ - "dotnet5.2" - ] + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.Reflection": "4.3.0-beta-24520-06", + "System.Reflection.Primitives": "4.3.0-beta-24520-06", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime": "4.3.0-beta-24520-06", + "System.Runtime.Extensions": "4.1.0", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.3.0-beta-24520-06" + } }, - "net45": { + "net463": { "dependencies": { - "Microsoft.TargetingPack.NETFramework.v4.5": "1.0.1" + "Microsoft.TargetingPack.NETFramework.v4.6": "1.0.1" } } } diff --git a/src/System.Drawing.Primitives/tests/ColorTests.cs b/src/System.Drawing.Primitives/tests/ColorTests.cs new file mode 100644 index 0000000000..d194e437ab --- /dev/null +++ b/src/System.Drawing.Primitives/tests/ColorTests.cs @@ -0,0 +1,386 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.Serialization.Formatters.Binary; +using Xunit; + +namespace System.Drawing.Primitives.Tests +{ + public partial class ColorTests + { + public static IEnumerable<object[]> NamedArgbValues => + new[] + { + new object[] {"Transparent", 0, 255, 255, 255}, + new object[] {"AliceBlue", 255, 240, 248, 255}, + new object[] {"AntiqueWhite", 255, 250, 235, 215}, + new object[] {"Aqua", 255, 0, 255, 255}, + new object[] {"Aquamarine", 255, 127, 255, 212}, + new object[] {"Azure", 255, 240, 255, 255}, + new object[] {"Beige", 255, 245, 245, 220}, + new object[] {"Bisque", 255, 255, 228, 196}, + new object[] {"Black", 255, 0, 0, 0}, + new object[] {"BlanchedAlmond", 255, 255, 235, 205}, + new object[] {"Blue", 255, 0, 0, 255}, + new object[] {"BlueViolet", 255, 138, 43, 226}, + new object[] {"Brown", 255, 165, 42, 42}, + new object[] {"BurlyWood", 255, 222, 184, 135}, + new object[] {"CadetBlue", 255, 95, 158, 160}, + new object[] {"Chartreuse", 255, 127, 255, 0}, + new object[] {"Chocolate", 255, 210, 105, 30}, + new object[] {"Coral", 255, 255, 127, 80}, + new object[] {"CornflowerBlue", 255, 100, 149, 237}, + new object[] {"Cornsilk", 255, 255, 248, 220}, + new object[] {"Crimson", 255, 220, 20, 60}, + new object[] {"Cyan", 255, 0, 255, 255}, + new object[] {"DarkBlue", 255, 0, 0, 139}, + new object[] {"DarkCyan", 255, 0, 139, 139}, + new object[] {"DarkGoldenrod", 255, 184, 134, 11}, + new object[] {"DarkGray", 255, 169, 169, 169}, + new object[] {"DarkGreen", 255, 0, 100, 0}, + new object[] {"DarkKhaki", 255, 189, 183, 107}, + new object[] {"DarkMagenta", 255, 139, 0, 139}, + new object[] {"DarkOliveGreen", 255, 85, 107, 47}, + new object[] {"DarkOrange", 255, 255, 140, 0}, + new object[] {"DarkOrchid", 255, 153, 50, 204}, + new object[] {"DarkRed", 255, 139, 0, 0}, + new object[] {"DarkSalmon", 255, 233, 150, 122}, + new object[] {"DarkSeaGreen", 255, 143, 188, 139}, + new object[] {"DarkSlateBlue", 255, 72, 61, 139}, + new object[] {"DarkSlateGray", 255, 47, 79, 79}, + new object[] {"DarkTurquoise", 255, 0, 206, 209}, + new object[] {"DarkViolet", 255, 148, 0, 211}, + new object[] {"DeepPink", 255, 255, 20, 147}, + new object[] {"DeepSkyBlue", 255, 0, 191, 255}, + new object[] {"DimGray", 255, 105, 105, 105}, + new object[] {"DodgerBlue", 255, 30, 144, 255}, + new object[] {"Firebrick", 255, 178, 34, 34}, + new object[] {"FloralWhite", 255, 255, 250, 240}, + new object[] {"ForestGreen", 255, 34, 139, 34}, + new object[] {"Fuchsia", 255, 255, 0, 255}, + new object[] {"Gainsboro", 255, 220, 220, 220}, + new object[] {"GhostWhite", 255, 248, 248, 255}, + new object[] {"Gold", 255, 255, 215, 0}, + new object[] {"Goldenrod", 255, 218, 165, 32}, + new object[] {"Gray", 255, 128, 128, 128}, + new object[] {"Green", 255, 0, 128, 0}, + new object[] {"GreenYellow", 255, 173, 255, 47}, + new object[] {"Honeydew", 255, 240, 255, 240}, + new object[] {"HotPink", 255, 255, 105, 180}, + new object[] {"IndianRed", 255, 205, 92, 92}, + new object[] {"Indigo", 255, 75, 0, 130}, + new object[] {"Ivory", 255, 255, 255, 240}, + new object[] {"Khaki", 255, 240, 230, 140}, + new object[] {"Lavender", 255, 230, 230, 250}, + new object[] {"LavenderBlush", 255, 255, 240, 245}, + new object[] {"LawnGreen", 255, 124, 252, 0}, + new object[] {"LemonChiffon", 255, 255, 250, 205}, + new object[] {"LightBlue", 255, 173, 216, 230}, + new object[] {"LightCoral", 255, 240, 128, 128}, + new object[] {"LightCyan", 255, 224, 255, 255}, + new object[] {"LightGoldenrodYellow", 255, 250, 250, 210}, + new object[] {"LightGreen", 255, 144, 238, 144}, + new object[] {"LightGray", 255, 211, 211, 211}, + new object[] {"LightPink", 255, 255, 182, 193}, + new object[] {"LightSalmon", 255, 255, 160, 122}, + new object[] {"LightSeaGreen", 255, 32, 178, 170}, + new object[] {"LightSkyBlue", 255, 135, 206, 250}, + new object[] {"LightSlateGray", 255, 119, 136, 153}, + new object[] {"LightSteelBlue", 255, 176, 196, 222}, + new object[] {"LightYellow", 255, 255, 255, 224}, + new object[] {"Lime", 255, 0, 255, 0}, + new object[] {"LimeGreen", 255, 50, 205, 50}, + new object[] {"Linen", 255, 250, 240, 230}, + new object[] {"Magenta", 255, 255, 0, 255}, + new object[] {"Maroon", 255, 128, 0, 0}, + new object[] {"MediumAquamarine", 255, 102, 205, 170}, + new object[] {"MediumBlue", 255, 0, 0, 205}, + new object[] {"MediumOrchid", 255, 186, 85, 211}, + new object[] {"MediumPurple", 255, 147, 112, 219}, + new object[] {"MediumSeaGreen", 255, 60, 179, 113}, + new object[] {"MediumSlateBlue", 255, 123, 104, 238}, + new object[] {"MediumSpringGreen", 255, 0, 250, 154}, + new object[] {"MediumTurquoise", 255, 72, 209, 204}, + new object[] {"MediumVioletRed", 255, 199, 21, 133}, + new object[] {"MidnightBlue", 255, 25, 25, 112}, + new object[] {"MintCream", 255, 245, 255, 250}, + new object[] {"MistyRose", 255, 255, 228, 225}, + new object[] {"Moccasin", 255, 255, 228, 181}, + new object[] {"NavajoWhite", 255, 255, 222, 173}, + new object[] {"Navy", 255, 0, 0, 128}, + new object[] {"OldLace", 255, 253, 245, 230}, + new object[] {"Olive", 255, 128, 128, 0}, + new object[] {"OliveDrab", 255, 107, 142, 35}, + new object[] {"Orange", 255, 255, 165, 0}, + new object[] {"OrangeRed", 255, 255, 69, 0}, + new object[] {"Orchid", 255, 218, 112, 214}, + new object[] {"PaleGoldenrod", 255, 238, 232, 170}, + new object[] {"PaleGreen", 255, 152, 251, 152}, + new object[] {"PaleTurquoise", 255, 175, 238, 238}, + new object[] {"PaleVioletRed", 255, 219, 112, 147}, + new object[] {"PapayaWhip", 255, 255, 239, 213}, + new object[] {"PeachPuff", 255, 255, 218, 185}, + new object[] {"Peru", 255, 205, 133, 63}, + new object[] {"Pink", 255, 255, 192, 203}, + new object[] {"Plum", 255, 221, 160, 221}, + new object[] {"PowderBlue", 255, 176, 224, 230}, + new object[] {"Purple", 255, 128, 0, 128}, + new object[] {"Red", 255, 255, 0, 0}, + new object[] {"RosyBrown", 255, 188, 143, 143}, + new object[] {"RoyalBlue", 255, 65, 105, 225}, + new object[] {"SaddleBrown", 255, 139, 69, 19}, + new object[] {"Salmon", 255, 250, 128, 114}, + new object[] {"SandyBrown", 255, 244, 164, 96}, + new object[] {"SeaGreen", 255, 46, 139, 87}, + new object[] {"SeaShell", 255, 255, 245, 238}, + new object[] {"Sienna", 255, 160, 82, 45}, + new object[] {"Silver", 255, 192, 192, 192}, + new object[] {"SkyBlue", 255, 135, 206, 235}, + new object[] {"SlateBlue", 255, 106, 90, 205}, + new object[] {"SlateGray", 255, 112, 128, 144}, + new object[] {"Snow", 255, 255, 250, 250}, + new object[] {"SpringGreen", 255, 0, 255, 127}, + new object[] {"SteelBlue", 255, 70, 130, 180}, + new object[] {"Tan", 255, 210, 180, 140}, + new object[] {"Teal", 255, 0, 128, 128}, + new object[] {"Thistle", 255, 216, 191, 216}, + new object[] {"Tomato", 255, 255, 99, 71}, + new object[] {"Turquoise", 255, 64, 224, 208}, + new object[] {"Violet", 255, 238, 130, 238}, + new object[] {"Wheat", 255, 245, 222, 179}, + new object[] {"White", 255, 255, 255, 255}, + new object[] {"WhiteSmoke", 255, 245, 245, 245}, + new object[] {"Yellow", 255, 255, 255, 0}, + new object[] {"YellowGreen", 255, 154, 205, 50}, + }; + + public static IEnumerable<object[]> ColorNames => Enum.GetNames(typeof(KnownColor)).Select(n => new object[] { n }); + + private Color? GetColorByProperty(string name) + { + return (Color?)typeof(Color).GetProperty(name)?.GetValue(null); + } + + [Theory] + [MemberData(nameof(NamedArgbValues))] + public void ArgbValues(string name, int alpha, int red, int green, int blue) + { + Color? color = GetColorByProperty(name); + if (color.HasValue) + { + Assert.Equal(alpha, color.Value.A); + Assert.Equal(red, color.Value.R); + Assert.Equal(green, color.Value.G); + Assert.Equal(blue, color.Value.B); + } + } + + [Fact] + public void Empty() + { + Assert.True(Color.Empty.IsEmpty); + Assert.False(Color.FromArgb(0, Color.Black).IsEmpty); + } + + [Fact] + public void IsKnownColor() + { + Assert.True(Color.FromKnownColor(KnownColor.AliceBlue).IsKnownColor); + Assert.True(Color.FromName("AliceBlue").IsKnownColor); + Assert.False(Color.FromArgb(Color.AliceBlue.A, Color.AliceBlue.R, Color.AliceBlue.G, Color.AliceBlue.B).IsKnownColor); + } + + [Fact] + public void IsNamedColor() + { + Assert.True(Color.AliceBlue.IsNamedColor); + Assert.True(Color.FromKnownColor(KnownColor.AliceBlue).IsNamedColor); + Assert.True(Color.FromName("AliceBlue").IsNamedColor); + Assert.False(Color.FromArgb(Color.AliceBlue.A, Color.AliceBlue.R, Color.AliceBlue.G, Color.AliceBlue.B).IsNamedColor); + } + + [Fact] + public void IsSystemColor() + { + Color c = Color.FromKnownColor(KnownColor.ActiveBorder); + Assert.True(c.IsSystemColor); + Assert.True(Color.FromName("ActiveBorder").IsSystemColor); + Assert.False(Color.FromArgb(c.A, c.R, c.G, c.B).IsSystemColor); + Assert.False(Color.FromKnownColor(KnownColor.AliceBlue).IsSystemColor); + Assert.False(Color.FromName("AliceBlue").IsSystemColor); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void KnownNames(string name) + { + Assert.Equal(name, Color.FromName(name).Name); + var colorByProperty = GetColorByProperty(name); + if (colorByProperty.HasValue) + { + Assert.Equal(name, colorByProperty.Value.Name); + } + } + + [Fact] + public void Name() + { + Assert.Equal("1122ccff", Color.FromArgb(0x11, 0x22, 0xcc, 0xff).Name); + } + + public static IEnumerable<object[]> ColorNamePairs => ColorNames.Zip(ColorNames.Skip(1), (l, r) => new[] { l[0], r[0] }); + + [Theory] + [MemberData(nameof(ColorNamePairs))] + public void GetHashCode(string name1, string name2) + { + Assert.NotEqual(name1, name2); + Color c1 = GetColorByProperty(name1) ?? Color.FromName(name1); + Color c2 = GetColorByProperty(name2) ?? Color.FromName(name2); + Assert.NotEqual(c2.GetHashCode(), c1.GetHashCode()); + Assert.Equal(c1.GetHashCode(), Color.FromName(name1).GetHashCode()); + } + + [Theory] + [InlineData(0x11cc8833, 0x11, 0xcc, 0x88, 0x33)] + [InlineData(unchecked((int)0xf1cc8833), 0xf1, 0xcc, 0x88, 0x33)] + public void ToArgb(int argb, int alpha, int red, int green, int blue) + { + Assert.Equal(argb, Color.FromArgb(alpha, red, green, blue).ToArgb()); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void ToKnownColor(string name) + { + var knownColor = (KnownColor)Enum.Parse(typeof(KnownColor), name); + var colorByProperty = GetColorByProperty(name); + if (colorByProperty.HasValue) + { + Assert.Equal(knownColor, colorByProperty.Value.ToKnownColor()); + } + Assert.Equal(knownColor, Color.FromName(name).ToKnownColor()); + } + + [Fact] + public void ToStringEmpty() + { + Assert.Equal("Color [Empty]", Color.Empty.ToString()); + } + + [Theory] + [MemberData(nameof(ColorNames))] + public void ToStringNamed(string name) + { + string expected = $"Color [{name}]"; + Assert.Equal(expected, Color.FromName(name).ToString()); + } + + [Theory] + [InlineData("Color [A=1, R=2, G=3, B=4]", 1, 2, 3, 4)] + public void ToStringArgb(string expected, int alpha, int red, int green, int blue) + { + Assert.Equal(expected, Color.FromArgb(alpha, red, green, blue).ToString()); + } + + public static IEnumerable<object[]> InvalidValues => + new[] + { + new object[] {-1}, + new object[] {256}, + }; + + [Theory] + [MemberData(nameof(InvalidValues))] + public void FromArgb_InvalidAlpha(int alpha) + { + Assert.Throws<ArgumentException>(() => + { + Color.FromArgb(alpha, Color.Red); + }); + Assert.Throws<ArgumentException>(() => + { + Color.FromArgb(alpha, 0, 0, 0); + }); + } + + [Theory] + [MemberData(nameof(InvalidValues))] + public void FromArgb_InvalidRed(int red) + { + Assert.Throws<ArgumentException>(() => + { + Color.FromArgb(red, 0, 0); + }); + Assert.Throws<ArgumentException>(() => + { + Color.FromArgb(0, red, 0, 0); + }); + } + + [Theory] + [MemberData(nameof(InvalidValues))] + public void FromArgb_InvalidGreen(int green) + { + Assert.Throws<ArgumentException>(() => + { + Color.FromArgb(0, green, 0); + }); + Assert.Throws<ArgumentException>(() => + { + Color.FromArgb(0, 0, green, 0); + }); + } + + [Theory] + [MemberData(nameof(InvalidValues))] + public void FromArgb_InvalidBlue(int blue) + { + Assert.Throws<ArgumentException>(() => + { + Color.FromArgb(0, 0, blue); + }); + Assert.Throws<ArgumentException>(() => + { + Color.FromArgb(0, 0, 0, blue); + }); + } + + [Fact] + public void FromName_Invalid() + { + Color c = Color.FromName("OingoBoingo"); + Assert.True(c.IsNamedColor); + Assert.Equal(0, c.ToArgb()); + Assert.Equal("OingoBoingo", c.Name); + } + + private void CheckRed(Color color) + { + Assert.Equal(255, color.A); + Assert.Equal(255, color.R); + Assert.Equal(0, color.G); + Assert.Equal(0, color.B); + Assert.Equal("Red", color.Name); + Assert.False(color.IsEmpty, "IsEmpty"); + Assert.True(color.IsKnownColor, "IsKnownColor"); + Assert.True(color.IsNamedColor, "IsNamedColor"); + Assert.False(color.IsSystemColor, "IsSystemColor"); + } + + [Fact] + public void SerializationRoundTrip() + { + Color c = Color.Red; + CheckRed(c); + + BinaryFormatter bf = new BinaryFormatter(); + MemoryStream ms = new MemoryStream(); + bf.Serialize(ms, c); + + ms.Position = 0; + Color color = (Color)bf.Deserialize(ms); + CheckRed(color); + } + } +} diff --git a/src/System.Drawing.Primitives/tests/PointFTests.cs b/src/System.Drawing.Primitives/tests/PointFTests.cs index a70d62d054..68467b8b74 100644 --- a/src/System.Drawing.Primitives/tests/PointFTests.cs +++ b/src/System.Drawing.Primitives/tests/PointFTests.cs @@ -68,7 +68,7 @@ namespace System.Drawing.PrimitivesTests [Theory] [InlineData(float.MaxValue, float.MinValue, int.MaxValue, int.MinValue)] [InlineData(float.MinValue, float.MaxValue, int.MinValue, int.MaxValue)] - [InlineData(0,0,0,0)] + [InlineData(0, 0, 0, 0)] public void ArithmeticTestWithSize(float x, float y, int x1, int y1) { PointF p = new PointF(x, y); @@ -104,7 +104,7 @@ namespace System.Drawing.PrimitivesTests [InlineData(float.MinValue, float.MaxValue)] [InlineData(float.MinValue, float.MinValue)] [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0,0)] + [InlineData(0, 0)] public void EqualityTest(float x, float y) { PointF pLeft = new PointF(x, y); diff --git a/src/System.Drawing.Primitives/tests/PointTests.cs b/src/System.Drawing.Primitives/tests/PointTests.cs index 14c7f4af14..4f656183dd 100644 --- a/src/System.Drawing.Primitives/tests/PointTests.cs +++ b/src/System.Drawing.Primitives/tests/PointTests.cs @@ -36,7 +36,7 @@ namespace System.Drawing.PrimitivesTests { Point p1 = new Point(x); Point p2 = new Point((short)(x & 0xFFFF), (short)((x >> 16) & 0xFFFF)); - + Assert.Equal(p1, p2); } diff --git a/src/System.Drawing.Primitives/tests/RectangleFTests.cs b/src/System.Drawing.Primitives/tests/RectangleFTests.cs index 3ec277cda5..eff09fd59d 100644 --- a/src/System.Drawing.Primitives/tests/RectangleFTests.cs +++ b/src/System.Drawing.Primitives/tests/RectangleFTests.cs @@ -119,7 +119,7 @@ namespace System.Drawing.PrimitivesTest Assert.False(rect1 == rect2); Assert.False(rect1.Equals(rect2)); } - + [Fact] public static void EqualityTest_NotRectangleF() { @@ -159,7 +159,7 @@ namespace System.Drawing.PrimitivesTest [Theory] [InlineData(0, 0, 0, 0)] - [InlineData(float.MaxValue/2, float.MinValue/2, float.MinValue/2, float.MaxValue/2)] + [InlineData(float.MaxValue / 2, float.MinValue / 2, float.MinValue / 2, float.MaxValue / 2)] [InlineData(0, float.MinValue, float.MaxValue, 0)] public void InflateTest(float x, float y, float width, float height) { @@ -177,7 +177,7 @@ namespace System.Drawing.PrimitivesTest } [Theory] - [InlineData(float.MaxValue, float.MinValue, float.MaxValue/2, float.MinValue/2)] + [InlineData(float.MaxValue, float.MinValue, float.MaxValue / 2, float.MinValue / 2)] [InlineData(0, float.MinValue, float.MaxValue, 0)] public void IntersectTest(float x, float y, float width, float height) { diff --git a/src/System.Drawing.Primitives/tests/RectangleTests.cs b/src/System.Drawing.Primitives/tests/RectangleTests.cs index 11eecf5ec7..bb3b984f4c 100644 --- a/src/System.Drawing.Primitives/tests/RectangleTests.cs +++ b/src/System.Drawing.Primitives/tests/RectangleTests.cs @@ -132,7 +132,7 @@ namespace System.Drawing.PrimitivesTest public void EqualityTest(int x, int y, int width, int height) { Rectangle rect1 = new Rectangle(x, y, width, height); - Rectangle rect2 = new Rectangle(width/2, height/2, x, y); + Rectangle rect2 = new Rectangle(width / 2, height / 2, x, y); Assert.True(rect1 != rect2); Assert.False(rect1 == rect2); @@ -183,7 +183,7 @@ namespace System.Drawing.PrimitivesTest [InlineData(0, int.MinValue, int.MaxValue, 0)] public void ContainsTest(int x, int y, int width, int height) { - Rectangle rect = new Rectangle(2*x-width, 2*y-height, width, height); + Rectangle rect = new Rectangle(2 * x - width, 2 * y - height, width, height); Point p = new Point(x, y); Rectangle r = new Rectangle(x, y, width / 2, height / 2); diff --git a/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.builds b/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.builds index 14fea7bf30..ead6e41ba3 100644 --- a/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.builds +++ b/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.builds @@ -7,7 +7,15 @@ <TestTFMs>netcore50;net46</TestTFMs> <OSGroup>Windows_NT</OSGroup> </Project> + <Project Include="System.Drawing.Primitives.Tests.csproj"> + <TargetGroup>netstandard1.7</TargetGroup> + <TestTFMs>netcoreapp1.1</TestTFMs> + </Project> + <Project Include="System.Drawing.Primitives.Tests.csproj"> + <TargetGroup>netstandard1.7</TargetGroup> + <TestTFMs>net463</TestTFMs> + <OSGroup>Windows_NT</OSGroup> + </Project> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" /> </Project> - diff --git a/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj b/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj index b197347922..71814ea8e5 100644 --- a/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj +++ b/src/System.Drawing.Primitives/tests/System.Drawing.Primitives.Tests.csproj @@ -1,21 +1,24 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> <PropertyGroup> <MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <OutputType>Library</OutputType> <RootNamespace>System.Drawing.Primitives.Tests</RootNamespace> <AssemblyName>System.Drawing.Primitives.Tests</AssemblyName> <ProjectGuid>{297A9116-1005-499D-A895-2063D03E4C94}</ProjectGuid> - <NugetTargetMoniker>.NETStandard,Version=v1.3</NugetTargetMoniker> </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.7_Debug|AnyCPU' "> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'netstandard1.7_Release|AnyCPU' "> </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net463_Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'net463_Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> <None Include="project.json" /> </ItemGroup> @@ -33,5 +36,8 @@ <Compile Include="SizeFTests.cs" /> <Compile Include="SizeTests.cs" /> </ItemGroup> + <ItemGroup Condition="'$(TargetGroup)' == 'netstandard1.7'"> + <Compile Include="ColorTests.cs" /> + </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> </Project> diff --git a/src/System.Drawing.Primitives/tests/project.json b/src/System.Drawing.Primitives/tests/project.json index e938efdb64..9557e39eab 100644 --- a/src/System.Drawing.Primitives/tests/project.json +++ b/src/System.Drawing.Primitives/tests/project.json @@ -2,8 +2,10 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.2-beta-24520-06", "System.Globalization": "4.3.0-beta-24520-06", + "System.IO": "4.3.0-beta-24520-06", "System.Linq.Expressions": "4.3.0-beta-24520-06", "System.ObjectModel": "4.3.0-beta-24520-06", + "System.Reflection.TypeExtensions": "4.3.0-beta-24520-06", "System.Runtime": "4.3.0-beta-24520-06", "System.Text.RegularExpressions": "4.3.0-beta-24520-06", "test-runtime": { @@ -14,7 +16,12 @@ "Microsoft.DotNet.BuildTools.TestSuite": "1.0.0-prerelease-00807-03" }, "frameworks": { - "netstandard1.3": {} + "netstandard1.3": {}, + "netstandard1.7": { + "dependencies": { + "System.Runtime.Serialization.Formatters": "4.3.0-beta-24520-06" + } + } }, "supports": { "coreFx.Test.netcore50": {}, @@ -22,6 +29,22 @@ "coreFx.Test.net46": {}, "coreFx.Test.net461": {}, "coreFx.Test.net462": {}, - "coreFx.Test.net463": {} + "coreFx.Test.net463": {}, + "coreFx.Test.netcoreapp1.1-ns17": { + "netstandard1.7": [ + "win7-x86", + "win7-x64", + "win10-arm64", + "osx.10.10-x64", + "centos.7-x64", + "debian.8-x64", + "rhel.7-x64", + "ubuntu.14.04-x64", + "ubuntu.16.04-x64", + "fedora.23-x64", + "linux-x64", + "opensuse.13.2-x64" + ] + } } } |