Handle breaking changes

This commit is contained in:
Tyrrrz
2025-02-02 21:49:30 +02:00
parent c79a8c6502
commit 078ddeaf07
4 changed files with 53 additions and 53 deletions

View File

@@ -13,9 +13,11 @@ using Microsoft.CodeAnalysis.Text;
namespace CliFx.Analyzers.Tests.Utils;
internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer)
: ReferenceTypeAssertions<DiagnosticAnalyzer, AnalyzerAssertions>(analyzer)
internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer, AssertionChain assertionChain)
: ReferenceTypeAssertions<DiagnosticAnalyzer, AnalyzerAssertions>(analyzer, assertionChain)
{
private readonly AssertionChain _assertionChain = assertionChain;
protected override string Identifier => "analyzer";
private Compilation Compile(string sourceCode)
@@ -102,8 +104,8 @@ internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer)
expectedDiagnosticIds.Intersect(producedDiagnosticIds).Count()
== expectedDiagnosticIds.Length;
Execute
.Assertion.ForCondition(isSuccessfulAssertion)
_assertionChain
.ForCondition(isSuccessfulAssertion)
.FailWith(() =>
{
var buffer = new StringBuilder();
@@ -146,8 +148,8 @@ internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer)
var producedDiagnostics = GetProducedDiagnostics(sourceCode);
var isSuccessfulAssertion = !producedDiagnostics.Any();
Execute
.Assertion.ForCondition(isSuccessfulAssertion)
_assertionChain
.ForCondition(isSuccessfulAssertion)
.FailWith(() =>
{
var buffer = new StringBuilder();
@@ -170,5 +172,6 @@ internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer)
internal static class AnalyzerAssertionsExtensions
{
public static AnalyzerAssertions Should(this DiagnosticAnalyzer analyzer) => new(analyzer);
public static AnalyzerAssertions Should(this DiagnosticAnalyzer analyzer) =>
new(analyzer, AssertionChain.GetOrCreate());
}

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using FluentAssertions;
using FluentAssertions.Execution;
using FluentAssertions.Primitives;
namespace CliFx.Tests.Utils.Extensions;
@@ -13,7 +12,7 @@ internal static class AssertionExtensions
params IEnumerable<string> lines
) =>
assertions
.Subject.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)
.Subject.Split(['\n', '\r'], StringSplitOptions.RemoveEmptyEntries)
.Should()
.Equal(lines);
@@ -30,7 +29,7 @@ internal static class AssertionExtensions
if (index < 0)
{
Execute.Assertion.FailWith(
assertions.CurrentAssertionChain.FailWith(
$"Expected string '{assertions.Subject}' to contain '{value}' after position {lastIndex}."
);
}

View File

@@ -6,8 +6,7 @@ namespace CliFx.Utils;
internal static class EnvironmentEx
{
private static readonly Lazy<string?> ProcessPathLazy =
new(() =>
private static readonly Lazy<string?> ProcessPathLazy = new(() =>
{
using var process = Process.GetCurrentProcess();
return process.MainModule?.FileName;

View File

@@ -38,8 +38,7 @@ internal partial class StackFrame
private const string NotSpace = @"[^\x20\t]";
// Taken from https://github.com/atifaziz/StackTraceParser
private static readonly Regex Pattern =
new(
private static readonly Regex Pattern = new(
$$"""
^
{{Space}}*