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 @@ -187,7 +187,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)

return new AssertionExtensionData(
classSymbol.Name,
classSymbol.ContainingNamespace?.ToDisplayString(),
NamespaceHelper.GetNamespaceOrNull(classSymbol.ContainingNamespace),
methodName!,
negatedMethodName,
overloadPriority,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private static AssertionClassModel BuildClassModel(INamedTypeSymbol classSymbol,
return new AssertionClassModel(
classSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat),
classSymbol.Name,
classSymbol.ContainingNamespace?.ToDisplayString(),
NamespaceHelper.GetNamespaceOrNull(classSymbol.ContainingNamespace),
entries.ToImmutableEquatableArray());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ private sealed record ForwardMethod(
}

var compilation = context.SemanticModel.Compilation;
var wrapperOpen = $"global::{target.ContainingNamespace.ToDisplayString()}.{target.Name}";
var wrapperNamespace = NamespaceHelper.GetNamespaceOrNull(target.ContainingNamespace);
var wrapperOpen = wrapperNamespace is null ? $"global::{target.Name}" : $"global::{wrapperNamespace}.{target.Name}";

var shapes = new List<ShapeModel>();
foreach (var row in Rows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public const string BuildAssertionGroup = "MethodAssertionGroup";

private static readonly DiagnosticDescriptor MethodMustBeStaticRule = new DiagnosticDescriptor(
id: "TUNITGEN001",

Check warning on line 26 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 26 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / WASI smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 26 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Browser smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 26 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Android smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 26 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Apple smoke tests

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 26 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / mock AOT

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 26 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)
title: "Method must be static",
messageFormat: "Method '{0}' decorated with [GenerateAssertion] must be static",
category: "TUnit.Assertions.SourceGenerator",
Expand All @@ -32,7 +32,7 @@
description: "Methods decorated with [GenerateAssertion] must be static to be used in generated assertions.");

private static readonly DiagnosticDescriptor MethodMustHaveParametersRule = new DiagnosticDescriptor(
id: "TUNITGEN002",

Check warning on line 35 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN002' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 35 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / WASI smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN002' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 35 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Browser smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN002' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 35 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Android smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN002' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 35 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Apple smoke tests

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN002' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 35 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / mock AOT

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN002' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 35 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN002' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)
title: "Method must have at least one parameter",
messageFormat: "Method '{0}' decorated with [GenerateAssertion] must have at least one parameter (the value to assert)",
category: "TUnit.Assertions.SourceGenerator",
Expand All @@ -41,18 +41,18 @@
description: "Methods decorated with [GenerateAssertion] must have at least one parameter representing the value being asserted.");

private static readonly DiagnosticDescriptor UnsupportedReturnTypeRule = new DiagnosticDescriptor(
id: "TUNITGEN003",

Check warning on line 44 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN003' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 44 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / WASI smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN003' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 44 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Browser smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN003' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 44 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Android smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN003' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 44 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Apple smoke tests

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN003' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 44 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / mock AOT

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN003' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 44 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN003' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)
title: "Unsupported return type",
messageFormat: "Method '{0}' decorated with [GenerateAssertion] has unsupported return type '{1}'. Supported types are: bool, AssertionResult, AssertionResult<T>, Task<bool>, Task<AssertionResult>, Task<AssertionResult<T>>",

Check warning on line 46 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 46 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / WASI smoke test

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 46 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Browser smoke test

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 46 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Android smoke test

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 46 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Apple smoke tests

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 46 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / mock AOT

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 46 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
category: "TUnit.Assertions.SourceGenerator",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
description: "Methods decorated with [GenerateAssertion] must return bool, AssertionResult, Task<bool>, or Task<AssertionResult>.");

private static readonly DiagnosticDescriptor RefStructRequiresInliningRule = new DiagnosticDescriptor(
id: "TUNITGEN004",

Check warning on line 53 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN004' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 53 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / WASI smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN004' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 53 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Browser smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN004' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 53 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Android smoke test

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN004' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 53 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Apple smoke tests

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN004' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

Check warning on line 53 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / mock AOT

Enable analyzer release tracking for the analyzer project containing rule 'TUNITGEN004' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)
title: "Ref struct parameter requires method body inlining",
messageFormat: "Method '{0}' has ref struct parameter '{1}' of type '{2}'. Use InlineMethodBody = true and ensure the method has a single-expression or single-return-statement body",

Check warning on line 55 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 55 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / WASI smoke test

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 55 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Browser smoke test

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 55 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Android smoke test

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 55 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Apple smoke tests

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 55 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / mock AOT

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period

Check warning on line 55 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
category: "TUnit.Assertions.SourceGenerator",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
Expand Down Expand Up @@ -355,7 +355,7 @@
containingTypeData = new ContainingTypeData(
methodSymbol.ContainingType.Name,
methodSymbol.ContainingType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat),
methodSymbol.ContainingType.ContainingNamespace.ToDisplayString()
NamespaceHelper.GetNamespaceOrNull(methodSymbol.ContainingType.ContainingNamespace)
);
}

Expand Down Expand Up @@ -953,7 +953,7 @@
// Add null-forgiving operator for reference types if not already present
// This is safe because we've already checked for null above
var isNullable = data.TargetType.IsNullable;
if (isNullable && !string.IsNullOrEmpty(inlinedBody) && !inlinedBody.StartsWith("value!", StringComparison.Ordinal))

Check warning on line 956 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

Dereference of a possibly null reference.

Check warning on line 956 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / WASI smoke test

Dereference of a possibly null reference.

Check warning on line 956 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Browser smoke test

Dereference of a possibly null reference.

Check warning on line 956 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Android smoke test

Dereference of a possibly null reference.

Check warning on line 956 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / Apple smoke tests

Dereference of a possibly null reference.

Check warning on line 956 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / nuget-package-tests-windows

Dereference of a possibly null reference.

Check warning on line 956 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / mock AOT

Dereference of a possibly null reference.

Check warning on line 956 in src/TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

Dereference of a possibly null reference.
{
// Replace null-conditional operators with null-forgiving + regular operators
// value?.Member becomes value!.Member (safe because we already null-checked)
Expand Down Expand Up @@ -1468,7 +1468,7 @@
private record ContainingTypeData(
string Name,
string FullContainingType,
string ContainingNamespace
string? ContainingNamespace
);

private record struct TargetTypeData(string TypeName, string SimpleTypeName, bool IsNullable, bool IsCovariantCandidate, string ConstraintTypeName);
Expand Down
14 changes: 14 additions & 0 deletions src/TUnit.Assertions.SourceGenerator/Generators/NamespaceHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.CodeAnalysis;

namespace TUnit.Assertions.SourceGenerator.Generators;

internal static class NamespaceHelper
{
/// <summary>
/// Returns the display name of <paramref name="namespaceSymbol"/>, or <see langword="null"/> for the global
/// namespace. The global namespace displays as <c>&lt;global namespace&gt;</c>, which is not valid in a
/// <c>using</c> directive or a qualified type name (#7133).
/// </summary>
public static string? GetNamespaceOrNull(INamespaceSymbol? namespaceSymbol)
=> namespaceSymbol is { IsGlobalNamespace: false } ? namespaceSymbol.ToDisplayString() : null;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using TUnit.Assertions.Core;
using TUnit.Assertions.Enums;

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated extension methods for GlobalStringIsEmptyAssertion.
/// </summary>
public static partial class GlobalStringIsEmptyAssertionExtensions
{

/// <summary>
/// Extension method for GlobalStringIsEmptyAssertion.
/// </summary>
public static GlobalStringIsEmptyAssertion IsEmptyGlobal(this IAssertionSource<string> source)
{
source.Context.ExpressionBuilder.Append(".IsEmptyGlobal("); source.Context.ExpressionBuilder.Append(")");
return new GlobalStringIsEmptyAssertion(source.Context);
}
}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using TUnit.Assertions.Core;
using TUnit.Assertions.Enums;

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated extension methods for GlobalStringIsEmptyAssertion.
/// </summary>
public static partial class GlobalStringIsEmptyAssertionExtensions
{

/// <summary>
/// Extension method for GlobalStringIsEmptyAssertion.
/// </summary>
public static GlobalStringIsEmptyAssertion IsEmptyGlobal(this IAssertionSource<string> source)
{
source.Context.ExpressionBuilder.Append(".IsEmptyGlobal("); source.Context.ExpressionBuilder.Append(")");
return new GlobalStringIsEmptyAssertion(source.Context);
}
}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using TUnit.Assertions.Core;
using TUnit.Assertions.Enums;

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated extension methods for GlobalStringIsEmptyAssertion.
/// </summary>
public static partial class GlobalStringIsEmptyAssertionExtensions
{

/// <summary>
/// Extension method for GlobalStringIsEmptyAssertion.
/// </summary>
public static GlobalStringIsEmptyAssertion IsEmptyGlobal(this IAssertionSource<string> source)
{
source.Context.ExpressionBuilder.Append(".IsEmptyGlobal("); source.Context.ExpressionBuilder.Append(")");
return new GlobalStringIsEmptyAssertion(source.Context);
}
}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using TUnit.Assertions.Core;
using TUnit.Assertions.Enums;

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated extension methods for GlobalStringIsEmptyAssertion.
/// </summary>
public static partial class GlobalStringIsEmptyAssertionExtensions
{

/// <summary>
/// Extension method for GlobalStringIsEmptyAssertion.
/// </summary>
public static GlobalStringIsEmptyAssertion IsEmptyGlobal(this IAssertionSource<string> source)
{
source.Context.ExpressionBuilder.Append(".IsEmptyGlobal("); source.Context.ExpressionBuilder.Append(")");
return new GlobalStringIsEmptyAssertion(source.Context);
}
}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using TUnit.Assertions.Core;

namespace TUnit.Assertions.Extensions;

public class StringIsNullOrEmptyWithStringAssertion : Assertion<string>
{
private readonly bool _negated;

public StringIsNullOrEmptyWithStringAssertion(AssertionContext<string> context, bool negated = false)
: base(context)
{
_negated = negated;
}

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<string> metadata)
{
var actualValue = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return Task.FromResult(AssertionResult.Failed($"threw {exception.GetType().FullName}"));
}

var result = string.IsNullOrEmpty(actualValue);
var condition = _negated ? result : !result;
return Task.FromResult(AssertionResult.FailIf(condition, $"'{actualValue}' was expected {(_negated ? "not " : "")}to satisfy IsNullOrEmpty"));
}

protected override string GetExpectation()
{
return $"{(_negated ? "not " : "")} be null or empty";
}
}

public static partial class GlobalStringAssertions
{
public static StringIsNullOrEmptyWithStringAssertion IsBlankGlobal(this IAssertionSource<string> source)
{
source.Context.ExpressionBuilder.Append(".IsBlankGlobal()");
return new StringIsNullOrEmptyWithStringAssertion(source.Context, false);
}

}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using TUnit.Assertions.Core;

namespace TUnit.Assertions.Extensions;

public class StringIsNullOrEmptyWithStringAssertion : Assertion<string>
{
private readonly bool _negated;

public StringIsNullOrEmptyWithStringAssertion(AssertionContext<string> context, bool negated = false)
: base(context)
{
_negated = negated;
}

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<string> metadata)
{
var actualValue = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return Task.FromResult(AssertionResult.Failed($"threw {exception.GetType().FullName}"));
}

var result = string.IsNullOrEmpty(actualValue);
var condition = _negated ? result : !result;
return Task.FromResult(AssertionResult.FailIf(condition, $"'{actualValue}' was expected {(_negated ? "not " : "")}to satisfy IsNullOrEmpty"));
}

protected override string GetExpectation()
{
return $"{(_negated ? "not " : "")} be null or empty";
}
}

public static partial class GlobalStringAssertions
{
public static StringIsNullOrEmptyWithStringAssertion IsBlankGlobal(this IAssertionSource<string> source)
{
source.Context.ExpressionBuilder.Append(".IsBlankGlobal()");
return new StringIsNullOrEmptyWithStringAssertion(source.Context, false);
}

}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using TUnit.Assertions.Core;

namespace TUnit.Assertions.Extensions;

public class StringIsNullOrEmptyWithStringAssertion : Assertion<string>
{
private readonly bool _negated;

public StringIsNullOrEmptyWithStringAssertion(AssertionContext<string> context, bool negated = false)
: base(context)
{
_negated = negated;
}

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<string> metadata)
{
var actualValue = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return Task.FromResult(AssertionResult.Failed($"threw {exception.GetType().FullName}"));
}

var result = string.IsNullOrEmpty(actualValue);
var condition = _negated ? result : !result;
return Task.FromResult(AssertionResult.FailIf(condition, $"'{actualValue}' was expected {(_negated ? "not " : "")}to satisfy IsNullOrEmpty"));
}

protected override string GetExpectation()
{
return $"{(_negated ? "not " : "")} be null or empty";
}
}

public static partial class GlobalStringAssertions
{
public static StringIsNullOrEmptyWithStringAssertion IsBlankGlobal(this IAssertionSource<string> source)
{
source.Context.ExpressionBuilder.Append(".IsBlankGlobal()");
return new StringIsNullOrEmptyWithStringAssertion(source.Context, false);
}

}

]
Loading
Loading