test(refactor): improve code coverage#635
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis update introduces new unit tests for the Changes
Sequence Diagram(s)sequenceDiagram
participant Test as DiagnosticEditPropertiesTests
participant DEP as DiagnosticEditProperties
Test->>DEP: ToImmutableDictionary()
DEP-->>Test: ImmutableDictionary
Test->>DEP: TryGetFromImmutableDictionary()
DEP-->>Test: DiagnosticEditProperties (parsed)
sequenceDiagram
participant Test as DiagnosticExtensionsTests
participant Roslyn as Roslyn API
participant Ext as DiagnosticExtensions
Test->>Roslyn: Create SyntaxNode/Location/IOperation
Test->>Ext: CreateDiagnostic(descriptor, RoslynEntity, [properties])
Ext-->>Test: Diagnostic
sequenceDiagram
participant Test as MoqVerificationHelpersTests
participant Code as C# Code Snippet
participant Semantic as SemanticModel
participant Helper as MoqVerificationHelpers
Test->>Code: Parse code with/without lambda
Test->>Semantic: Get operation for argument
Test->>Helper: ExtractLambdaFromArgument(operation)
Helper-->>Test: IAnonymousFunctionOperation or null
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR improves test coverage by adding comprehensive unit tests for two common utility classes in the Moq Analyzers project. The changes focus on testing edge cases and ensuring robust functionality of diagnostic-related extension methods and properties.
- Adds complete test coverage for
DiagnosticExtensionsmethods that create diagnostics from various sources - Enhances test coverage for
DiagnosticEditPropertieswith edge cases, equality checks, and culture-invariant parsing - Introduces tests for boundary conditions and error scenarios previously untested
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| DiagnosticExtensionsTests.cs | New test file covering all CreateDiagnostic extension methods for SyntaxNode, Location, and IOperation |
| DiagnosticEditPropertiesTests.cs | Enhanced existing tests with comprehensive edge case coverage, equality testing, and culture-invariant parsing validation |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs (2)
1-1: Remove redundantusing System.Collections.Immutable;The
System.Collections.Immutablenamespace is already included viasrc/Common/GlobalUsings.cs, so you can safely remove the explicit using.• tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs:1
- using System.Collections.Immutable;
36-49: Consider extracting common setup to reduce duplication.This test has duplicated setup code with the next test method (lines 54-58). The compilation creation and method declaration retrieval logic should be extracted into a helper method.
+ private static (CSharpCompilation compilation, SemanticModel model, MethodDeclarationSyntax methodDecl) SetupCompilationAndMethod() + { + SyntaxTree tree = CSharpSyntaxTree.ParseText("class C { void M() {} }"); + SyntaxNode root = tree.GetRoot(); + CSharpCompilation compilation = CSharpCompilation.Create("Test", new[] { tree }); + SemanticModel model = compilation.GetSemanticModel(tree); + MethodDeclarationSyntax methodDecl = root.DescendantNodes().OfType<MethodDeclarationSyntax>().First(); + return (compilation, model, methodDecl); + } [Fact] public void CreateDiagnostic_FromOperation_DelegatesToSyntax() { - SyntaxTree tree = CSharpSyntaxTree.ParseText("class C { void M() {} }"); - SyntaxNode root = tree.GetRoot(); - CSharpCompilation compilation = CSharpCompilation.Create("Test", new[] { tree }); - SemanticModel model = compilation.GetSemanticModel(tree); - MethodDeclarationSyntax methodDecl = root.DescendantNodes().OfType<MethodDeclarationSyntax>().First(); + var (compilation, model, methodDecl) = SetupCompilationAndMethod(); Microsoft.CodeAnalysis.IOperation? operation = model.GetOperation(methodDecl); DiagnosticDescriptor rule = new DiagnosticDescriptor("TEST0003", "Test3", "Test message 3", "Test", DiagnosticSeverity.Error, true); Diagnostic diag = operation!.CreateDiagnostic(rule); Assert.Equal("TEST0003", diag.Id); Assert.Equal(DiagnosticSeverity.Error, diag.Severity); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs(1 hunks)tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{csproj,props,targets,cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
All code must target .NET 9 and C# 13.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.cs: Rundotnet formatand commit all changes. PRs with formatting issues will be rejected.
Rundotnet formatbefore building or testing. Style settings come from.editorconfig.
Document public and internal APIs and complex logic. All public and internal APIs must have XML documentation that provides clear, practical explanations of their real-world use and purpose.
In XML documentation, use<see langword="..."/>for language keywords liketrue,false, andnull. Do not use<c>...</c>for these keywords.
Add explicit input validation and error handling (e.g., guard clauses, early returns on invalid state).
Use static analyzers (e.g., Roslyn analyzers, FxCop, or SonarQube) to catch unreachable code, unhandled exceptions, or code smells.
Do NOT add redundantusingstatements if the namespace is already covered by a global using (seesrc/Common/GlobalUsings.cs).When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use the
AllAnalyzersVerifierhelper class by callingawait AllAnalyzersVerifier.VerifyAllAnalyzersAsync(sourceCode, referenceAssemblyGroup);.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
⚙️ CodeRabbit Configuration File
**/*.cs: I need your help tracking down and fixing some bugs that have been reported in this codebase.I suspect the bugs are related to:
- Incorrect handling of edge cases
- Off-by-one errors in loops or array indexing
- Unexpected data types
- Uncaught exceptions
- Concurrency issues
- Improper configuration settings
To diagnose:
- Review the code carefully and systematically
- Trace the relevant code paths
- Consider boundary conditions and potential error states
- Look for antipatterns that tend to cause bugs
- Run the code mentally with example inputs
- Think about interactions between components
When you find potential bugs, for each one provide:
- File path and line number(s)
- Description of the issue and why it's a bug
- Example input that would trigger the bug
- Suggestions for how to fix it
After analysis, please update the code with your proposed fixes. Try to match the existing code style. Add regression tests if possible to prevent the bugs from recurring.
I appreciate your diligence and attention to detail! Let me know if you need any clarification on the intended behavior of the code.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
tests/**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/**/*.cs: Run all unit tests:dotnet test --settings ./build/targets/tests/test.runsettings. All tests must pass.
Add or update xUnit tests for every new feature or bug fix. Write the test first to assert the behavior, then add or modify the logic.
UseAllAnalyzersVerifier.VerifyAllAnalyzersAsyncto check for false positives across all analyzers.
When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use theAllAnalyzersVerifierhelper class.
Write unit tests for every branch, including edge and fail paths.
When adding or updating test data, group tests by Moq version compatibility.
Do not include tests for features/APIs that do not exist in the targeted Moq version.
Do not add tests for direct event setups (e.g.,.Setup(x => x.Event))—this is invalid C# and will not compile.
Always specify and test for bothMockBehavior.DefaultandMockBehavior.Strictwhere relevant.
Use all relevant verification methods (Verify,VerifyGet,VerifySet,VerifyAdd,VerifyRemove) in tests to ensure analyzer/fixer correctness.
If mocking internal members, ensure[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]is present in the test assembly.
For every supported Moq feature, write tests that cover both valid and invalid usage. UseAssert.Throws<...>in tests to verify that invalid setups fail as expected.
Avoid unnecessary complexity in test types and mock setups. Each test should demonstrate a single Moq feature or analyzer rule.
Always group and annotate tests by Moq version compatibility. Do not include tests for features/APIs that do not exist in the targeted Moq version.
When testing code fixes that modify a class member (method, property, etc.), you MUST use the data-driven pattern with a public static IEnumerable<object[]> data source, [Theory] test method, and code template with diagnostic marker.
Use the[MemberData]-annotated[Theory]pattern with a public static IEnumerable<object[]...
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
**/*.{cs,csproj,props,targets}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.{cs,csproj,props,targets}: Run Codacy CLI analysis on all changed files. Fix all reported issues before submitting the PR.
After any file edit, immediately run Codacy analysis for the edited file and resolve all reported issues before proceeding.
Re-rundotnet format, build, and tests after resolving feedback or merge conflicts.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
{tests/**/*.cs,docs/rules/**/*.md}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Update or add xUnit tests and documentation under
docs/rules/when analyzers change.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
{src/Analyzers/**/*.cs,src/CodeFixes/**/*.cs,tests/**/*.cs,docs/rules/**/*.md}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
If adding an analyzer: also add a code fix, a benchmark, and documentation in
docs/rules.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
**/*.{cs,csproj,props,targets,md}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
All formatting and linting issues flagged by bots or CI must be resolved before requesting review or merging.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
{src/Analyzers/**/*.cs,tests/**/*.cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
{src/Analyzers/**/*.cs,tests/**/*.cs}: Diagnostic spans must be character-precise (column X to column Y).
Only set up or verify virtual, abstract, or interface members. Do not attempt to set up or verify non-virtual, static, or sealed members.
UseSetupAddandSetupRemoveonly for virtual events, and only in Moq 4.18.4+.
Set up indexers only if they are virtual or defined on an interface.
Setups for explicit interface implementations must use the correct cast syntax (e.g.,((IMyInterface)x).Method()). Only test these scenarios if the Moq version supports them.
Use.Protected().Setup(...)only for protected virtual members, and only in Moq 4.18.4+.
Moq cannot mock or set up static, const, or readonly members. Do not add analyzer tests for these scenarios.
Moq supports setups for async methods returningTaskorValueTask. Always include bothTaskandValueTaskscenarios in analyzer tests.
If your analyzer or code fix interacts withCallbackorSetupSequence, ensure you have tests for both single and sequence setups.
If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
tests/Moq.Analyzers.Test/**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Add or update unit tests in
tests/Moq.Analyzers.Test/for every analyzer or code fix change.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
{src/**/*.cs,tests/**/*.cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Follow the layout and DI patterns used in existing files under
src/andtests/.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: All changes must have 100% test coverage.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-23T03:41:57.897Z
Learning: PerfDiff tool in src/tools/PerfDiff currently has no test coverage and requires comprehensive unit testing following repository guidelines for 100% coverage, including all 5 regression strategies, file I/O operations, mathematical edge cases, and command-line interface testing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in `tests/Moq.Analyzers.Test/` for every analyzer or code fix change.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Add or update xUnit tests for every new feature or bug fix. Write the test first to assert the behavior, then add or modify the logic.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to {tests/**/*.cs,docs/rules/**/*.md} : Update or add xUnit tests and documentation under `docs/rules/` when analyzers change.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When testing code fixes that modify a class member (method, property, etc.), you MUST use the data-driven pattern with a public static IEnumerable<object[]> data source, [Theory] test method, and code template with diagnostic marker.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Use `AllAnalyzersVerifier.VerifyAllAnalyzersAsync()` for "no diagnostics" tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: If tests are added/changed, specify which Moq versions are targeted and how test data is grouped.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For Roslyn analyzer development: diagnostic spans must be character-precise; a test failure related to a diagnostic span is a critical failure and requires re-evaluation.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Write unit tests for every branch, including edge and fail paths.
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs (12)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: If tests are added/changed, specify which Moq versions are targeted and how test data is grouped.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When testing code fixes that modify a class member (method, property, etc.), you MUST use the data-driven pattern with a public static IEnumerable<object[]> data source, [Theory] test method, and code template with diagnostic marker.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Avoid unnecessary complexity in test types and mock setups. Each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use the AllAnalyzersVerifier helper class.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Use all relevant verification methods (Verify, VerifyGet, VerifySet, VerifyAdd, VerifyRemove) in tests to ensure analyzer/fixer correctness.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When adding or updating test data, group tests by Moq version compatibility.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs} : If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs (21)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change.
Learnt from: MattKotsenas
PR: #239
File: src/BannedSymbols.txt:1-8
Timestamp: 2024-10-24T21:06:43.546Z
Learning: All direct uses of Diagnostic.Create should be banned, even if DiagnosticExtensions doesn't currently wrap them. Developers should add an extension to DiagnosticExtensions if they need to use any of the Diagnostic.Create APIs.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to {src/Analyzers/*Analyzer.cs,src/CodeFixes/*Fixer.cs,tests/*AnalyzerTests.cs,tests/*CodeFixTests.cs} : Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use the AllAnalyzersVerifier helper class.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When testing code fixes that modify a class member (method, property, etc.), you MUST use the data-driven pattern with a public static IEnumerable<object[]> data source, [Theory] test method, and code template with diagnostic marker.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Avoid unnecessary complexity in test types and mock setups. Each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for "no diagnostics" tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-22T02:59:40.503Z
Learning: Applies to **/*.cs : When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use the AllAnalyzersVerifier helper class by calling await AllAnalyzersVerifier.VerifyAllAnalyzersAsync(sourceCode, referenceAssemblyGroup);.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs} : If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to **/*.cs : Do NOT add redundant using statements if the namespace is already covered by a global using (see src/Common/GlobalUsings.cs).
Learnt from: MattKotsenas
PR: #226
File: src/Moq.Analyzers/SetExplicitMockBehaviorAnalyzer.cs:45-49
Timestamp: 2024-10-15T20:25:09.079Z
Learning: In this codebase, WellKnownTypeNames is included via global usings.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to src/Analyzers/**/*.cs : Keep analyzers efficient, memory-friendly, and organized using existing patterns and dependency injection.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-20T07:33:27.604Z
Learning: Moq1100 (CallbackSignatureShouldMatchMockedMethodAnalyzer) has severe performance characteristics due to two expensive operations per file: FindSetupMethodFromCallbackInvocation() uses a while(true) loop for syntax tree traversal, and GetAllMatchingMockedMethodSymbolsFromSetupMethodInvocation() performs expensive symbol resolution for method overloads. Processing 1,000 files takes 1.6+ seconds due to this compound complexity.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Never guess which Roslyn API to use; consult existing, working analyzers in src/ if unsure.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Before implementing an analyzer, verify you can trace the syntax tree path from mock.Verify() to the member access, understand Roslyn expression types, diagnostic span requirements, and when to use IOperation vs ISyntaxNode.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : For every supported Moq feature, write tests that cover both valid and invalid usage. Use Assert.Throws<...> in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs} : Setups for explicit interface implementations must use the correct cast syntax (e.g., ((IMyInterface)x).Method()). Only test these scenarios if the Moq version supports them.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Roslyn analyzer development requires deep understanding of syntax tree navigation and manipulation, diagnostic span precision, IOperation vs ISyntaxNode usage patterns, and code fix provider implementation patterns.
🧬 Code Graph Analysis (1)
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs (1)
src/Common/DiagnosticEditProperties.cs (4)
DiagnosticEditProperties(6-86)ToImmutableDictionary(41-47)EditType(14-25)TryGetFromImmutableDictionary(55-85)
🪛 GitHub Check: Codacy Static Code Analysis
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs
[notice] 85-85: tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs#L85
Assign this magic number '1234' to a well-named variable or constant, and use that instead.
tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
[warning] 1-1: tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs#L1
Provide an 'AssemblyVersion' attribute for assembly 'srcassembly.dll'.
[notice] 2-2: tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs#L2
Remove this unnecessary 'using'.
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (7)
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs (4)
14-26: LGTM! Comprehensive enum value testing.This test effectively validates that all
EditTypeenum values can be round-tripped through dictionary serialization, ensuring robust coverage of the enum handling logic.
28-42: Excellent edge case coverage for EditPosition bounds.The test properly validates handling of negative values and maximum integer values, ensuring robust serialization behavior at the boundaries of the integer range.
44-54: Good test for deserialization robustness.This test validates that the deserialization logic correctly ignores extraneous keys, ensuring the parser is resilient to additional data in the dictionary.
56-67: Appropriate testing of record equality semantics.This test properly validates the equality behavior and hash code consistency of the
DiagnosticEditPropertiesrecord, ensuring correct behavior in collections and comparisons.tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs (3)
13-22: LGTM! Basic diagnostic creation test is well-structured.This test effectively validates the core functionality of creating diagnostics from syntax nodes with proper assertions on the key diagnostic properties.
24-34: Good coverage of Location-based diagnostics with properties.This test appropriately validates diagnostic creation from Location objects and ensures custom properties are correctly preserved.
51-65: Good coverage of IOperation diagnostics with properties.This test appropriately completes the coverage for IOperation-based diagnostic creation with custom properties. The duplication issue with setup code was addressed in the previous test method comment.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{csproj,props,targets,cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
All code must target .NET 9 and C# 13.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.cs: Rundotnet formatand commit all changes. PRs with formatting issues will be rejected.
Rundotnet formatbefore building or testing. Style settings come from.editorconfig.
Document public and internal APIs and complex logic. All public and internal APIs must have XML documentation that provides clear, practical explanations of their real-world use and purpose.
In XML documentation, use<see langword="..."/>for language keywords liketrue,false, andnull. Do not use<c>...</c>for these keywords.
Add explicit input validation and error handling (e.g., guard clauses, early returns on invalid state).
Use static analyzers (e.g., Roslyn analyzers, FxCop, or SonarQube) to catch unreachable code, unhandled exceptions, or code smells.
Do NOT add redundantusingstatements if the namespace is already covered by a global using (seesrc/Common/GlobalUsings.cs).When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use the
AllAnalyzersVerifierhelper class by callingawait AllAnalyzersVerifier.VerifyAllAnalyzersAsync(sourceCode, referenceAssemblyGroup);.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
⚙️ CodeRabbit Configuration File
**/*.cs: I need your help tracking down and fixing some bugs that have been reported in this codebase.I suspect the bugs are related to:
- Incorrect handling of edge cases
- Off-by-one errors in loops or array indexing
- Unexpected data types
- Uncaught exceptions
- Concurrency issues
- Improper configuration settings
To diagnose:
- Review the code carefully and systematically
- Trace the relevant code paths
- Consider boundary conditions and potential error states
- Look for antipatterns that tend to cause bugs
- Run the code mentally with example inputs
- Think about interactions between components
When you find potential bugs, for each one provide:
- File path and line number(s)
- Description of the issue and why it's a bug
- Example input that would trigger the bug
- Suggestions for how to fix it
After analysis, please update the code with your proposed fixes. Try to match the existing code style. Add regression tests if possible to prevent the bugs from recurring.
I appreciate your diligence and attention to detail! Let me know if you need any clarification on the intended behavior of the code.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
tests/**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
tests/**/*.cs: Run all unit tests:dotnet test --settings ./build/targets/tests/test.runsettings. All tests must pass.
Add or update xUnit tests for every new feature or bug fix. Write the test first to assert the behavior, then add or modify the logic.
UseAllAnalyzersVerifier.VerifyAllAnalyzersAsyncto check for false positives across all analyzers.
When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use theAllAnalyzersVerifierhelper class.
Write unit tests for every branch, including edge and fail paths.
When adding or updating test data, group tests by Moq version compatibility.
Do not include tests for features/APIs that do not exist in the targeted Moq version.
Do not add tests for direct event setups (e.g.,.Setup(x => x.Event))—this is invalid C# and will not compile.
Always specify and test for bothMockBehavior.DefaultandMockBehavior.Strictwhere relevant.
Use all relevant verification methods (Verify,VerifyGet,VerifySet,VerifyAdd,VerifyRemove) in tests to ensure analyzer/fixer correctness.
If mocking internal members, ensure[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]is present in the test assembly.
For every supported Moq feature, write tests that cover both valid and invalid usage. UseAssert.Throws<...>in tests to verify that invalid setups fail as expected.
Avoid unnecessary complexity in test types and mock setups. Each test should demonstrate a single Moq feature or analyzer rule.
Always group and annotate tests by Moq version compatibility. Do not include tests for features/APIs that do not exist in the targeted Moq version.
When testing code fixes that modify a class member (method, property, etc.), you MUST use the data-driven pattern with a public static IEnumerable<object[]> data source, [Theory] test method, and code template with diagnostic marker.
Use the[MemberData]-annotated[Theory]pattern with a public static IEnumerable<object[]...
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
**/*.{cs,csproj,props,targets}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
**/*.{cs,csproj,props,targets}: Run Codacy CLI analysis on all changed files. Fix all reported issues before submitting the PR.
After any file edit, immediately run Codacy analysis for the edited file and resolve all reported issues before proceeding.
Re-rundotnet format, build, and tests after resolving feedback or merge conflicts.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
{tests/**/*.cs,docs/rules/**/*.md}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Update or add xUnit tests and documentation under
docs/rules/when analyzers change.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
{src/Analyzers/**/*.cs,src/CodeFixes/**/*.cs,tests/**/*.cs,docs/rules/**/*.md}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
If adding an analyzer: also add a code fix, a benchmark, and documentation in
docs/rules.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
**/*.{cs,csproj,props,targets,md}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
All formatting and linting issues flagged by bots or CI must be resolved before requesting review or merging.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
{src/Analyzers/**/*.cs,tests/**/*.cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
{src/Analyzers/**/*.cs,tests/**/*.cs}: Diagnostic spans must be character-precise (column X to column Y).
Only set up or verify virtual, abstract, or interface members. Do not attempt to set up or verify non-virtual, static, or sealed members.
UseSetupAddandSetupRemoveonly for virtual events, and only in Moq 4.18.4+.
Set up indexers only if they are virtual or defined on an interface.
Setups for explicit interface implementations must use the correct cast syntax (e.g.,((IMyInterface)x).Method()). Only test these scenarios if the Moq version supports them.
Use.Protected().Setup(...)only for protected virtual members, and only in Moq 4.18.4+.
Moq cannot mock or set up static, const, or readonly members. Do not add analyzer tests for these scenarios.
Moq supports setups for async methods returningTaskorValueTask. Always include bothTaskandValueTaskscenarios in analyzer tests.
If your analyzer or code fix interacts withCallbackorSetupSequence, ensure you have tests for both single and sequence setups.
If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
tests/Moq.Analyzers.Test/**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Add or update unit tests in
tests/Moq.Analyzers.Test/for every analyzer or code fix change.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
{src/**/*.cs,tests/**/*.cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Follow the layout and DI patterns used in existing files under
src/andtests/.
Files:
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: All changes must have 100% test coverage.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-23T03:41:57.897Z
Learning: PerfDiff tool in src/tools/PerfDiff currently has no test coverage and requires comprehensive unit testing following repository guidelines for 100% coverage, including all 5 regression strategies, file I/O operations, mathematical edge cases, and command-line interface testing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in `tests/Moq.Analyzers.Test/` for every analyzer or code fix change.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: If tests are added/changed, specify which Moq versions are targeted and how test data is grouped.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When adding or updating test data, group tests by Moq version compatibility.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Add or update xUnit tests for every new feature or bug fix. Write the test first to assert the behavior, then add or modify the logic.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Avoid unnecessary complexity in test types and mock setups. Each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use the `AllAnalyzersVerifier` helper class.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When testing code fixes that modify a class member (method, property, etc.), you MUST use the data-driven pattern with a public static IEnumerable<object[]> data source, [Theory] test method, and code template with diagnostic marker.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs (12)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use the AllAnalyzersVerifier helper class.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : For every supported Moq feature, write tests that cover both valid and invalid usage. Use Assert.Throws<...> in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-22T02:59:40.503Z
Learning: Applies to **/*.cs : When writing tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer, use the AllAnalyzersVerifier helper class by calling await AllAnalyzersVerifier.VerifyAllAnalyzersAsync(sourceCode, referenceAssemblyGroup);.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs} : If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to tests/**/*.cs : Avoid unnecessary complexity in test types and mock setups. Each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs} : Setups for explicit interface implementations must use the correct cast syntax (e.g., ((IMyInterface)x).Method()). Only test these scenarios if the Moq version supports them.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-22T02:59:32.747Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs} : Moq supports setups for async methods returning Task or ValueTask. Always include both Task and ValueTask scenarios in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: build (ubuntu-24.04-arm)
- GitHub Check: build (windows-11-arm)
🔇 Additional comments (2)
tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs (2)
13-25: Good test coverage for the positive case.The test correctly validates that
ExtractLambdaFromArgumentcan extract lambda expressions from operations. The test setup using Roslyn APIs is appropriate and the assertions are clear.
27-38: Good test coverage for the negative case.The test correctly validates that
ExtractLambdaFromArgumentreturns null for non-lambda expressions. The use of a literal expression as a counter-example is appropriate.
…lude additional cases for Times usage
…ationAnalyzerTests
…cationHelpersTests
…prove readability
…age report settings
e928265 to
39c3999
Compare
…illo/moq.analyzers into refactor/coverage-analysis
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (7)
-
.github/workflows/main.yml(4 hunks) -
build/targets/tests/Tests.targets(2 hunks) -
build/targets/tests/test.runsettings(2 hunks) -
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs(1 hunks) -
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs(2 hunks) -
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs(2 hunks) -
tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.github/workflows/**/*.yml
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
When making CI/CD changes, test workflows locally, provide validation evidence, update documentation, and consider performance impact.
Files:
.github/workflows/main.yml
**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Do not add or duplicate usings covered by src/Common/GlobalUsings.cs
**/*.cs: Add XML documentation for all public APIs.
Use tags for all type references in XML documentation instead of plain text.
Use for C# keywords in XML documentation.
Use for parameter references in XML documentation.
Use .. for inline code snippets in XML documentation.
All public APIs must have complete XML documentation with accurate and up-to-date information.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
⚙️ CodeRabbit Configuration File
**/*.cs: I need your help tracking down and fixing some bugs that have been reported in this codebase.I suspect the bugs are related to:
- Incorrect handling of edge cases
- Off-by-one errors in loops or array indexing
- Unexpected data types
- Uncaught exceptions
- Concurrency issues
- Improper configuration settings
To diagnose:
- Review the code carefully and systematically
- Trace the relevant code paths
- Consider boundary conditions and potential error states
- Look for antipatterns that tend to cause bugs
- Run the code mentally with example inputs
- Think about interactions between components
When you find potential bugs, for each one provide:
- File path and line number(s)
- Description of the issue and why it's a bug
- Example input that would trigger the bug
- Suggestions for how to fix it
After analysis, please update the code with your proposed fixes. Try to match the existing code style. Add regression tests if possible to prevent the bugs from recurring.
I appreciate your diligence and attention to detail! Let me know if you need any clarification on the intended behavior of the code.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
{src/Analyzers/*Analyzer.cs,src/CodeFixes/*Fixer.cs,tests/Moq.Analyzers.Test/*AnalyzerTests.cs,tests/Moq.Analyzers.Test/*CodeFixTests.cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
tests/Moq.Analyzers.Test/*AnalyzerTests.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
tests/Moq.Analyzers.Test/**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
**/*.{cs,csproj,sln}
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
Build with 'dotnet build /p:PedanticMode=true'. All warnings must be treated as errors. PRs that do not build cleanly will be closed.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
tests/**/*.cs
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
tests/**/*.cs: Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Every analyzer and fixer must have comprehensive unit tests.
Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Setups for explicit interface implementations must use the correct cast syntax (e.g., ((IMyInterface)x).Method()).
Use .Protected().Setup(...) only for protected virtual members, and only in Moq 4.18.4+.
Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Always include both Task and ValueTask scenarios in analyzer tests for async methods.
If your analyzer or code fix interacts with Callback or SetupSequence, ensure you have tests for both single and sequence setups.
Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
🧠 Learnings (8)
📓 Common learnings
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-23T03:41:57.897Z
Learning: PerfDiff tool in src/tools/PerfDiff currently has no test coverage and requires comprehensive unit testing following repository guidelines for 100% coverage, including all 5 regression strategies, file I/O operations, mathematical edge cases, and command-line interface testing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Ensure all changes are covered by tests and documentation before committing
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
build/targets/tests/test.runsettings (16)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to **/*.cs : Do not add or duplicate usings covered by src/Common/GlobalUsings.cs
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/*.cs : Add XML documentation for all public APIs.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Every analyzer and fixer must have comprehensive unit tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
build/targets/tests/Tests.targets (11)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Every analyzer and fixer must have comprehensive unit tests.
.github/workflows/main.yml (4)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to .github/workflows/**/*.yml : When making CI/CD changes, test workflows locally, provide validation evidence, update documentation, and consider performance impact.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/*.{cs} : Run Codacy CLI analysis on all changed files and fix all reported issues before submitting the PR.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Run dotnet test (all must pass)
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs (19)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Moq supports setups for async methods returning Task or ValueTask; always include both Task and ValueTask scenarios in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not add tests for direct event setups (e.g., .Setup(x => x.Event)); this is invalid C# and will not compile.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs (12)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not add tests for direct event setups (e.g., .Setup(x => x.Event)); this is invalid C# and will not compile.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (20)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs (20)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: For Moq analyzers and tests: only set up or verify virtual, abstract, or interface members; do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Note Moq version compatibility for analyzer/test changes
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Group test data by Moq version compatibility: 'new' for Moq 4.18.4+, 'both' or 'old' for features available in both 4.8.2 and 4.18.4.
🧬 Code Graph Analysis (1)
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs (1)
tests/Moq.Analyzers.Test/RaiseEventArgumentsShouldMatchEventSignatureAnalyzerTests.cs (1)
InvalidTestData(28-44)
🪛 actionlint (1.7.7)
.github/workflows/main.yml
73-73: if: condition "success() && ${{ env.IS_TARGET_MAIN == 'true' }}" is always evaluated to true because extra characters are around ${{ }}
(if-cond)
80-80: if: condition "success() && ${{ env.IS_TARGET_MAIN == 'true' }}" is always evaluated to true because extra characters are around ${{ }}
(if-cond)
🔇 Additional comments (19)
build/targets/tests/test.runsettings (2)
13-14: LGTM: Enhanced coverage exclusions improve focus on application code.The addition of
ExcludeByAttributefor generated code and obsolete members, plusSkipAutoPropsfor auto-implemented properties, are standard best practices that help focus coverage metrics on meaningful application logic.
50-51: LGTM: Framework function exclusions are appropriate.Adding exclusions for
Microsoft.Testing.*andSystem.Diagnostics.*functions prevents framework code from being counted in coverage metrics, which aligns with the goal of measuring only application-specific code coverage..github/workflows/main.yml (4)
47-47: LGTM: New environment variable for branch detection.The
IS_TARGET_MAINvariable provides a clean way to detect when running on the main branch, which is useful for conditional coverage history management.
59-65: LGTM: Coverage history restoration enhances continuity.The coverage history restoration step with
continue-on-error: trueis well-implemented, allowing the workflow to proceed even if no previous history exists.
198-198: LGTM: Baseline SHA inclusion improves performance report context.Adding the baseline SHA to the performance summary provides valuable context for understanding performance comparisons.
228-234: LGTM: General artifacts upload provides comprehensive backup.The final artifacts upload step with
if: success() || failure()ensures all artifacts are preserved regardless of job outcome, which is valuable for debugging.build/targets/tests/Tests.targets (2)
9-9: LGTM: Coverage history directory property follows established patterns.The new
_TestCoverageHistoryDirectoryproperty is consistent with existing coverage-related properties and provides the necessary path for coverage history tracking.
34-35: LGTM: ReportGenerator integration enables coverage history tracking.Adding the
HistoryDirectoryparameter to the ReportGenerator task properly enables coverage trend analysis by passing the history directory path defined in the new property.tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs (3)
26-48: LGTM: Test data formatting improved without logic changes.The conversion from array initializer to collection initializer syntax improves readability while maintaining the same test logic and diagnostic expectations.
50-50: LGTM: Proper union of test data collections.The return statement correctly combines both the existing and new edge case test data while maintaining the namespace and reference assembly group extensions.
9-23: Confirm null-lambda Setup compilesThe edge case
new Mock<IFoo>().Setup(null);may not compile, since the compiler can’t infer the generic
TResultfrom anullliteral. Please verify that this is valid C# in your test suite. If it isn’t, consider specifying the type parameter explicitly (e.g.Setup<int>(null)) or removing the case.• File: tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs, lines 9–23
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs (2)
38-71: LGTM: New test method follows established patterns.The
ShouldHandleInvalidEventSetupstest method properly uses the data-driven pattern with[Theory]and[MemberData], and reuses the same interface definitions as existing tests for consistency.
8-24: Fix invalid method group assignment test case.The new invalid test data provides good coverage of edge cases, but one test case has incorrect syntax.
The test case on line 19 has invalid syntax:
["""mockProvider.SetupAdd(x => {|CS0131:x.ToString()|} += It.IsAny<Action>());"""]The issue is that
ToString()is a method, not an event, sox.ToString() +=is not valid syntax for event operations. This should be testing assignment to an actual event.Apply this diff to fix the test case:
- // Method group assignment, compiler emits CS0131 (not assignable) - ["""mockProvider.SetupAdd(x => {|CS0131:x.ToString()|} += It.IsAny<Action>());"""], + // Invalid event assignment syntax, compiler emits CS0131 + ["""mockProvider.SetupAdd(x => {|CS0131:x.StringEvent|} = It.IsAny<Action<string>>());"""],This tests assignment (
=) instead of subscription (+=) which would trigger CS0131.⛔ Skipped due to learnings
Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.110Z Learning: Do not add tests for direct event setups (e.g., .Setup(x => x.Event)); this is invalid C# and will not compile.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: CONTRIBUTING.md:0-0 Timestamp: 2025-07-27T02:45:02.136Z Learning: Applies to tests/**/*.cs : Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: CONTRIBUTING.md:0-0 Timestamp: 2025-07-27T02:45:02.136Z Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-07-27T02:44:39.596Z Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix changeLearnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.111Z Learning: If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.111Z Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.Learnt from: rjmurillo PR: rjmurillo/moq.analyzers#0 File: :0-0 Timestamp: 2025-07-22T17:25:24.857Z Learning: Applies to {src/Analyzers/**/*.cs,tests/**/*.cs}: For Moq protected member setups using string-based overloads (e.g., `mock.Protected().Setup("MethodName", ...)`), use `ItExpr` matchers instead of `It` matchers. When using `As<T>()` interface mapping, regular `It` matchers are allowed in lambda expressions.Learnt from: rjmurillo PR: rjmurillo/moq.analyzers#0 File: :0-0 Timestamp: 2025-07-22T17:25:24.857Z Learning: Applies to {src/Analyzers/**/*.cs,tests/**/*.cs}: For Moq protected member setups using string-based overloads (e.g., `mock.Protected().Setup("MethodName", ...)`), use `ItExpr` matchers instead of `It` matchers. When using `As<T>()` interface mapping, regular `It` matchers are allowed in lambda expressions.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.110Z Learning: Use 'SetupAdd' and 'SetupRemove' only for virtual events and only in Moq 4.18.4+.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.111Z Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-07-27T02:44:39.596Z Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix testsLearnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.111Z Learning: Setups for explicit interface implementations must use the correct cast syntax (e.g., ((IMyInterface)x).Method()), and only test these scenarios if the Moq version supports them.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.111Z Learning: Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests.Learnt from: rjmurillo PR: rjmurillo/moq.analyzers#0 File: :0-0 Timestamp: 2025-07-22T17:25:24.857Z Learning: Applies to {src/Analyzers/**/*.cs,tests/**/*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet<T>, SetupSet<T>, Verify, VerifyGet<T>, VerifySet<T>, and As<T>() for interface mapping. All protected members must be virtual or abstract to be mockable.tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs (3)
9-52: Excellent comprehensive test coverage for the redundant Times specification analyzer.The test data is well-structured with clear comments explaining expected behavior. The diagnostic markers are correctly applied only to
Times.AtLeastOnce()cases, and the negative test cases ensure no false positives for otherTimesspecifications.
54-69: Proper Moq version compatibility grouping for VerifySet tests.The separation of
newMoqOnlytest cases correctly isolates features available only in newer Moq versions, following the repository's guidelines for version-specific test organization.
71-71: Correct test data combination pattern.The use of
.Concat()followed by the extension methods properly combines version-specific test data and ensures comprehensive coverage across different Moq versions and namespaces.tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (3)
9-25: Excellent edge case coverage for LINQ-to-Mocks expressions.The test cases cover important edge scenarios including null predicates, constant expressions, and non-virtual member calls. The diagnostic markers are correctly applied only where expected, and the comments clearly explain the behavior.
63-86: Well-structured edge case test method.The test method follows the established patterns with proper [Theory]/[MemberData] usage, async/await, and a clean template structure. The minimal interface definition is appropriate for the edge case scenarios being tested.
7-7: Consider removing redundant field assignment.The constructor parameter
outputcan be used directly in test methods that need it, making this field assignment unnecessary.- private readonly ITestOutputHelper output = output;The constructor parameter can be used directly in methods like
ShouldReportDiagnosticForComplexLinqToMocksExpressions.⛔ Skipped due to learnings
Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: CONTRIBUTING.md:0-0 Timestamp: 2025-07-27T02:45:02.136Z Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.111Z Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.111Z Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-07-27T02:44:39.596Z Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix testsLearnt from: CR PR: rjmurillo/moq.analyzers#0 File: CONTRIBUTING.md:0-0 Timestamp: 2025-07-27T02:45:02.136Z Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: CONTRIBUTING.md:0-0 Timestamp: 2025-07-27T02:45:02.136Z Learning: Applies to tests/**/*.cs : Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (7)
-
.github/workflows/main.yml(4 hunks) -
build/targets/tests/Tests.targets(2 hunks) -
build/targets/tests/test.runsettings(2 hunks) -
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs(1 hunks) -
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs(2 hunks) -
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs(2 hunks) -
tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
.github/workflows/**/*.yml
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
When making CI/CD changes, test workflows locally, provide validation evidence, update documentation, and consider performance impact.
Files:
.github/workflows/main.yml
**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Do not add or duplicate usings covered by src/Common/GlobalUsings.cs
**/*.cs: Add XML documentation for all public APIs.
Use tags for all type references in XML documentation instead of plain text.
Use for C# keywords in XML documentation.
Use for parameter references in XML documentation.
Use .. for inline code snippets in XML documentation.
All public APIs must have complete XML documentation with accurate and up-to-date information.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
⚙️ CodeRabbit Configuration File
**/*.cs: I need your help tracking down and fixing some bugs that have been reported in this codebase.I suspect the bugs are related to:
- Incorrect handling of edge cases
- Off-by-one errors in loops or array indexing
- Unexpected data types
- Uncaught exceptions
- Concurrency issues
- Improper configuration settings
To diagnose:
- Review the code carefully and systematically
- Trace the relevant code paths
- Consider boundary conditions and potential error states
- Look for antipatterns that tend to cause bugs
- Run the code mentally with example inputs
- Think about interactions between components
When you find potential bugs, for each one provide:
- File path and line number(s)
- Description of the issue and why it's a bug
- Example input that would trigger the bug
- Suggestions for how to fix it
After analysis, please update the code with your proposed fixes. Try to match the existing code style. Add regression tests if possible to prevent the bugs from recurring.
I appreciate your diligence and attention to detail! Let me know if you need any clarification on the intended behavior of the code.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
{src/Analyzers/*Analyzer.cs,src/CodeFixes/*Fixer.cs,tests/Moq.Analyzers.Test/*AnalyzerTests.cs,tests/Moq.Analyzers.Test/*CodeFixTests.cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
tests/Moq.Analyzers.Test/*AnalyzerTests.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
tests/Moq.Analyzers.Test/**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
**/*.{cs,csproj,sln}
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
Build with 'dotnet build /p:PedanticMode=true'. All warnings must be treated as errors. PRs that do not build cleanly will be closed.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
tests/**/*.cs
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
tests/**/*.cs: Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Every analyzer and fixer must have comprehensive unit tests.
Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Setups for explicit interface implementations must use the correct cast syntax (e.g., ((IMyInterface)x).Method()).
Use .Protected().Setup(...) only for protected virtual members, and only in Moq 4.18.4+.
Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Always include both Task and ValueTask scenarios in analyzer tests for async methods.
If your analyzer or code fix interacts with Callback or SetupSequence, ensure you have tests for both single and sequence setups.
Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
🧠 Learnings (8)
📓 Common learnings
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-23T03:41:57.897Z
Learning: PerfDiff tool in src/tools/PerfDiff currently has no test coverage and requires comprehensive unit testing following repository guidelines for 100% coverage, including all 5 regression strategies, file I/O operations, mathematical edge cases, and command-line interface testing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Ensure all changes are covered by tests and documentation before committing
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
build/targets/tests/test.runsettings (16)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Every analyzer and fixer must have comprehensive unit tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to **/*.cs : Do not add or duplicate usings covered by src/Common/GlobalUsings.cs
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/*.cs : Add XML documentation for all public APIs.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
.github/workflows/main.yml (6)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to .github/workflows/**/*.yml : When making CI/CD changes, test workflows locally, provide validation evidence, update documentation, and consider performance impact.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When making changes, follow the workflow: Edit/Add Code or Test → Run codacy_cli_analyze → Fix issues if any → Run/Update Tests → Fix test failures if any → Update Docs → Commit & PR.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/CONTRIBUTING.md : Update contributing guidelines for workflow changes.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/*.{cs} : Run Codacy CLI analysis on all changed files and fix all reported issues before submitting the PR.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Run dotnet test (all must pass)
build/targets/tests/Tests.targets (11)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Every analyzer and fixer must have comprehensive unit tests.
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs (19)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Moq supports setups for async methods returning Task or ValueTask; always include both Task and ValueTask scenarios in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not add tests for direct event setups (e.g., .Setup(x => x.Event)); this is invalid C# and will not compile.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs (13)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not add tests for direct event setups (e.g., .Setup(x => x.Event)); this is invalid C# and will not compile.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Use 'SetupAdd' and 'SetupRemove' only for virtual events and only in Moq 4.18.4+.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs (20)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: For Moq analyzers and tests: only set up or verify virtual, abstract, or interface members; do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Note Moq version compatibility for analyzer/test changes
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Group test data by Moq version compatibility: 'new' for Moq 4.18.4+, 'both' or 'old' for features available in both 4.8.2 and 4.18.4.
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (21)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Note Moq version compatibility for analyzer/test changes
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
🧬 Code Graph Analysis (1)
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs (1)
tests/Moq.Analyzers.Test/Helpers/TestDataExtensions.cs (1)
TestDataExtensions(3-58)
🪛 actionlint (1.7.7)
.github/workflows/main.yml
73-73: if: condition "success() && ${{ env.IS_TARGET_MAIN == 'true' }}" is always evaluated to true because extra characters are around ${{ }}
(if-cond)
80-80: if: condition "success() && ${{ env.IS_TARGET_MAIN == 'true' }}" is always evaluated to true because extra characters are around ${{ }}
(if-cond)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (17)
build/targets/tests/Tests.targets (2)
9-9: LGTM: Coverage history directory property added.The new
_TestCoverageHistoryDirectoryproperty enables coverage trend tracking across test runs, which is essential for monitoring coverage improvements over time.
34-35: LGTM: Enhanced coverage reporting with history tracking.The addition of
MarkdownSummaryGithubreport type andHistoryDirectoryattribute enables GitHub-friendly coverage summaries and historical trend analysis, directly supporting the PR's objective to improve code coverage tracking.build/targets/tests/test.runsettings (2)
13-14: LGTM: Improved coverage filtering for accurate metrics.The exclusion of
Obsolete,GeneratedCodeAttribute, andCompilerGeneratedAttributealong with enablingSkipAutoPropsensures coverage metrics focus on meaningful, testable code rather than compiler-generated artifacts.
50-51: LGTM: Appropriate framework exclusions added.Excluding
Microsoft.TestingandSystem.Diagnosticsnamespaces from coverage is appropriate as these are framework functions that don't require testing coverage in application code..github/workflows/main.yml (4)
47-47: LGTM: Environment variable for main branch detection.The
IS_TARGET_MAINvariable enables conditional logic for main branch-specific operations like coverage history management.
59-64: LGTM: Coverage history restoration with proper error handling.The
continue-on-error: trueensures the workflow doesn't fail when coverage history artifacts are missing (e.g., on first run), which is appropriate for this optional enhancement.
198-198: LGTM: Enhanced performance summary with baseline SHA.Adding the baseline commit SHA to the GitHub step summary improves traceability and debugging of performance comparisons.
228-234: LGTM: Comprehensive artifact upload for diagnostics.The final artifact upload step ensures all build outputs are available for debugging, with appropriate error handling when no files are found.
tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs (3)
9-52: Excellent test data organization and coverage.The test data structure is well-designed with comprehensive coverage of both positive and negative test cases. The collection initializer syntax improves readability, and proper diagnostic markers are used throughout. The categorization clearly separates cases that should trigger diagnostics from those that shouldn't.
54-69: Proper separation of version-specific test cases.The
newMoqOnlycollection correctly isolates tests forVerifySet, which is only available in Moq 4.18.4+. This follows the coding guidelines for grouping tests by Moq version compatibility and maintains consistency with the existing test patterns.
71-71: Proper use of test data extension methods.The return statement correctly combines both test collections and applies the standard extension methods for namespace and Moq version variations. This ensures comprehensive test coverage across different configurations following the established testing patterns.
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs (1)
9-23: Excellent edge case coverage for analyzer robustness.The new edge case test data covers important boundary conditions including null inputs, non-method expressions, and complex nested scenarios. Each case is well-documented with clear comments explaining the expected behavior. The diagnostic markers are correctly applied where the analyzer should trigger.
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs (2)
8-24: Well-designed invalid test scenarios with proper error markers.The test data covers important edge cases where event setups have compiler errors. The compiler error markers (
{|CS0029:...|,{|CS0131:...|) are correctly applied, and the comments clearly explain the expected behavior. This ensures the analyzer handles invalid code gracefully without crashing.
38-71: Proper test method implementation following established patterns.The new test method correctly follows the established pattern with proper parameterization, template structure, and verification logic. The test template includes all necessary type definitions and uses appropriate string interpolation for dynamic content.
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (3)
11-25: Good edge case coverage for LINQ-to-Mocks expressions.The test data covers important edge cases including null expressions, constant comparisons, and non-virtual member access. The diagnostic marker for
object.Equalsis correctly applied since it's a non-virtual member. The comments clearly explain the expected behavior for each case.
63-86: Solid test method implementation following established patterns.The new test method properly follows the established testing pattern with correct parameterization, appropriate template structure, and proper verification logic. The minimal interface definition is sufficient for the edge case scenarios being tested.
7-7: Remove unnecessary field declaration.The private readonly field is redundant since the
outputparameter is already available through the primary constructor. The existing usage in theShouldReportDiagnosticForComplexLinqToMocksExpressionsmethod can continue using the constructor parameter directly.- private readonly ITestOutputHelper output = output;⛔ Skipped due to learnings
Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: CONTRIBUTING.md:0-0 Timestamp: 2025-07-27T02:45:02.136Z Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: .github/copilot-instructions.md:0-0 Timestamp: 2025-06-25T12:42:47.111Z Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.Learnt from: MattKotsenas PR: rjmurillo/moq.analyzers#239 File: src/BannedSymbols.txt:1-8 Timestamp: 2024-10-24T21:06:43.546Z Learning: All direct uses of `Diagnostic.Create` should be banned, even if `DiagnosticExtensions` doesn't currently wrap them. Developers should add an extension to `DiagnosticExtensions` if they need to use any of the `Diagnostic.Create` APIs.Learnt from: CR PR: rjmurillo/moq.analyzers#0 File: CONTRIBUTING.md:0-0 Timestamp: 2025-07-27T02:45:02.136Z Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
There was a problem hiding this comment.
Actionable comments posted: 5
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (7)
-
.github/workflows/main.yml(4 hunks) -
build/targets/tests/Tests.targets(2 hunks) -
build/targets/tests/test.runsettings(2 hunks) -
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs(1 hunks) -
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs(2 hunks) -
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs(2 hunks) -
tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Do not add or duplicate usings covered by src/Common/GlobalUsings.cs
**/*.cs: Add XML documentation for all public APIs.
Use tags for all type references in XML documentation instead of plain text.
Use for C# keywords in XML documentation.
Use for parameter references in XML documentation.
Use .. for inline code snippets in XML documentation.
All public APIs must have complete XML documentation with accurate and up-to-date information.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
⚙️ CodeRabbit Configuration File
**/*.cs: I need your help tracking down and fixing some bugs that have been reported in this codebase.I suspect the bugs are related to:
- Incorrect handling of edge cases
- Off-by-one errors in loops or array indexing
- Unexpected data types
- Uncaught exceptions
- Concurrency issues
- Improper configuration settings
To diagnose:
- Review the code carefully and systematically
- Trace the relevant code paths
- Consider boundary conditions and potential error states
- Look for antipatterns that tend to cause bugs
- Run the code mentally with example inputs
- Think about interactions between components
When you find potential bugs, for each one provide:
- File path and line number(s)
- Description of the issue and why it's a bug
- Example input that would trigger the bug
- Suggestions for how to fix it
After analysis, please update the code with your proposed fixes. Try to match the existing code style. Add regression tests if possible to prevent the bugs from recurring.
I appreciate your diligence and attention to detail! Let me know if you need any clarification on the intended behavior of the code.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
{src/Analyzers/*Analyzer.cs,src/CodeFixes/*Fixer.cs,tests/Moq.Analyzers.Test/*AnalyzerTests.cs,tests/Moq.Analyzers.Test/*CodeFixTests.cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
tests/Moq.Analyzers.Test/*AnalyzerTests.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
tests/Moq.Analyzers.Test/**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
**/*.{cs,csproj,sln}
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
Build with 'dotnet build /p:PedanticMode=true'. All warnings must be treated as errors. PRs that do not build cleanly will be closed.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
tests/**/*.cs
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
tests/**/*.cs: Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Every analyzer and fixer must have comprehensive unit tests.
Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Setups for explicit interface implementations must use the correct cast syntax (e.g., ((IMyInterface)x).Method()).
Use .Protected().Setup(...) only for protected virtual members, and only in Moq 4.18.4+.
Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Always include both Task and ValueTask scenarios in analyzer tests for async methods.
If your analyzer or code fix interacts with Callback or SetupSequence, ensure you have tests for both single and sequence setups.
Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Files:
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cstests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs
.github/workflows/**/*.yml
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
When making CI/CD changes, test workflows locally, provide validation evidence, update documentation, and consider performance impact.
Files:
.github/workflows/main.yml
🧠 Learnings (8)
📓 Common learnings
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-23T03:41:57.897Z
Learning: PerfDiff tool in src/tools/PerfDiff currently has no test coverage and requires comprehensive unit testing following repository guidelines for 100% coverage, including all 5 regression strategies, file I/O operations, mathematical edge cases, and command-line interface testing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Ensure all changes are covered by tests and documentation before committing
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
build/targets/tests/Tests.targets (11)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Every analyzer and fixer must have comprehensive unit tests.
build/targets/tests/test.runsettings (16)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Every analyzer and fixer must have comprehensive unit tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to **/*.cs : Do not add or duplicate usings covered by src/Common/GlobalUsings.cs
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/*.cs : Add XML documentation for all public APIs.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs (20)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Moq supports setups for async methods returning Task or ValueTask; always include both Task and ValueTask scenarios in analyzer tests.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not add tests for direct event setups (e.g., .Setup(x => x.Event)); this is invalid C# and will not compile.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs (12)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not add tests for direct event setups (e.g., .Setup(x => x.Event)); this is invalid C# and will not compile.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
.github/workflows/main.yml (5)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to .github/workflows/**/*.yml : When making CI/CD changes, test workflows locally, provide validation evidence, update documentation, and consider performance impact.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When making changes, follow the workflow: Edit/Add Code or Test → Run codacy_cli_analyze → Fix issues if any → Run/Update Tests → Fix test failures if any → Update Docs → Commit & PR.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/*.{cs} : Run Codacy CLI analysis on all changed files and fix all reported issues before submitting the PR.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Run dotnet test (all must pass)
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (21)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs (20)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: For Moq analyzers and tests: only set up or verify virtual, abstract, or interface members; do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Note Moq version compatibility for analyzer/test changes
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Group test data by Moq version compatibility: 'new' for Moq 4.18.4+, 'both' or 'old' for features available in both 4.8.2 and 4.18.4.
🪛 actionlint (1.7.7)
.github/workflows/main.yml
73-73: if: condition "success() && ${{ env.IS_TARGET_MAIN == 'true' }}" is always evaluated to true because extra characters are around ${{ }}
(if-cond)
80-80: if: condition "success() && ${{ env.IS_TARGET_MAIN == 'true' }}" is always evaluated to true because extra characters are around ${{ }}
(if-cond)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (21)
tests/Moq.Analyzers.Test/EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs (2)
7-24: LGTM! Comprehensive invalid test data covers key edge cases.The
InvalidTestDatamethod provides excellent coverage of invalid event setup scenarios:
- Null assignment (valid C# but edge case)
- Type mismatches with proper compiler error annotations
- Invalid syntax scenarios
The test cases correctly use the expected compiler error markers (
CS0029,CS0131) and follow the repository's pattern withWithNamespaces().WithNewMoqReferenceAssemblyGroups().
38-71: LGTM! Test method follows repository patterns and provides valuable coverage.The
ShouldHandleInvalidEventSetupstest method:
- Correctly uses
[Theory]with[MemberData]pattern as required by coding guidelines- Uses proper string interpolation with
$$for dynamic test code generation- Includes all necessary test infrastructure (CustomArgs, MyDelegate, ITestInterface)
- Calls
Verifier.VerifyAnalyzerAsyncwith appropriate parametersThis test ensures the analyzer gracefully handles invalid event setups without crashing, which is essential for robustness.
tests/Moq.Analyzers.Test/MethodSetupShouldSpecifyReturnValueAnalyzerTests.cs (3)
9-23: Excellent addition of edge case test coverage.The new edge cases effectively test analyzer robustness with null inputs, constant expressions, method groups, and nested lambdas. The diagnostic markers are correctly applied following the repository's testing patterns.
26-48: Good modernization to collection initializer syntax.The conversion to collection initializer syntax improves code consistency and readability while preserving all existing test cases.
50-50: Proper implementation of test data combination.The Union() approach correctly combines both test collections while maintaining the required namespace and reference assembly group extensions.
tests/Moq.Analyzers.Test/RedundantTimesSpecificationAnalyzerTests.cs (3)
9-52: Excellent comprehensive test coverage expansion.The expanded test cases thoroughly cover various Times specifications, including positive and negative cases. The inclusion of variable/expression-based Times tests helps prevent false positives, and the coverage of VerifyGet with message arguments is thorough. Diagnostic markers are correctly applied.
54-69: Proper separation of version-specific test cases.The
newMoqOnlycollection correctly isolates VerifySet tests that are only available in newer Moq versions, following the repository's pattern for Moq version compatibility grouping.
71-71: Correct implementation of version-aware test data combination.The use of Concat() properly combines both collections while maintaining the required namespace and reference assembly group extensions, ensuring proper test execution across different Moq versions.
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (4)
7-7: Approve the field declaration.The private readonly field follows C# conventions and correctly captures the injected dependency.
22-23: Correct diagnostic marker placement.The diagnostic marker appears to be correctly placed for
object.Equalswhich is indeed a non-virtual static method that cannot be mocked.
63-86: Approve the edge case test method implementation.The test method follows the established pattern with proper use of [Theory], [MemberData], and the async Task signature. The test template correctly embeds the mock expressions and uses the analyzer verifier appropriately.
The method adheres to repository guidelines:
- Uses data-driven test pattern with [Theory] and [MemberData]
- Includes proper diagnostic markers where expected
- Uses minimal interface definition for test isolation
- Follows async/await pattern consistently
19-20: No action needed: Invocation expressions are intentionally allowed in LINQ-to-MocksThe existing
LinqToMocksExpressionShouldBeValidAnalyzerTestsexplicitly includes// new Func<int>(() => 1)() is a non-virtual member, but analyzer does not report a diagnostic ["""Mock.Of<IRepository>(r => new Func<int>(() => 1)() == 1);"""],to verify that delegate invocations aren’t flagged by Moq1302 in the LINQ-to-Mocks context. Since this behavior is by design and covered by tests, no changes are required.
build/targets/tests/test.runsettings (3)
13-13: LGTM! Appropriate coverage exclusions added.The addition of
Obsolete,GeneratedCodeAttribute, andCompilerGeneratedAttributeto the exclusion list aligns with best practices by excluding code that shouldn't be tested or counted against coverage metrics.
14-14: LGTM! Sensible auto-property exclusion.Setting
SkipAutoPropsto true appropriately excludes auto-implemented properties from coverage calculations, as they contain no testable logic and are compiler-generated.
50-51: LGTM! Framework function exclusions are appropriate.The regex patterns excluding
Microsoft.Testing.*andSystem.Diagnostics.*functions are well-formed and appropriately exclude framework-level code that shouldn't be counted in application coverage metrics.build/targets/tests/Tests.targets (2)
9-9: LGTM! Coverage history directory property well-defined.The new
_TestCoverageHistoryDirectoryproperty follows MSBuild conventions and maintains consistency with the existing coverage property patterns.
34-35: LGTM! Coverage history integration properly implemented.The addition of
MarkdownSummaryGithubreport type andHistoryDirectoryattribute correctly implements coverage history tracking functionality, with proper reference to the newly defined property..github/workflows/main.yml (4)
47-47: LGTM! Branch detection environment variable properly defined.The
IS_TARGET_MAINenvironment variable correctly identifies the main branch using standard GitHub Actions syntax.
59-64: LGTM! Coverage history restoration step properly implemented.The step correctly uses
continue-on-error: truefor graceful handling when coverage history doesn't exist yet, and the artifact path aligns with the MSBuild configuration.
198-198: LGTM! Performance reporting enhancement.Adding the baseline SHA to the GitHub step summary improves transparency and helps understand performance comparison context.
47-234: Test workflow changes locally and provide validation evidence.Based on the coding guidelines for CI/CD changes, these workflow modifications should be tested locally before merging. The changes include syntax errors that could cause workflow failures.
Please:
- Fix the syntax errors in the conditional statements (lines 73, 80)
- Remove the duplicate upload step (lines 78-83)
- Test the workflow locally using act or similar tools
- Provide validation evidence that coverage history artifacts are correctly managed
- Consider the performance impact of the additional artifact uploads
The workflow changes significantly expand artifact management and should be validated to ensure they work as expected without causing CI performance degradation.
… test for culture handling
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
.github/workflows/main.yml (1)
221-227: Previous nitpick about possible redundancy with existing targeted uploads still applies.tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs (1)
43-57: Extract common setup logic to reduce code duplication.This test method contains significant duplication with the previous test method (lines 31-40). The setup code for creating compilation, semantic model, and finding the method declaration is identical.
Consider extracting the common setup into a helper method:
+ private static (MethodDeclarationSyntax methodDecl, Microsoft.CodeAnalysis.IOperation operation) GetTestOperation() + { + SyntaxTree tree = CSharpSyntaxTree.ParseText("class C { void M() {} }"); + SyntaxNode root = tree.GetRoot(); + CSharpCompilation compilation = CSharpCompilation.Create("Test", new[] { tree }); + SemanticModel model = compilation.GetSemanticModel(tree); + MethodDeclarationSyntax methodDecl = root.DescendantNodes().OfType<MethodDeclarationSyntax>().First(); + Microsoft.CodeAnalysis.IOperation operation = model.GetOperation(methodDecl)!; + return (methodDecl, operation); + } [Fact] public void CreateDiagnostic_FromOperation_WithProperties() { - SyntaxTree tree = CSharpSyntaxTree.ParseText("class C { void M() {} }"); - SyntaxNode root = tree.GetRoot(); - CSharpCompilation compilation = CSharpCompilation.Create("Test", new[] { tree }); - SemanticModel model = compilation.GetSemanticModel(tree); - MethodDeclarationSyntax methodDecl = root.DescendantNodes().OfType<MethodDeclarationSyntax>().First(); - Microsoft.CodeAnalysis.IOperation? operation = model.GetOperation(methodDecl); + var (_, operation) = GetTestOperation(); DiagnosticDescriptor rule = new DiagnosticDescriptor("TEST0004", "Test4", "Test message 4", "Test", DiagnosticSeverity.Warning, true); ImmutableDictionary<string, string?> properties = ImmutableDictionary<string, string?>.Empty.Add("Key2", "Value2"); - Diagnostic diag = operation!.CreateDiagnostic(rule, properties); + Diagnostic diag = operation.CreateDiagnostic(rule, properties); Assert.Equal("TEST0004", diag.Id); Assert.Equal("Value2", diag.Properties["Key2"]); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (12)
.github/workflows/main.yml(4 hunks)src/Analyzers/LinqToMocksExpressionShouldBeValidAnalyzer.cs(0 hunks)src/Analyzers/MockRepositoryVerifyAnalyzer.cs(0 hunks)src/Analyzers/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzer.cs(0 hunks)src/Common/EventSyntaxExtensions.cs(0 hunks)tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs(1 hunks)tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs(1 hunks)tests/Moq.Analyzers.Test/IsRaisesMethodTests.cs(0 hunks)tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs(2 hunks)tests/Moq.Analyzers.Test/RefOutCallbackTests.cs(0 hunks)tests/Moq.Analyzers.Test/ReturnsAsyncShouldBeUsedForAsyncMethodsAnalyzerTests.cs(0 hunks)tests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cs(1 hunks)
💤 Files with no reviewable changes (7)
- src/Analyzers/LinqToMocksExpressionShouldBeValidAnalyzer.cs
- src/Analyzers/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzer.cs
- src/Analyzers/MockRepositoryVerifyAnalyzer.cs
- tests/Moq.Analyzers.Test/IsRaisesMethodTests.cs
- src/Common/EventSyntaxExtensions.cs
- tests/Moq.Analyzers.Test/ReturnsAsyncShouldBeUsedForAsyncMethodsAnalyzerTests.cs
- tests/Moq.Analyzers.Test/RefOutCallbackTests.cs
🧰 Additional context used
📓 Path-based instructions (7)
.github/workflows/**/*.yml
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
When making CI/CD changes, test workflows locally, provide validation evidence, update documentation, and consider performance impact.
Files:
.github/workflows/main.yml
**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Do not add or duplicate usings covered by src/Common/GlobalUsings.cs
**/*.cs: Add XML documentation for all public APIs.
Use tags for all type references in XML documentation instead of plain text.
Use for C# keywords in XML documentation.
Use for parameter references in XML documentation.
Use .. for inline code snippets in XML documentation.
All public APIs must have complete XML documentation with accurate and up-to-date information.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
⚙️ CodeRabbit Configuration File
**/*.cs: I need your help tracking down and fixing some bugs that have been reported in this codebase.I suspect the bugs are related to:
- Incorrect handling of edge cases
- Off-by-one errors in loops or array indexing
- Unexpected data types
- Uncaught exceptions
- Concurrency issues
- Improper configuration settings
To diagnose:
- Review the code carefully and systematically
- Trace the relevant code paths
- Consider boundary conditions and potential error states
- Look for antipatterns that tend to cause bugs
- Run the code mentally with example inputs
- Think about interactions between components
When you find potential bugs, for each one provide:
- File path and line number(s)
- Description of the issue and why it's a bug
- Example input that would trigger the bug
- Suggestions for how to fix it
After analysis, please update the code with your proposed fixes. Try to match the existing code style. Add regression tests if possible to prevent the bugs from recurring.
I appreciate your diligence and attention to detail! Let me know if you need any clarification on the intended behavior of the code.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
tests/Moq.Analyzers.Test/**/*.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
**/*.{cs,csproj,sln}
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
Build with 'dotnet build /p:PedanticMode=true'. All warnings must be treated as errors. PRs that do not build cleanly will be closed.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
tests/**/*.cs
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
tests/**/*.cs: Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Every analyzer and fixer must have comprehensive unit tests.
Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Use SetupAdd and SetupRemove only for virtual events, and only in Moq 4.18.4+.
Setups for explicit interface implementations must use the correct cast syntax (e.g., ((IMyInterface)x).Method()).
Use .Protected().Setup(...) only for protected virtual members, and only in Moq 4.18.4+.
Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Always include both Task and ValueTask scenarios in analyzer tests for async methods.
If your analyzer or code fix interacts with Callback or SetupSequence, ensure you have tests for both single and sequence setups.
Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Files:
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cstests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cstests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
{src/Analyzers/*Analyzer.cs,src/CodeFixes/*Fixer.cs,tests/Moq.Analyzers.Test/*AnalyzerTests.cs,tests/Moq.Analyzers.Test/*CodeFixTests.cs}
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components
Files:
tests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
tests/Moq.Analyzers.Test/*AnalyzerTests.cs
📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)
Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Files:
tests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cstests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs
🧠 Learnings (6)
📓 Common learnings
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-23T03:41:57.897Z
Learning: PerfDiff tool in src/tools/PerfDiff currently has no test coverage and requires comprehensive unit testing following repository guidelines for 100% coverage, including all 5 regression strategies, file I/O operations, mathematical edge cases, and command-line interface testing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: All changes must be covered by tests (including edge/failure paths)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Ensure all changes are covered by tests and documentation before committing
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
.github/workflows/main.yml (25)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to .github/workflows/**/*.yml : When making CI/CD changes, test workflows locally, provide validation evidence, update documentation, and consider performance impact.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/*.{cs} : Run Codacy CLI analysis on all changed files and fix all reported issues before submitting the PR.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: After rebasing or merging, review for duplicate or conflicting changes, especially in shared files or properties, and remove redundant changes.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .cursor/rules/codacy.mdc:0-0
Timestamp: 2025-07-19T08:09:35.156Z
Learning: If any issues are found in the new edits by codacy_cli_analyze, propose and apply fixes for them
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When making changes, follow the workflow: Edit/Add Code or Test → Run codacy_cli_analyze → Fix issues if any → Run/Update Tests → Fix test failures if any → Update Docs → Commit & PR.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-23T03:41:57.897Z
Learning: PerfDiff tool in src/tools/PerfDiff currently has no test coverage and requires comprehensive unit testing following repository guidelines for 100% coverage, including all 5 regression strategies, file I/O operations, mathematical edge cases, and command-line interface testing.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .cursor/rules/codacy.mdc:0-0
Timestamp: 2025-07-19T08:09:35.156Z
Learning: Do not run codacy_cli_analyze looking for changes in code coverage
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: src/tools/PerfDiff/.cursor/rules/codacy.mdc:0-0
Timestamp: 2025-07-27T02:45:09.441Z
Learning: Do not run codacy_cli_analyze looking for changes in code coverage.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Address all feedback from automated bots (e.g., Codeclimate, formatting/linting bots) as you would human reviewers; resolve all formatting and linting issues flagged by bots or CI before requesting review or merging.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: After any dependency change, run Codacy analysis with 'tool: trivy' and resolve vulnerabilities before continuing.
Learnt from: MattKotsenas
PR: #325
File: .github/workflows/label-issues.yml:14-14
Timestamp: 2025-01-17T21:44:41.600Z
Learning: As of January 2025, GitHub Actions ARM64 runners should use the syntax ubuntu-24.04-arm for the runs-on field, not the array syntax with separate OS and architecture labels.
Learnt from: MattKotsenas
PR: #325
File: .github/workflows/label-pr.yml:13-13
Timestamp: 2025-01-17T21:45:05.188Z
Learning: As of January 2025, GitHub-hosted ARM64 runners should use the syntax ubuntu-24.04-arm in GitHub Actions workflow files, as documented in the GitHub changelog.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to **/{packages.config,.csproj,.sln,global.json} : All dependency updates require security scanning. Run Trivy scan after dependency changes and address any vulnerabilities before merging.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .cursor/rules/conventional-commit-messages.mdc:0-0
Timestamp: 2025-07-19T08:09:45.503Z
Learning: The type fix MUST be used when a commit represents a bug fix for your application
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: All changes must have 100% test coverage, with xUnit tests written or updated for every new feature or bug fix.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always check for and follow any new rules in .cursor/rules/, .editorconfig, and .github/copilot-instructions.md before making changes.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Ensure all changes are covered by tests and documentation before committing.
Learnt from: rjmurillo
PR: #325
File: .github/workflows/dependabot-approve-and-auto-merge.yml:8-8
Timestamp: 2025-01-22T00:47:24.622Z
Learning: For the moq.analyzers repository, ARM64 runner migration can proceed without staged rollout as there are minimal dependencies, with policy configurations to be adjusted post-merge.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to {docs/rules/**,README.md} : Update docs/rules/ and README.md for any analyzer, code fix, or workflow change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Every pull request must include evidence of running code formatting, building with warnings as errors, and running all unit tests (console log/text or screenshots) in the PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Run all unit tests using 'dotnet test --settings ./build/targets/tests/test.runsettings'. All tests must pass.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Run dotnet test (all must pass)
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs (15)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to {src/Analyzers/*Analyzer.cs,src/CodeFixes/*Fixer.cs,tests/Moq.Analyzers.Test/*AnalyzerTests.cs,tests/Moq.Analyzers.Test/*CodeFixTests.cs} : Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use the project's data-driven test pattern for code fix tests: provide a public static IEnumerable<object[]> data source, use [Theory] and [MemberData], and define a static Template function with placeholders.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always check for and follow any new rules in .cursor/rules/, .editorconfig, and .github/copilot-instructions.md before making changes.
tests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cs (16)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: For Moq analyzers and tests: only set up or verify virtual, abstract, or interface members; do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Setups for explicit interface implementations must use the correct cast syntax (e.g., ((IMyInterface)x).Method()), and only test these scenarios if the Moq version supports them.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use all relevant verification methods (Verify, VerifyGet, VerifySet, VerifyAdd, VerifyRemove) in tests to ensure analyzer/fixer correctness.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: When testing code fixes that modify a class member, use a data-driven pattern: a public static IEnumerable<object[]> data source, a [Theory] test method with [MemberData], a static Template function with placeholders, and Verify.VerifyCodeFixAsync.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (26)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: Moq protected member APIs that need analyzer validation include: Setup, SetupSequence, SetupGet, SetupSet, Verify, VerifyGet, VerifySet, and As() for interface mapping. All protected members must be virtual or abstract to be mockable.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: If your PR changes or adds analyzer tests, include a note in the PR description about which Moq versions are targeted and how test data is grouped accordingly.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T17:25:24.857Z
Learning: Applies to {src/Analyzers//*.cs,tests//*.cs}: For Moq protected member setups using string-based overloads (e.g., mock.Protected().Setup("MethodName", ...)), use ItExpr matchers instead of It matchers. When using As<T>() interface mapping, regular It matchers are allowed in lambda expressions.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Always specify and test for both MockBehavior.Default and MockBehavior.Strict where relevant in analyzer tests.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Note Moq version compatibility for analyzer/test changes
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not add analyzer tests for static, const, or readonly members, as Moq cannot mock or set up these members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If a Moq feature has known limitations or edge cases (e.g., explicit interface implementation, event setup), document this in the test or analyzer code.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Do not include tests for APIs or patterns that do not exist in the targeted Moq version; such tests will fail at compile time.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to {src/Analyzers/*Analyzer.cs,src/CodeFixes/*Fixer.cs,tests/Moq.Analyzers.Test/*AnalyzerTests.cs,tests/Moq.Analyzers.Test/*CodeFixTests.cs} : Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: For every supported Moq feature, write tests that cover both valid and invalid usage; use Assert.Throws in tests to verify that invalid setups fail as expected.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .cursor/rules/conventional-commit-messages.mdc:0-0
Timestamp: 2025-07-19T08:09:45.503Z
Learning: The type fix MUST be used when a commit represents a bug fix for your application
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Always group and annotate tests by Moq version compatibility; do not include tests for features/APIs that do not exist in the targeted Moq version.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Only set up or verify virtual, abstract, or interface members in Moq analyzer tests. Do not attempt to set up or verify non-virtual, static, or sealed members.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.110Z
Learning: Do not include tests for features/APIs that do not exist in the targeted Moq version.
tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs (20)
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : In code fix tests, the code that triggers the analyzer MUST be wrapped with the diagnostic marker syntax (e.g., {|Moq1210:...|}).
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/**/*.cs : Add or update unit tests in tests/Moq.Analyzers.Test/ for every analyzer or code fix change
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to {src/Analyzers/*Analyzer.cs,src/CodeFixes/*Fixer.cs,tests/Moq.Analyzers.Test/*AnalyzerTests.cs,tests/Moq.Analyzers.Test/*CodeFixTests.cs} : Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*AnalyzerTests.cs : Use AllAnalyzersVerifier.VerifyAllAnalyzersAsync() for 'no diagnostics' tests
Learnt from: MattKotsenas
PR: #239
File: src/BannedSymbols.txt:1-8
Timestamp: 2024-10-24T21:06:43.546Z
Learning: All direct uses of Diagnostic.Create should be banned, even if DiagnosticExtensions doesn't currently wrap them. Developers should add an extension to DiagnosticExtensions if they need to use any of the Diagnostic.Create APIs.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Use [Description]Analyzer.cs, [Description]Fixer.cs, [Description]AnalyzerTests.cs, [Description]CodeFixTests.cs for new components.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/Moq.Analyzers.Benchmarks/**/*.cs : Performance-sensitive changes require benchmark validation. Run performance tests locally before submitting PRs and include performance regression analysis in PR description.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Use AllAnalyzersVerifier for tests that verify code patterns don't trigger unwanted diagnostics from any Moq analyzer.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Group analyzer tests by Moq version compatibility: place tests for features only available in Moq 4.18.4+ in a 'new' group, and tests for features available in both 4.8.2 and 4.18.4 in a 'both' or 'old' group.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to tests/Moq.Analyzers.Test/*CodeFixTests.cs : Use the [MemberData]-annotated [Theory] pattern with a public static IEnumerable<object[]> data source for code fix tests
Learnt from: rjmurillo
PR: #635
File: tests/Moq.Analyzers.Test/Common/MoqVerificationHelpersTests.cs:1-7
Timestamp: 2025-07-27T02:38:19.770Z
Learning: This project uses ImplicitUsings feature (<ImplicitUsings>enable</ImplicitUsings> in csproj files) which automatically includes common namespaces like System.Linq, making explicit using statements for these namespaces unnecessary.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-27T02:44:39.596Z
Learning: Applies to **/*.cs : Do not add or duplicate usings covered by src/Common/GlobalUsings.cs
Learnt from: MattKotsenas
PR: #226
File: src/Moq.Analyzers/SetExplicitMockBehaviorAnalyzer.cs:45-49
Timestamp: 2024-10-15T20:25:09.079Z
Learning: In this codebase, WellKnownTypeNames is included via global usings.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: If mocking internal members, ensure [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] is present in the test assembly.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-20T07:33:27.604Z
Learning: Moq1100 (CallbackSignatureShouldMatchMockedMethodAnalyzer) has severe performance characteristics due to two expensive operations per file: FindSetupMethodFromCallbackInvocation() uses a while(true) loop for syntax tree traversal, and GetAllMatchingMockedMethodSymbolsFromSetupMethodInvocation() performs expensive symbol resolution for method overloads. Processing 1,000 files takes 1.6+ seconds due to this compound complexity.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Never guess which Roslyn API to use; consult existing, working analyzers in src/ if unsure.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Avoid unnecessary complexity in test types and mock setups; each test should demonstrate a single Moq feature or analyzer rule.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-25T12:42:47.111Z
Learning: Before implementing an analyzer, verify you can trace the syntax tree path from mock.Verify() to the member access, understand Roslyn expression types, diagnostic span requirements, and when to use IOperation vs ISyntaxNode.
Learnt from: rjmurillo
PR: rjmurillo/moq.analyzers#0
File: :0-0
Timestamp: 2025-07-22T08:42:51.055Z
Learning: For the moq.analyzers repository, diagnostic IDs follow specific ranges: Moq1000-1099 (Usage), Moq1100-1199 (Correctness), Moq1200-1299 (Correctness), Moq1300-1399 (Usage), Moq1400-1499 (Best Practice), Moq1500-1599 (Best Practice), Moq1600-1999 (Reserved). No analyzers exist above 1600.
Learnt from: CR
PR: rjmurillo/moq.analyzers#0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-07-27T02:45:02.136Z
Learning: Applies to tests/**/*.cs : Every analyzer and fixer must have comprehensive unit tests.
🧬 Code Graph Analysis (1)
tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (1)
tests/Moq.Analyzers.Test/NoSealedClassMocksAnalyzerTests.cs (2)
EdgeCaseMethodCallsTestData(110-135)ShouldHandleEdgeCaseMethodCalls(353-376)
🪛 GitHub Check: Codacy Static Code Analysis
tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
[warning] 1-1: tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs#L1
Provide an 'AssemblyVersion' attribute for assembly 'srcassembly.dll'.
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: build (windows-11-arm)
🔇 Additional comments (13)
tests/Moq.Analyzers.Test/VerifyShouldBeUsedOnlyForOverridableMembersAnalyzerTests.cs (1)
395-423: Excellent edge case coverage for explicit interface implementations.The new test method properly covers an important edge case where the analyzer should handle explicit interface implementations gracefully without crashing or offering inappropriate fixes. The test correctly:
- Uses the established
[Theory]and[MemberData]pattern- Tests across all Moq reference assembly groups
- Uses the correct cast syntax
((IMyInterface)x).MyMethod()for explicit interface implementations- Verifies that no code fix is applied by expecting the source to remain unchanged
- Includes a helpful comment explaining the intent
The test aligns with the repository's comprehensive testing approach and follows all coding guidelines.
.github/workflows/main.yml (3)
47-47: Environment flag addition looks correct.
IS_TARGET_MAINis correctly computed using a branch-ref comparison and produces"true"/"false"strings that work cleanly in subsequentif:expressions.
71-76: Fail fast if coverage history is unexpectedly missing.Uploading nothing will silently succeed (default is
warn) and break future diffs. Enforce presence:with: name: CoverageHistory-${{ matrix.os }} path: ./artifacts/TestResults/coveragehistory + if-no-files-found: error
191-191: Baseline SHA surfaced—nice!Including the baseline commit in the step summary will make perf regressions far easier to triage.
tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs (3)
5-14: Test method correctly validates basic diagnostic creation from syntax nodes.The test appropriately creates a minimal syntax tree, constructs a diagnostic descriptor, and verifies that the resulting diagnostic has the expected ID and severity properties.
16-26: Test method correctly validates diagnostic creation from location with properties.The test properly verifies that diagnostics created from locations with custom properties retain both the diagnostic metadata and the additional properties dictionary.
28-41: Test method correctly validates diagnostic creation from IOperation.The test appropriately sets up the compilation context to obtain an IOperation and verifies that diagnostic creation delegates properly to the underlying syntax.
tests/Moq.Analyzers.Test/Common/DiagnosticEditPropertiesTests.cs (4)
14-26: Comprehensive test for all enum values ensures robust serialization.The test effectively uses
Enum.GetValuesto dynamically test all enum values, ensuring both current and future enum values are properly handled in round-trip serialization/deserialization.
28-42: Test properly validates edge cases for EditPosition values.The test appropriately covers boundary conditions by testing both negative values and the maximum integer value, ensuring robust serialization/deserialization of EditPosition across the full integer range.
44-54: Test ensures deserialization resilience against extra dictionary keys.The test appropriately validates that the deserialization logic ignores extraneous keys, which is important for robustness in scenarios where dictionaries may contain additional data.
56-67: Test comprehensively validates equality and hash code semantics.The test properly covers all aspects of equality testing including the
Equalsmethod, equality comparison, inequality comparison, and the hash code contract for equal objects.tests/Moq.Analyzers.Test/LinqToMocksExpressionShouldBeValidAnalyzerTests.cs (2)
10-38: Edge case test data provides comprehensive coverage of expression scenarios.The test data appropriately covers diverse expression types including conditional operators, null coalescing, casts, delegate invocations, and discard parameters. The diagnostic markers are correctly applied to invalid cases.
76-99: Test method properly implements edge case testing following established patterns.The test method correctly uses the theory/member data pattern and provides an appropriate interface definition to support the edge case expressions. The implementation follows the same structure as other test methods in the class.
There was a problem hiding this comment.
Bugbot free trial expires on July 29, 2025
Learn more in the Cursor dashboard.
| // Mismatched event handler type, compiler emits CS0029 for Action to EventHandler<CustomArgs> (span 23,36,23,71) | ||
| ["""mockProvider.SetupAdd(x => {|CS0029:x.CustomEvent += It.IsAny<Action>()|});"""], | ||
| }.WithNamespaces().WithNewMoqReferenceAssemblyGroups(); | ||
| } |
There was a problem hiding this comment.
Bug: Analyzer Tests Contain Compiler Errors
Analyzer tests in EventSetupHandlerShouldMatchEventTypeAnalyzerTests.cs's InvalidTestData include code that produces C# compiler errors (CS0029, CS0131). This violates a new mandatory rule in csharp.instructions.md prohibiting compiler errors in analyzer tests.
Locations (1)
| ["""mockProvider.SetupAdd(x => {|CS0131:x.ToString()|} += It.IsAny<Action>());"""], | ||
|
|
||
| // Mismatched event handler type, compiler emits CS0029 for Action to EventHandler<CustomArgs> (span 23,36,23,71) | ||
| ["""mockProvider.SetupAdd(x => {|CS0029:x.CustomEvent += It.IsAny<Action>()|});"""], |
There was a problem hiding this comment.
Bug: Test Cases Violate C# Compiler Error Guideline
The commit introduces test cases that produce or expect C# compiler errors (e.g., new Mock<IFoo>().Setup(null);, CS0029, CS0131). This violates the new mandatory guideline in csharp.instructions.md that prohibits such code in analyzer or code fix tests.
Related to #639
Summary by CodeRabbit
New Features
Documentation
Chores
Refactor / Style