mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Handle breaking changes
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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}."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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}}*
|
||||
|
||||
Reference in New Issue
Block a user