From 329a8fc7ac550c5d5d7c9868ec24efd2af5f0477 Mon Sep 17 00:00:00 2001 From: Miepee Date: Mon, 6 Mar 2023 12:33:26 +0100 Subject: [PATCH 1/6] Use multiple target frameworks for Eto.Forms --- src/Eto/Eto.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Eto/Eto.csproj b/src/Eto/Eto.csproj index 2e114f75ea..071b308770 100644 --- a/src/Eto/Eto.csproj +++ b/src/Eto/Eto.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + netstandard2.0;net6.0 10 true true From 880fac875e910eec993ef9497fc483d72ec58349 Mon Sep 17 00:00:00 2001 From: Miepee Date: Mon, 6 Mar 2023 13:40:05 +0100 Subject: [PATCH 2/6] Fix using references after having multiple target frameworks --- src/Eto/Drawing/ColorConverter.cs | 10 +++++----- src/Eto/Drawing/ImageConverter.cs | 8 ++++---- src/Eto/Drawing/PaddingConverter.cs | 6 +++--- src/Eto/Drawing/PointConverter.cs | 6 +++--- src/Eto/Drawing/PointFConverter.cs | 6 +++--- src/Eto/Drawing/RectangleConverter.cs | 6 +++--- src/Eto/Drawing/RectangleFConverter.cs | 6 +++--- src/Eto/Drawing/SizeConverter.cs | 6 +++--- src/Eto/Drawing/SizeFConverter.cs | 6 +++--- src/Eto/Forms/Binding/ICommand.cs | 2 +- src/Eto/Forms/Controls/Control.cs | 6 +++--- src/Eto/Forms/Layout/DynamicTable.cs | 6 +++--- 12 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Eto/Drawing/ColorConverter.cs b/src/Eto/Drawing/ColorConverter.cs index 8ddf38b2f4..9e6b9d0a76 100644 --- a/src/Eto/Drawing/ColorConverter.cs +++ b/src/Eto/Drawing/ColorConverter.cs @@ -88,7 +88,7 @@ public override object ConvertTo(sc.ITypeDescriptorContext context, CultureInfo /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class ColorConverter : TypeConverter +public class ColorConverter : sc.TypeConverter { /// /// Determines if this can convert a to the @@ -96,7 +96,7 @@ public class ColorConverter : TypeConverter /// Context of the conversion /// Type to convert to /// True if this converter supports the , false otherwise - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(sc.ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(string); } @@ -107,7 +107,7 @@ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinati /// Context of the conversion /// Type to convert from /// True if this can convert to the , false otherwise - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -119,7 +119,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Culture to use for the conversion /// Value to convert /// A instance with the converted value - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) { var str = value as string; if (str != null) @@ -140,7 +140,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c /// value to convert /// Type to convert the to /// An object of type converted from - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object ConvertTo(sc.ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { diff --git a/src/Eto/Drawing/ImageConverter.cs b/src/Eto/Drawing/ImageConverter.cs index 90e4054eb5..228ff2a22c 100644 --- a/src/Eto/Drawing/ImageConverter.cs +++ b/src/Eto/Drawing/ImageConverter.cs @@ -130,7 +130,7 @@ public override object ConvertFrom (sc.ITypeDescriptorContext context, System.Gl /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class ImageConverter : TypeConverter +public class ImageConverter : sc.TypeConverter { /// /// Prefix to use to load an image from a resource of an assembly @@ -158,7 +158,7 @@ protected virtual bool IsIcon (string fileName) /// Conversion context /// Type to convert from /// True if this converter can handle converting from the specified to an image - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string) || typeof(NamespaceInfo).IsAssignableFrom(sourceType) || typeof(Stream).IsAssignableFrom(sourceType); } @@ -169,7 +169,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Conversion context /// Type to convert to /// True if this converter can convert to the specified , otherwise false. - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(sc.ITypeDescriptorContext context, Type destinationType) { return false; } @@ -213,7 +213,7 @@ Image LoadImage (string resourceName) /// Culture to perform the conversion /// Value to convert to an image /// A new instance of an image, or null if it cannot be converted - public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value is NamespaceInfo ns) return LoadImage(ns); diff --git a/src/Eto/Drawing/PaddingConverter.cs b/src/Eto/Drawing/PaddingConverter.cs index 7b4a6829a0..dc788ad1e3 100644 --- a/src/Eto/Drawing/PaddingConverter.cs +++ b/src/Eto/Drawing/PaddingConverter.cs @@ -80,7 +80,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class PaddingConverter : TypeConverter +public class PaddingConverter : sc.TypeConverter { /// /// The character to split up the string which will be converted @@ -93,7 +93,7 @@ public class PaddingConverter : TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -105,7 +105,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Culture to perform the conversion for /// Value to convert /// A new instance of the object with the value represented by - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/PointConverter.cs b/src/Eto/Drawing/PointConverter.cs index 2174449794..6f244437a8 100644 --- a/src/Eto/Drawing/PointConverter.cs +++ b/src/Eto/Drawing/PointConverter.cs @@ -71,7 +71,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class PointConverter : TypeConverter +public class PointConverter : sc.TypeConverter { /// /// The character to split up the string which will be converted @@ -84,7 +84,7 @@ public class PointConverter : TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -96,7 +96,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/PointFConverter.cs b/src/Eto/Drawing/PointFConverter.cs index 6d069886e2..8b70479777 100644 --- a/src/Eto/Drawing/PointFConverter.cs +++ b/src/Eto/Drawing/PointFConverter.cs @@ -71,7 +71,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class PointFConverter : TypeConverter +public class PointFConverter : sc.TypeConverter { /// /// The character to split up the string which will be converted @@ -84,7 +84,7 @@ public class PointFConverter : TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -96,7 +96,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/RectangleConverter.cs b/src/Eto/Drawing/RectangleConverter.cs index 897543b312..d55daf5a2e 100644 --- a/src/Eto/Drawing/RectangleConverter.cs +++ b/src/Eto/Drawing/RectangleConverter.cs @@ -72,7 +72,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class RectangleConverter : TypeConverter +public class RectangleConverter : sc.TypeConverter { /// /// The character to split up the string which will be converted @@ -85,7 +85,7 @@ public class RectangleConverter : TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -97,7 +97,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/RectangleFConverter.cs b/src/Eto/Drawing/RectangleFConverter.cs index a1e6622aeb..0ac0b5bbd9 100644 --- a/src/Eto/Drawing/RectangleFConverter.cs +++ b/src/Eto/Drawing/RectangleFConverter.cs @@ -72,7 +72,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class RectangleFConverter : TypeConverter +public class RectangleFConverter : sc.TypeConverter { /// /// The character to split up the string which will be converted @@ -85,7 +85,7 @@ public class RectangleFConverter : TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -97,7 +97,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/SizeConverter.cs b/src/Eto/Drawing/SizeConverter.cs index 6bc1c2c290..c46076c697 100644 --- a/src/Eto/Drawing/SizeConverter.cs +++ b/src/Eto/Drawing/SizeConverter.cs @@ -70,7 +70,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class SizeConverter : TypeConverter +public class SizeConverter : sc.TypeConverter { /// /// The character to split up the string which will be converted @@ -83,7 +83,7 @@ public class SizeConverter : TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -95,7 +95,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/SizeFConverter.cs b/src/Eto/Drawing/SizeFConverter.cs index 0b3b07d065..7efa71c0e6 100644 --- a/src/Eto/Drawing/SizeFConverter.cs +++ b/src/Eto/Drawing/SizeFConverter.cs @@ -70,7 +70,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class SizeFConverter : TypeConverter +public class SizeFConverter : sc.TypeConverter { /// /// The character to split up the string which will be converted @@ -83,7 +83,7 @@ public class SizeFConverter : TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -95,7 +95,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Forms/Binding/ICommand.cs b/src/Eto/Forms/Binding/ICommand.cs index c81efb8503..08e4b4d3e0 100644 --- a/src/Eto/Forms/Binding/ICommand.cs +++ b/src/Eto/Forms/Binding/ICommand.cs @@ -1,4 +1,4 @@ -#if !NETSTANDARD +#if !NETSTANDARD && !NETCOREAPP using System; namespace System.Windows.Input diff --git a/src/Eto/Forms/Controls/Control.cs b/src/Eto/Forms/Controls/Control.cs index 46801b4eb1..9b6b08a289 100755 --- a/src/Eto/Forms/Controls/Control.cs +++ b/src/Eto/Forms/Controls/Control.cs @@ -15,9 +15,9 @@ namespace Eto.Forms; /// load/unload, and common events. /// #if !NETSTANDARD - [ToolboxItem(true)] - [DesignTimeVisible(true)] - [DesignerCategory("Eto.Forms")] + [sc.ToolboxItem(true)] + [sc.DesignTimeVisible(true)] + [sc.DesignerCategory("Eto.Forms")] #endif [sc.TypeConverter(typeof(ControlConverter))] public partial class Control : BindableWidget, IMouseInputSource, IKeyboardInputSource, ICallbackSource diff --git a/src/Eto/Forms/Layout/DynamicTable.cs b/src/Eto/Forms/Layout/DynamicTable.cs index 486965bc3a..b0fbee8183 100644 --- a/src/Eto/Forms/Layout/DynamicTable.cs +++ b/src/Eto/Forms/Layout/DynamicTable.cs @@ -202,7 +202,7 @@ protected override void SetItem(int index, DynamicItem item) /// The maximum number of items in the determines the columns of the table. /// [ContentProperty("Rows")] -public class DynamicTable : DynamicItem, ISupportInitialize +public class DynamicTable : DynamicItem, sc.ISupportInitialize { internal DynamicLayout layout; bool visible = true; @@ -405,11 +405,11 @@ public override Control Create(DynamicLayout layout) return table; } - void ISupportInitialize.BeginInit() + void sc.ISupportInitialize.BeginInit() { } - void ISupportInitialize.EndInit() + void sc.ISupportInitialize.EndInit() { } From 8574183427539c1cb20317f579ca8d77614632dd Mon Sep 17 00:00:00 2001 From: Miepee Date: Wed, 5 Apr 2023 15:32:02 +0200 Subject: [PATCH 3/6] Replace binaryformatter with xmlSerializer --- src/Eto/Forms/Clipboard.cs | 9 +++++---- src/Eto/Forms/DataObject.cs | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Eto/Forms/Clipboard.cs b/src/Eto/Forms/Clipboard.cs index a2ebc90a8e..850c10a16a 100644 --- a/src/Eto/Forms/Clipboard.cs +++ b/src/Eto/Forms/Clipboard.cs @@ -5,6 +5,7 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Diagnostics; using System.Reflection; +using System.Xml.Serialization; namespace Eto.Forms; @@ -205,8 +206,8 @@ public void SetObject(object value, string type) { using (var ms = new MemoryStream()) { - var binaryFormatter = new BinaryFormatter(); - binaryFormatter.Serialize(ms, value); + var xmlFormatter = new XmlSerializer(value.GetType()); + xmlFormatter.Serialize(ms, value); SetDataStream(ms, type); return; } @@ -273,8 +274,8 @@ public object GetObject(string type) return null; try { - var binaryFormatter = new BinaryFormatter(); - return binaryFormatter.Deserialize(stream); + var xmlFormatter = new XmlSerializer(new object().GetType()); + return xmlFormatter.Deserialize(stream); } catch (Exception ex) { diff --git a/src/Eto/Forms/DataObject.cs b/src/Eto/Forms/DataObject.cs index dd600b734d..41a37dcbc8 100644 --- a/src/Eto/Forms/DataObject.cs +++ b/src/Eto/Forms/DataObject.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Runtime.Serialization.Formatters.Binary; using System.Text; +using System.Xml.Serialization; namespace Eto.Forms; @@ -261,9 +262,8 @@ public void SetObject(object value, string type) { using (var ms = new MemoryStream()) { - var binaryFormatter = new BinaryFormatter(); - binaryFormatter.Serialize(ms, value); - SetDataStream(ms, type); + var xmlFormatter = new XmlSerializer(value.GetType()); + xmlFormatter.Serialize(ms, value); return; } } @@ -329,8 +329,8 @@ public object GetObject(string type) return null; try { - var binaryFormatter = new BinaryFormatter(); - return binaryFormatter.Deserialize(stream); + var xmlFormatter = new XmlSerializer(new object().GetType()); + return xmlFormatter.Deserialize(stream); } catch (Exception ex) { From b8b9e35e3e49e0079482c884865443ce952134f0 Mon Sep 17 00:00:00 2001 From: Miepee Date: Wed, 5 Apr 2023 15:54:08 +0200 Subject: [PATCH 4/6] Revert accidental switch from System.ComponentModel Type converter to Eto.TypeConverter --- src/Eto/Drawing/ColorConverter.cs | 10 +++++----- src/Eto/Drawing/ImageConverter.cs | 8 ++++---- src/Eto/Drawing/PaddingConverter.cs | 6 +++--- src/Eto/Drawing/PointConverter.cs | 6 +++--- src/Eto/Drawing/PointFConverter.cs | 6 +++--- src/Eto/Drawing/RectangleConverter.cs | 6 +++--- src/Eto/Drawing/RectangleFConverter.cs | 6 +++--- src/Eto/Drawing/SizeConverter.cs | 6 +++--- src/Eto/Drawing/SizeFConverter.cs | 6 +++--- src/Eto/Forms/Controls/Control.cs | 8 ++++---- src/Eto/Forms/Layout/DynamicTable.cs | 6 +++--- src/Eto/PclTypes.cs | 2 +- 12 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Eto/Drawing/ColorConverter.cs b/src/Eto/Drawing/ColorConverter.cs index 9e6b9d0a76..8ddf38b2f4 100644 --- a/src/Eto/Drawing/ColorConverter.cs +++ b/src/Eto/Drawing/ColorConverter.cs @@ -88,7 +88,7 @@ public override object ConvertTo(sc.ITypeDescriptorContext context, CultureInfo /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class ColorConverter : sc.TypeConverter +public class ColorConverter : TypeConverter { /// /// Determines if this can convert a to the @@ -96,7 +96,7 @@ public class ColorConverter : sc.TypeConverter /// Context of the conversion /// Type to convert to /// True if this converter supports the , false otherwise - public override bool CanConvertTo(sc.ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(string); } @@ -107,7 +107,7 @@ public override bool CanConvertTo(sc.ITypeDescriptorContext context, Type destin /// Context of the conversion /// Type to convert from /// True if this can convert to the , false otherwise - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -119,7 +119,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Culture to use for the conversion /// Value to convert /// A instance with the converted value - public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var str = value as string; if (str != null) @@ -140,7 +140,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// value to convert /// Type to convert the to /// An object of type converted from - public override object ConvertTo(sc.ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { diff --git a/src/Eto/Drawing/ImageConverter.cs b/src/Eto/Drawing/ImageConverter.cs index 228ff2a22c..90e4054eb5 100644 --- a/src/Eto/Drawing/ImageConverter.cs +++ b/src/Eto/Drawing/ImageConverter.cs @@ -130,7 +130,7 @@ public override object ConvertFrom (sc.ITypeDescriptorContext context, System.Gl /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class ImageConverter : sc.TypeConverter +public class ImageConverter : TypeConverter { /// /// Prefix to use to load an image from a resource of an assembly @@ -158,7 +158,7 @@ protected virtual bool IsIcon (string fileName) /// Conversion context /// Type to convert from /// True if this converter can handle converting from the specified to an image - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string) || typeof(NamespaceInfo).IsAssignableFrom(sourceType) || typeof(Stream).IsAssignableFrom(sourceType); } @@ -169,7 +169,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Conversion context /// Type to convert to /// True if this converter can convert to the specified , otherwise false. - public override bool CanConvertTo(sc.ITypeDescriptorContext context, Type destinationType) + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return false; } @@ -213,7 +213,7 @@ Image LoadImage (string resourceName) /// Culture to perform the conversion /// Value to convert to an image /// A new instance of an image, or null if it cannot be converted - public override object ConvertFrom(sc.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value is NamespaceInfo ns) return LoadImage(ns); diff --git a/src/Eto/Drawing/PaddingConverter.cs b/src/Eto/Drawing/PaddingConverter.cs index dc788ad1e3..7b4a6829a0 100644 --- a/src/Eto/Drawing/PaddingConverter.cs +++ b/src/Eto/Drawing/PaddingConverter.cs @@ -80,7 +80,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class PaddingConverter : sc.TypeConverter +public class PaddingConverter : TypeConverter { /// /// The character to split up the string which will be converted @@ -93,7 +93,7 @@ public class PaddingConverter : sc.TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -105,7 +105,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Culture to perform the conversion for /// Value to convert /// A new instance of the object with the value represented by - public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/PointConverter.cs b/src/Eto/Drawing/PointConverter.cs index 6f244437a8..2174449794 100644 --- a/src/Eto/Drawing/PointConverter.cs +++ b/src/Eto/Drawing/PointConverter.cs @@ -71,7 +71,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class PointConverter : sc.TypeConverter +public class PointConverter : TypeConverter { /// /// The character to split up the string which will be converted @@ -84,7 +84,7 @@ public class PointConverter : sc.TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -96,7 +96,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/PointFConverter.cs b/src/Eto/Drawing/PointFConverter.cs index 8b70479777..6d069886e2 100644 --- a/src/Eto/Drawing/PointFConverter.cs +++ b/src/Eto/Drawing/PointFConverter.cs @@ -71,7 +71,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class PointFConverter : sc.TypeConverter +public class PointFConverter : TypeConverter { /// /// The character to split up the string which will be converted @@ -84,7 +84,7 @@ public class PointFConverter : sc.TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -96,7 +96,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/RectangleConverter.cs b/src/Eto/Drawing/RectangleConverter.cs index d55daf5a2e..897543b312 100644 --- a/src/Eto/Drawing/RectangleConverter.cs +++ b/src/Eto/Drawing/RectangleConverter.cs @@ -72,7 +72,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class RectangleConverter : sc.TypeConverter +public class RectangleConverter : TypeConverter { /// /// The character to split up the string which will be converted @@ -85,7 +85,7 @@ public class RectangleConverter : sc.TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -97,7 +97,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/RectangleFConverter.cs b/src/Eto/Drawing/RectangleFConverter.cs index 0ac0b5bbd9..a1e6622aeb 100644 --- a/src/Eto/Drawing/RectangleFConverter.cs +++ b/src/Eto/Drawing/RectangleFConverter.cs @@ -72,7 +72,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class RectangleFConverter : sc.TypeConverter +public class RectangleFConverter : TypeConverter { /// /// The character to split up the string which will be converted @@ -85,7 +85,7 @@ public class RectangleFConverter : sc.TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -97,7 +97,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/SizeConverter.cs b/src/Eto/Drawing/SizeConverter.cs index c46076c697..6bc1c2c290 100644 --- a/src/Eto/Drawing/SizeConverter.cs +++ b/src/Eto/Drawing/SizeConverter.cs @@ -70,7 +70,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class SizeConverter : sc.TypeConverter +public class SizeConverter : TypeConverter { /// /// The character to split up the string which will be converted @@ -83,7 +83,7 @@ public class SizeConverter : sc.TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -95,7 +95,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Drawing/SizeFConverter.cs b/src/Eto/Drawing/SizeFConverter.cs index 7efa71c0e6..0b3b07d065 100644 --- a/src/Eto/Drawing/SizeFConverter.cs +++ b/src/Eto/Drawing/SizeFConverter.cs @@ -70,7 +70,7 @@ public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInf /// (c) 2014 by Curtis Wensley /// See LICENSE for full terms [Obsolete("Since 2.5. Use TypeDescriptor.GetConverter instead")] -public class SizeFConverter : sc.TypeConverter +public class SizeFConverter : TypeConverter { /// /// The character to split up the string which will be converted @@ -83,7 +83,7 @@ public class SizeFConverter : sc.TypeConverter /// Conversion context /// Type to convert from /// True if this converter can convert from the specified type, false otherwise - public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sourceType) + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); } @@ -95,7 +95,7 @@ public override bool CanConvertFrom(sc.ITypeDescriptorContext context, Type sour /// Culture to perform the conversion /// Value to convert /// A new instance of a converted from the specified - public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value) + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) diff --git a/src/Eto/Forms/Controls/Control.cs b/src/Eto/Forms/Controls/Control.cs index 9b6b08a289..ff35c8d7fb 100755 --- a/src/Eto/Forms/Controls/Control.cs +++ b/src/Eto/Forms/Controls/Control.cs @@ -14,10 +14,10 @@ namespace Eto.Forms; /// All visual user interface elements should inherit from this class to provide common functionality like binding, /// load/unload, and common events. /// -#if !NETSTANDARD - [sc.ToolboxItem(true)] - [sc.DesignTimeVisible(true)] - [sc.DesignerCategory("Eto.Forms")] +#if !NETSTANDARD && !NETCOREAPP + [ToolboxItem(true)] + [DesignTimeVisible(true)] + [DesignerCategory("Eto.Forms")] #endif [sc.TypeConverter(typeof(ControlConverter))] public partial class Control : BindableWidget, IMouseInputSource, IKeyboardInputSource, ICallbackSource diff --git a/src/Eto/Forms/Layout/DynamicTable.cs b/src/Eto/Forms/Layout/DynamicTable.cs index b0fbee8183..486965bc3a 100644 --- a/src/Eto/Forms/Layout/DynamicTable.cs +++ b/src/Eto/Forms/Layout/DynamicTable.cs @@ -202,7 +202,7 @@ protected override void SetItem(int index, DynamicItem item) /// The maximum number of items in the determines the columns of the table. /// [ContentProperty("Rows")] -public class DynamicTable : DynamicItem, sc.ISupportInitialize +public class DynamicTable : DynamicItem, ISupportInitialize { internal DynamicLayout layout; bool visible = true; @@ -405,11 +405,11 @@ public override Control Create(DynamicLayout layout) return table; } - void sc.ISupportInitialize.BeginInit() + void ISupportInitialize.BeginInit() { } - void sc.ISupportInitialize.EndInit() + void ISupportInitialize.EndInit() { } diff --git a/src/Eto/PclTypes.cs b/src/Eto/PclTypes.cs index e36027b3e8..6f01ca7853 100644 --- a/src/Eto/PclTypes.cs +++ b/src/Eto/PclTypes.cs @@ -1,4 +1,4 @@ -#if NETSTANDARD +#if NETSTANDARD || NETCOREAPP using System; using System.Collections.Generic; using System.Globalization; From 5f8cc931ae74f86ca139690e9cf52adbe7dc9509 Mon Sep 17 00:00:00 2001 From: Miepee Date: Wed, 17 May 2023 09:33:31 +0200 Subject: [PATCH 5/6] Revert "Replace binaryformatter with xmlSerializer" This reverts commit 8574183427539c1cb20317f579ca8d77614632dd. --- src/Eto/Forms/Clipboard.cs | 9 ++++----- src/Eto/Forms/DataObject.cs | 10 +++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Eto/Forms/Clipboard.cs b/src/Eto/Forms/Clipboard.cs index 850c10a16a..a2ebc90a8e 100644 --- a/src/Eto/Forms/Clipboard.cs +++ b/src/Eto/Forms/Clipboard.cs @@ -5,7 +5,6 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Diagnostics; using System.Reflection; -using System.Xml.Serialization; namespace Eto.Forms; @@ -206,8 +205,8 @@ public void SetObject(object value, string type) { using (var ms = new MemoryStream()) { - var xmlFormatter = new XmlSerializer(value.GetType()); - xmlFormatter.Serialize(ms, value); + var binaryFormatter = new BinaryFormatter(); + binaryFormatter.Serialize(ms, value); SetDataStream(ms, type); return; } @@ -274,8 +273,8 @@ public object GetObject(string type) return null; try { - var xmlFormatter = new XmlSerializer(new object().GetType()); - return xmlFormatter.Deserialize(stream); + var binaryFormatter = new BinaryFormatter(); + return binaryFormatter.Deserialize(stream); } catch (Exception ex) { diff --git a/src/Eto/Forms/DataObject.cs b/src/Eto/Forms/DataObject.cs index 41a37dcbc8..dd600b734d 100644 --- a/src/Eto/Forms/DataObject.cs +++ b/src/Eto/Forms/DataObject.cs @@ -7,7 +7,6 @@ using System.Reflection; using System.Runtime.Serialization.Formatters.Binary; using System.Text; -using System.Xml.Serialization; namespace Eto.Forms; @@ -262,8 +261,9 @@ public void SetObject(object value, string type) { using (var ms = new MemoryStream()) { - var xmlFormatter = new XmlSerializer(value.GetType()); - xmlFormatter.Serialize(ms, value); + var binaryFormatter = new BinaryFormatter(); + binaryFormatter.Serialize(ms, value); + SetDataStream(ms, type); return; } } @@ -329,8 +329,8 @@ public object GetObject(string type) return null; try { - var xmlFormatter = new XmlSerializer(new object().GetType()); - return xmlFormatter.Deserialize(stream); + var binaryFormatter = new BinaryFormatter(); + return binaryFormatter.Deserialize(stream); } catch (Exception ex) { From 062b2b51a4318fe06afbb8b0a8d841cd24f3a178 Mon Sep 17 00:00:00 2001 From: Miepee Date: Wed, 17 May 2023 09:37:00 +0200 Subject: [PATCH 6/6] Allow binaryserializer for now --- src/Eto/Forms/Clipboard.cs | 4 ++++ src/Eto/Forms/DataObject.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Eto/Forms/Clipboard.cs b/src/Eto/Forms/Clipboard.cs index a2ebc90a8e..a1890b4444 100644 --- a/src/Eto/Forms/Clipboard.cs +++ b/src/Eto/Forms/Clipboard.cs @@ -205,9 +205,11 @@ public void SetObject(object value, string type) { using (var ms = new MemoryStream()) { +#pragma warning disable SYSLIB0011 var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(ms, value); SetDataStream(ms, type); +#pragma warning restore SYSLIB0011 return; } } @@ -273,8 +275,10 @@ public object GetObject(string type) return null; try { +#pragma warning disable SYSLIB0011 var binaryFormatter = new BinaryFormatter(); return binaryFormatter.Deserialize(stream); +#pragma warning restore SYSLIB0011 } catch (Exception ex) { diff --git a/src/Eto/Forms/DataObject.cs b/src/Eto/Forms/DataObject.cs index dd600b734d..017575ead3 100644 --- a/src/Eto/Forms/DataObject.cs +++ b/src/Eto/Forms/DataObject.cs @@ -261,9 +261,11 @@ public void SetObject(object value, string type) { using (var ms = new MemoryStream()) { +#pragma warning disable SYSLIB0011 var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(ms, value); SetDataStream(ms, type); +#pragma warning restore SYSLIB0011 return; } } @@ -329,8 +331,10 @@ public object GetObject(string type) return null; try { +#pragma warning disable SYSLIB0011 var binaryFormatter = new BinaryFormatter(); return binaryFormatter.Deserialize(stream); +#pragma warning restore SYSLIB0011 } catch (Exception ex) {