Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 3.32 KB

File metadata and controls

46 lines (35 loc) · 3.32 KB

Gemini Code Assistant Context

This document provides context for the Gemini Code Assistant to understand the project structure, conventions, and tasks.

Project Overview

This project implements Roslyn analyzers for the ErrorOr<T> type to enforce safe access patterns.

  • Goal: This project implements Roslyn analyzers for the ErrorOr<T> type to enforce safe access patterns.
  • Key Files:
    • Analyzers are located in src/Result.Analyzers/Diagnostics/ErrorOr/.
    • Unit tests are in tests/Result.Analyzers.Tests/.
    • A real-world sample project for observing analyzer behavior is in tests/Result.Analyzers.Sample/.

Building and Running

  • Testing Framework: The project uses TUnit with Microsoft.Testing.Platform. Every piece of code we write, should be covered by a unit test.
  • Primary Test Command: To run the full suite, use the command:
    dotnet run
  • Important Limitation: The test runner configuration does not support the standard dotnet test --filter command. To validate specific scenarios, you may need to run the full suite or temporarily disable other tests.

Development Conventions

  • Validation Scope: When implementing a new validation check (e.g., for a C# operator or pattern), the logic must be applied consistently to all relevant ErrorOr<T> properties: .Value, .FirstError, and .Errors. The shared ResultAccessAnalyzerBase class should be used to facilitate this.
  • Sample Project Scenarios: The tests/Result.Analyzers.Sample/Program.cs file contains important real-world test cases. These should be referenced to understand and replicate specific bugs or desired behaviors. For example, EAT5 and EAT6 are specific ternary operator test cases which are expected not to warn as they represent safe access patterns within the sample.
  • Analyzer Best Practices:
    • RS1038: Do not reference Microsoft.CodeAnalysis.Workspaces packages in the analyzer project (Result.Analyzers.csproj).
    • RS1030: Avoid calling compilation.GetSemanticModel() repeatedly. Instead, get the SemanticModel once from the OperationAnalysisContext (context.Operation.SemanticModel) at the beginning of the analysis and pass it to helper methods.
  • Test Refactoring: The test project currently uses partial classes. This is a temporary state and should be refactored into single, consolidated files when possible (Task noted in Todo.md).

Project Roadmap

The Todo.md file outlines a comprehensive roadmap for the project, including:

  • v1.1 - v1.5: Additional property tracking, pattern matching support, ternary/conditional operators, variable state tracking, and advanced control flow.
  • v1.G: General tasks like removing partial classes from tests.
  • v1.6: Additional code fixes.
  • v2.0 - v2.1: Custom attributes support and interprocedural analysis.
  • v3.0: Multi-library support.
  • Performance & Optimization: Benchmarking, profiling, and optimizations.
  • Developer Experience: Improved diagnostic messages, tooltips, and configuration.
  • Testing: Increased test coverage, integration tests, and performance regression tests.
  • Documentation: Wiki, migration guide, best practices, and tutorials.
  • Community & Ecosystem: Collaboration with other projects and community engagement.