diff --git a/Directory.Build.props b/Directory.Build.props
index 8162e6e9..827d02ea 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -8,7 +8,7 @@
-
+
true
diff --git a/NSubstitute.Analyzers.sln b/NSubstitute.Analyzers.sln
index 376b393c..e127a92e 100644
--- a/NSubstitute.Analyzers.sln
+++ b/NSubstitute.Analyzers.sln
@@ -47,6 +47,7 @@ ProjectSection(SolutionItems) = preProject
documentation\rules\NS5001.md = documentation\rules\NS5001.md
documentation\rules\NS5001.md = documentation\rules\NS5002.md
documentation\rules\NS5001.md = documentation\rules\NS5003.md
+ documentation\rules\NS5001.md = documentation\rules\NS5004.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{1629DF5F-9BC0-49C0-975E-E45C3E58EB3A}"
diff --git a/benchmarks/NSubstitute.Analyzers.Benchmarks.Source.CSharp/DiagnosticsSources/WithAnyArgsDiagnosticsSource.cs b/benchmarks/NSubstitute.Analyzers.Benchmarks.Source.CSharp/DiagnosticsSources/WithAnyArgsDiagnosticsSource.cs
new file mode 100644
index 00000000..428344ef
--- /dev/null
+++ b/benchmarks/NSubstitute.Analyzers.Benchmarks.Source.CSharp/DiagnosticsSources/WithAnyArgsDiagnosticsSource.cs
@@ -0,0 +1,40 @@
+using NSubstitute.Analyzers.Benchmarks.Source.CSharp.Models;
+
+namespace NSubstitute.Analyzers.Benchmarks.Source.CSharp.DiagnosticsSources
+{
+ public class WithAnyArgsDiagnosticsSource
+ {
+ public void NS5004_InvalidArgumentMatcherUsedWithAnyArgs()
+ {
+ var substitute = Substitute.For();
+
+ _ = substitute.DidNotReceiveWithAnyArgs()[Arg.Is(1)];
+ _ = substitute.DidNotReceiveWithAnyArgs()[Arg.Do(_ => { })];
+ substitute.DidNotReceiveWithAnyArgs().IntReturningProperty = Arg.Is(1);
+ substitute.DidNotReceiveWithAnyArgs().IntReturningProperty = Arg.Do(_ => { });
+ substitute.DidNotReceiveWithAnyArgs()
+ .ObjectReturningMethodWithArguments(Arg.Is(1), Arg.Is(1), Arg.Do(_ => { }));
+
+ _ = substitute.DidNotReceiveWithAnyArgs()[Arg.Is(1)];
+ _ = substitute.DidNotReceiveWithAnyArgs()[Arg.Do(_ => { })];
+ substitute.DidNotReceiveWithAnyArgs().IntReturningProperty = Arg.Is(1);
+ substitute.DidNotReceiveWithAnyArgs().IntReturningProperty = Arg.Do(_ => { });
+ substitute.DidNotReceiveWithAnyArgs()
+ .ObjectReturningMethodWithArguments(Arg.Is(1), Arg.Is(1), Arg.Do(_ => { }));
+
+ _ = SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute)[Arg.Is(1)];
+ _ = SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute)[Arg.Do(_ => { })];
+ SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute).IntReturningProperty = Arg.Is(1);
+ SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute).IntReturningProperty = Arg.Do(_ => { });
+ SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute)
+ .ObjectReturningMethodWithArguments(Arg.Is(1), Arg.Is(1), Arg.Do(_ => { }));
+
+ _ = SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute)[Arg.Is(1)];
+ _ = SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute)[Arg.Do(_ => { })];
+ SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute).IntReturningProperty = Arg.Is(1);
+ SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute).IntReturningProperty = Arg.Do(_ => { });
+ SubstituteExtensions.DidNotReceiveWithAnyArgs(substitute)
+ .ObjectReturningMethodWithArguments(Arg.Is(1), Arg.Is(1), Arg.Do(_ => { }));
+ }
+ }
+}
diff --git a/benchmarks/NSubstitute.Analyzers.Benchmarks.Source.CSharp/Models/Foo.cs b/benchmarks/NSubstitute.Analyzers.Benchmarks.Source.CSharp/Models/Foo.cs
index 06c97121..4c08092d 100644
--- a/benchmarks/NSubstitute.Analyzers.Benchmarks.Source.CSharp/Models/Foo.cs
+++ b/benchmarks/NSubstitute.Analyzers.Benchmarks.Source.CSharp/Models/Foo.cs
@@ -42,7 +42,7 @@ public Task