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
@@ -0,0 +1,71 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

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

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated assertion for HasItem
/// </summary>
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
public sealed class MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T> : Assertion<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver>
{
private static readonly Task<AssertionResult> _passedTask = Task.FromResult(AssertionResult.Passed);

private readonly T _item;

public MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion(AssertionContext<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> context, T item)
: base(context)
{
_item = item;
}

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

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

if (value is null)
{
return Task.FromResult(AssertionResult.Failed("Actual value is null"));
}

var result = value!.HasItem<T>(_item);
return result
? _passedTask
: Task.FromResult(AssertionResult.Failed($"found {value}"));
}

protected override string GetExpectation()
{
return $"to satisfy HasItem({_item})";
}
}

public static partial class MethodOnConcreteNonSealedReceiverExtensions
{
/// <summary>
/// Generated extension method for HasItem
/// </summary>
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
public static MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T> HasItem<T>(this IAssertionSource<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> source, T item, [CallerArgumentExpression(nameof(item))] string? itemExpression = null)
{
source.Context.ExpressionBuilder.Append($".HasItem({itemExpression})");
return new MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T>(source.Context, item);
}

}

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

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

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated assertion for HasItem
/// </summary>
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
public sealed class MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T> : Assertion<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver>
{
private static readonly Task<AssertionResult> _passedTask = Task.FromResult(AssertionResult.Passed);

private readonly T _item;

public MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion(AssertionContext<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> context, T item)
: base(context)
{
_item = item;
}

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

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

if (value is null)
{
return Task.FromResult(AssertionResult.Failed("Actual value is null"));
}

var result = value!.HasItem<T>(_item);
return result
? _passedTask
: Task.FromResult(AssertionResult.Failed($"found {value}"));
}

protected override string GetExpectation()
{
return $"to satisfy HasItem({_item})";
}
}

public static partial class MethodOnConcreteNonSealedReceiverExtensions
{
/// <summary>
/// Generated extension method for HasItem
/// </summary>
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
public static MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T> HasItem<T>(this IAssertionSource<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> source, T item, [CallerArgumentExpression(nameof(item))] string? itemExpression = null)
{
source.Context.ExpressionBuilder.Append($".HasItem({itemExpression})");
return new MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T>(source.Context, item);
}

}

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

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

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated assertion for HasItem
/// </summary>
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
public sealed class MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T> : Assertion<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver>
{
private static readonly Task<AssertionResult> _passedTask = Task.FromResult(AssertionResult.Passed);

private readonly T _item;

public MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion(AssertionContext<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> context, T item)
: base(context)
{
_item = item;
}

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

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

if (value is null)
{
return Task.FromResult(AssertionResult.Failed("Actual value is null"));
}

var result = value!.HasItem<T>(_item);
return result
? _passedTask
: Task.FromResult(AssertionResult.Failed($"found {value}"));
}

protected override string GetExpectation()
{
return $"to satisfy HasItem({_item})";
}
}

public static partial class MethodOnConcreteNonSealedReceiverExtensions
{
/// <summary>
/// Generated extension method for HasItem
/// </summary>
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
public static MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T> HasItem<T>(this IAssertionSource<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> source, T item, [CallerArgumentExpression(nameof(item))] string? itemExpression = null)
{
source.Context.ExpressionBuilder.Append($".HasItem({itemExpression})");
return new MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T>(source.Context, item);
}

}

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

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

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated assertion for HasItem
/// </summary>
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
public sealed class MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T> : Assertion<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver>
{
private static readonly Task<AssertionResult> _passedTask = Task.FromResult(AssertionResult.Passed);

private readonly T _item;

public MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion(AssertionContext<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> context, T item)
: base(context)
{
_item = item;
}

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

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

if (value is null)
{
return Task.FromResult(AssertionResult.Failed("Actual value is null"));
}

var result = value!.HasItem<T>(_item);
return result
? _passedTask
: Task.FromResult(AssertionResult.Failed($"found {value}"));
}

protected override string GetExpectation()
{
return $"to satisfy HasItem({_item})";
}
}

public static partial class MethodOnConcreteNonSealedReceiverExtensions
{
/// <summary>
/// Generated extension method for HasItem
/// </summary>
[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2091", Justification = "Generic type parameter is only used for property access, not instantiation")]
public static MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T> HasItem<T>(this IAssertionSource<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> source, T item, [CallerArgumentExpression(nameof(item))] string? itemExpression = null)
{
source.Context.ExpressionBuilder.Append($".HasItem({itemExpression})");
return new MethodOnConcreteNonSealedReceiver_HasItem_T_Assertion<T>(source.Context, item);
}

}

]
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,27 @@ await Assert.That(mainFile).Contains(
// that a content-only assertion cannot see.
await CompileChecker.AssertNoErrors(generatedFiles);
});

[Test]
public Task MethodOnConcreteNonSealedReceiver() => RunTest(
Path.Combine(Sourcy.Git.RootDirectory.FullName,
"TUnit.Assertions.SourceGenerator.Tests",
"TestData",
"MethodOnConcreteNonSealedReceiver.cs"),
async generatedFiles =>
{
await Assert.That(generatedFiles).Count().IsEqualTo(1);

var mainFile = generatedFiles.First();
await Assert.That(mainFile).IsNotNull();

// The generated extension method must declare a single type parameter (T from the
// source method) and target the exact receiver type. Prepending the covariant
// receiver-type parameter (TActual) for this shape produces a two-type-parameter
// signature that callers cannot satisfy via partial type-argument specification,
// breaking call sites like .HasItem<int>(42) with CS1929.
await Assert.That(mainFile).Contains("HasItem<T>(this IAssertionSource<TUnit.Assertions.Tests.TestData.MethodOnConcreteNonSealedReceiver> source");
await Assert.That(mainFile).DoesNotContain("HasItem<TActual, T>");
await Assert.That(mainFile).DoesNotContain("where TActual :");
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using TUnit.Assertions.Attributes;

namespace TUnit.Assertions.Tests.TestData;

/// <summary>
/// Test case: generic [GenerateAssertion] method on a concrete non-sealed receiver.
/// Generated extension must declare a single type parameter (T) targeting the exact
/// receiver type, not a two-parameter <c>&lt;TActual, T&gt;</c> covariant shape.
/// </summary>
public class MethodOnConcreteNonSealedReceiver
{
}

public static partial class MethodOnConcreteNonSealedReceiverExtensions
{
[GenerateAssertion]
public static bool HasItem<T>(this MethodOnConcreteNonSealedReceiver receiver, T item) => true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public static string BuildAssertion = "MethodAssertionData";

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

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

View workflow job for this annotation

GitHub Actions / integration-tests

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

View workflow job for this annotation

GitHub Actions / modularpipeline (de-DE)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (pl-PL)

Włącz śledzenie wydań analizatora dla projektu analizatora zawierającego regułę „TUNITGEN001” (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (fr-FR)

Activer le suivi de version d'analyseur pour le projet d'analyseur contenant la règle 'TUNITGEN001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (windows-latest)

title: "Method must be static",
messageFormat: "Method '{0}' decorated with [GenerateAssertion] must be static",
category: "TUnit.Assertions.SourceGenerator",
Expand All @@ -29,7 +29,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 32 in TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

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

View workflow job for this annotation

GitHub Actions / modularpipeline (de-DE)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (pl-PL)

Włącz śledzenie wydań analizatora dla projektu analizatora zawierającego regułę „TUNITGEN002” (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (fr-FR)

Activer le suivi de version d'analyseur pour le projet d'analyseur contenant la règle 'TUNITGEN002' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (ubuntu-latest)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (windows-latest)

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 @@ -38,18 +38,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 41 in TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

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

View workflow job for this annotation

GitHub Actions / modularpipeline (de-DE)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (pl-PL)

Włącz śledzenie wydań analizatora dla projektu analizatora zawierającego regułę „TUNITGEN003” (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (fr-FR)

Activer le suivi de version d'analyseur pour le projet d'analyseur contenant la règle 'TUNITGEN003' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (ubuntu-latest)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (windows-latest)

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 43 in 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 43 in TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (de-DE)

Die Diagnosemeldung darf keine Zeilenvorschubzeichen und keine führenden oder nachfolgenden Leerzeichen enthalten und muss entweder einen einzelnen Satz ohne Satzendepunkt oder mehrere Sätze mit Satzendepunkt umfassen.

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

View workflow job for this annotation

GitHub Actions / modularpipeline (pl-PL)

Komunikat dotyczący diagnostyki nie powinien zawierać znaku nowego wiersza ani odstępów na początku i końcu oraz powinien być pojedynczym zdaniem bez kropki na końcu lub wieloma zdaniami z kropkami na końcu

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

View workflow job for this annotation

GitHub Actions / modularpipeline (fr-FR)

Le message du diagnostic ne doit comporter aucun caractère de retour de ligne et aucun espace blanc de début ou de fin, et doit tenir en une seule phrase sans point final ou en plusieurs phrases avec un point final

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

View workflow job for this annotation

GitHub Actions / modularpipeline (ubuntu-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

Check warning on line 43 in 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

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

View workflow job for this annotation

GitHub Actions / modularpipeline (windows-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 50 in TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / integration-tests

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

View workflow job for this annotation

GitHub Actions / modularpipeline (de-DE)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (pl-PL)

Włącz śledzenie wydań analizatora dla projektu analizatora zawierającego regułę „TUNITGEN004” (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (fr-FR)

Activer le suivi de version d'analyseur pour le projet d'analyseur contenant la règle 'TUNITGEN004' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

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

View workflow job for this annotation

GitHub Actions / modularpipeline (windows-latest)

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 52 in 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 52 in TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (de-DE)

Die Diagnosemeldung darf keine Zeilenvorschubzeichen und keine führenden oder nachfolgenden Leerzeichen enthalten und muss entweder einen einzelnen Satz ohne Satzendepunkt oder mehrere Sätze mit Satzendepunkt umfassen.

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

View workflow job for this annotation

GitHub Actions / modularpipeline (pl-PL)

Komunikat dotyczący diagnostyki nie powinien zawierać znaku nowego wiersza ani odstępów na początku i końcu oraz powinien być pojedynczym zdaniem bez kropki na końcu lub wieloma zdaniami z kropkami na końcu

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

View workflow job for this annotation

GitHub Actions / modularpipeline (fr-FR)

Le message du diagnostic ne doit comporter aucun caractère de retour de ligne et aucun espace blanc de début ou de fin, et doit tenir en une seule phrase sans point final ou en plusieurs phrases avec un point final

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

View workflow job for this annotation

GitHub Actions / modularpipeline (ubuntu-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

Check warning on line 52 in 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

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

View workflow job for this annotation

GitHub Actions / modularpipeline (windows-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 @@ -929,7 +929,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!"))

Check warning on line 932 in 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 932 in TUnit.Assertions.SourceGenerator/Generators/MethodAssertionGenerator.cs

View workflow job for this annotation

GitHub Actions / modularpipeline (de-DE)

Dereferenzierung eines möglichen Nullverweises.

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

View workflow job for this annotation

GitHub Actions / modularpipeline (pl-PL)

Wyłuskanie odwołania, które może mieć wartość null.

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

View workflow job for this annotation

GitHub Actions / modularpipeline (fr-FR)

Déréférencement d'une éventuelle référence null.

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

View workflow job for this annotation

GitHub Actions / modularpipeline (ubuntu-latest)

Dereference of a possibly null reference.

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

View workflow job for this annotation

GitHub Actions / modularpipeline (macos-latest)

Dereference of a possibly null reference.

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

View workflow job for this annotation

GitHub Actions / modularpipeline (windows-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 @@ -996,7 +996,14 @@
var targetTypeName = data.TargetType.TypeName;
var methodName = data.Method.Name;
var genericParams = data.Method.GenericTypeParameters;
var isCovariant = data.TargetType.IsCovariantCandidate;
// Suppress receiver-type covariance when the source method has its own type
// parameters. With covariance, the extension prepends a TActual parameter so a
// more-derived static receiver can bind; but the resulting two-parameter signature
// cannot accept a call site that names the method's own type arguments explicitly
// (e.g. `.MyMethod<int>(...)`) because C# does not allow partial type-argument
// specification, so the call fails with CS1929. The dominant call shape supplies
// the method's own arguments; a more-derived static receiver can upcast.
var isCovariant = data.TargetType.IsCovariantCandidate && genericParams.Count == 0;

// Pick a covariant type param name that doesn't collide with existing generic params
var covariantParam = isCovariant ? CovarianceHelper.GetCovariantTypeParamName(genericParams) : null;
Expand Down
Loading
Loading