fluentassertions / fluentassertions.analyzers Goto Github PK
View Code? Open in Web Editor NEWAnalyzers based on the FluentAssertions best practices docs
Home Page: https://www.fluentassertions.com/tips
License: MIT License
Analyzers based on the FluentAssertions best practices docs
Home Page: https://www.fluentassertions.com/tips
License: MIT License
When using a simple EBF (expression based function) the analyzers crash in Visual Studio 15.7.3.
To reproduce:
FluentAssertions.Analyzers 0.10.0
.public class TestClass
{
private SomeClass CreateSomeClass() => new SomeClass();
public class SomeClass
{ }
}
Expected:
No errors.
Actual:
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountLessOrEqualToAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountGreaterOrEqualToAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldNotBeNullOrEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotBeEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldEqualOtherCollectionByComparerAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotHaveCountAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldBeInAscendingOrderAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountGreaterThanAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotContainItemAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldContainPropertyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldBeInDescendingOrderAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountLessThanAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldOnlyHaveUniqueItemsByComparerAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldOnlyContainPropertyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldOnlyHaveUniqueItemsAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.NumericShouldBeApproximatelyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveSameCountAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotIntersectWithAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldBeNullOrWhiteSpaceAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotContainPropertyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldContainSingleAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldEndWithAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldBeEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldStartWithAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldBeNullOrEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldContainItemAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveElementAtAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldIntersectWithAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotBeNullOrEmptyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotContainNullsAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldNotHaveSameCountAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldHaveLengthAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
1>CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.StringShouldNotBeNullOrWhiteSpaceAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
When applying the codefix for CollectionShouldNotContainProperty
, the comparison inside the lambda should also be negated.
actual.Should().OnlyContain(x => x.OtherProperty == expectedValue); // before
actual.Should().NotContain(x => x.OtherProperty == expectedValue); // after
Use of actual.Should().Equals(expected)
(which is not an assertion at all) is perhaps the single most serious recurrent error I tend to see with FluentAssertions use. Would an analyzer to detect this construct fit with the goals for this project?
N.B.: To be honest, the fact that there isn't already an analyzer for this (or apparently even an existing issue requesting its addition) strikes me as sufficiently odd that I'm wondering if I'm missing some other mechanism that would detect this problem. If such a beastie does exist, an analyzer would presumably be unnecessary, but a documentation update to increase its visibility might be helpful...
The rules CollectionShouldContainSingleAnalyzer
and CollectionShouldBeEmptyAnalyzer
throws InvalidOperationException
with message This operation does not apply to an empty instance
.
For some weird reason, the stack trace disappear every time I try to expand the issue, this one is the only one which remains:
Severity Code Description Project File Line Category Suppression State Tool Detail Description
Warning AD0001 Analyzer 'FluentAssertions.Analyzers.CollectionShouldContainSingleAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'This operation does not apply to an empty instance.'. SonarScanner.MSBuild.PreProcessor.Tests 1 Compiler Active FluentAssertions.Analyzers Analyzer 'FluentAssertions.Analyzers.CollectionShouldContainSingleAnalyzer' threw the following exception:
'Exception occurred with following context:
Compilation: SonarScanner.MSBuild.PreProcessor.Tests
ISymbol: GetActiveRules_UseParamAsKey (Method)
SyntaxTree: C:\Src\SonarSource\scanner-msbuild\tests\SonarScanner.MSBuild.PreProcessor.Tests\SonarWebServiceTest.cs
SyntaxNode: [TestMethod] public void GetActiveRules_UseParamAsKey ... [MethodDeclarationSyntax]@[12810..14357) (264,8)-(305,9)
System.InvalidOperationException: This operation does not apply to an empty instance.
at System.Collections.Immutable.ImmutableStack`1.Peek()
at FluentAssertions.Analyzers.FluentAssertionsCSharpSyntaxVisitor.VisitElementAccessExpression(ElementAccessExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.ElementAccessExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.Analyzers.FluentAssertionsCSharpSyntaxVisitor.VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.Analyzers.FluentAssertionsCSharpSyntaxVisitor.VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.Analyzers.FluentAssertionsCSharpSyntaxVisitor.VisitInvocationExpression(InvocationExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.Analyzers.FluentAssertionsCSharpSyntaxVisitor.VisitMemberAccessExpression(MemberAccessExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.Analyzers.FluentAssertionsCSharpSyntaxVisitor.VisitInvocationExpression(InvocationExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at FluentAssertions.Analyzers.FluentAssertionsAnalyzer`1.AnalyzeExpression(ExpressionSyntax expression, SemanticModel semanticModel)
at FluentAssertions.Analyzers.FluentAssertionsAnalyzer`1.AnalyzeCodeBlock(CodeBlockAnalysisContext context)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__49`2.<ExecuteBlockActions>b__49_0(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
-----
'.
My test project contains quite a lot of tests so it's quite hard to narrow down to the one failing but I hope that the stacktrace will help you understanding the failure.
Seems to be related to #78
for example:
public class MyCustomException : Exception
{
public string MyCustomProperty { get; }
public MyCustomException(string myCustomProperty)
{
MyCustomProperty = MyCustomProperty;
}
}
when hovering over the property MyCustomProperty
I would like to have a suggestion to generate an assertion for that property.
The generated assertion will something like this:
public static class MyCustomExceptionExtensions
{
public static ExceptionAssertions<TException> WithMyCustomProperty<TException>(this ExceptionAssertions<TException> assertions,
string expectedMyCustomProperty, string because = "", params object[] becauseArgs) where TException : MyCustomException
{
Execute.Assertion
.ForCondition(assertions.And.MyCustomProperty.Equals(expectedMyCustomProperty))
.BecauseOf(because, becauseArgs)
.FailWith("Expected exception with MyCustomProperty {0}{reason}, but found {1}.", assertions.And.MyCustomProperty, expectedMyCustomProperty);
return assertions;
}
}
I have a custom dictionary that has a method with the signature: public bool ContainsKey(TKey1 key1, TKey2 key2)
.
This incorrectly triggers DictionaryShouldContainsKey
.
class MyDict<TKey, TValue>
{
public bool ContainsKey(TKey key) => false;
}
var dict = new MyDict<int, string>();
dict.ContainsKey(0).Should().BeTrue();
is transformed into
dict.Should().ContainKey(0);
As dict
is not a Dictionary
, Should()
returns an ObjectAssertions
which does not have the ContainKey()
assertion.
class MyDict2<TKey1, TKey2, TValue> : Dictionary<TKey1, TValue>
{
public bool ContainsKey(TKey1 key1, TKey2 key2) => false;
}
var dict2 = new MyDict2<int, int, string>();
dict2.ContainsKey(0, 0).Should().BeTrue();
is
var dict2 = new MyDict2<int, int, string>();
dict2.Should().ContainKey(0, 0);
but there is no such ContainKey(0, 0)
on GenericDictionaryAssertions
The analyzer should not be triggered.
The analyzer was triggered
Fluent Assertions Analyzers 0.11.2
.NET framework 4.6.1
This is really just a nice to have.
list.Count().Should().Be(0);
list.Count().Should().Be(1);
are correctly simplified into:
list.Should().HaveCount(0);
list.Should().HaveCount(1);
It would be nice, if they could be simplified directly into the ContainSingle
and BeEmpty
instead.
list.Should().ContainSingle();
list.Should().BeEmpty();
If I run the analyzers on this code:
public class TestClass
{
public static void Main()
{
System.Console.WriteLine();
}
}
A null-reference exception is thrown.
Nice project!
I've attached a project with failing tests for all the before and after examples I listed in the Fluent Assertions docs.
UnitTests2.zip
Analyzer suggests to use an assertion that does not exist.
using System.Xml;
using FluentAssertions;
namespace Foo
{
class Bar
{
void Baz()
{
XmlNodeList childNodes = new XmlDocument().ChildNodes;
childNodes.Should().HaveCount(1);
// childNodes.Should().ContainSingle();
}
}
}
FluentAssetions 0.11.4
.NET 4.5
// cloudEvent.Time is Nullable<DateTime>
(cloudEvent.Time?.ToUniversalTime()).Should().Be(cloudEvent2.Time?.ToUniversalTime());
This code will get a NullConditionalAssertion warning.
But
var x = cloudEvent.Time?.ToUniversalTime();
x.Should().Be(cloudEvent2.Time?.ToUniversalTime());
has no warning.
Is it a bug of the analyzer?
If not, how should I fix my code?
When including the analyzer in my project I get 44 build warnings about a null reference exception:
CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldOnlyHaveUniqueItemsAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [C:\...\UnitTests.csproj]
I've narrowed it down to the following code that causes the issue:
public class TestClass
{
private static string StaticResult { get; set; }
public static void Main()
{
StaticResult = nameof(Main);
}
}
No warning is generated by the analyzer during the build
Multiple warnings are generated during the build
FluentAssertions Version 5.4.1
FluentAssertions.Analyzers Version 0.11.0
.NET Core 2.0
I've been able to reproduce this in a unit test so will submit a PR shortly (this issue is so I can reference it in the PR)
When installing the NuGet-package using paket, an IOException is thrown:
Paket failed with
-> Error during extraction of D:\projects\...\packages\FluentAssertions.Analyzers\fluentassertions.analyzers.0.11.4.nupkg.
In rare cases a firewall might have blocked the download. Please look into the file and see if it contains text with further information.
-> IOException: Die Datei "D:\projects\...\packages\FluentAssertions.Analyzers\analyzers\dotnet\cs\FluentAssertions.Analyzers.dll" ist bereits vorhanden.
The package should be installed like using any other package manager
An IOException (see above) is thrown and the package cannot be installed.
When inspecting the pacakge I noticed that there are two files with the same name conatined in the same folder.
based on @jnyrup's comment fluentassertions/fluentassertions#873 (comment)
An analyzer for fluentassertions/fluentassertions#711
should cover both cases of NotThrow
& Throw
The CollectionShouldNotContainProperty
is triggered when the assertions already seems idiomatic.
An example is when the expression inside OnlyContain
contains no negations.
var list = new[] { "" };
list.Should().OnlyContain(e => e.Contains(""));
The analyzer should not be triggered, as the assertion is already idiomatic.
The analyzer is triggered.
Fluent Assertions Analyzers 0.11.2
.NET Framework 4.6.1
The default Roslyn analyzer template allows one to run the analyzer in a Visual Studio Debug instance, which makes debugging your analyzers incredibly easy. This project does not have Visual Studio debug integration, any specific reason why?
Should the reason be that it is Visual Studio specific, maybe an option would be to add a second solution that includes the Visual Studio debugging support project.
The analyzer reports this piece of code:
Dictionary<string, object> dict = new Dictionary<string, object>();
dict.Should().HaveCount(1);
and wants me to convert it to .Should().ContainSingle()
but this is not supported for the Dictionary
type.
In some of my projects I get the following error when building:
CSC : warning AD0001: Analyzer 'FluentAssertions.Analyzers.CollectionShouldHaveCountAnalyzer' threw an exception of type 'System.InvalidOperationException' with message 'This operation does not apply to an empty instance.'.
My guess is that the following IsEmpty
check should happen before Peek()
:
If you need me to provide more information, let me know how and I will see what I can do.
I'm using FluentAssertions version 5.4.0 and FluentAssertions.Analyzers version 0.10.1. When I create a test that asserts the values in dictionaries, the analyzer incorrectly suggests I use HaveElementAt
which doesn't compile, i.e. given this code:
[Fact]
public void DictionaryTest()
{
var dictionary = new Dictionary<string, int> { ["123"] = 123 };
dictionary["123"].Should().Be(123);
}
The analyzer incorrectly suggests:
[Fact]
public void DictionaryTest()
{
var dictionary = new Dictionary<string, int> { ["123"] = 123 };
dictionary.Should().HaveElementAt("123", 123);
}
Perhaps it could suggest (though it's not simplifying but is more idiomatic):
dictionary.Should().ContainKey("123").WhichValue.Should().Be(123);
Happy to take a stab at a PR
This will improve the stacktrace of failing tests and much more
When using the Count method with a predicate overload the predicate is not taken into account.
list.Count(e => e > 1).Should().Be(2);
is simplified into:
list.Should().HaveCount(2);
AnalyzeCodeBlock
throws an exception for expression bodied members.
I guess an expression bodied member does not have Body
but only an ExpressionBody
?
When trying to run tests, I can see that some of them failed. Is it expected?
dotnet test
in src
directory results in
Test Run Failed.
Total tests: 1148
Passed: 1132
Failed: 13
Skipped: 3
Total time: 11,1403 Seconds
I would expect tests to be green.
.NET Core 2.0.
actual.Select(x => x.SomeProperty).Should().OnlyHaveUniqueItems(); // before
FluentAssertions.BestPractices.FluentAssertionsDiagnosticProperties.Should().OnlyHaveUniqueItems(x => x.SomeProperty) // after
When a class implements IDictionary
and a custom ContainsKey(TKey1, TKey2)
, the analyzer does not distinguish between IDictionary.ContainsKey(TKey)
and ContainsKey(TKey1, TKey2)
.
Related to #65
public class MultiKeyDict<TKey1, TKey2, TValue>
: Dictionary<TKey1, Dictionary<TKey2, TValue>>
{
public bool ContainsKey(TKey1 key1, TKey2 key2) => false;
}
[TestMethod]
public void MyTestMethod()
{
var dict = new MultiKeyDict<int, int, string>();
dict.ContainsKey(0, 1).Should().BeTrue();
}
No analyzer should be triggered.
DictionaryShouldContainsKey
is suggested, but is not applicable as GenericDictionaryAssertions<TKey, TValue>
does not implement ContainKey(TKey1, TKey2)
.
following fluentassertions/fluentassertions#684 the repository is being renamed from fluentassertions.bestpractices
to fluentassertions.analyzers
actual.Should().ContainValue(pair.Value).And.ContainKey(otherPair.Key);
triggers the analyzer DictionaryShouldContainPairAnalyzer
and the codefix DictionaryShouldContainPairCodeFix
it should only trigger if both Key
and Value
are properties of the same variable
The tests FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix
fail on my environment running with Test Explorer and ReSharper in Visual Studio 15.7.3.
If needed I can provide more information.
Stack traces:
Test Name: NumericShouldBeInRange_TestCodeFix
Test FullName: FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix
Test Source: C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs : line 65
Test Outcome: Failed
Test Duration: 0:02:01.8116214
Result1 Name:
old: "actual.Should().BeGreaterOrEqualTo(lower).And.BeLessOrEqualTo(upper);"
new: "actual.Should().BeInRange(lower, upper);"
Result1 Outcome: Failed
Result1 Duration: 0:01:50.3334727
Result1 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result1 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result1 StandardOutput:
Result1 StandardError:
Result2 Name:
old: "actual.Should().BeGreaterOrEqualTo(lower).And.BeLessOrEqualTo(upper);"
new: "actual.Should().BeInRange(lower, upper);"
Result2 Outcome: Failed
Result2 Duration: 0:00:00.8277047
Result2 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result2 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result2 StandardOutput:
Result2 StandardError:
Result3 Name:
old: "actual.Should().BeGreaterOrEqualTo(lower).And.BeLessOrEqualTo(upper, "because it's possible");"
new: "actual.Should().BeInRange(lower, upper, "because it's possible");"
Result3 Outcome: Failed
Result3 Duration: 0:00:00.8592891
Result3 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result3 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result3 StandardOutput:
Result3 StandardError:
Result4 Name:
old: "actual.Should().BeGreaterOrEqualTo(lower).And.BeLessOrEqualTo(upper, "because message with {0} placeholders {1} at {2}", 3, "is awesome", DateTime.Now.Add(2.Seconds()));"
new: "actual.Should().BeInRange(lower, upper, "because message with {0} placeholders {1} at {2}", 3, "is awesome", DateTime.Now.Add(2.Seconds()));"
Result4 Outcome: Failed
Result4 Duration: 0:00:00.8328375
Result4 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result4 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result4 StandardOutput:
Result4 StandardError:
Result5 Name:
old: "actual.Should().BeGreaterOrEqualTo(lower, "because it's possible").And.BeLessOrEqualTo(upper);"
new: "actual.Should().BeInRange(lower, upper, "because it's possible");"
Result5 Outcome: Failed
Result5 Duration: 0:00:00.9558045
Result5 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result5 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result5 StandardOutput:
Result5 StandardError:
Result6 Name:
old: "actual.Should().BeGreaterOrEqualTo(lower, "because message with {0} placeholders {1} at {2}", 3, "is awesome", DateTime.Now.Add(2.Seconds())).And.BeLessOrEqualTo(upper);"
new: "actual.Should().BeInRange(lower, upper, "because message with {0} placeholders {1} at {2}", 3, "is awesome", DateTime.Now.Add(2.Seconds()));"
Result6 Outcome: Failed
Result6 Duration: 0:00:00.8882536
Result6 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result6 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result6 StandardOutput:
Result6 StandardError:
Result7 Name:
old: "actual.Should().BeLessOrEqualTo(upper).And.BeGreaterOrEqualTo(lower);"
new: "actual.Should().BeInRange(lower, upper);"
Result7 Outcome: Failed
Result7 Duration: 0:00:00.8569277
Result7 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result7 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result7 StandardOutput:
Result7 StandardError:
Result8 Name:
old: "actual.Should().BeLessOrEqualTo(upper).And.BeGreaterOrEqualTo(lower);"
new: "actual.Should().BeInRange(lower, upper);"
Result8 Outcome: Failed
Result8 Duration: 0:00:01.8561607
Result8 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result8 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result8 StandardOutput:
Result8 StandardError:
Result9 Name:
old: "actual.Should().BeLessOrEqualTo(upper).And.BeGreaterOrEqualTo(lower, "because it's possible");"
new: "actual.Should().BeInRange(lower, upper, "because it's possible");"
Result9 Outcome: Failed
Result9 Duration: 0:00:01.3581949
Result9 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result9 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result9 StandardOutput:
Result9 StandardError:
Result10 Name:
old: "actual.Should().BeLessOrEqualTo(upper).And.BeGreaterOrEqualTo(lower, "because message with {0} placeholders {1} at {2}", 3, "is awesome", DateTime.Now.Add(2.Seconds()));"
new: "actual.Should().BeInRange(lower, upper, "because message with {0} placeholders {1} at {2}", 3, "is awesome", DateTime.Now.Add(2.Seconds()));"
Result10 Outcome: Failed
Result10 Duration: 0:00:01.3221536
Result10 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result10 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result10 StandardOutput:
Result10 StandardError:
Result11 Name:
old: "actual.Should().BeLessOrEqualTo(upper, "because it's possible").And.BeGreaterOrEqualTo(lower);"
new: "actual.Should().BeInRange(lower, upper, "because it's possible");"
Result11 Outcome: Failed
Result11 Duration: 0:00:00.8878991
Result11 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result11 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result11 StandardOutput:
Result11 StandardError:
Result12 Name:
old: "actual.Should().BeLessOrEqualTo(upper, "because message with {0} placeholders {1} at {2}", 3, "is awesome", DateTime.Now.Add(2.Seconds())).And.BeGreaterOrEqualTo(lower);"
new: "actual.Should().BeInRange(lower, upper, "because message with {0} placeholders {1} at {2}", 3, "is awesome", DateTime.Now.Add(2.Seconds()));"
Result12 Outcome: Failed
Result12 Duration: 0:00:00.8329233
Result12 StackTrace:
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression, NodeReplacement replacement) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 81
at FluentAssertions.Analyzers.NumericShouldBeApproximatelyCodeFix.GetNewExpression(ExpressionSyntax expression, FluentAssertionsDiagnosticProperties properties) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Tips\Numerics\NumericShouldBeApproximately.cs:line 60
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.<RewriteAssertion>d__3.MoveNext() in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers\Utilities\FluentAssertionsCodeFixProvider.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetChangedSolutionAsync>d__21.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 144
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__18.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<ComputeOperationsAsync>d__19.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 125
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsCoreAsync>d__16.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 83
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.CodeActions.CodeAction.<GetOperationsAsync>d__15.MoveNext() in /_/src/Workspaces/Core/Portable/CodeActions/CodeAction.cs:line 74
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.ApplyFix(Document document, CodeAction codeAction) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 166
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyFix(String language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 128
at FluentAssertions.Analyzers.Tests.DiagnosticVerifier.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSource, String newSource, Nullable`1 codeFixIndex, Boolean allowNewCompilerDiagnostics) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\DiagnosticVerifier.cs:line 82
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.VerifyCSharpFix[TCodeFixProvider,TDiagnosticAnalyzer](String oldSourceAssertion, String newSourceAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 106
at FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix(String oldAssertion, String newAssertion) in C:\Users\ZZZ\Documents\GitHub\fluentassertions.analyzers\src\FluentAssertions.Analyzers.Tests\Tips\NumericTests.cs:line 65
Result12 Message:
Test method FluentAssertions.Analyzers.Tests.Tips.NumericTests.NumericShouldBeInRange_TestCodeFix threw exception:
System.AggregateException: One or more errors occurred. (should not get here) ---> System.InvalidOperationException: should not get here
Result12 StandardOutput:
Result12 StandardError:
Given a class like MyClass
class MyClass
{
public string MyProperty { get; set; }
}
The following tests all pass because they use a conditional operator before Should()
.
public void MyTestMethod0()
{
var myClass = new MyClass();
myClass.MyProperty?.Should().Be("foo");
}
[TestMethod]
public void MyTestMethod1()
{
MyClass myClass = null;
myClass?.MyProperty.Should().Be("foo");
}
[TestMethod]
public void MyTestMethod2()
{
var myClass = new MyClass();
myClass.MyProperty?[0].Should().Be('f');
}
[TestMethod]
public void MyTestMethod3()
{
MyClass myClass = null;
myClass?.MyProperty[0].Should().Be('f');
}
It would be nice if the analyzer from #22 could be extended to support these cases too.
I really really like that analyzer as it not only improves the assertions but catches bugs.
Awesome job!
I get several exceptions in the error list:
The stack traces seems to be identical for all of them, see below for one of them.
A lot of the analyzers mentioned in the stack traces don't seem to apply for my test method?
I haven't been able to come up with an example that triggers the bug.
Any ideas?
Severity Code Description Project File Line Suppression State Detail Description
Warning AD0001 Analyzer 'FluentAssertions.BestPractices.CollectionShouldEqualOtherCollectionByComparerAnalyzer' threw an exception of type 'System.ArgumentException' with message 'An item with the same key has already been added.'. CIUnitTests 1 Active Analyzer 'FluentAssertions.BestPractices.CollectionShouldEqualOtherCollectionByComparerAnalyzer' threw the following exception:
'Exception occurred with following context:
Compilation: CIUnitTests
ISymbol: MyTest (Method)
SyntaxTree: C:\Test.cs
SyntaxNode: [TestMethod] public void MyTest ... [MethodDeclarationSyntax]@[8641..10638) (200,8)-(232,9)
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at FluentAssertions.BestPractices.FluentAssertionsWithArgumentsCSharpSyntaxVisitor.VisitArguments(SeparatedSyntaxList`1 arguments)
at FluentAssertions.BestPractices.FluentAssertionsWithArgumentsCSharpSyntaxVisitor.VisitArgumentList(ArgumentListSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentListSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.BestPractices.FluentAssertionsCSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.BestPractices.FluentAssertionsCSharpSyntaxVisitor.VisitInvocationExpression(InvocationExpressionSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.BestPractices.FluentAssertionsCSharpSyntaxVisitor.Visit(SyntaxNode node)
at FluentAssertions.BestPractices.FluentAssertionsCSharpSyntaxVisitor.VisitExpressionStatement(ExpressionStatementSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax.Accept(CSharpSyntaxVisitor visitor)
at FluentAssertions.BestPractices.FluentAssertionsAnalyzer`1.AnalyzeExpressionStatement(ExpressionStatementSyntax statement)
at FluentAssertions.BestPractices.FluentAssertionsAnalyzer`1.AnalyzeCodeBlock(CodeBlockAnalysisContext context)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__48`2.<ExecuteBlockActions>b__48_0(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
-----
'.
CollectionShouldOnlyHaveUniqueItemsByComparer
is triggered by this code
var list = new[] { 1, 2, 3 };
list.Select(e => e.ToString())
.Where(e => e != "")
.Should()
.OnlyHaveUniqueItems();
Which turns it into this invalid code, as the Where
now tries to compare an int
to a string
.
var list = new[] { 1, 2, 3 };
list.Where(e => e != "")
.Should()
.OnlyHaveUniqueItems(e => e.ToString());
The analyzer should not be triggered.
The analyzer is triggered.
Fluent Assertions Analyzers 0.11.2
.NET Framework 4.6.1
Why don't we target latest framework versions?
Is it possible to use this package in netcore3.1 assembly?
I suspect this might be related to the other issue about the syntax tree?
public class MyClass
{
public string Message { get; }
}
var list = new List<MyClass>();
list[0].Message.Should().Be(""); // throws exception
System.InvalidCastException : Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.ElementAccessExpressionSyntax'.
at FluentAssertions.Analyzers.NodeReplacement.RemoveAndRetrieveIndexerArgumentsNodeReplacement.ComputeNew(LinkedListNode`1 listNode)
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewStatement(ExpressionStatementSyntax statement,NodeReplacement replacement)
at FluentAssertions.Analyzers.CollectionShouldHaveElementAtCodeFix.GetNewStatement(ExpressionStatementSyntax statement,FluentAssertionsDiagnosticProperties properties)
at async FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.RewriteAssertion(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputePreviewOperationsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
If I rewrite the assertion to be valid for all enumerables
list.ElementAt(0).Message.Should().Be("");
it is simplified into the invalid
list.Message.Should().HaveElementAt(0, "");
Applying the codefix for CollectionShouldHaveElementAtCodeFix
var list = new[] { " FOO " };
list[0].Trim().Should().Be("FOO");
gives this stacktrace
System.InvalidCastException : Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.InvocationExpressionSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.ElementAccessExpressionSyntax'.
at FluentAssertions.Analyzers.NodeReplacement.RemoveAndRetrieveIndexerArgumentsNodeReplacement.ComputeNew(LinkedListNode`1 listNode)
at FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.GetNewExpression(ExpressionSyntax expression,NodeReplacement replacement)
at FluentAssertions.Analyzers.CollectionShouldHaveElementAtCodeFix.GetNewExpression(ExpressionSyntax expression,FluentAssertionsDiagnosticProperties properties)
at async FluentAssertions.Analyzers.FluentAssertionsCodeFixProvider.RewriteAssertion(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputePreviewOperationsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
The analyzer should probably not be triggered.
At least I see no semantically equivalent using HaveElementAt()
The analyzer was triggered.
When verifying multiple assertions against the same object, you often combine them with .And
.
Currently it seems the codefixer is not aware of this concept.
actual.Should().NotBeNull()
.And.NotBeEmpty()
.And.HaveCount(2);
is replaced with
actual.Should().NotBeNullOrEmpty();
In main FA repository, there was an issue reported fluentassertions/fluentassertions#569.
To keep it short, the user used ?.
operator:
int? val = null;
val?.Should().Be(400);
instead of regular
val.Should().Be(400);
Do you think it is possible to detect such scenario and suggest code fix?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.