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
4 changes: 2 additions & 2 deletions src/AppCoreNet.Diagnostics.Sources/Ensure.Arg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ public static void OfGenericType<TExpected>(
/// <exception cref="ArgumentException">The type argument is not of the expected type.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[StackTraceHidden]
[RequiresUnreferencedCode("Requires unreferenced code, use the overload with Type parameter.")]
public static void OfGenericType(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
object? value,
Type expectedType,
[CallerArgumentExpression("value")] string? paramName = null)
Expand All @@ -371,8 +371,8 @@ public static void OfGenericType(
/// <exception cref="ArgumentException">The type argument is not of the expected type.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[StackTraceHidden]
[RequiresUnreferencedCode("Requires unreferenced code, use the overload with Type parameter.")]
public static void OfGenericType<TExpected>(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
object? value,
[CallerArgumentExpression("value")] string? paramName = null)
{
Expand Down
4 changes: 4 additions & 0 deletions test/AppCoreNet.Diagnostics.Tests/EnsureTests.Arg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -232,6 +233,7 @@ public void OfGenericTypeDoesNotThrowForRelatedTypes(Type expectedType)
[InlineData(typeof(IEnumerable<>))]
[InlineData(typeof(ExpectedArgBaseType))]
[InlineData(typeof(ExpectedArgType))]
[RequiresUnreferencedCode("This test requires types to be preserved for reflection.")]
public void OfGenericTypeDoesNotThrowForRelatedValue(Type expectedType)
{
object value = new ExpectedArgType();
Expand All @@ -245,6 +247,7 @@ public void OfGenericTypeDoesNotThrowForNullType()
}

[Fact]
[RequiresUnreferencedCode("This test requires types to be preserved for reflection.")]
public void OfGenericTypeDoesNotThrowForNullValue()
{
Ensure.Arg.OfGenericType((object?)null, typeof(string));
Expand All @@ -261,6 +264,7 @@ public void OfGenericTypeThrowsForUnrelatedType()
}

[Fact]
[RequiresUnreferencedCode("This test requires types to be preserved for reflection.")]
public void OfGenericTypeThrowsForUnrelatedValue()
{
var exception = Assert.Throws<ArgumentException>(
Expand Down