Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
hide obsolete API from editor (#4938)
Browse files Browse the repository at this point in the history
- fixes #4772
  • Loading branch information
StephaneDelcroix authored Jan 10, 2019
1 parent 5bb1559 commit 6d20db1
Show file tree
Hide file tree
Showing 105 changed files with 202 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Rocks;
Expand Down Expand Up @@ -235,13 +236,15 @@ public static CustomAttribute GetCustomAttribute(this TypeReference typeRef, Mod
}

[Obsolete]
[EditorBrowsable(EditorBrowsableState.Never)]
public static MethodDefinition GetMethod(this TypeReference typeRef, Func<MethodDefinition, bool> predicate)
{
TypeReference declaringTypeReference;
return typeRef.GetMethod(predicate, out declaringTypeReference);
}

[Obsolete]
[EditorBrowsable(EditorBrowsableState.Never)]
public static MethodDefinition GetMethod(this TypeReference typeRef, Func<MethodDefinition, bool> predicate,
out TypeReference declaringTypeRef)
{
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Build.Tasks/XamlCTask.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Xml;
Expand All @@ -22,6 +23,7 @@ public class XamlCTask : XamlTask
public bool OptimizeIL { get; set; }

[Obsolete("OutputGeneratedILAsCode is obsolete as of version 2.3.4. This option is no longer available.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public bool OutputGeneratedILAsCode { get; set; }

public bool CompileByDefault { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Build.Tasks/XamlTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Mono.Cecil.Cil;
using Mono.Cecil.Pdb;
using Mono.Cecil.Mdb;
using System.ComponentModel;

namespace Xamarin.Forms.Build.Tasks
{
Expand All @@ -24,6 +25,7 @@ public abstract class XamlTask : MarshalByRefObject, ITask
public string DependencyPaths { get; set; }
public string ReferencePath { get; set; }
[Obsolete("this is no longer used")]
[EditorBrowsable(EditorBrowsableState.Never)]
public int Verbosity { get; set; }
public bool DebugSymbols { get; set; }
public string DebugType { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Core/AbsoluteLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected override void OnChildRemoved(Element child)
}

[Obsolete("OnSizeRequest is obsolete as of version 2.2.0. Please use OnMeasure instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
{
var bestFitSize = new Size();
Expand Down
8 changes: 5 additions & 3 deletions Xamarin.Forms.Core/BindableObjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;

namespace Xamarin.Forms
Expand Down Expand Up @@ -41,15 +42,16 @@ public static void SetBinding(this BindableObject self, BindableProperty targetP
}

[Obsolete]
[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetBinding<TSource>(this BindableObject self, BindableProperty targetProperty, Expression<Func<TSource, object>> sourceProperty, BindingMode mode = BindingMode.Default,
IValueConverter converter = null, string stringFormat = null)
{
if (self == null)
throw new ArgumentNullException("self");
throw new ArgumentNullException(nameof(self));
if (targetProperty == null)
throw new ArgumentNullException("targetProperty");
throw new ArgumentNullException(nameof(targetProperty));
if (sourceProperty == null)
throw new ArgumentNullException("sourceProperty");
throw new ArgumentNullException(nameof(sourceProperty));

Binding binding = Binding.Create(sourceProperty, mode, converter, stringFormat: stringFormat);
self.SetBinding(targetProperty, binding);
Expand Down
7 changes: 7 additions & 0 deletions Xamarin.Forms.Core/BindableProperty.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
Expand Down Expand Up @@ -120,6 +121,7 @@ public sealed class BindableProperty
internal ValidateValueDelegate ValidateValue { get; private set; }

[Obsolete("Create<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static BindableProperty Create<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue, BindingMode defaultBindingMode = BindingMode.OneWay,
ValidateValueDelegate<TPropertyType> validateValue = null, BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null,
BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null, CoerceValueDelegate<TPropertyType> coerceValue = null,
Expand All @@ -137,6 +139,7 @@ public static BindableProperty Create(string propertyName, Type returnType, Type
}

[Obsolete("CreateAttached<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static BindableProperty CreateAttached<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue,
BindingMode defaultBindingMode = BindingMode.OneWay, ValidateValueDelegate<TPropertyType> validateValue = null, BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null,
BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null, CoerceValueDelegate<TPropertyType> coerceValue = null,
Expand All @@ -154,6 +157,7 @@ public static BindableProperty CreateAttached(string propertyName, Type returnTy
}

[Obsolete("CreateAttachedReadOnly<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static BindablePropertyKey CreateAttachedReadOnly<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue,
BindingMode defaultBindingMode = BindingMode.OneWayToSource, ValidateValueDelegate<TPropertyType> validateValue = null,
BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null, BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null,
Expand All @@ -175,6 +179,7 @@ public static BindablePropertyKey CreateAttachedReadOnly(string propertyName, Ty
}

[Obsolete("CreateReadOnly<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static BindablePropertyKey CreateReadOnly<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue,
BindingMode defaultBindingMode = BindingMode.OneWayToSource, ValidateValueDelegate<TPropertyType> validateValue = null,
BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null, BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null,
Expand All @@ -193,6 +198,7 @@ public static BindablePropertyKey CreateReadOnly(string propertyName, Type retur
}

[Obsolete("Create<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
[EditorBrowsable(EditorBrowsableState.Never)]
internal static BindableProperty Create<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue, BindingMode defaultBindingMode,
ValidateValueDelegate<TPropertyType> validateValue, BindingPropertyChangedDelegate<TPropertyType> propertyChanged, BindingPropertyChangingDelegate<TPropertyType> propertyChanging,
CoerceValueDelegate<TPropertyType> coerceValue, BindablePropertyBindingChanging bindingChanging, bool isReadOnly = false,
Expand Down Expand Up @@ -242,6 +248,7 @@ internal static BindableProperty Create(string propertyName, Type returnType, Ty
}

[Obsolete("CreateAttached<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
[EditorBrowsable(EditorBrowsableState.Never)]
internal static BindableProperty CreateAttached<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue, BindingMode defaultBindingMode,
ValidateValueDelegate<TPropertyType> validateValue, BindingPropertyChangedDelegate<TPropertyType> propertyChanged, BindingPropertyChangingDelegate<TPropertyType> propertyChanging,
CoerceValueDelegate<TPropertyType> coerceValue, BindablePropertyBindingChanging bindingChanging, bool isReadOnly = false,
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/Binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public string UpdateSourceEventName {
}

[Obsolete]
[EditorBrowsable(EditorBrowsableState.Never)]
public static Binding Create<TSource>(Expression<Func<TSource, object>> propertyGetter, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null,
string stringFormat = null)
{
Expand Down Expand Up @@ -171,6 +172,7 @@ internal override void Unapply(bool fromBindingContextChanged = false)
}

[Obsolete]
[EditorBrowsable(EditorBrowsableState.Never)]
static string GetBindingPath<TSource>(Expression<Func<TSource, object>> propertyGetter)
{
Expression expr = propertyGetter.Body;
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/BoxView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using Xamarin.Forms.Platform;

namespace Xamarin.Forms
Expand Down Expand Up @@ -33,6 +34,7 @@ public IPlatformElementConfiguration<T, BoxView> On<T>() where T : IConfigPlatfo
}

[Obsolete("OnSizeRequest is obsolete as of version 2.2.0. Please use OnMeasure instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
{
return new SizeRequest(new Size(40, 40));
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class Button : View, IFontElement, ITextElement, IBorderElement, IButtonC
public static readonly BindableProperty BorderColorProperty = BorderElement.BorderColorProperty;

[Obsolete("BorderRadiusProperty is obsolete as of 2.5.0. Please use CornerRadius instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty BorderRadiusProperty = BindableProperty.Create("BorderRadius", typeof(int), typeof(Button), defaultValue: DefaultBorderRadius,
propertyChanged: BorderRadiusPropertyChanged);

Expand Down Expand Up @@ -80,6 +81,7 @@ public Color BorderColor
}

[Obsolete("BorderRadius is obsolete as of 2.5.0. Please use CornerRadius instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public int BorderRadius
{
get { return (int)GetValue(BorderRadiusProperty); }
Expand Down
6 changes: 4 additions & 2 deletions Xamarin.Forms.Core/Cells/EntryCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class EntryCell : Cell, ITextAlignmentElement, IEntryCellController

public static readonly BindableProperty HorizontalTextAlignmentProperty = TextAlignmentElement.HorizontalTextAlignmentProperty;

[Obsolete("XAlignProperty is obsolete as of version 2.0.0. Please use HorizontalTextAlignmentProperty instead.")]
[Obsolete("XAlignProperty is obsolete as of version 2.0.0. Please use HorizontalTextAlignmentProperty instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty XAlignProperty = HorizontalTextAlignmentProperty;

public TextAlignment HorizontalTextAlignment
Expand Down Expand Up @@ -56,7 +57,8 @@ public string Text
set { SetValue(TextProperty, value); }
}

[Obsolete("XAlign is obsolete as of version 2.0.0. Please use HorizontalTextAlignment instead.")]
[Obsolete("XAlign is obsolete as of version 2.0.0. Please use HorizontalTextAlignment instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public TextAlignment XAlign
{
get { return (TextAlignment)GetValue(XAlignProperty); }
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Core/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ public static implicit operator Color(System.Drawing.Color color)
public static readonly Color ForestGreen = FromRgb(34, 139, 34);
public static readonly Color Fuchsia = FromRgb(255, 0, 255);
[Obsolete("Fuschia is obsolete as of version 1.3.0. Please use Fuchsia instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly Color Fuschia = FromRgb(255, 0, 255);
public static readonly Color Gainsboro = FromRgb(220, 220, 220);
public static readonly Color GhostWhite = FromRgb(248, 248, 255);
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/ContentPresenter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

namespace Xamarin.Forms
{
Expand Down Expand Up @@ -29,6 +30,7 @@ protected override void LayoutChildren(double x, double y, double width, double
}

[Obsolete("OnSizeRequest is obsolete as of version 2.2.0. Please use OnMeasure instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
{
double widthRequest = WidthRequest;
Expand Down
9 changes: 6 additions & 3 deletions Xamarin.Forms.Core/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ public static class Device
public static void SetTargetIdiom(TargetIdiom value) => Idiom = value;

[Obsolete("TargetPlatform is obsolete as of version 2.3.4. Please use RuntimePlatform instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable 0618
public static TargetPlatform OS
public static TargetPlatform OS
{
get
{
Expand Down Expand Up @@ -114,7 +115,8 @@ public static double GetNamedSize(NamedSize size, Type targetElementType)
}

[Obsolete("OnPlatform is obsolete as of version 2.3.4. Please use 'switch (Device.RuntimePlatform)' instead.")]
public static void OnPlatform(Action iOS = null, Action Android = null, Action WinPhone = null, Action Default = null)
[EditorBrowsable(EditorBrowsableState.Never)]
public static void OnPlatform(Action iOS = null, Action Android = null, Action WinPhone = null, Action Default = null)
{
switch (OS)
{
Expand Down Expand Up @@ -145,7 +147,8 @@ public static void OnPlatform(Action iOS = null, Action Android = null, Action W
}

[Obsolete("OnPlatform<> (generic) is obsolete as of version 2.3.4. Please use 'switch (Device.RuntimePlatform)' instead.")]
public static T OnPlatform<T>(T iOS, T Android, T WinPhone)
[EditorBrowsable(EditorBrowsableState.Never)]
public static T OnPlatform<T>(T iOS, T Android, T WinPhone)
{
switch (OS)
{
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Core/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public Guid Id
}

[Obsolete("ParentView is obsolete as of version 2.1.0. Please use Parent instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public VisualElement ParentView
{
get
Expand Down
3 changes: 3 additions & 0 deletions Xamarin.Forms.Core/Font.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

namespace Xamarin.Forms
{
Expand Down Expand Up @@ -83,13 +84,15 @@ public static Font SystemFontOfSize(NamedSize size, FontAttributes attributes)
}

[Obsolete("BoldSystemFontOfSize is obsolete as of version 1.2.0. Please use SystemFontOfSize (double, FontAttributes) instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static Font BoldSystemFontOfSize(double size)
{
var result = new Font { FontSize = size, FontAttributes = FontAttributes.Bold };
return result;
}

[Obsolete("BoldSystemFontOfSize is obsolete as of version 1.2.0. Please use SystemFontOfSize (NamedSize, FontAttributes) instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static Font BoldSystemFontOfSize(NamedSize size)
{
var result = new Font { NamedSize = size, FontAttributes = FontAttributes.Bold };
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/FontSizeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using System.Globalization;
using Xamarin.Forms.Xaml;

Expand All @@ -8,6 +9,7 @@ namespace Xamarin.Forms
public class FontSizeConverter : TypeConverter, IExtendedTypeConverter
{
[Obsolete("IExtendedTypeConverter.ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string, IServiceProvider) instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
object IExtendedTypeConverter.ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider)
=> ((IExtendedTypeConverter)this).ConvertFromInvariantString(value as string, serviceProvider);

Expand Down
3 changes: 3 additions & 0 deletions Xamarin.Forms.Core/Frame.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using Xamarin.Forms.Platform;

namespace Xamarin.Forms
Expand All @@ -8,6 +9,7 @@ namespace Xamarin.Forms
public class Frame : ContentView, IElementConfiguration<Frame>, IPaddingElement, IBorderElement
{
[Obsolete("OutlineColorProperty is obsolete as of version 3.0.0. Please use BorderColorProperty instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty OutlineColorProperty = BorderElement.BorderColorProperty;

public static readonly BindableProperty BorderColorProperty = BorderElement.BorderColorProperty;
Expand Down Expand Up @@ -36,6 +38,7 @@ public bool HasShadow
}

[Obsolete("OutlineColor is obsolete as of version 3.0.0. Please use BorderColor instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public Color OutlineColor
{
get { return (Color)GetValue(OutlineColorProperty); }
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/GridCalc.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace Xamarin.Forms
Expand Down Expand Up @@ -50,6 +51,7 @@ protected override void LayoutChildren(double x, double y, double width, double
}

[Obsolete("OnSizeRequest is obsolete as of version 2.2.0. Please use OnMeasure instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
{
if (!InternalChildren.Any())
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/IExtendedTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.ComponentModel;
using System.Globalization;

namespace Xamarin.Forms
{
public interface IExtendedTypeConverter
{
[Obsolete("IExtendedTypeConverter.ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string, IServiceProvider) instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
object ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider);

object ConvertFromInvariantString(string value, IServiceProvider serviceProvider);
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Core/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected override void OnBindingContextChanged()
}

[Obsolete("OnSizeRequest is obsolete as of version 2.2.0. Please use OnMeasure instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
{
SizeRequest desiredSize = base.OnSizeRequest(double.PositiveInfinity, double.PositiveInfinity);
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/Internals/INamescopeProvider.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.ComponentModel;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Xaml.Internals
{
[Obsolete]
[EditorBrowsable(EditorBrowsableState.Never)]
interface INameScopeProvider
{
INameScope NameScope { get; }
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/Internals/ResourceLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static class ResourceLoader
static Func<AssemblyName, string, string> resourceProvider;

[Obsolete("You shouldn't have used this one to begin with, don't use the other one either")]
[EditorBrowsable(EditorBrowsableState.Never)]
//takes a resource path, returns string content
public static Func<AssemblyName, string, string> ResourceProvider {
get => resourceProvider;
Expand All @@ -32,6 +33,7 @@ internal set {
}

[Obsolete("Can't touch this")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static bool CanProvideContentFor(ResourceLoadingQuery rlq)
{
if (_resourceProvider2 == null)
Expand Down
Loading

0 comments on commit 6d20db1

Please sign in to comment.