Add [NotNullIfNotNull] polyfill for CanvasEffect

このコミットが含まれているのは:
Sergio Pedri committed 2022-12-23 23:18:56 +01:00
1 親 4cc15152fe
コミット 21723238b7
3ファイル変更
+32 -1

検索条件に一致するファイルはありません

+1
ファイルの表示
@@ -13,6 +13,7 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics.CodeAnalysis\DoesNotReturnAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics.CodeAnalysis\DisallowNullAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics.CodeAnalysis\NotNullAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics.CodeAnalysis\NotNullIfNotNullAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Math.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RuntimeHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)..\ComputeSharp.NetStandard\System\Runtime\InteropServices\NativeMemory.cs" Link="System\Runtime\InteropServices\NativeMemory.cs" />
@@ -0,0 +1,29 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Diagnostics.CodeAnalysis;
/// <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)]
internal 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; }
}
+2 -1
ファイルの表示
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using ABI.Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas;
@@ -103,7 +104,7 @@ public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop.I
/// <param name="storage">The storage for the effect property value.</param>
/// <param name="value">The new effect property value to set.</param>
/// <param name="invalidationType">The invalidation type to request.</param>
protected void SetAndInvalidateCanvasImage<T>(/*[NotNullIfNotNull(nameof(newValue))]*/ ref T storage, T value, InvalidationType invalidationType = InvalidationType.Update)
protected void SetAndInvalidateCanvasImage<T>([NotNullIfNotNull(nameof(value))] ref T storage, T value, InvalidationType invalidationType = InvalidationType.Update)
{
if (EqualityComparer<T>.Default.Equals(storage, value))
{