Browse Source

Merge pull request #4182 from MarchingCube/misc-cleanup

Remove warnings from Avalonia.Base
pull/4221/head
Steven Kirk 6 years ago
committed by GitHub
parent
commit
a90bd23a0f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Avalonia.Base/AvaloniaProperty.cs
  2. 4
      src/Avalonia.Base/AvaloniaPropertyRegistry.cs
  3. 2
      src/Avalonia.Base/Collections/Pooled/IReadOnlyPooledList.cs
  4. 3
      src/Avalonia.Base/Collections/Pooled/PooledList.cs
  5. 34
      src/Avalonia.Base/Data/BindingValue.cs
  6. 16
      src/Avalonia.Base/Data/Optional.cs
  7. 2
      src/Avalonia.Base/DirectPropertyBase.cs
  8. 2
      src/Avalonia.Base/IStyledPropertyMetadata.cs
  9. 140
      src/Avalonia.Base/Metadata/NullableAttributes.cs
  10. 7
      src/Avalonia.Base/PropertyStore/IPriorityValueEntry.cs
  11. 7
      src/Avalonia.Base/PropertyStore/LocalValueEntry.cs
  12. 3
      src/Avalonia.Base/StyledPropertyMetadata`1.cs
  13. 2
      src/Avalonia.Base/ValueStore.cs
  14. 5
      src/Avalonia.Styling/IStyledElement.cs
  15. 1
      src/Avalonia.Styling/StyledElement.cs
  16. 1
      src/Avalonia.Styling/Styling/Styles.cs

4
src/Avalonia.Base/AvaloniaProperty.cs

@ -159,8 +159,6 @@ namespace Avalonia
/// </summary> /// </summary>
internal int Id { get; } internal int Id { get; }
internal bool HasChangedSubscriptions => _changed?.HasObservers ?? false;
/// <summary> /// <summary>
/// Provides access to a property's binding via the <see cref="AvaloniaObject"/> /// Provides access to a property's binding via the <see cref="AvaloniaObject"/>
/// indexer. /// indexer.
@ -512,7 +510,7 @@ namespace Avalonia
/// <returns> /// <returns>
/// An <see cref="IDisposable"/> if setting the property can be undone, otherwise null. /// An <see cref="IDisposable"/> if setting the property can be undone, otherwise null.
/// </returns> /// </returns>
internal abstract IDisposable? RouteSetValue( internal abstract IDisposable RouteSetValue(
IAvaloniaObject o, IAvaloniaObject o,
object value, object value,
BindingPriority priority); BindingPriority priority);

4
src/Avalonia.Base/AvaloniaPropertyRegistry.cs

@ -362,7 +362,7 @@ namespace Avalonia
/// <param name="property">The property.</param> /// <param name="property">The property.</param>
/// <remarks> /// <remarks>
/// You won't usually want to call this method directly, instead use the /// You won't usually want to call this method directly, instead use the
/// <see cref="AvaloniaProperty.Register{TOwner, TValue}(string, TValue, bool, Data.BindingMode, Func{TOwner, TValue, TValue}, Action{IAvaloniaObject, bool})"/> /// <see cref="AvaloniaProperty.Register{TOwner, TValue}(string, TValue, bool, Data.BindingMode, Func{TValue, bool}, Func{IAvaloniaObject, TValue, TValue}, Action{IAvaloniaObject, bool})"/>
/// method. /// method.
/// </remarks> /// </remarks>
public void Register(Type type, AvaloniaProperty property) public void Register(Type type, AvaloniaProperty property)
@ -413,7 +413,7 @@ namespace Avalonia
/// <param name="property">The property.</param> /// <param name="property">The property.</param>
/// <remarks> /// <remarks>
/// You won't usually want to call this method directly, instead use the /// You won't usually want to call this method directly, instead use the
/// <see cref="AvaloniaProperty.RegisterAttached{THost, TValue}(string, Type, TValue, bool, Data.BindingMode, Func{THost, TValue, TValue})"/> /// <see cref="AvaloniaProperty.RegisterAttached{THost, TValue}(string, Type, TValue, bool, Data.BindingMode, Func{TValue, bool}, Func{IAvaloniaObject, TValue, TValue})"/>
/// method. /// method.
/// </remarks> /// </remarks>
public void RegisterAttached(Type type, AvaloniaProperty property) public void RegisterAttached(Type type, AvaloniaProperty property)

2
src/Avalonia.Base/Collections/Pooled/IReadOnlyPooledList.cs

@ -13,9 +13,11 @@ namespace Avalonia.Collections.Pooled
public interface IReadOnlyPooledList<T> : IReadOnlyList<T> public interface IReadOnlyPooledList<T> : IReadOnlyList<T>
{ {
#pragma warning disable CS0419
/// <summary> /// <summary>
/// Gets a <see cref="System.ReadOnlySpan{T}"/> for the items currently in the collection. /// Gets a <see cref="System.ReadOnlySpan{T}"/> for the items currently in the collection.
/// </summary> /// </summary>
#pragma warning restore CS0419
ReadOnlySpan<T> Span { get; } ReadOnlySpan<T> Span { get; }
} }
} }

3
src/Avalonia.Base/Collections/Pooled/PooledList.cs

@ -138,7 +138,6 @@ namespace Avalonia.Collections.Pooled
/// initially empty, but will have room for the given number of elements /// initially empty, but will have room for the given number of elements
/// before any reallocations are required. /// before any reallocations are required.
/// </summary> /// </summary>
/// <param name="sizeToCapacity">If true, Count of list equals capacity. Depending on ClearMode, rented items may or may not hold dirty values.</param>
public PooledList(int capacity, ClearMode clearMode, ArrayPool<T> customPool, bool sizeToCapacity) public PooledList(int capacity, ClearMode clearMode, ArrayPool<T> customPool, bool sizeToCapacity)
{ {
if (capacity < 0) if (capacity < 0)
@ -499,11 +498,13 @@ namespace Avalonia.Collections.Pooled
public void AddRange(T[] array) public void AddRange(T[] array)
=> AddRange(array.AsSpan()); => AddRange(array.AsSpan());
#pragma warning disable CS0419
/// <summary> /// <summary>
/// Adds the elements of the given <see cref="ReadOnlySpan{T}"/> to the end of this list. If /// Adds the elements of the given <see cref="ReadOnlySpan{T}"/> to the end of this list. If
/// required, the capacity of the list is increased to twice the previous /// required, the capacity of the list is increased to twice the previous
/// capacity or the new size, whichever is larger. /// capacity or the new size, whichever is larger.
/// </summary> /// </summary>
#pragma warning restore CS0419
public void AddRange(ReadOnlySpan<T> span) public void AddRange(ReadOnlySpan<T> span)
{ {
var newSpan = InsertSpan(_size, span.Length, false); var newSpan = InsertSpan(_size, span.Length, false);

34
src/Avalonia.Base/Data/BindingValue.cs

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Utilities; using Avalonia.Utilities;
#nullable enable #nullable enable
@ -81,14 +82,14 @@ namespace Avalonia.Data
/// </remarks> /// </remarks>
public readonly struct BindingValue<T> public readonly struct BindingValue<T>
{ {
private readonly T _value; [AllowNull] private readonly T _value;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="BindingValue{T}"/> struct with a type of /// Initializes a new instance of the <see cref="BindingValue{T}"/> struct with a type of
/// <see cref="BindingValueType.Value"/> /// <see cref="BindingValueType.Value"/>
/// </summary> /// </summary>
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
public BindingValue(T value) public BindingValue([AllowNull] T value)
{ {
ValidateValue(value); ValidateValue(value);
_value = value; _value = value;
@ -96,7 +97,7 @@ namespace Avalonia.Data
Error = null; Error = null;
} }
private BindingValue(BindingValueType type, T value, Exception? error) private BindingValue(BindingValueType type, [AllowNull] T value, Exception? error)
{ {
_value = value; _value = value;
Type = type; Type = type;
@ -154,7 +155,7 @@ namespace Avalonia.Data
BindingValueType.UnsetValue => AvaloniaProperty.UnsetValue, BindingValueType.UnsetValue => AvaloniaProperty.UnsetValue,
BindingValueType.DoNothing => BindingOperations.DoNothing, BindingValueType.DoNothing => BindingOperations.DoNothing,
BindingValueType.Value => _value, BindingValueType.Value => _value,
BindingValueType.BindingError => BindingValueType.BindingError =>
new BindingNotification(Error, BindingErrorType.Error), new BindingNotification(Error, BindingErrorType.Error),
BindingValueType.BindingErrorWithFallback => BindingValueType.BindingErrorWithFallback =>
new BindingNotification(Error, BindingErrorType.Error, Value), new BindingNotification(Error, BindingErrorType.Error, Value),
@ -175,7 +176,7 @@ namespace Avalonia.Data
/// The binding type is <see cref="BindingValueType.UnsetValue"/> or /// The binding type is <see cref="BindingValueType.UnsetValue"/> or
/// <see cref="BindingValueType.DoNothing"/>. /// <see cref="BindingValueType.DoNothing"/>.
/// </exception> /// </exception>
public BindingValue<T> WithValue(T value) public BindingValue<T> WithValue([AllowNull] T value)
{ {
if (Type == BindingValueType.DoNothing) if (Type == BindingValueType.DoNothing)
{ {
@ -190,6 +191,7 @@ namespace Avalonia.Data
/// Gets the value of the binding value if present, otherwise the default value. /// Gets the value of the binding value if present, otherwise the default value.
/// </summary> /// </summary>
/// <returns>The value.</returns> /// <returns>The value.</returns>
[return: MaybeNull]
public T GetValueOrDefault() => HasValue ? _value : default; public T GetValueOrDefault() => HasValue ? _value : default;
/// <summary> /// <summary>
@ -206,6 +208,7 @@ namespace Avalonia.Data
/// The value if present and of the correct type, `default(TResult)` if the value is /// The value if present and of the correct type, `default(TResult)` if the value is
/// not present or of an incorrect type. /// not present or of an incorrect type.
/// </returns> /// </returns>
[return: MaybeNull]
public TResult GetValueOrDefault<TResult>() public TResult GetValueOrDefault<TResult>()
{ {
return HasValue ? return HasValue ?
@ -222,7 +225,8 @@ namespace Avalonia.Data
/// present but not of the correct type or null, or <paramref name="defaultValue"/> if the /// present but not of the correct type or null, or <paramref name="defaultValue"/> if the
/// value is not present. /// value is not present.
/// </returns> /// </returns>
public TResult GetValueOrDefault<TResult>(TResult defaultValue) [return: MaybeNull]
public TResult GetValueOrDefault<TResult>([AllowNull] TResult defaultValue)
{ {
return HasValue ? return HasValue ?
_value is TResult result ? result : default _value is TResult result ? result : default
@ -242,7 +246,7 @@ namespace Avalonia.Data
UnsetValueType _ => Unset, UnsetValueType _ => Unset,
DoNothingType _ => DoNothing, DoNothingType _ => DoNothing,
BindingNotification n => n.ToBindingValue().Cast<T>(), BindingNotification n => n.ToBindingValue().Cast<T>(),
_ => (T)value _ => new BindingValue<T>((T)value)
}; };
} }
@ -250,7 +254,7 @@ namespace Avalonia.Data
/// Creates a binding value from an instance of the underlying value type. /// Creates a binding value from an instance of the underlying value type.
/// </summary> /// </summary>
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
public static implicit operator BindingValue<T>(T value) => new BindingValue<T>(value); public static implicit operator BindingValue<T>([AllowNull] T value) => new BindingValue<T>(value);
/// <summary> /// <summary>
/// Creates a binding value from an <see cref="Optional{T}"/>. /// Creates a binding value from an <see cref="Optional{T}"/>.
@ -278,7 +282,7 @@ namespace Avalonia.Data
/// <param name="e">The binding error.</param> /// <param name="e">The binding error.</param>
public static BindingValue<T> BindingError(Exception e) public static BindingValue<T> BindingError(Exception e)
{ {
e = e ?? throw new ArgumentNullException("e"); e = e ?? throw new ArgumentNullException(nameof(e));
return new BindingValue<T>(BindingValueType.BindingError, default, e); return new BindingValue<T>(BindingValueType.BindingError, default, e);
} }
@ -290,7 +294,7 @@ namespace Avalonia.Data
/// <param name="fallbackValue">The fallback value.</param> /// <param name="fallbackValue">The fallback value.</param>
public static BindingValue<T> BindingError(Exception e, T fallbackValue) public static BindingValue<T> BindingError(Exception e, T fallbackValue)
{ {
e = e ?? throw new ArgumentNullException("e"); e = e ?? throw new ArgumentNullException(nameof(e));
return new BindingValue<T>(BindingValueType.BindingErrorWithFallback, fallbackValue, e); return new BindingValue<T>(BindingValueType.BindingErrorWithFallback, fallbackValue, e);
} }
@ -303,7 +307,7 @@ namespace Avalonia.Data
/// <param name="fallbackValue">The fallback value.</param> /// <param name="fallbackValue">The fallback value.</param>
public static BindingValue<T> BindingError(Exception e, Optional<T> fallbackValue) public static BindingValue<T> BindingError(Exception e, Optional<T> fallbackValue)
{ {
e = e ?? throw new ArgumentNullException("e"); e = e ?? throw new ArgumentNullException(nameof(e));
return new BindingValue<T>( return new BindingValue<T>(
fallbackValue.HasValue ? fallbackValue.HasValue ?
@ -319,7 +323,7 @@ namespace Avalonia.Data
/// <param name="e">The data validation error.</param> /// <param name="e">The data validation error.</param>
public static BindingValue<T> DataValidationError(Exception e) public static BindingValue<T> DataValidationError(Exception e)
{ {
e = e ?? throw new ArgumentNullException("e"); e = e ?? throw new ArgumentNullException(nameof(e));
return new BindingValue<T>(BindingValueType.DataValidationError, default, e); return new BindingValue<T>(BindingValueType.DataValidationError, default, e);
} }
@ -331,7 +335,7 @@ namespace Avalonia.Data
/// <param name="fallbackValue">The fallback value.</param> /// <param name="fallbackValue">The fallback value.</param>
public static BindingValue<T> DataValidationError(Exception e, T fallbackValue) public static BindingValue<T> DataValidationError(Exception e, T fallbackValue)
{ {
e = e ?? throw new ArgumentNullException("e"); e = e ?? throw new ArgumentNullException(nameof(e));
return new BindingValue<T>(BindingValueType.DataValidationErrorWithFallback, fallbackValue, e); return new BindingValue<T>(BindingValueType.DataValidationErrorWithFallback, fallbackValue, e);
} }
@ -344,7 +348,7 @@ namespace Avalonia.Data
/// <param name="fallbackValue">The fallback value.</param> /// <param name="fallbackValue">The fallback value.</param>
public static BindingValue<T> DataValidationError(Exception e, Optional<T> fallbackValue) public static BindingValue<T> DataValidationError(Exception e, Optional<T> fallbackValue)
{ {
e = e ?? throw new ArgumentNullException("e"); e = e ?? throw new ArgumentNullException(nameof(e));
return new BindingValue<T>( return new BindingValue<T>(
fallbackValue.HasValue ? fallbackValue.HasValue ?
@ -354,7 +358,7 @@ namespace Avalonia.Data
e); e);
} }
private static void ValidateValue(T value) private static void ValidateValue([AllowNull] T value)
{ {
if (value is UnsetValueType) if (value is UnsetValueType)
{ {

16
src/Avalonia.Base/Data/Optional.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#nullable enable #nullable enable
@ -22,13 +23,13 @@ namespace Avalonia.Data
/// </remarks> /// </remarks>
public readonly struct Optional<T> : IEquatable<Optional<T>> public readonly struct Optional<T> : IEquatable<Optional<T>>
{ {
private readonly T _value; [AllowNull] private readonly T _value;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Optional{T}"/> struct with value. /// Initializes a new instance of the <see cref="Optional{T}"/> struct with value.
/// </summary> /// </summary>
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
public Optional(T value) public Optional([AllowNull] T value)
{ {
_value = value; _value = value;
HasValue = true; HasValue = true;
@ -48,7 +49,7 @@ namespace Avalonia.Data
public T Value => HasValue ? _value : throw new InvalidOperationException("Optional has no value."); public T Value => HasValue ? _value : throw new InvalidOperationException("Optional has no value.");
/// <inheritdoc/> /// <inheritdoc/>
public override bool Equals(object obj) => obj is Optional<T> o && this == o; public override bool Equals(object? obj) => obj is Optional<T> o && this == o;
/// <inheritdoc/> /// <inheritdoc/>
public bool Equals(Optional<T> other) => this == other; public bool Equals(Optional<T> other) => this == other;
@ -69,6 +70,7 @@ namespace Avalonia.Data
/// Gets the value if present, otherwise the default value. /// Gets the value if present, otherwise the default value.
/// </summary> /// </summary>
/// <returns>The value.</returns> /// <returns>The value.</returns>
[return: MaybeNull]
public T GetValueOrDefault() => HasValue ? _value : default; public T GetValueOrDefault() => HasValue ? _value : default;
/// <summary> /// <summary>
@ -85,6 +87,7 @@ namespace Avalonia.Data
/// The value if present and of the correct type, `default(TResult)` if the value is /// The value if present and of the correct type, `default(TResult)` if the value is
/// not present or of an incorrect type. /// not present or of an incorrect type.
/// </returns> /// </returns>
[return: MaybeNull]
public TResult GetValueOrDefault<TResult>() public TResult GetValueOrDefault<TResult>()
{ {
return HasValue ? return HasValue ?
@ -101,7 +104,8 @@ namespace Avalonia.Data
/// present but not of the correct type or null, or <paramref name="defaultValue"/> if the /// present but not of the correct type or null, or <paramref name="defaultValue"/> if the
/// value is not present. /// value is not present.
/// </returns> /// </returns>
public TResult GetValueOrDefault<TResult>(TResult defaultValue) [return: MaybeNull]
public TResult GetValueOrDefault<TResult>([AllowNull] TResult defaultValue)
{ {
return HasValue ? return HasValue ?
_value is TResult result ? result : default _value is TResult result ? result : default
@ -112,7 +116,7 @@ namespace Avalonia.Data
/// Creates an <see cref="Optional{T}"/> from an instance of the underlying value type. /// Creates an <see cref="Optional{T}"/> from an instance of the underlying value type.
/// </summary> /// </summary>
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
public static implicit operator Optional<T>(T value) => new Optional<T>(value); public static implicit operator Optional<T>([AllowNull] T value) => new Optional<T>(value);
/// <summary> /// <summary>
/// Compares two <see cref="Optional{T}"/>s for inequality. /// Compares two <see cref="Optional{T}"/>s for inequality.
@ -128,7 +132,7 @@ namespace Avalonia.Data
/// <param name="x">The first value.</param> /// <param name="x">The first value.</param>
/// <param name="y">The second value.</param> /// <param name="y">The second value.</param>
/// <returns>True if the values are equal; otherwise false.</returns> /// <returns>True if the values are equal; otherwise false.</returns>
public static bool operator==(Optional<T> x, Optional<T> y) public static bool operator ==(Optional<T> x, Optional<T> y)
{ {
if (!x.HasValue && !y.HasValue) if (!x.HasValue && !y.HasValue)
{ {

2
src/Avalonia.Base/DirectPropertyBase.cs

@ -120,7 +120,7 @@ namespace Avalonia
return o.GetValue<TValue>(this); return o.GetValue<TValue>(this);
} }
internal override object RouteGetBaseValue(IAvaloniaObject o, BindingPriority maxPriority) internal override object? RouteGetBaseValue(IAvaloniaObject o, BindingPriority maxPriority)
{ {
return o.GetValue<TValue>(this); return o.GetValue<TValue>(this);
} }

2
src/Avalonia.Base/IStyledPropertyMetadata.cs

@ -1,5 +1,3 @@
using System;
namespace Avalonia namespace Avalonia
{ {
/// <summary> /// <summary>

140
src/Avalonia.Base/Metadata/NullableAttributes.cs

@ -0,0 +1,140 @@
#pragma warning disable MA0048 // File name must match type name
#define INTERNAL_NULLABLE_ATTRIBUTES
#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48
// https://github.com/dotnet/corefx/blob/48363ac826ccf66fbe31a5dcb1dc2aab9a7dd768/src/Common/src/CoreLib/System/Diagnostics/CodeAnalysis/NullableAttributes.cs
// 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.Diagnostics.CodeAnalysis
{
/// <summary>Specifies that null is allowed as an input even if the corresponding type disallows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class AllowNullAttribute : Attribute
{ }
/// <summary>Specifies that null is disallowed as an input even if the corresponding type allows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class DisallowNullAttribute : Attribute
{ }
/// <summary>Specifies that an output may be null even if the corresponding type disallows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class MaybeNullAttribute : Attribute
{ }
/// <summary>Specifies that an output will not be null even if the corresponding type allows it.</summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class NotNullAttribute : Attribute
{ }
/// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter may be null even if the corresponding type disallows it.</summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class MaybeNullWhenAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified return value condition.</summary>
/// <param name="returnValue">
/// The return value condition. If the method returns this value, the associated parameter may be null.
/// </param>
public MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
/// <summary>Gets the return value condition.</summary>
public bool ReturnValue { get; }
}
/// <summary>Specifies that when a method returns <see cref="ReturnValue"/>, the parameter will not be null even if the corresponding type allows it.</summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class NotNullWhenAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified return value condition.</summary>
/// <param name="returnValue">
/// The return value condition. If the method returns this value, the associated parameter will not be null.
/// </param>
public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
/// <summary>Gets the return value condition.</summary>
public bool ReturnValue { get; }
}
/// <summary>Specifies that the output will be non-null if the named parameter is non-null.</summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class NotNullIfNotNullAttribute : Attribute
{
/// <summary>Initializes the attribute with the associated parameter name.</summary>
/// <param name="parameterName">
/// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null.
/// </param>
public NotNullIfNotNullAttribute(string parameterName) => ParameterName = parameterName;
/// <summary>Gets the associated parameter name.</summary>
public string ParameterName { get; }
}
/// <summary>Applied to a method that will never return under any circumstance.</summary>
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class DoesNotReturnAttribute : Attribute
{ }
/// <summary>Specifies that the method will not return if the associated Boolean parameter is passed the specified value.</summary>
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
#if INTERNAL_NULLABLE_ATTRIBUTES
internal
#else
public
#endif
sealed class DoesNotReturnIfAttribute : Attribute
{
/// <summary>Initializes the attribute with the specified parameter value.</summary>
/// <param name="parameterValue">
/// The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to
/// the associated parameter matches this value.
/// </param>
public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue;
/// <summary>Gets the condition parameter value.</summary>
public bool ParameterValue { get; }
}
}
#endif

7
src/Avalonia.Base/PropertyStore/IPriorityValueEntry.cs

@ -1,7 +1,4 @@
using System; #nullable enable
using Avalonia.Data;
#nullable enable
namespace Avalonia.PropertyStore namespace Avalonia.PropertyStore
{ {
@ -10,8 +7,6 @@ namespace Avalonia.PropertyStore
/// </summary> /// </summary>
internal interface IPriorityValueEntry : IValue internal interface IPriorityValueEntry : IValue
{ {
BindingPriority Priority { get; }
void Reparent(IValueSink sink); void Reparent(IValueSink sink);
} }

7
src/Avalonia.Base/PropertyStore/LocalValueEntry.cs

@ -1,4 +1,5 @@
using Avalonia.Data; using System.Diagnostics.CodeAnalysis;
using Avalonia.Data;
#nullable enable #nullable enable
@ -11,9 +12,9 @@ namespace Avalonia.PropertyStore
/// <typeparam name="T">The property type.</typeparam> /// <typeparam name="T">The property type.</typeparam>
internal class LocalValueEntry<T> : IValue<T> internal class LocalValueEntry<T> : IValue<T>
{ {
private T _value; [AllowNull] private T _value;
public LocalValueEntry(T value) => _value = value; public LocalValueEntry([AllowNull] T value) => _value = value;
public BindingPriority Priority => BindingPriority.LocalValue; public BindingPriority Priority => BindingPriority.LocalValue;
Optional<object> IValue.GetValue() => new Optional<object>(_value); Optional<object> IValue.GetValue() => new Optional<object>(_value);

3
src/Avalonia.Base/StyledPropertyMetadata`1.cs

@ -1,5 +1,4 @@
using System; using System;
using System.Diagnostics;
using Avalonia.Data; using Avalonia.Data;
namespace Avalonia namespace Avalonia
@ -35,7 +34,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Gets the value coercion callback, if any. /// Gets the value coercion callback, if any.
/// </summary> /// </summary>
public Func<IAvaloniaObject, TValue, TValue>? CoerceValue { get; private set; } public Func<IAvaloniaObject, TValue, TValue> CoerceValue { get; private set; }
object IStyledPropertyMetadata.DefaultValue => DefaultValue; object IStyledPropertyMetadata.DefaultValue => DefaultValue;

2
src/Avalonia.Base/ValueStore.cs

@ -162,7 +162,7 @@ namespace Avalonia
_sink.ValueChanged(new AvaloniaPropertyChangedEventArgs<T>( _sink.ValueChanged(new AvaloniaPropertyChangedEventArgs<T>(
_owner, _owner,
property, property,
old, new Optional<T>(old),
default, default,
BindingPriority.Unset)); BindingPriority.Unset));
} }

5
src/Avalonia.Styling/IStyledElement.cs

@ -17,11 +17,6 @@ namespace Avalonia
/// </summary> /// </summary>
event EventHandler Initialized; event EventHandler Initialized;
/// <summary>
/// Raised when resources on the element are changed.
/// </summary>
event EventHandler<ResourcesChangedEventArgs> ResourcesChanged;
/// <summary> /// <summary>
/// Gets a value that indicates whether the element has finished initialization. /// Gets a value that indicates whether the element has finished initialization.
/// </summary> /// </summary>

1
src/Avalonia.Styling/StyledElement.cs

@ -67,7 +67,6 @@ namespace Avalonia
private List<IStyleInstance>? _appliedStyles; private List<IStyleInstance>? _appliedStyles;
private ITemplatedControl? _templatedParent; private ITemplatedControl? _templatedParent;
private bool _dataContextUpdating; private bool _dataContextUpdating;
private bool _notifyingResourcesChanged;
/// <summary> /// <summary>
/// Initializes static members of the <see cref="StyledElement"/> class. /// Initializes static members of the <see cref="StyledElement"/> class.

1
src/Avalonia.Styling/Styling/Styles.cs

@ -21,7 +21,6 @@ namespace Avalonia.Styling
private IResourceHost? _owner; private IResourceHost? _owner;
private IResourceDictionary? _resources; private IResourceDictionary? _resources;
private Dictionary<Type, List<IStyle>?>? _cache; private Dictionary<Type, List<IStyle>?>? _cache;
private bool _notifyingResourcesChanged;
public Styles() public Styles()
{ {

Loading…
Cancel
Save