Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ECS0200 suppression and update WellKnownTypes to not trigger ECS0600 #236

Merged
merged 5 commits into from
Oct 23, 2024

Conversation

rjmurillo
Copy link
Owner

@rjmurillo rjmurillo commented Oct 23, 2024

Effective C# rules 0200 and 0600 have violations in src/Common/WellKnownTypeNames.cs. This change updates the members in WellKnownTypes type and their usages

Related to rjmurillo/EffectiveCSharp.Analyzers#73, see item for discussion

  • Updated constant declarations to static read-only fields for improved flexibility as referenced in ECS0200 and removed suppression.
  • Updated naming conventions for WellKnownTypes to avoid triggering ECS0600
  • Updated control flow in src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs to move from switch, which requires compile time constants, to a more traditional if/else
  • Updated names in the former WellKnownTypeNames type (now WellKnownMoqNames) with improved names and added documentation

Copy link

coderabbitai bot commented Oct 23, 2024

📝 Walkthrough

Walkthrough

The pull request introduces significant updates to various classes in the Moq.Analyzers namespace, including ConstructorArgumentsShouldMatchAnalyzer, MoqMethodDescriptorBase, and AsShouldBeUsedOnlyForInterfaceAnalyzer. Key changes involve restructuring logic for improved clarity in method implementations, updating identifiers to reflect new naming conventions, and removing the WellKnownTypeNames class in favor of a new WellKnownMoqNames class. These modifications enhance the analyzers' ability to accurately identify mock object creations and improve diagnostic reporting without altering public entity signatures.

Changes

File Path Change Summary
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs - Replaced switch statement with if-else in AnalyzeInstanceCall for identifier checks.
- Updated identifier check in AnalyzeNewObject from WellKnownTypeNames.MockName to WellKnownMoqNames.MockTypeName.
src/Common/MoqMethodDescriptorBase.cs - Updated static string variables ContainingNamespace and ContainingType to use WellKnownMoqNames constants instead of WellKnownTypeNames.
src/Common/WellKnownTypeNames.cs - Entire class removed, eliminating various string constants related to Moq types.
src/Analyzers/AsShouldBeUsedOnlyForInterfaceAnalyzer.cs - Updated method name lookup from WellKnownTypeNames.As to WellKnownMoqNames.AsMethodName.
src/Analyzers/SetExplicitMockBehaviorAnalyzer.cs - Changed type and method name retrieval to use fully qualified names from WellKnownMoqNames.
src/Common/CompilationExtensions.cs - Updated parameters in GetMoqMock method to use fully qualified type names from WellKnownMoqNames.
src/Common/WellKnownMoqNames.cs - New class added containing static readonly fields for Moq identifiers, including namespace, type names, and method names.

Possibly related PRs

  • Refactor to support RS1038 #216: This PR introduces a new project structure and updates references that may affect the analyzers, including the SetExplicitMockBehaviorAnalyzer, which is relevant to the changes in the main PR regarding mock behavior handling.
  • Add rule to explicitly pick MockBehavior #226: This PR adds a new rule to explicitly pick MockBehavior, which directly relates to the changes in the main PR that enhance the handling of mock object creation and behavior.
  • Add IOperation to DiagnosticExtensions and clean up overloads #233: This PR modifies diagnostic reporting methods, which aligns with the changes in the main PR that also focus on improving diagnostic reporting in the ConstructorArgumentsShouldMatchAnalyzer and other analyzers.
  • Bug/fix issue 144 #224: This PR includes updates to the CallbackSignatureShouldMatchMockedMethodCodeFixTests, which may relate to the changes in the main PR that enhance the clarity and efficiency of mock handling in analyzers.

Suggested labels

bug, documentation, feature

Suggested reviewers

  • MattKotsenas

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codacy-production bot commented Oct 23, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.22% (target: -1.00%) 96.67% (target: 95.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (bbb213d) 601 538 89.52%
Head commit (8b16498) 614 (+13) 551 (+13) 89.74% (+0.22%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#236) 30 29 96.67%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range comments (4)
src/Common/MoqMethodDescriptorBase.cs (1)

Line range hint 19-26: Add null checks to prevent NullReferenceException.

The methods IsInMoqNamespace and IsInMockType could throw NullReferenceException if the input symbol or its properties are null.

Add defensive null checks:

 private static bool IsInMoqNamespace(ISymbol symbol)
-    => symbol.ContainingNamespace.Name.AsSpan().SequenceEqual(ContainingNamespace.AsSpan());
+    => symbol?.ContainingNamespace?.Name is string name 
+       && name.AsSpan().SequenceEqual(ContainingNamespace.AsSpan());

 private static bool IsInMockType(ISymbol symbol)
-    => symbol.ContainingType.Name.AsSpan().SequenceEqual(ContainingType.AsSpan());
+    => symbol?.ContainingType?.Name is string name 
+       && name.AsSpan().SequenceEqual(ContainingType.AsSpan());
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (3)

Line range hint 76-82: Fix potential ArgumentOutOfRangeException in IsFirstArgumentMockBehavior.

The method accesses argumentList?.Arguments[0] without checking if the Arguments collection is empty, which could throw an exception.

Apply this fix:

     private static bool IsFirstArgumentMockBehavior(SyntaxNodeAnalysisContext context, ArgumentListSyntax? argumentList)
     {
+        if (argumentList?.Arguments.Count == 0)
+        {
+            return false;
+        }
         ExpressionSyntax? expression = argumentList?.Arguments[0].Expression;
         return IsExpressionMockBehavior(context, expression);
     }

Line range hint 437-441: Add null check before accessing arguments in VerifyMockAttempt.

The code uses the null-coalescing operator but still accesses arguments array without checking if it's empty when hasMockBehavior is true.

Apply this fix:

     if (hasMockBehavior && arguments.Length > 0 && IsFirstArgumentMockBehavior(context, argumentList))
     {
         // They passed a mock behavior as the first argument; ignore as Moq swallows it
-        arguments = arguments.RemoveAt(0);
+        arguments = arguments.Length > 0 ? arguments.RemoveAt(0) : arguments;
     }

Line range hint 334-424: Consider simplifying complex constructor matching logic.

The AnyConstructorsFound method is quite complex and could be simplified to improve maintainability and reduce the risk of bugs.

Consider breaking down the method into smaller, focused methods:

  1. ValidateArgumentCount
  2. ValidateFixedParameters
  3. ValidateParamsParameters

This would make the code easier to test and maintain while reducing the cognitive complexity.

Example structure:

private static bool AnyConstructorsFound(
    IMethodSymbol[] constructors,
    ArgumentSyntax[] arguments,
    SyntaxNodeAnalysisContext context)
{
    return constructors.Any(constructor => 
        ValidateArgumentCount(constructor, arguments) &&
        ValidateFixedParameters(constructor, arguments, context) &&
        ValidateParamsParameters(constructor, arguments, context));
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between bbb213d and 06ea6bc.

📒 Files selected for processing (3)
  • src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (2 hunks)
  • src/Common/MoqMethodDescriptorBase.cs (1 hunks)
  • src/Common/WellKnownTypeNames.cs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Common/MoqMethodDescriptorBase.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Common/WellKnownTypeNames.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

🔇 Additional comments (5)
src/Common/WellKnownTypeNames.cs (3)

5-8: 🧹 Nitpick (assertive)

Consider the cross-assembly versioning implications of const to static readonly change.

While the change from const to static readonly addresses the ECS0200 rule, it has important implications:

  • Constants are embedded at compile-time in dependent assemblies
  • Static readonly fields require runtime lookup
  • This change makes the values more flexible but could affect cross-assembly version compatibility

Let's check for cross-assembly dependencies:


9-12: 🛠️ Refactor suggestion

Ensure initialization safety for interpolated strings.

The interpolated strings depend on other fields being properly initialized. While the C# runtime guarantees static field initialization order within a class, consider making these more robust:

Consider this alternative approach:

-    internal static readonly string MoqMock = $"{Moq}.{Mock}";
-    internal static readonly string MoqMock1 = $"{MoqMock}`1";
-    internal static readonly string MoqBehavior = $"{Moq}.{MockBehavior}";
-    internal static readonly string MoqRepository = $"{Moq}.MockRepository";
+    internal static readonly string MoqMock = string.Join(".", Moq, Mock);
+    internal static readonly string MoqMock1 = string.Concat(MoqMock, "`1");
+    internal static readonly string MoqBehavior = string.Join(".", Moq, MockBehavior);
+    internal static readonly string MoqRepository = string.Join(".", Moq, "MockRepository");

This approach:

  • Is more explicit about string concatenation
  • Provides better null-handling semantics
  • Maintains readability while being more robust

Likely invalid or redundant comment.


13-15: Verify method name constants match Moq's public API.

These method names are critical for the analyzer to correctly identify Moq API usage. Let's verify they match the actual API:

✅ Verification successful

Let me try a different approach to verify these method names in the codebase.


Based on the search results, I can now generate a final response.

Method name constants correctly match Moq's API

The search results confirm these method names are actively used in Moq's API:

  • As: Verified through AsShouldBeUsedOnlyForInterfaceAnalyzer.cs and documentation showing .As() is used for implementing multiple interfaces
  • Of: Verified through SetExplicitMockBehaviorAnalyzer.cs referencing Mock.Of() method
  • Create: While seen mostly in utility contexts, it appears to be a valid part of the API based on the analyzer implementations

The constants in WellKnownTypeNames.cs correctly represent these method names used throughout the codebase for analyzer matching purposes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for these method names in Moq's public API
ast-grep --pattern 'public $_ As($$$) { $$$ }'
ast-grep --pattern 'public static $_ Create($$$) { $$$ }'
ast-grep --pattern 'public static $_ Of($$$) { $$$ }'

Length of output: 164


Script:

#!/bin/bash
# Search for these method names using ripgrep for broader coverage
echo "Searching for 'As' method:"
rg "\.As\(" -A 2 -B 2

echo -e "\nSearching for 'Create' method:"
rg "\.Create\(" -A 2 -B 2

echo -e "\nSearching for 'Of' method:"
rg "\.Of\(" -A 2 -B 2

# Also check test files as they often demonstrate API usage
echo -e "\nSearching in test files:"
fd -e test.cs -X rg "\.As\(|\.Create\(|\.Of\("

Length of output: 10975

src/Common/MoqMethodDescriptorBase.cs (1)

15-15: LGTM! The field rename maintains consistency.

The update from WellKnownTypeNames.MockName to WellKnownTypeNames.Mock aligns with the changes in the WellKnownTypeNames class.

src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (1)

293-293: LGTM! Verify usage of WellKnownTypeNames.Mock across the codebase.

The update to use WellKnownTypeNames.Mock is correct and maintains consistency with the type name changes.

Let's verify that this is the only occurrence that needs updating:

✅ Verification successful

Based on the search results, I can now generate the final response:

All usages of WellKnownTypeNames.Mock are consistent across the codebase

The verification shows that all references to WellKnownTypeNames.Mock are being used correctly in their respective contexts:

  • Constructor argument analysis in ConstructorArgumentsShouldMatchAnalyzer.cs
  • Method descriptor base configuration in Common/MoqMethodDescriptorBase.cs

No instances of outdated "MockName" were found, and all existing usages follow the same pattern using WellKnownTypeNames.Mock.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining occurrences of the old mock type name
# that might need to be updated for consistency

# Search for any remaining occurrences of "MockName" that might need updating
rg "MockName" --type cs

# Search for all usages of Mock to verify consistency
rg "WellKnownTypeNames\.Mock" --type cs

Length of output: 970

src/Common/MoqMethodDescriptorBase.cs Show resolved Hide resolved
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs Outdated Show resolved Hide resolved
src/Common/WellKnownTypeNames.cs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 06ea6bc and 424f04d.

📒 Files selected for processing (1)
  • src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

🔇 Additional comments (2)
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (2)

289-289: LGTM! The WellKnownTypeNames.Mock usage is correct.

The change properly aligns with the PR objective to update WellKnownTypes and maintains the correct string comparison behavior.


213-219: 🛠️ Refactor suggestion

Extract string comparisons to improve maintainability.

The string comparison logic could be extracted to a helper method to improve maintainability and reduce duplication. This aligns with the DRY principle and makes the code more readable.

+ private static bool IsMethodName(string value, string expectedName) => 
+     string.Equals(value, expectedName, StringComparison.Ordinal);

- if (string.Equals(genericNameSyntaxIdentifierValue, WellKnownTypeNames.Create, StringComparison.Ordinal))
+ if (IsMethodName(genericNameSyntaxIdentifierValue, WellKnownTypeNames.Create))
 {
     AnalyzeInvocation(context, invocationExpressionSyntax, WellKnownTypeNames.MockFactory, true, true);
 }
- else if (string.Equals(genericNameSyntaxIdentifierValue, WellKnownTypeNames.Of, StringComparison.Ordinal))
+ else if (IsMethodName(genericNameSyntaxIdentifierValue, WellKnownTypeNames.Of))
 {
     AnalyzeInvocation(context, invocationExpressionSyntax, WellKnownTypeNames.Mock, false, true);
 }

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 23, 2024
@rjmurillo rjmurillo added housekeeping analyzers Change that impacts an analyzer behavior and removed bug labels Oct 23, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range comments (2)
src/Common/MoqMethodDescriptorBase.cs (2)

Line range hint 22-26: Add null checks and optimize string comparisons.

The string comparison methods lack null checks and make multiple string-to-span conversions. Consider:

  1. Adding null checks for parameters
  2. Caching the span conversions of static fields
+    // Cache the spans for better performance
+    private static readonly ReadOnlySpan<char> ContainingNamespaceSpan => ContainingNamespace.AsSpan();
+    private static readonly ReadOnlySpan<char> ContainingTypeSpan => ContainingType.AsSpan();

-    private static bool IsInMoqNamespace(ISymbol symbol) => 
-        symbol.ContainingNamespace.Name.AsSpan().SequenceEqual(ContainingNamespace.AsSpan());
+    private static bool IsInMoqNamespace(ISymbol symbol)
+    {
+        if (symbol?.ContainingNamespace?.Name is null)
+            return false;
+        return symbol.ContainingNamespace.Name.AsSpan().SequenceEqual(ContainingNamespaceSpan);
+    }

-    private static bool IsInMockType(ISymbol symbol) => 
-        symbol.ContainingType.Name.AsSpan().SequenceEqual(ContainingType.AsSpan());
+    private static bool IsInMockType(ISymbol symbol)
+    {
+        if (symbol?.ContainingType?.Name is null)
+            return false;
+        return symbol.ContainingType.Name.AsSpan().SequenceEqual(ContainingTypeSpan);
+    }

Line range hint 20-20: Add null check in IsFastMatch method.

The IsFastMatch method could throw NullReferenceException if memberAccessSyntax is null.

-    protected static bool IsFastMatch(MemberAccessExpressionSyntax memberAccessSyntax, ReadOnlySpan<char> methodName) => 
-        memberAccessSyntax.Name.Identifier.Text.AsSpan().SequenceEqual(methodName);
+    protected static bool IsFastMatch(MemberAccessExpressionSyntax memberAccessSyntax, ReadOnlySpan<char> methodName)
+    {
+        if (memberAccessSyntax?.Name?.Identifier.Text is null)
+            return false;
+        return memberAccessSyntax.Name.Identifier.Text.AsSpan().SequenceEqual(methodName);
+    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 424f04d and a4e7819.

📒 Files selected for processing (3)
  • src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (3 hunks)
  • src/Common/MoqMethodDescriptorBase.cs (1 hunks)
  • src/Common/WellKnownTypeNames.cs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Common/MoqMethodDescriptorBase.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Common/WellKnownTypeNames.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

🪛 GitHub Check: Codacy Static Code Analysis
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs

[failure] 217-217: src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs#L217
Add the missing 'else' clause with either the appropriate action or a suitable comment as to why no action is taken.

🔇 Additional comments (6)
src/Common/WellKnownTypeNames.cs (3)

5-6: LGTM! Clear separation of namespace and symbol name concerns.

The split into separate fields with explicit string literals better represents their distinct purposes and addresses the previous nameof() concerns.


7-9: LGTM! Appropriate use of nameof() for type names.

The use of nameof() is correct here as these represent actual type names, and the static readonly modifier provides the desired flexibility while maintaining immutability.


14-16: Verify the method name usage across the codebase.

The method names look correct, but let's verify they are used consistently for method symbol matching.

✅ Verification successful

Based on the results, I can now generate the final response as we have sufficient evidence about how these method names are used in the codebase.

Method names are correctly used for symbol matching across analyzers

The method names As, Create, and Of are consistently used for method symbol matching in various analyzers:

  • As is used in AsShouldBeUsedOnlyForInterfaceAnalyzer for identifying generic method symbols
  • Of is used in both SetExplicitMockBehaviorAnalyzer and ConstructorArgumentsShouldMatchAnalyzer for method identification
  • Create is used in ConstructorArgumentsShouldMatchAnalyzer for comparing method names

The usage aligns with their intended purpose as method symbol identifiers, and they are properly referenced using the WellKnownTypeNames class.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how these method names are used in the codebase
# to ensure they are used for method symbol matching

echo "Checking usage of As, Create, and Of methods:"
rg -A 5 "WellKnownTypeNames\.(As|Create|Of)"

Length of output: 3062

src/Common/MoqMethodDescriptorBase.cs (1)

Line range hint 14-26: Verify the impact of null checks across the codebase.

Let's verify how these methods are used across the codebase to ensure the added null checks won't cause unexpected behavior.

src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (2)

208-211: Simplify the null check pattern.

This pattern can be more concise by combining it with the return statement.


Line range hint 289-300: LGTM! Type name reference updates are consistent.

The updates to use WellKnownTypeNames.Mock and WellKnownTypeNames.MoqSymbolName are consistent with the PR objectives and maintain the same behavior.

src/Common/WellKnownTypeNames.cs Outdated Show resolved Hide resolved
src/Common/MoqMethodDescriptorBase.cs Outdated Show resolved Hide resolved
src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs Outdated Show resolved Hide resolved
src/Common/WellKnownTypeNames.cs Outdated Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 23, 2024
Copy link

codeclimate bot commented Oct 23, 2024

Code Climate has analyzed commit 8b16498 and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Style 1

View more on Code Climate.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Outside diff range comments (2)
src/Common/CompilationExtensions.cs (1)

Line range hint 26-38: Document the behavior when Moq types aren't found.

The XML documentation should clarify what happens when Moq isn't referenced in the compilation.

  /// <summary>
  /// Get the Moq.MockRepository, Moq.Mock and Moq.Mock`1 type symbols (if part of the compilation).
  /// </summary>
  /// <param name="compilation">The <see cref="Compilation"/> to inspect.</param>
  /// <returns>
  /// <see cref="INamedTypeSymbol"/>s for the Moq.Mock symbols that are part of the compilation.
- /// An empty array if none (never <see langword="null"/>).
+ /// An empty array if none of the types are found, which can happen when:
+ /// - Moq isn't referenced in the compilation
+ /// - Only some of the types are found due to version mismatches
+ /// The method never returns <see langword="null"/>.
  /// </returns>
src/Analyzers/SetExplicitMockBehaviorAnalyzer.cs (1)

Line range hint 91-102: Potential bug: Analyzer might miss valid behavior specifications.

The analyzer only checks for behavior specified through field references (e.g., MockBehavior.Strict). It might miss cases where the behavior is specified through:

  1. Local variables
  2. Properties
  3. Method calls
  4. Constants

This could lead to false positives where the analyzer reports a warning even though the behavior is explicitly set.

Consider updating the argument checking logic to handle more cases. Here's a suggested approach:

 foreach (IArgumentOperation argument in creationOperation.Arguments)
 {
-    if (argument.Value is IFieldReferenceOperation fieldReferenceOperation)
+    if (argument.Value.Type?.IsInstanceOf(mockBehaviorSymbol) == true)
     {
-        ISymbol field = fieldReferenceOperation.Member;
-        if (field.ContainingType.IsInstanceOf(mockBehaviorSymbol) && IsExplicitBehavior(field.Name))
+        // If it's a field reference, check the name
+        if (argument.Value is IFieldReferenceOperation fieldRef &&
+            IsExplicitBehavior(fieldRef.Member.Name))
         {
             return;
         }
+        // If it's a property reference or method call, consider it explicit
+        if (argument.Value is IPropertyReferenceOperation or IMethodReferenceOperation)
+        {
+            return;
+        }
     }
 }

Apply the same changes to the AnalyzeInvocation method.

Also applies to: 121-132

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between a4e7819 and 8b16498.

📒 Files selected for processing (7)
  • src/Analyzers/AsShouldBeUsedOnlyForInterfaceAnalyzer.cs (1 hunks)
  • src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (6 hunks)
  • src/Analyzers/SetExplicitMockBehaviorAnalyzer.cs (2 hunks)
  • src/Common/CompilationExtensions.cs (1 hunks)
  • src/Common/MoqMethodDescriptorBase.cs (1 hunks)
  • src/Common/WellKnownMoqNames.cs (1 hunks)
  • src/Common/WellKnownTypeNames.cs (0 hunks)
💤 Files with no reviewable changes (1)
  • src/Common/WellKnownTypeNames.cs
🧰 Additional context used
📓 Path-based instructions (6)
src/Analyzers/AsShouldBeUsedOnlyForInterfaceAnalyzer.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Analyzers/SetExplicitMockBehaviorAnalyzer.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Common/CompilationExtensions.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Common/MoqMethodDescriptorBase.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

src/Common/WellKnownMoqNames.cs (1)

Pattern **/*.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:

  1. Review the code carefully and systematically
  2. Trace the relevant code paths
  3. Consider boundary conditions and potential error states
  4. Look for antipatterns that tend to cause bugs
  5. Run the code mentally with example inputs
  6. Think about interactions between components

When you find potential bugs, for each one provide:

  1. File path and line number(s)
  2. Description of the issue and why it's a bug
  3. Example input that would trigger the bug
  4. 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.

📓 Learnings (2)
src/Analyzers/SetExplicitMockBehaviorAnalyzer.cs (1)
Learnt from: MattKotsenas
PR: rjmurillo/moq.analyzers#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.
src/Common/WellKnownMoqNames.cs (1)
Learnt from: MattKotsenas
PR: rjmurillo/moq.analyzers#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.
🔇 Additional comments (9)
src/Common/MoqMethodDescriptorBase.cs (1)

14-15: Verify complete migration from WellKnownTypeNames.

Let's ensure all references have been updated from WellKnownTypeNames to WellKnownMoqNames.

✅ Verification successful

Let me gather more context about the usage of WellKnownMoqNames to ensure the migration is complete and consistent.


Based on the comprehensive results, I can now provide the final response:

Migration from WellKnownTypeNames to WellKnownMoqNames is complete and consistent

The verification shows that:

  • No references to the old WellKnownTypeNames remain in the codebase
  • All usages consistently use WellKnownMoqNames with proper member access
  • The migration appears to be part of a well-executed refactoring, with WellKnownMoqNames being used consistently across multiple files including analyzers and common utilities
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify complete migration from WellKnownTypeNames to WellKnownMoqNames

# Test 1: Check for any remaining references to WellKnownTypeNames
echo "Checking for remaining WellKnownTypeNames references..."
rg "WellKnownTypeNames" -l

# Test 2: Verify consistent usage of new WellKnownMoqNames
echo "Verifying WellKnownMoqNames usage..."
rg "WellKnownMoqNames\.(MoqNamespace|MockTypeName)" -l

Length of output: 382


Script:

#!/bin/bash
# Let's examine the actual usage in both files to verify the consistency

echo "Checking usage in MoqMethodDescriptorBase.cs:"
rg "WellKnownMoqNames" src/Common/MoqMethodDescriptorBase.cs -B 1 -A 1

echo -e "\nChecking usage in ConstructorArgumentsShouldMatchAnalyzer.cs:"
rg "WellKnownMoqNames" src/Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs -B 1 -A 1

# Let's also check if there are any other similar "WellKnown" types in use
echo -e "\nChecking for other WellKnown types:"
rg "WellKnown\w+Names?" --type cs

Length of output: 5200

src/Common/CompilationExtensions.cs (1)

37-37: Verify WellKnownMoqNames constants exist in the codebase.

Let's ensure the new constants are properly defined and accessible.

✅ Verification successful

Let me gather more context about the WellKnownMoqNames class to ensure it's properly defined with all necessary components.


WellKnownMoqNames constants are properly defined and used correctly

The verification shows that:

  • The WellKnownMoqNames class is well-structured and properly defined
  • All required constants (FullyQualifiedMoqMockTypeName, FullyQualifiedMoqMock1TypeName, FullyQualifiedMoqRepositoryTypeName) are correctly defined using string interpolation
  • The base components (MoqNamespace and MockTypeName) are properly initialized
  • The class is well-documented with XML comments explaining each constant's purpose

The usage in CompilationExtensions.cs is correct and type-safe. No issues were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and definition of WellKnownMoqNames constants

# Test 1: Find the WellKnownMoqNames class definition
echo "Searching for WellKnownMoqNames class definition..."
ast-grep --pattern 'class WellKnownMoqNames {
  $$$
}'

# Test 2: Find the specific constant definitions
echo "Searching for the specific constants..."
rg "FullyQualifiedMoqMockTypeName|FullyQualifiedMoqMock1TypeName|FullyQualifiedMoqRepositoryTypeName" -A 1

Length of output: 1174


Script:

#!/bin/bash
# Get the full content of WellKnownMoqNames.cs to verify the class structure and dependencies
echo "Full content of WellKnownMoqNames.cs:"
cat src/Common/WellKnownMoqNames.cs

# Check if MoqNamespace and MockTypeName are defined
echo -e "\nSearching for MoqNamespace and MockTypeName definitions:"
rg "MoqNamespace|MockTypeName" src/Common/WellKnownMoqNames.cs

Length of output: 3655

src/Common/WellKnownMoqNames.cs (3)

1-7: LGTM! Well-structured class declaration with clear documentation.

The class is appropriately scoped as internal static and follows good documentation practices.


57-74: LGTM! Well-documented method names.

The method name constants are clearly documented and follow the same pattern as the rest of the class.


1-74: Verify migration from WellKnownTypeNames.

Let's ensure all references to the old WellKnownTypeNames class have been updated to use WellKnownMoqNames.

✅ Verification successful

Based on the results, I can now generate the final response:

Migration from WellKnownTypeNames is complete

The verification shows that:

  • No references to the old WellKnownTypeNames class remain in the codebase
  • The new WellKnownMoqNames class is properly used across multiple files including:
    • ConstructorArgumentsShouldMatchAnalyzer.cs
    • SetExplicitMockBehaviorAnalyzer.cs
    • AsShouldBeUsedOnlyForInterfaceAnalyzer.cs
    • CompilationExtensions.cs
    • MoqMethodDescriptorBase.cs
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to WellKnownTypeNames

# Test: Search for WellKnownTypeNames references
echo "Checking for remaining references to WellKnownTypeNames..."
rg "WellKnownTypeNames"

# Test: Verify all files using the new WellKnownMoqNames
echo "Verifying usage of WellKnownMoqNames..."
rg "WellKnownMoqNames"

Length of output: 3040

src/Analyzers/AsShouldBeUsedOnlyForInterfaceAnalyzer.cs (2)

47-47: LGTM: Member name update is correct.

The change from WellKnownTypeNames.As to WellKnownMoqNames.AsMethodName aligns with the PR objectives to update naming conventions.


46-50: Verify thread safety of member lookup.

The code enables concurrent execution but performs member lookups that could potentially be affected by concurrent compilation changes.

Let's verify the thread safety implications:

src/Analyzers/SetExplicitMockBehaviorAnalyzer.cs (2)

54-54: LGTM! Verify the method name.

The change to use WellKnownMoqNames.OfMethodName is correct and maintains proper filtering for generic methods.

Let's verify the method name is correctly defined:

#!/bin/bash
# Description: Verify the method name for Mock.Of()
# Expected: Should find the constant definition in WellKnownMoqNames

# Test: Search for the constant definition
ast-grep --pattern 'public const string OfMethodName = $_'

45-45: LGTM! Verify the fully qualified type name.

The change to use WellKnownMoqNames.FullyQualifiedMoqBehaviorTypeName is correct and maintains proper null checking.

Let's verify the type name is correctly defined:

✅ Verification successful

Let me try a different approach to verify the type name definition.


Let me check the specific content of the WellKnownMoqNames.cs file to verify the constant definition.


The type name change is correctly implemented and verified

The change to use WellKnownMoqNames.FullyQualifiedMoqBehaviorTypeName is correct. The constant is properly defined in WellKnownMoqNames.cs as $"{MoqNamespace}.{MockBehaviorTypeName}" which resolves to "Moq.MockBehavior", the correct fully qualified name for the Moq behavior type.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the fully qualified type name for MockBehavior
# Expected: Should find the constant definition in WellKnownMoqNames

# Test: Search for the constant definition
ast-grep --pattern 'public const string FullyQualifiedMoqBehaviorTypeName = $_'

Length of output: 154


Script:

#!/bin/bash
# Search for files that might contain the WellKnownMoqNames class
fd "WellKnownMoqNames.cs"

# Search for any file containing MoqBehavior type name definition
rg -l "MoqBehavior" 

# Get content of any file containing WellKnownMoqNames
rg -A 5 "WellKnownMoqNames" 

Length of output: 8275


Script:

#!/bin/bash
# Get the content of WellKnownMoqNames.cs
cat src/Common/WellKnownMoqNames.cs

Length of output: 2828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzers Change that impacts an analyzer behavior bug housekeeping releasable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants