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
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ public Task MethodWithDefaultValues() => RunTest(
await Assert.That(mainFile).Contains("bool exact = true");
});

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[Test]
public Task RefStructParameter() => RunTest(
Path.Combine(Sourcy.Git.RootDirectory.FullName,
"TUnit.Assertions.SourceGenerator.Tests",
"TestData",
"RefStructParameterAssertion.cs"),
new RunTestOptions { PreprocessorSymbols = ["NET6_0_OR_GREATER"] },
new RunTestOptions { PreprocessorSymbols = ["NET8_0_OR_GREATER"] },
async generatedFiles =>
{
await Assert.That(generatedFiles).HasCount(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using System.Runtime.CompilerServices;
using TUnit.Assertions.Attributes;

Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/DateOnlyAssertionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using TUnit.Assertions.Extensions;

namespace TUnit.Assertions.Tests;
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/EquatableTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
namespace TUnit.Assertions.Tests;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/IndexAssertionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using TUnit.Assertions.Extensions;

namespace TUnit.Assertions.Tests;
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/RangeAssertionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using TUnit.Assertions.Extensions;

namespace TUnit.Assertions.Tests;
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/TaskAssertionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async Task Test_Task_IsNotFaulted()
await Assert.That(task).IsNotFaulted();
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[Test]
public async Task Test_Task_IsCompletedSuccessfully()
{
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/TimeOnlyAssertionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using TUnit.Assertions.Extensions;

namespace TUnit.Assertions.Tests;
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/TimeZoneInfoAssertionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public async Task Test_TimeZoneInfo_DoesNotSupportDaylightSavingTime()
await Assert.That(utc).DoesNotSupportDaylightSavingTime();
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[Test]
public async Task Test_TimeZoneInfo_HasIanaId()
{
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Assertions/Conditions/BigIntegerAssertionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ namespace TUnit.Assertions.Conditions;
[AssertionFrom<BigInteger>(nameof(BigInteger.IsZero), ExpectationMessage = "be zero")]
[AssertionFrom<BigInteger>(nameof(BigInteger.IsZero), CustomName = "IsNotZero", NegateLogic = true, ExpectationMessage = "be zero")]

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[AssertionFrom<BigInteger>(nameof(BigInteger.IsOne), ExpectationMessage = "be one")]
[AssertionFrom<BigInteger>(nameof(BigInteger.IsOne), CustomName = "IsNotOne", NegateLogic = true, ExpectationMessage = "be one")]
#endif

[AssertionFrom<BigInteger>(nameof(BigInteger.IsEven), ExpectationMessage = "be even")]
[AssertionFrom<BigInteger>(nameof(BigInteger.IsEven), CustomName = "IsNotEven", NegateLogic = true, ExpectationMessage = "be even")]

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[AssertionFrom<BigInteger>(nameof(BigInteger.IsPowerOfTwo), ExpectationMessage = "be a power of two")]
[AssertionFrom<BigInteger>(nameof(BigInteger.IsPowerOfTwo), CustomName = "IsNotPowerOfTwo", NegateLogic = true, ExpectationMessage = "be a power of two")]
#endif
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Conditions/DateOnlyAssertionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using TUnit.Assertions.Attributes;

namespace TUnit.Assertions.Conditions;
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Conditions/Helpers/TypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static bool IsPrimitiveOrWellKnownType(Type type)
|| type == typeof(Guid)
|| typeof(Type).IsAssignableFrom(type)
|| typeof(MemberInfo).IsAssignableFrom(type)
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
|| type == typeof(DateOnly)
|| type == typeof(TimeOnly)
#endif
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Conditions/IndexAssertionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using TUnit.Assertions.Attributes;

namespace TUnit.Assertions.Conditions;
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Conditions/RangeAssertionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using TUnit.Assertions.Attributes;

namespace TUnit.Assertions.Conditions;
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Assertions/Conditions/SpecializedEqualityAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace TUnit.Assertions.Conditions;

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
/// <summary>
/// Asserts that a DateOnly value is equal to another, with optional tolerance.
/// </summary>
Expand Down Expand Up @@ -49,7 +49,7 @@ protected override string GetExpectation()
}
#endif

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
/// <summary>
/// Asserts that a TimeOnly value is equal to another, with optional tolerance.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Conditions/TaskAssertionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace TUnit.Assertions.Conditions;
[AssertionFrom<Task>(nameof(Task.IsFaulted), ExpectationMessage = "be faulted")]
[AssertionFrom<Task>(nameof(Task.IsFaulted), CustomName = "IsNotFaulted", NegateLogic = true, ExpectationMessage = "be faulted")]

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[AssertionFrom<Task>(nameof(Task.IsCompletedSuccessfully), ExpectationMessage = "be completed successfully")]
[AssertionFrom<Task>(nameof(Task.IsCompletedSuccessfully), CustomName = "IsNotCompletedSuccessfully", NegateLogic = true, ExpectationMessage = "be completed successfully")]
#endif
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Conditions/TimeOnlyAssertionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
using TUnit.Assertions.Attributes;

namespace TUnit.Assertions.Conditions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TUnit.Assertions.Conditions;
[AssertionFrom<TimeZoneInfo>(nameof(TimeZoneInfo.SupportsDaylightSavingTime), ExpectationMessage = "support daylight saving time")]
[AssertionFrom<TimeZoneInfo>(nameof(TimeZoneInfo.SupportsDaylightSavingTime), CustomName = "DoesNotSupportDaylightSavingTime", NegateLogic = true, ExpectationMessage = "support daylight saving time")]

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[AssertionFrom<TimeZoneInfo>(nameof(TimeZoneInfo.HasIanaId), ExpectationMessage = "have an IANA ID")]
[AssertionFrom<TimeZoneInfo>(nameof(TimeZoneInfo.HasIanaId), CustomName = "DoesNotHaveIanaId", NegateLogic = true, ExpectationMessage = "have an IANA ID")]
#endif
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Extensions/AssertionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ public static TValue_IsLessThanOrEqualTo_TValue_Assertion<DateTimeOffset> IsBefo
return new TValue_IsLessThanOrEqualTo_TValue_Assertion<DateTimeOffset>(source.Context, expected);
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
/// <summary>
/// Asserts that the DateOnly is after the expected DateOnly.
/// Alias for IsGreaterThan for better readability with dates.
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Sources/AsyncDelegateAssertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public TaskIsFaultedAssertion<Task> IsNotFaulted()
return ((IAssertionSource<Task>)this).IsNotFaulted();
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
/// <summary>
/// Asserts that the task completed successfully.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Sources/TaskAssertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public TaskIsFaultedAssertion<Task<TValue>> IsNotFaulted()
return ((IAssertionSource<Task<TValue>>)this).IsNotFaulted();
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
/// <summary>
/// Asserts that the task completed successfully.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace TUnit.Core;

#if NET7_0_OR_GREATER
#if NET8_0_OR_GREATER
[AttributeUsage(AttributeTargets.Parameter)]
public class MatrixRangeAttribute<T>(T min, T max, T step)
: MatrixAttribute<T>(CreateRange(min, max, step))
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Core/DataGeneratorMetadataCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public static DataGeneratorMetadata CreateForPropertyInjection(
/// Creates DataGeneratorMetadata for property injection using PropertyInfo (reflection mode).
/// This method is only called in reflection mode, not in source-generated/AOT scenarios.
/// </summary>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access",
Justification = "This method is only used in reflection mode. In AOT/source-gen mode, property injection uses compile-time generated PropertyMetadata.")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling",
Expand Down Expand Up @@ -267,7 +267,7 @@ private static ParameterMetadata[] FilterOutCancellationToken(ParameterMetadata[
return parameters;
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access",
Justification = "This helper is only used in reflection mode. In AOT/source-gen mode, class metadata is generated at compile time.")]
[UnconditionalSuppressMessage("Trimming", "IL2070:Target method return value does not satisfy 'DynamicallyAccessedMembersAttribute'",
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/DynamicTestBuilderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public DynamicTestBuilderContext(string filePath, int lineNumber)

public IReadOnlyList<AbstractDynamicTest> Tests => _tests.AsReadOnly();

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Adding dynamic tests requires reflection which is not supported in native AOT scenarios.")]
#endif
public void AddTest(AbstractDynamicTest test)
Expand Down
10 changes: 5 additions & 5 deletions TUnit.Core/Extensions/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static T[] GetCustomAttributesSafe<T>(this ICustomAttributeProvider provi
#endif
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Attribute instantiation uses reflection for .NET Framework compatibility")]
#endif
private static Attribute[] GetAttributesViaCustomAttributeData(ICustomAttributeProvider provider, Type attributeType, bool inherit)
Expand Down Expand Up @@ -173,7 +173,7 @@ private static Attribute[] GetAttributesViaCustomAttributeData(ICustomAttributeP
return attributes.ToArray();
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Attribute instantiation uses reflection for .NET Framework compatibility")]
#endif
private static Attribute? CreateAttributeInstance(CustomAttributeData attributeData)
Expand Down Expand Up @@ -240,7 +240,7 @@ private static Attribute[] GetAttributesViaCustomAttributeData(ICustomAttributeP
return attribute;
}

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Runtime type property access for attribute argument extraction")]
#endif
private static object? ExtractArgumentValue(CustomAttributeTypedArgument arg)
Expand Down Expand Up @@ -278,7 +278,7 @@ private static Attribute[] GetAttributesViaCustomAttributeData(ICustomAttributeP
/// <summary>
/// Gets the "Value" property from a type in an AOT-safer manner.
/// </summary>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Property access used for unwrapping test data")]
#endif
private static PropertyInfo? GetValuePropertySafe([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type)
Expand All @@ -289,7 +289,7 @@ private static Attribute[] GetAttributesViaCustomAttributeData(ICustomAttributeP
/// <summary>
/// Gets the "Value" property from a runtime type.
/// </summary>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Runtime type property access for attribute argument extraction")]
#endif
private static PropertyInfo? GetValuePropertyForType(Type type)
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Core/Extensions/TestContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ internal static string GetNestedTypeName(Type type)
/// </summary>
public static bool IsVariant(this Interfaces.ITestDependencies dependencies) => dependencies.ParentTestId != null;

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Dynamic test metadata creation uses reflection")]
#endif
public static async Task AddDynamicTest<[DynamicallyAccessedMembers(
Expand All @@ -118,7 +118,7 @@ internal static string GetNestedTypeName(Type type)
/// <param name="relationship">The relationship category of this variant to its parent test (defaults to Derived)</param>
/// <param name="displayName">Optional user-facing display name for the variant (e.g., "Shrink Attempt", "Mutant")</param>
/// <returns>Information about the created test variant, including its TestId and DisplayName</returns>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Creating test variants requires runtime compilation and reflection")]
#endif
public static async Task<TestVariantInfo> CreateTestVariant(
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/Helpers/DataSourceHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public static void RegisterTypeCreator<T>(Func<MethodMetadata, string, Task<T>>
/// This method handles all IDataSourceAttribute implementations generically.
/// Only used in reflection mode - in AOT/source-gen mode, property injection is handled by generated code.
/// </summary>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access",
Justification = "This method is only used in reflection mode. In AOT/source-gen mode, property injection uses compile-time generated code.")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling",
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/Helpers/GenericTypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class GenericTypeHelper
/// <returns>The constructed generic type</returns>
/// <exception cref="ArgumentNullException">Thrown when genericTypeDefinition is null</exception>
/// <exception cref="ArgumentException">Thrown when type arguments don't match the generic type definition</exception>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("MakeGenericType requires runtime code generation")]
[RequiresDynamicCode("MakeGenericType requires runtime code generation")]
#endif
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/Helpers/TupleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static bool IsTupleArrayType(Type type)
/// Expands an array of tuples into individual tuple elements for data source generation
/// For example: [(1, "a"), (2, "b")] becomes individual items that each unwrap to [1, "a"] and [2, "b"]
/// </summary>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Tuple expansion uses reflection as fallback")]
#endif
public static IEnumerable<object?[]> ExpandTupleArray(object? value)
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/Hooks/LastTestInClassAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace TUnit.Core.Hooks;

#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Method with DynamicallyAccessedMembersAttribute accessed via reflection")]
#endif
public class LastTestInClassAdapter(ILastTestInClassEventReceiver lastTestInClassEventReceiver, TestContext testContext) : IExecutableHook<ClassHookContext>
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Core/Interfaces/ITestRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface ITestRegistry
/// <param name="context">The current test context</param>
/// <param name="dynamicTest">The dynamic test instance to add</param>
/// <returns>A task that completes when the test has been queued for execution</returns>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Adding dynamic tests requires runtime compilation and reflection which are not supported in native AOT scenarios.")]
#endif
Task AddDynamicTest<[DynamicallyAccessedMembers(
Expand All @@ -39,7 +39,7 @@ public interface ITestRegistry
/// <param name="relationship">The relationship category of this variant to its parent test</param>
/// <param name="displayName">Optional user-facing display name for the variant (e.g., "Shrink Attempt", "Mutant")</param>
/// <returns>A task containing information about the created test variant</returns>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Creating test variants requires runtime compilation and reflection which are not supported in native AOT scenarios.")]
#endif
Task<TestVariantInfo> CreateTestVariant(
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Core/PropertyInjection/ClassMetadataHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class ClassMetadataHelper
/// <summary>
/// Gets or creates ClassMetadata for the specified type.
/// </summary>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Metadata creation requires reflection")]
#endif
public static ClassMetadata GetOrCreateClassMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static PropertyInjectionPlan BuildSourceGeneratedPlan(Type type)
/// <summary>
/// Creates an injection plan for reflection mode.
/// </summary>
#if NET6_0_OR_GREATER
#if NET8_0_OR_GREATER
[RequiresUnreferencedCode("Reflection mode requires runtime property discovery")]
#endif
public static PropertyInjectionPlan BuildReflectionPlan(Type type)
Expand Down
Loading
Loading