Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CommunityToolkit.Common/Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
Expand All @@ -24,7 +27,11 @@ public static class TaskExtensions
/// a value type, which adds overhead. It should only be used when using generics is not possible.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static object? GetResultOrDefault(this Task task)
public static object? GetResultOrDefault(
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
#endif
this Task task)
{
// Check if the instance is a completed Task
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ private void ClearErrorsForProperty(string propertyName)
/// </summary>
/// <param name="propertyName">The target property name being validated.</param>
/// <returns>The display name for the property.</returns>
[RequiresUnreferencedCode("The type of the current instance cannot be statically discovered.")]
private string GetDisplayNameForProperty(string propertyName)
{
static Dictionary<string, string> GetDisplayNames(Type type)
Expand Down