diff --git a/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.DotNet8_0.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.DotNet8_0.verified.txt
index 776124a663..4c2caae9f8 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.DotNet8_0.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.DotNet8_0.verified.txt
@@ -406,93 +406,113 @@ public static partial class ExceptionAssertionExtensions
///
/// Generated extension method for HasInnerException
///
- public static Exception_HasInnerException_Assertion HasInnerException(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasInnerException_Assertion HasInnerException(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasInnerException()");
- return new Exception_HasInnerException_Assertion(source.Context);
+ return new Exception_HasInnerException_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoInnerException
///
- public static Exception_HasNoInnerException_Assertion HasNoInnerException(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoInnerException_Assertion HasNoInnerException(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoInnerException()");
- return new Exception_HasNoInnerException_Assertion(source.Context);
+ return new Exception_HasNoInnerException_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasStackTrace
///
- public static Exception_HasStackTrace_Assertion HasStackTrace(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasStackTrace_Assertion HasStackTrace(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasStackTrace()");
- return new Exception_HasStackTrace_Assertion(source.Context);
+ return new Exception_HasStackTrace_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoData
///
- public static Exception_HasNoData_Assertion HasNoData(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoData_Assertion HasNoData(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoData()");
- return new Exception_HasNoData_Assertion(source.Context);
+ return new Exception_HasNoData_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasHelpLink
///
- public static Exception_HasHelpLink_Assertion HasHelpLink(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasHelpLink_Assertion HasHelpLink(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasHelpLink()");
- return new Exception_HasHelpLink_Assertion(source.Context);
+ return new Exception_HasHelpLink_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoHelpLink
///
- public static Exception_HasNoHelpLink_Assertion HasNoHelpLink(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoHelpLink_Assertion HasNoHelpLink(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoHelpLink()");
- return new Exception_HasNoHelpLink_Assertion(source.Context);
+ return new Exception_HasNoHelpLink_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasSource
///
- public static Exception_HasSource_Assertion HasSource(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasSource_Assertion HasSource(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasSource()");
- return new Exception_HasSource_Assertion(source.Context);
+ return new Exception_HasSource_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoSource
///
- public static Exception_HasNoSource_Assertion HasNoSource(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoSource_Assertion HasNoSource(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoSource()");
- return new Exception_HasNoSource_Assertion(source.Context);
+ return new Exception_HasNoSource_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasTargetSite
///
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Exception.TargetSite uses reflection which may be trimmed in AOT scenarios")]
- public static Exception_HasTargetSite_Assertion HasTargetSite(this IAssertionSource source)
+ public static Exception_HasTargetSite_Assertion HasTargetSite(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasTargetSite()");
- return new Exception_HasTargetSite_Assertion(source.Context);
+ return new Exception_HasTargetSite_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoTargetSite
///
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Exception.TargetSite uses reflection which may be trimmed in AOT scenarios")]
- public static Exception_HasNoTargetSite_Assertion HasNoTargetSite(this IAssertionSource source)
+ public static Exception_HasNoTargetSite_Assertion HasNoTargetSite(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoTargetSite()");
- return new Exception_HasNoTargetSite_Assertion(source.Context);
+ return new Exception_HasNoTargetSite_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
}
diff --git a/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.DotNet9_0.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.DotNet9_0.verified.txt
index 776124a663..4c2caae9f8 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.DotNet9_0.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.DotNet9_0.verified.txt
@@ -406,93 +406,113 @@ public static partial class ExceptionAssertionExtensions
///
/// Generated extension method for HasInnerException
///
- public static Exception_HasInnerException_Assertion HasInnerException(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasInnerException_Assertion HasInnerException(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasInnerException()");
- return new Exception_HasInnerException_Assertion(source.Context);
+ return new Exception_HasInnerException_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoInnerException
///
- public static Exception_HasNoInnerException_Assertion HasNoInnerException(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoInnerException_Assertion HasNoInnerException(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoInnerException()");
- return new Exception_HasNoInnerException_Assertion(source.Context);
+ return new Exception_HasNoInnerException_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasStackTrace
///
- public static Exception_HasStackTrace_Assertion HasStackTrace(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasStackTrace_Assertion HasStackTrace(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasStackTrace()");
- return new Exception_HasStackTrace_Assertion(source.Context);
+ return new Exception_HasStackTrace_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoData
///
- public static Exception_HasNoData_Assertion HasNoData(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoData_Assertion HasNoData(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoData()");
- return new Exception_HasNoData_Assertion(source.Context);
+ return new Exception_HasNoData_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasHelpLink
///
- public static Exception_HasHelpLink_Assertion HasHelpLink(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasHelpLink_Assertion HasHelpLink(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasHelpLink()");
- return new Exception_HasHelpLink_Assertion(source.Context);
+ return new Exception_HasHelpLink_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoHelpLink
///
- public static Exception_HasNoHelpLink_Assertion HasNoHelpLink(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoHelpLink_Assertion HasNoHelpLink(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoHelpLink()");
- return new Exception_HasNoHelpLink_Assertion(source.Context);
+ return new Exception_HasNoHelpLink_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasSource
///
- public static Exception_HasSource_Assertion HasSource(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasSource_Assertion HasSource(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasSource()");
- return new Exception_HasSource_Assertion(source.Context);
+ return new Exception_HasSource_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoSource
///
- public static Exception_HasNoSource_Assertion HasNoSource(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoSource_Assertion HasNoSource(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoSource()");
- return new Exception_HasNoSource_Assertion(source.Context);
+ return new Exception_HasNoSource_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasTargetSite
///
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Exception.TargetSite uses reflection which may be trimmed in AOT scenarios")]
- public static Exception_HasTargetSite_Assertion HasTargetSite(this IAssertionSource source)
+ public static Exception_HasTargetSite_Assertion HasTargetSite(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasTargetSite()");
- return new Exception_HasTargetSite_Assertion(source.Context);
+ return new Exception_HasTargetSite_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoTargetSite
///
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Exception.TargetSite uses reflection which may be trimmed in AOT scenarios")]
- public static Exception_HasNoTargetSite_Assertion HasNoTargetSite(this IAssertionSource source)
+ public static Exception_HasNoTargetSite_Assertion HasNoTargetSite(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoTargetSite()");
- return new Exception_HasNoTargetSite_Assertion(source.Context);
+ return new Exception_HasNoTargetSite_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
}
diff --git a/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.Net4_7.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.Net4_7.verified.txt
index 1300707a92..a4f7f65aae 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.Net4_7.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/ExceptionAssertionGeneratorTests.GeneratesExceptionAssertions.Net4_7.verified.txt
@@ -404,91 +404,111 @@ public static partial class ExceptionAssertionExtensions
///
/// Generated extension method for HasInnerException
///
- public static Exception_HasInnerException_Assertion HasInnerException(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasInnerException_Assertion HasInnerException(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasInnerException()");
- return new Exception_HasInnerException_Assertion(source.Context);
+ return new Exception_HasInnerException_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoInnerException
///
- public static Exception_HasNoInnerException_Assertion HasNoInnerException(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoInnerException_Assertion HasNoInnerException(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoInnerException()");
- return new Exception_HasNoInnerException_Assertion(source.Context);
+ return new Exception_HasNoInnerException_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasStackTrace
///
- public static Exception_HasStackTrace_Assertion HasStackTrace(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasStackTrace_Assertion HasStackTrace(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasStackTrace()");
- return new Exception_HasStackTrace_Assertion(source.Context);
+ return new Exception_HasStackTrace_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoData
///
- public static Exception_HasNoData_Assertion HasNoData(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoData_Assertion HasNoData(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoData()");
- return new Exception_HasNoData_Assertion(source.Context);
+ return new Exception_HasNoData_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasHelpLink
///
- public static Exception_HasHelpLink_Assertion HasHelpLink(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasHelpLink_Assertion HasHelpLink(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasHelpLink()");
- return new Exception_HasHelpLink_Assertion(source.Context);
+ return new Exception_HasHelpLink_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoHelpLink
///
- public static Exception_HasNoHelpLink_Assertion HasNoHelpLink(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoHelpLink_Assertion HasNoHelpLink(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoHelpLink()");
- return new Exception_HasNoHelpLink_Assertion(source.Context);
+ return new Exception_HasNoHelpLink_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasSource
///
- public static Exception_HasSource_Assertion HasSource(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasSource_Assertion HasSource(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasSource()");
- return new Exception_HasSource_Assertion(source.Context);
+ return new Exception_HasSource_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoSource
///
- public static Exception_HasNoSource_Assertion HasNoSource(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoSource_Assertion HasNoSource(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoSource()");
- return new Exception_HasNoSource_Assertion(source.Context);
+ return new Exception_HasNoSource_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasTargetSite
///
- public static Exception_HasTargetSite_Assertion HasTargetSite(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasTargetSite_Assertion HasTargetSite(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasTargetSite()");
- return new Exception_HasTargetSite_Assertion(source.Context);
+ return new Exception_HasTargetSite_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
///
/// Generated extension method for HasNoTargetSite
///
- public static Exception_HasNoTargetSite_Assertion HasNoTargetSite(this IAssertionSource source)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static Exception_HasNoTargetSite_Assertion HasNoTargetSite(this IAssertionSource source)
+ where TActual : System.Exception
{
source.Context.ExpressionBuilder.Append(".HasNoTargetSite()");
- return new Exception_HasNoTargetSite_Assertion(source.Context);
+ return new Exception_HasNoTargetSite_Assertion(source.Context.Map(static x => (System.Exception?)x));
}
}
diff --git a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.DotNet8_0.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.DotNet8_0.verified.txt
index 56eb54174c..62c15bf931 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.DotNet8_0.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.DotNet8_0.verified.txt
@@ -70,10 +70,12 @@ public static partial class AssertionResultOfTMethodExtensions
///
/// Generated extension method for ContainsMatch
///
- public static IEnumerableString_ContainsMatch_String_Assertion ContainsMatch(this IAssertionSource> source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static IEnumerableString_ContainsMatch_String_Assertion ContainsMatch(this IAssertionSource source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ where TActual : System.Collections.Generic.IEnumerable
{
source.Context.ExpressionBuilder.Append($".ContainsMatch({needleExpression})");
- return new IEnumerableString_ContainsMatch_String_Assertion(source.Context, needle);
+ return new IEnumerableString_ContainsMatch_String_Assertion(source.Context.Map>(static x => (System.Collections.Generic.IEnumerable?)x), needle);
}
}
diff --git a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.DotNet9_0.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.DotNet9_0.verified.txt
index 56eb54174c..62c15bf931 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.DotNet9_0.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.DotNet9_0.verified.txt
@@ -70,10 +70,12 @@ public static partial class AssertionResultOfTMethodExtensions
///
/// Generated extension method for ContainsMatch
///
- public static IEnumerableString_ContainsMatch_String_Assertion ContainsMatch(this IAssertionSource> source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static IEnumerableString_ContainsMatch_String_Assertion ContainsMatch(this IAssertionSource source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ where TActual : System.Collections.Generic.IEnumerable
{
source.Context.ExpressionBuilder.Append($".ContainsMatch({needleExpression})");
- return new IEnumerableString_ContainsMatch_String_Assertion(source.Context, needle);
+ return new IEnumerableString_ContainsMatch_String_Assertion(source.Context.Map>(static x => (System.Collections.Generic.IEnumerable?)x), needle);
}
}
diff --git a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.Net4_7.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.Net4_7.verified.txt
index 56eb54174c..62c15bf931 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.Net4_7.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AssertionResultOfTMethod.Net4_7.verified.txt
@@ -70,10 +70,12 @@ public static partial class AssertionResultOfTMethodExtensions
///
/// Generated extension method for ContainsMatch
///
- public static IEnumerableString_ContainsMatch_String_Assertion ContainsMatch(this IAssertionSource> source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static IEnumerableString_ContainsMatch_String_Assertion ContainsMatch(this IAssertionSource source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ where TActual : System.Collections.Generic.IEnumerable
{
source.Context.ExpressionBuilder.Append($".ContainsMatch({needleExpression})");
- return new IEnumerableString_ContainsMatch_String_Assertion(source.Context, needle);
+ return new IEnumerableString_ContainsMatch_String_Assertion(source.Context.Map>(static x => (System.Collections.Generic.IEnumerable?)x), needle);
}
}
diff --git a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.DotNet8_0.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.DotNet8_0.verified.txt
index 25500147f3..a6a2aa30eb 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.DotNet8_0.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.DotNet8_0.verified.txt
@@ -70,10 +70,12 @@ public static partial class AsyncAssertionResultOfTMethodExtensions
///
/// Generated extension method for ContainsMatchAsync
///
- public static IEnumerableString_ContainsMatchAsync_String_Assertion ContainsMatchAsync(this IAssertionSource> source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static IEnumerableString_ContainsMatchAsync_String_Assertion ContainsMatchAsync(this IAssertionSource source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ where TActual : System.Collections.Generic.IEnumerable
{
source.Context.ExpressionBuilder.Append($".ContainsMatchAsync({needleExpression})");
- return new IEnumerableString_ContainsMatchAsync_String_Assertion(source.Context, needle);
+ return new IEnumerableString_ContainsMatchAsync_String_Assertion(source.Context.Map>(static x => (System.Collections.Generic.IEnumerable?)x), needle);
}
}
diff --git a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.DotNet9_0.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.DotNet9_0.verified.txt
index 25500147f3..a6a2aa30eb 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.DotNet9_0.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.DotNet9_0.verified.txt
@@ -70,10 +70,12 @@ public static partial class AsyncAssertionResultOfTMethodExtensions
///
/// Generated extension method for ContainsMatchAsync
///
- public static IEnumerableString_ContainsMatchAsync_String_Assertion ContainsMatchAsync(this IAssertionSource> source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static IEnumerableString_ContainsMatchAsync_String_Assertion ContainsMatchAsync(this IAssertionSource source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ where TActual : System.Collections.Generic.IEnumerable
{
source.Context.ExpressionBuilder.Append($".ContainsMatchAsync({needleExpression})");
- return new IEnumerableString_ContainsMatchAsync_String_Assertion(source.Context, needle);
+ return new IEnumerableString_ContainsMatchAsync_String_Assertion(source.Context.Map>(static x => (System.Collections.Generic.IEnumerable?)x), needle);
}
}
diff --git a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.Net4_7.verified.txt b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.Net4_7.verified.txt
index 25500147f3..a6a2aa30eb 100644
--- a/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.Net4_7.verified.txt
+++ b/TUnit.Assertions.SourceGenerator.Tests/MethodAssertionGeneratorTests.AsyncAssertionResultOfTMethod.Net4_7.verified.txt
@@ -70,10 +70,12 @@ public static partial class AsyncAssertionResultOfTMethodExtensions
///
/// Generated extension method for ContainsMatchAsync
///
- public static IEnumerableString_ContainsMatchAsync_String_Assertion ContainsMatchAsync(this IAssertionSource> source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
+ public static IEnumerableString_ContainsMatchAsync_String_Assertion ContainsMatchAsync(this IAssertionSource source, string needle, [CallerArgumentExpression(nameof(needle))] string? needleExpression = null)
+ where TActual : System.Collections.Generic.IEnumerable
{
source.Context.ExpressionBuilder.Append($".ContainsMatchAsync({needleExpression})");
- return new IEnumerableString_ContainsMatchAsync_String_Assertion(source.Context, needle);
+ return new IEnumerableString_ContainsMatchAsync_String_Assertion(source.Context.Map>(static x => (System.Collections.Generic.IEnumerable?)x), needle);
}
}
diff --git a/TUnit.Assertions.Tests/StringLengthAssertionTests.cs b/TUnit.Assertions.Tests/StringLengthAssertionTests.cs
index 87fd7e2ae2..f93b5781cd 100644
--- a/TUnit.Assertions.Tests/StringLengthAssertionTests.cs
+++ b/TUnit.Assertions.Tests/StringLengthAssertionTests.cs
@@ -161,4 +161,123 @@ await Assert.That(str)
.Length().IsGreaterThan(3)
.And.IsLessThan(10);
}
+
+ [Test]
+ public async Task HasMinLength_Passes_When_At_Minimum()
+ {
+ await Assert.That("Hello").HasMinLength(5);
+ }
+
+ [Test]
+ public async Task HasMinLength_Passes_When_Above_Minimum()
+ {
+ await Assert.That("Hello, World!").HasMinLength(5);
+ }
+
+ [Test]
+ public async Task HasMinLength_Fails_When_Below_Minimum()
+ {
+ await Assert.That(async () => await Assert.That("Hi").HasMinLength(5))
+ .Throws()
+ .And.HasMessageContaining("minimum length")
+ .And.HasMessageContaining("found length 2");
+ }
+
+ [Test]
+ public async Task HasMinLength_Fails_For_Null()
+ {
+ string? str = null;
+ await Assert.That(async () => await Assert.That(str!).HasMinLength(1))
+ .Throws()
+ .And.HasMessageContaining("null");
+ }
+
+ [Test]
+ public async Task HasMaxLength_Passes_When_At_Maximum()
+ {
+ await Assert.That("Hello").HasMaxLength(5);
+ }
+
+ [Test]
+ public async Task HasMaxLength_Passes_When_Below_Maximum()
+ {
+ await Assert.That("Hi").HasMaxLength(5);
+ }
+
+ [Test]
+ public async Task HasMaxLength_Fails_When_Above_Maximum()
+ {
+ await Assert.That(async () => await Assert.That("Hello, World!").HasMaxLength(5))
+ .Throws()
+ .And.HasMessageContaining("maximum length")
+ .And.HasMessageContaining("found length 13");
+ }
+
+ [Test]
+ public async Task HasMaxLength_Fails_For_Null()
+ {
+ string? str = null;
+ await Assert.That(async () => await Assert.That(str!).HasMaxLength(10))
+ .Throws()
+ .And.HasMessageContaining("null");
+ }
+
+ [Test]
+ public async Task HasLengthBetween_Passes_When_Within_Range()
+ {
+ await Assert.That("Hello").HasLengthBetween(3, 10);
+ }
+
+ [Test]
+ public async Task HasLengthBetween_Passes_When_At_Lower_Bound()
+ {
+ await Assert.That("Hello").HasLengthBetween(5, 10);
+ }
+
+ [Test]
+ public async Task HasLengthBetween_Passes_When_At_Upper_Bound()
+ {
+ await Assert.That("Hello").HasLengthBetween(1, 5);
+ }
+
+ [Test]
+ public async Task HasLengthBetween_Fails_When_Below_Range()
+ {
+ await Assert.That(async () => await Assert.That("Hi").HasLengthBetween(5, 10))
+ .Throws()
+ .And.HasMessageContaining("between")
+ .And.HasMessageContaining("found length 2");
+ }
+
+ [Test]
+ public async Task HasLengthBetween_Fails_When_Above_Range()
+ {
+ await Assert.That(async () => await Assert.That("Hello, World!").HasLengthBetween(1, 5))
+ .Throws()
+ .And.HasMessageContaining("between")
+ .And.HasMessageContaining("found length 13");
+ }
+
+ [Test]
+ public async Task HasLengthBetween_Fails_For_Null()
+ {
+ string? str = null;
+ await Assert.That(async () => await Assert.That(str!).HasLengthBetween(1, 10))
+ .Throws()
+ .And.HasMessageContaining("null");
+ }
+
+ [Test]
+ public async Task HasLengthBetween_Throws_When_Min_Greater_Than_Max()
+ {
+ await Assert.That(async () => await Assert.That("Hello").HasLengthBetween(10, 3))
+ .Throws()
+ .And.HasMessageContaining("minLength");
+ }
+
+ [Test]
+ public async Task HasMinLength_And_HasMaxLength_Chained()
+ {
+ await Assert.That("Hello").HasMinLength(3).And.HasMaxLength(10);
+ }
}
diff --git a/TUnit.Assertions/Conditions/StringLengthRangeAssertionExtensions.cs b/TUnit.Assertions/Conditions/StringLengthRangeAssertionExtensions.cs
new file mode 100644
index 0000000000..bf27c18f81
--- /dev/null
+++ b/TUnit.Assertions/Conditions/StringLengthRangeAssertionExtensions.cs
@@ -0,0 +1,45 @@
+using System;
+using System.ComponentModel;
+using TUnit.Assertions.Attributes;
+using TUnit.Assertions.Core;
+
+namespace TUnit.Assertions.Conditions;
+
+///
+/// Source-generated string length range assertions using [GenerateAssertion] attributes.
+///
+public static partial class StringLengthRangeAssertionExtensions
+{
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GenerateAssertion(ExpectationMessage = "to have a minimum length of {minLength}")]
+ public static AssertionResult HasMinLength(this string value, int minLength)
+ {
+ return value.Length >= minLength
+ ? AssertionResult.Passed
+ : AssertionResult.Failed($"found length {value.Length}");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GenerateAssertion(ExpectationMessage = "to have a maximum length of {maxLength}")]
+ public static AssertionResult HasMaxLength(this string value, int maxLength)
+ {
+ return value.Length <= maxLength
+ ? AssertionResult.Passed
+ : AssertionResult.Failed($"found length {value.Length}");
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GenerateAssertion(ExpectationMessage = "to have length between {minLength} and {maxLength}")]
+ public static AssertionResult HasLengthBetween(this string value, int minLength, int maxLength)
+ {
+ if (minLength > maxLength)
+ {
+ throw new ArgumentOutOfRangeException(nameof(minLength),
+ $"minLength ({minLength}) must be less than or equal to maxLength ({maxLength}).");
+ }
+
+ return value.Length >= minLength && value.Length <= maxLength
+ ? AssertionResult.Passed
+ : AssertionResult.Failed($"found length {value.Length}");
+ }
+}
diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet10_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet10_0.verified.txt
index 3c92472c75..b897d0c5d6 100644
--- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet10_0.verified.txt
+++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet10_0.verified.txt
@@ -2035,6 +2035,15 @@ namespace .Conditions
protected override .<.> CheckAsync(. metadata) { }
protected override string GetExpectation() { }
}
+ public static class StringLengthRangeAssertionExtensions
+ {
+ [.(ExpectationMessage="to have length between {minLength} and {maxLength}")]
+ public static . HasLengthBetween(this string value, int minLength, int maxLength) { }
+ [.(ExpectationMessage="to have a maximum length of {maxLength}")]
+ public static . HasMaxLength(this string value, int maxLength) { }
+ [.(ExpectationMessage="to have a minimum length of {minLength}")]
+ public static . HasMinLength(this string value, int minLength) { }
+ }
public class StringLengthValueAssertion : .
{
public StringLengthValueAssertion(. stringContext) { }
@@ -5128,6 +5137,12 @@ namespace .Extensions
protected override .<.> CheckAsync(. metadata) { }
protected override string GetExpectation() { }
}
+ public static class StringLengthRangeAssertionExtensions
+ {
+ public static ._HasLengthBetween_Int_Int_Assertion HasLengthBetween(this . source, int minLength, int maxLength, [.("minLength")] string? minLengthExpression = null, [.("maxLength")] string? maxLengthExpression = null) { }
+ public static ._HasMaxLength_Int_Assertion HasMaxLength(this . source, int maxLength, [.("maxLength")] string? maxLengthExpression = null) { }
+ public static ._HasMinLength_Int_Assertion HasMinLength(this . source, int minLength, [.("minLength")] string? minLengthExpression = null) { }
+ }
public static class StringStartsWithAssertionExtensions
{
public static . StartsWith(this . source, string expected, [.("expected")] string? expectedExpression = null) { }
@@ -5140,6 +5155,24 @@ namespace .Extensions
public static . IsNullOrEmpty(this . source) { }
public static . IsNullOrWhiteSpace(this . source) { }
}
+ public sealed class String_HasLengthBetween_Int_Int_Assertion : .
+ {
+ public String_HasLengthBetween_Int_Int_Assertion(. context, int minLength, int maxLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
+ public sealed class String_HasMaxLength_Int_Assertion : .
+ {
+ public String_HasMaxLength_Int_Assertion(. context, int maxLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
+ public sealed class String_HasMinLength_Int_Assertion : .
+ {
+ public String_HasMinLength_Int_Assertion(. context, int minLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
public sealed class String_IsEmpty_Assertion : .
{
public String_IsEmpty_Assertion(. context) { }
diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt
index 2600b47a79..68131a895b 100644
--- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt
+++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt
@@ -2018,6 +2018,15 @@ namespace .Conditions
protected override .<.> CheckAsync(. metadata) { }
protected override string GetExpectation() { }
}
+ public static class StringLengthRangeAssertionExtensions
+ {
+ [.(ExpectationMessage="to have length between {minLength} and {maxLength}")]
+ public static . HasLengthBetween(this string value, int minLength, int maxLength) { }
+ [.(ExpectationMessage="to have a maximum length of {maxLength}")]
+ public static . HasMaxLength(this string value, int maxLength) { }
+ [.(ExpectationMessage="to have a minimum length of {minLength}")]
+ public static . HasMinLength(this string value, int minLength) { }
+ }
public class StringLengthValueAssertion : .
{
public StringLengthValueAssertion(. stringContext) { }
@@ -5068,6 +5077,12 @@ namespace .Extensions
protected override .<.> CheckAsync(. metadata) { }
protected override string GetExpectation() { }
}
+ public static class StringLengthRangeAssertionExtensions
+ {
+ public static ._HasLengthBetween_Int_Int_Assertion HasLengthBetween(this . source, int minLength, int maxLength, [.("minLength")] string? minLengthExpression = null, [.("maxLength")] string? maxLengthExpression = null) { }
+ public static ._HasMaxLength_Int_Assertion HasMaxLength(this . source, int maxLength, [.("maxLength")] string? maxLengthExpression = null) { }
+ public static ._HasMinLength_Int_Assertion HasMinLength(this . source, int minLength, [.("minLength")] string? minLengthExpression = null) { }
+ }
public static class StringStartsWithAssertionExtensions
{
public static . StartsWith(this . source, string expected, [.("expected")] string? expectedExpression = null) { }
@@ -5080,6 +5095,24 @@ namespace .Extensions
public static . IsNullOrEmpty(this . source) { }
public static . IsNullOrWhiteSpace(this . source) { }
}
+ public sealed class String_HasLengthBetween_Int_Int_Assertion : .
+ {
+ public String_HasLengthBetween_Int_Int_Assertion(. context, int minLength, int maxLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
+ public sealed class String_HasMaxLength_Int_Assertion : .
+ {
+ public String_HasMaxLength_Int_Assertion(. context, int maxLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
+ public sealed class String_HasMinLength_Int_Assertion : .
+ {
+ public String_HasMinLength_Int_Assertion(. context, int minLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
public sealed class String_IsEmpty_Assertion : .
{
public String_IsEmpty_Assertion(. context) { }
diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt
index 87b3a330a5..e896d0349d 100644
--- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt
+++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt
@@ -2035,6 +2035,15 @@ namespace .Conditions
protected override .<.> CheckAsync(. metadata) { }
protected override string GetExpectation() { }
}
+ public static class StringLengthRangeAssertionExtensions
+ {
+ [.(ExpectationMessage="to have length between {minLength} and {maxLength}")]
+ public static . HasLengthBetween(this string value, int minLength, int maxLength) { }
+ [.(ExpectationMessage="to have a maximum length of {maxLength}")]
+ public static . HasMaxLength(this string value, int maxLength) { }
+ [.(ExpectationMessage="to have a minimum length of {minLength}")]
+ public static . HasMinLength(this string value, int minLength) { }
+ }
public class StringLengthValueAssertion : .
{
public StringLengthValueAssertion(. stringContext) { }
@@ -5128,6 +5137,12 @@ namespace .Extensions
protected override .<.> CheckAsync(. metadata) { }
protected override string GetExpectation() { }
}
+ public static class StringLengthRangeAssertionExtensions
+ {
+ public static ._HasLengthBetween_Int_Int_Assertion HasLengthBetween(this . source, int minLength, int maxLength, [.("minLength")] string? minLengthExpression = null, [.("maxLength")] string? maxLengthExpression = null) { }
+ public static ._HasMaxLength_Int_Assertion HasMaxLength(this . source, int maxLength, [.("maxLength")] string? maxLengthExpression = null) { }
+ public static ._HasMinLength_Int_Assertion HasMinLength(this . source, int minLength, [.("minLength")] string? minLengthExpression = null) { }
+ }
public static class StringStartsWithAssertionExtensions
{
public static . StartsWith(this . source, string expected, [.("expected")] string? expectedExpression = null) { }
@@ -5140,6 +5155,24 @@ namespace .Extensions
public static . IsNullOrEmpty(this . source) { }
public static . IsNullOrWhiteSpace(this . source) { }
}
+ public sealed class String_HasLengthBetween_Int_Int_Assertion : .
+ {
+ public String_HasLengthBetween_Int_Int_Assertion(. context, int minLength, int maxLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
+ public sealed class String_HasMaxLength_Int_Assertion : .
+ {
+ public String_HasMaxLength_Int_Assertion(. context, int maxLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
+ public sealed class String_HasMinLength_Int_Assertion : .
+ {
+ public String_HasMinLength_Int_Assertion(. context, int minLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
public sealed class String_IsEmpty_Assertion : .
{
public String_IsEmpty_Assertion(. context) { }
diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt
index 1fcf252a29..a88feff098 100644
--- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt
+++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt
@@ -1811,6 +1811,15 @@ namespace .Conditions
protected override .<.> CheckAsync(. metadata) { }
protected override string GetExpectation() { }
}
+ public static class StringLengthRangeAssertionExtensions
+ {
+ [.(ExpectationMessage="to have length between {minLength} and {maxLength}")]
+ public static . HasLengthBetween(this string value, int minLength, int maxLength) { }
+ [.(ExpectationMessage="to have a maximum length of {maxLength}")]
+ public static . HasMaxLength(this string value, int maxLength) { }
+ [.(ExpectationMessage="to have a minimum length of {minLength}")]
+ public static . HasMinLength(this string value, int minLength) { }
+ }
public class StringLengthValueAssertion : .
{
public StringLengthValueAssertion(. stringContext) { }
@@ -4415,6 +4424,12 @@ namespace .Extensions
protected override .<.> CheckAsync(. metadata) { }
protected override string GetExpectation() { }
}
+ public static class StringLengthRangeAssertionExtensions
+ {
+ public static ._HasLengthBetween_Int_Int_Assertion HasLengthBetween(this . source, int minLength, int maxLength, [.("minLength")] string? minLengthExpression = null, [.("maxLength")] string? maxLengthExpression = null) { }
+ public static ._HasMaxLength_Int_Assertion HasMaxLength(this . source, int maxLength, [.("maxLength")] string? maxLengthExpression = null) { }
+ public static ._HasMinLength_Int_Assertion HasMinLength(this . source, int minLength, [.("minLength")] string? minLengthExpression = null) { }
+ }
public static class StringStartsWithAssertionExtensions
{
public static . StartsWith(this . source, string expected, [.("expected")] string? expectedExpression = null) { }
@@ -4427,6 +4442,24 @@ namespace .Extensions
public static . IsNullOrEmpty(this . source) { }
public static . IsNullOrWhiteSpace(this . source) { }
}
+ public sealed class String_HasLengthBetween_Int_Int_Assertion : .
+ {
+ public String_HasLengthBetween_Int_Int_Assertion(. context, int minLength, int maxLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
+ public sealed class String_HasMaxLength_Int_Assertion : .
+ {
+ public String_HasMaxLength_Int_Assertion(. context, int maxLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
+ public sealed class String_HasMinLength_Int_Assertion : .
+ {
+ public String_HasMinLength_Int_Assertion(. context, int minLength) { }
+ protected override .<.> CheckAsync(. metadata) { }
+ protected override string GetExpectation() { }
+ }
public sealed class String_IsEmpty_Assertion : .
{
public String_IsEmpty_Assertion(. context) { }