Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

Visitor Pattern Generator Enhancement Plan

Analysis Complete

  • Analyzed existing VisitorGenerator implementation
  • Identified missing features from requirements
  • Reviewed existing test coverage and documentation

Implementation Plan

Phase 1: Core Enhancements

  • Add support for interface base types (IShape example)
  • Add support for value types (structs)
  • Enhanced type discovery for all type kinds
  • Intelligent visitor interface naming
  • Add support for abstract base classes validation
  • Add comprehensive diagnostics (PKVIS001, PKVIS002, PKVIS004)
  • Add proper record type support with correct keywords

Phase 2: Advanced Features

  • Add multiple visitor families support (deferred)
  • Add context parameter support for visitors (deferred)
  • Add generic type hierarchy support (deferred)

Phase 3: Documentation & Testing

  • Update visitor-generator.md documentation
  • Add comprehensive tests for diagnostic scenarios
  • Add tests for record hierarchies
  • Add tests for interface partial validation
  • Existing examples demonstrate new capabilities

Phase 4: Quality & Coverage

  • Run linting and fix any issues
  • Ensure all new code has test coverage
  • Run code review and address ALL feedback
  • Run CodeQL security checks - CLEAN ✓

Completed Features

  • ✅ Interface-based hierarchies fully supported
  • ✅ Struct visitor support with value semantics
  • ✅ Record type support with correct keywords
  • ✅ Smart naming (IShape -> IShapeVisitor)
  • ✅ Comprehensive diagnostics (PKVIS001, PKVIS002, PKVIS004)
  • ✅ All 37 tests passing (7 new tests total)
  • ✅ Documentation updated and accurate
  • ✅ All PR review feedback addressed
  • ✅ Security scan clean

PR Review Feedback Addressed

First Review (99942b4):

  • ✅ Fixed interface partial check (was incorrectly excluded)
  • ✅ Added proper record type keyword detection
  • ✅ Removed unused PKVIS003 diagnostic
  • ✅ Added explicit .Where() for filtering
  • ✅ Simplified IsPartial with LINQ
  • ✅ Added record hierarchy tests
  • ✅ Added non-partial interface test

Second Review (this commit):

  • ✅ Use IsDerivedFrom for structs (consistency with classes/records)
  • ✅ Fixed documentation clarifying interfaces require partial keyword
Original prompt

This section details on the original issue you should resolve

<issue_title>Generator: Create Visitor Pattern</issue_title>
<issue_description>## Summary

Implement a source generator that emits all the boilerplate normally required for the Visitor design pattern, including:

  • visitor interface definitions
  • accept methods on element types
  • visitor dispatch logic
  • optional generic return types for visitors
  • support for multiple visitor families
  • ergonomic annotations to opt in and control behavior

All generated code should be:

  • reflection-free
  • compile-time deterministic
  • allocation-light
  • consistent with PatternKit’s source-gen approach

Motivation & Context

The Visitor pattern is a classic behavioral design pattern that separates algorithms from the objects on which they operate, enabling new operations to be added without modifying the object structure. ([refactoring.guru][2])

In C#, implementing a visitor typically requires:

  • a visitor interface with a Visit method for each concrete element
  • an Accept method in every element
  • a lot of repetitive boilerplate
  • error-prone pattern matching or casts

Source generation can make this automatic, safe, and ergonomic.


Goals

G1 — Source-gen visitor interfaces and accept methods

From minimal input, generate a visitor interface (or interfaces) and implement the required accept methods on all participating types.

G2 — Support multiple visitor families

Allow multiple independent visitor sets within a single project.

For example, one family for validation logic and another for serialization logic.

G3 — Support void and generic visitors

Visitor operations should optionally return values (TResult) and accept context parameters.

G4 — Make the generated API ergonomic

Prefer compile-time dispatch over switch / if / type casting. Avoid reflection entirely.

G5 — Deterministic ordering & diagnostics

The generator should provide diagnostics if new concrete types are introduced but not included in visitors, and deterministic visit order where applicable.


User Experience

Opt-in Model

Users mark a base type and, optionally, concrete types they want included in a visitor family.

Example: Interface base

[VisitorNode]
public partial interface IShape { }

User defines shapes:

public partial class Circle : IShape { /*...*/ }
public partial class Rectangle : IShape { /*...*/ }
public partial class Triangle : IShape { /*...*/ }

The generator produces:

  • IShapeVisitor interface with Visit(Circle), Visit(Rectangle), Visit(Triangle)
  • Accept(visitor) on each concrete type

Example: Abstract base class

[VisitorNode]
public abstract partial class Node { }

User defines:

public partial class Leaf : Node { /* ... */ }
public partial class Branch : Node { /* ... */ }

Generated code augments both with Accept.


Generated Output (Desired Shape)

Visitor Interface

Generated on the base type:

public interface IShapeVisitor
{
    void Visit(Circle shape);
    void Visit(Rectangle shape);
    void Visit(Triangle shape);
}

Generic Visitor

Optionally support returning a result:

public interface IShapeVisitor<TResult>
{
    TResult Visit(Circle shape);
    TResult Visit(Rectangle shape);
    TResult Visit(Triangle shape);
}

Accept Methods

public partial class Circle : IShape
{
    public void Accept(IShapeVisitor visitor) => visitor.Visit(this);
    public TResult Accept<TResult>(IShapeVisitor<TResult> visitor)
        => visitor.Visit(this);
}

Multiple Visitor Families Supported

Example with diagnostics:

[VisitorNode("Validation")]
public partial interface IAstNode { }

[VisitorNode("Rendering")]
public partial interface IAstNode { }

Each family emits:

  • IAstNodeVisitor_Validation
  • IAstNodeVisitor_Rendering
  • augment accept methods accordingly

Options & Extensions

Support for Interface Segregation

Allow optional base visitor interfaces to group common visit methods:

[VisitorNode(BaseVisitor = typeof(IVisitorBase))]
public partial interface IExpr { }

Generated visitors implement the base.

Context Parameters

Visitors may accept a context parameter:

interface IShapeVisitor<TContext>
{
    void Visit(Circle shape, TContext ctx);}

This allows stateful visitors without external state capture.

Default Implementation Hooks

Generated partial visitor interface stub could contain no-op defaults:

public partial interface IShapeVisitor
{
    void Visit(Circle shape) => DefaultVisit(shape);}

Optional generator flag to emit defaults.


Diagnostics

Provide generator diagnostics for:

| ID | Meaning |
| -------- | -------------------...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits January 22, 2026 02:44
- Support interface-based hierarchies (e.g., IShape)
- Support struct types that implement visitor interfaces
- Intelligent visitor interface naming (IShape -> IShapeVisitor, not IIShapeVisitor)
- Enhanced type discovery to find classes, structs, records, and interfaces
- Add comprehensive tests for interface and struct hierarchies

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
- Add PKVIS001: Warning for no concrete types found
- Add PKVIS002: Error for non-partial base types
- Add PKVIS003: Warning for inaccessible types
- Add PKVIS004: Error for non-partial derived types
- Update AnalyzerReleases.Unshipped.md with new diagnostic IDs
- Add IsPartial helper method for checking partial keyword

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
- Add comprehensive section on supported hierarchy types
- Document interface-based hierarchies with examples
- Document struct-based hierarchies for allocation-free patterns
- Document record types support
- Add Diagnostics section with all PKVIS001-004 errors
- Update overview to mention support for all type kinds

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
- Add test for PKVIS001 (no concrete types found)
- Add test for PKVIS002 (base type not partial)
- Add test for PKVIS004 (derived type not partial)
- Add test for valid hierarchy with no diagnostics
- All 34 visitor generator tests passing

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
- Add using statement for Microsoft.CodeAnalysis.CSharp
- Extract interface naming logic into GetDefaultVisitorInterfaceName method
- Improve code maintainability and testability
- All tests passing, CodeQL clean

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add source generator for Visitor pattern implementation feat: Extend Visitor generator to support interface and struct hierarchies Jan 22, 2026
Copilot AI requested a review from JerrettDavis January 22, 2026 03:01
@JerrettDavis JerrettDavis marked this pull request as ready for review January 22, 2026 03:12
@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

Test Results

145 tests   145 ✅  25s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit eb05aaa.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

🔍 PR Validation Results

Version: ``

✅ Validation Steps

  • Build solution
  • Run tests
  • Build documentation
  • Dry-run NuGet packaging

📊 Artifacts

Dry-run artifacts have been uploaded and will be available for 7 days.


This comment was automatically generated by the PR validation workflow.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.09%. Comparing base (a99c27d) to head (eb05aaa).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #90      +/-   ##
==========================================
+ Coverage   85.75%   90.09%   +4.33%     
==========================================
  Files         143      143              
  Lines       12205    12288      +83     
  Branches     1623     1641      +18     
==========================================
+ Hits        10467    11071     +604     
+ Misses       1329     1217     -112     
+ Partials      409        0     -409     
Flag Coverage Δ
unittests 90.09% <100.00%> (+4.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request extends the Visitor Pattern Generator to support interface, struct, and record hierarchies, not just class-based hierarchies. The generator now produces visitor infrastructure for any type hierarchy marked with [GenerateVisitor], enabling value-type visitors without boxing and interface-based polymorphism patterns.

Changes:

  • Extended type discovery to accept interfaces, structs, and records as base types for visitor hierarchies
  • Implemented intelligent visitor interface naming that avoids double-I prefixes for interface base types (IShape → IShapeVisitor)
  • Added four new diagnostics (PKVIS001-004) to validate hierarchy structure and partial keyword requirements

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/PatternKit.Generators/VisitorGenerator.cs Core generator logic extended with interface/struct support, type discovery helpers, and diagnostic reporting
test/PatternKit.Generators.Tests/VisitorGeneratorTests.cs Added 6 new tests covering interface/struct hierarchies and diagnostic validation
src/PatternKit.Generators.Abstractions/Visitors/VisitorAttributes.cs Updated AttributeUsage to allow Interface and Struct targets
docs/generators/visitor-generator.md Comprehensive documentation of new hierarchy types and diagnostic codes
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Documented four new diagnostic codes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JerrettDavis
Copy link
Owner

@copilot apply changes based on the comments in this thread

- Remove interface exclusion from partial check (fixes PKVIS002 for interfaces)
- Add proper record type keyword detection (record/record struct)
- Remove unused PKVIS003 diagnostic
- Add explicit .Where() and .Select() for better readability
- Simplify IsPartial method with LINQ
- Add tests for record hierarchies
- Add test for non-partial interface base types
- Update documentation to remove PKVIS003

All 37 tests passing.

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot apply changes based on the comments in this thread

All review feedback addressed in commit 99942b4. Changes include:

✅ Fixed interface partial validation (PKVIS002 now applies to interfaces)
✅ Added proper record/record struct keyword detection
✅ Removed unused PKVIS003 diagnostic
✅ Added 3 new tests (record hierarchies + non-partial interface)
✅ Improved code readability with explicit LINQ filtering

All 37 tests passing.

Copilot AI requested a review from JerrettDavis January 22, 2026 03:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JerrettDavis
Copy link
Owner

@copilot apply changes based on the comments in this thread

- Use IsDerivedFrom instead of ImplementsInterface for struct discovery (consistency)
- Update documentation to clarify interfaces also require partial keyword
- All 37 tests passing

Co-authored-by: JerrettDavis <2610199+JerrettDavis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot apply changes based on the comments in this thread

Both issues addressed in commit eb05aaa:

✅ Structs now use IsDerivedFrom for consistency
✅ Documentation updated to clarify interfaces require partial keyword

All 37 tests passing.

@github-actions
Copy link
Contributor

Code Coverage

Summary
  Generated on: 01/22/2026 - 04:44:27
  Coverage date: 01/22/2026 - 04:43:38 - 01/22/2026 - 04:44:21
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 338
  Files: 209
  Line coverage: 80.5%
  Covered lines: 11176
  Uncovered lines: 2702
  Coverable lines: 13878
  Total lines: 36214
  Branch coverage: 71.3% (3330 of 4669)
  Covered branches: 3330
  Total branches: 4669
  Method coverage: 77.4% (2241 of 2892)
  Full method coverage: 72% (2085 of 2892)
  Covered methods: 2241
  Fully covered methods: 2085
  Total methods: 2892

PatternKit.Core                                                                                                   96.8%
  PatternKit.Behavioral.Chain.ActionChain<T>                                                                       100%
  PatternKit.Behavioral.Chain.AsyncActionChain<T>                                                                  100%
  PatternKit.Behavioral.Chain.AsyncResultChain<T1, T2>                                                            97.7%
  PatternKit.Behavioral.Chain.ResultChain<T1, T2>                                                                  100%
  PatternKit.Behavioral.Command.Command<T>                                                                         100%
  PatternKit.Behavioral.Interpreter.ActionInterpreter                                                              100%
  PatternKit.Behavioral.Interpreter.ActionInterpreter<T>                                                          96.9%
  PatternKit.Behavioral.Interpreter.ActionInterpreterBuilder<T>                                                    100%
  PatternKit.Behavioral.Interpreter.AsyncActionInterpreter                                                         100%
  PatternKit.Behavioral.Interpreter.AsyncActionInterpreter<T>                                                      100%
  PatternKit.Behavioral.Interpreter.AsyncActionInterpreterBuilder<T>                                               100%
  PatternKit.Behavioral.Interpreter.AsyncInterpreter                                                               100%
  PatternKit.Behavioral.Interpreter.AsyncInterpreter<T1, T2>                                                      96.8%
  PatternKit.Behavioral.Interpreter.AsyncInterpreterBuilder<T1, T2>                                                100%
  PatternKit.Behavioral.Interpreter.Builder<T1, T2>                                                                 96%
  PatternKit.Behavioral.Interpreter.ExpressionExtensions                                                           100%
  PatternKit.Behavioral.Interpreter.Interpreter                                                                    100%
  PatternKit.Behavioral.Interpreter.Interpreter<T1, T2>                                                           96.6%
  PatternKit.Behavioral.Interpreter.NonTerminalExpression                                                          100%
  PatternKit.Behavioral.Interpreter.TerminalExpression                                                             100%
  PatternKit.Behavioral.Iterator.AsyncFlow<T>                                                                      100%
  PatternKit.Behavioral.Iterator.AsyncFlowExtensions                                                               100%
  PatternKit.Behavioral.Iterator.AsyncReplayBuffer<T>                                                             93.6%
  PatternKit.Behavioral.Iterator.Flow<T>                                                                          94.4%
  PatternKit.Behavioral.Iterator.FlowExtensions                                                                    100%
  PatternKit.Behavioral.Iterator.ReplayableSequence<T>                                                            98.2%
  PatternKit.Behavioral.Iterator.ReplayableSequenceExtensions                                                      100%
  PatternKit.Behavioral.Iterator.SharedAsyncFlow<T>                                                                100%
  PatternKit.Behavioral.Iterator.SharedFlow<T>                                                                     100%
  PatternKit.Behavioral.Iterator.WindowSequence                                                                    100%
  PatternKit.Behavioral.Mediator.Mediator                                                                         91.9%
  PatternKit.Behavioral.Mediator.MediatorHelpers                                                                   100%
  PatternKit.Behavioral.Mediator.TaskExtensions                                                                    100%
  PatternKit.Behavioral.Memento.Memento<T>                                                                         100%
  PatternKit.Behavioral.Observer.AsyncObserver<T>                                                                 98.7%
  PatternKit.Behavioral.Observer.Observer<T>                                                                      98.2%
  PatternKit.Behavioral.State.AsyncStateMachine<T1, T2>                                                             95%
  PatternKit.Behavioral.State.StateMachine<T1, T2>                                                                  99%
  PatternKit.Behavioral.Strategy.ActionStrategy<T>                                                                  97%
  PatternKit.Behavioral.Strategy.AsyncActionStrategy<T>                                                            100%
  PatternKit.Behavioral.Strategy.AsyncStrategy<T1, T2>                                                             100%
  PatternKit.Behavioral.Strategy.Strategy<T1, T2>                                                                  100%
  PatternKit.Behavioral.Strategy.TryStrategy<T1, T2>                                                              95.8%
  PatternKit.Behavioral.Template.ActionTemplate<T>                                                                 100%
  PatternKit.Behavioral.Template.AsyncActionTemplate<T>                                                            100%
  PatternKit.Behavioral.Template.AsyncTemplate<T1, T2>                                                            97.1%
  PatternKit.Behavioral.Template.AsyncTemplateMethod<T1, T2>                                                       100%
  PatternKit.Behavioral.Template.Template<T1, T2>                                                                  100%
  PatternKit.Behavioral.Template.TemplateMethod<T1, T2>                                                            100%
  PatternKit.Behavioral.TypeDispatcher.ActionTypeDispatcher<T>                                                    91.4%
  PatternKit.Behavioral.TypeDispatcher.AsyncActionTypeDispatcher<T>                                               94.5%
  PatternKit.Behavioral.TypeDispatcher.AsyncTypeDispatcher<T1, T2>                                                94.4%
  PatternKit.Behavioral.TypeDispatcher.TypeDispatcher<T1, T2>                                                      100%
  PatternKit.Behavioral.Visitor.ActionVisitor<T>                                                                  85.7%
  PatternKit.Behavioral.Visitor.ActionVisitorBase<T>                                                               100%
  PatternKit.Behavioral.Visitor.AsyncActionVisitor<T>                                                             94.5%
  PatternKit.Behavioral.Visitor.AsyncFluentActionVisitor<T>                                                        100%
  PatternKit.Behavioral.Visitor.AsyncFluentVisitor<T1, T2>                                                         100%
  PatternKit.Behavioral.Visitor.AsyncVisitor<T1, T2>                                                              86.1%
  PatternKit.Behavioral.Visitor.FluentActionVisitor<T>                                                             100%
  PatternKit.Behavioral.Visitor.FluentVisitor<T1, T2>                                                              100%
  PatternKit.Behavioral.Visitor.Visitor<T1, T2>                                                                   91.1%
  PatternKit.Behavioral.Visitor.VisitorBase<T1, T2>                                                                100%
  PatternKit.Common.Option<T>                                                                                      100%
  PatternKit.Common.Throw                                                                                          100%
  PatternKit.Common.TryHandlerExtensions                                                                           100%
  PatternKit.Creational.AbstractFactory.AbstractFactory<T>                                                        91.6%
  PatternKit.Creational.Builder.BranchBuilder<T1, T2>                                                              100%
  PatternKit.Creational.Builder.BuilderExtensions                                                                  100%
  PatternKit.Creational.Builder.ChainBuilder<T>                                                                    100%
  PatternKit.Creational.Builder.Composer<T1, T2>                                                                   100%
  PatternKit.Creational.Builder.MutableBuilder<T>                                                                  100%
  PatternKit.Creational.Factory.Factory<T1, T2>                                                                   92.3%
  PatternKit.Creational.Factory.Factory<T1, T2, T3>                                                               92.3%
  PatternKit.Creational.Prototype.Prototype<T>                                                                     100%
  PatternKit.Creational.Prototype.Prototype<T1, T2>                                                                 90%
  PatternKit.Creational.Singleton.Singleton<T>                                                                    96.5%
  PatternKit.Structural.Adapter.Adapter<T1, T2>                                                                    100%
  PatternKit.Structural.Adapter.AsyncAdapter<T1, T2>                                                               100%
  PatternKit.Structural.Bridge.ActionBridge<T1, T2>                                                               90.9%
  PatternKit.Structural.Bridge.AsyncActionBridge<T1, T2>                                                          96.5%
  PatternKit.Structural.Bridge.AsyncBridge<T1, T2, T3>                                                            90.6%
  PatternKit.Structural.Bridge.Bridge<T1, T2, T3>                                                                  100%
  PatternKit.Structural.Composite.ActionComposite<T>                                                               100%
  PatternKit.Structural.Composite.AsyncActionComposite<T>                                                          100%
  PatternKit.Structural.Composite.AsyncComposite<T1, T2>                                                          97.8%
  PatternKit.Structural.Composite.Composite<T1, T2>                                                               97.3%
  PatternKit.Structural.Decorator.ActionDecorator<T>                                                               100%
  PatternKit.Structural.Decorator.AsyncActionDecorator<T>                                                          100%
  PatternKit.Structural.Decorator.AsyncDecorator<T1, T2>                                                            98%
  PatternKit.Structural.Decorator.Decorator<T1, T2>                                                               97.6%
  PatternKit.Structural.Facade.Facade<T1, T2>                                                                     88.8%
  PatternKit.Structural.Facade.TypedFacade<T>                                                                     79.4%
  PatternKit.Structural.Facade.TypedFacadeDispatchProxy<T>                                                        81.8%
  PatternKit.Structural.Facade.TypedFacadeProxyFactory<T>                                                          100%
  PatternKit.Structural.Flyweight.Flyweight<T1, T2>                                                               97.9%
  PatternKit.Structural.Proxy.ActionProxy<T>                                                                       100%
  PatternKit.Structural.Proxy.AsyncActionProxy<T>                                                                  100%
  PatternKit.Structural.Proxy.AsyncProxy<T1, T2>                                                                  98.6%
  PatternKit.Structural.Proxy.Proxy<T1, T2>                                                                       98.8%

PatternKit.Examples                                                                                                 65%
  PatternKit.Examples.AbstractFactoryDemo.AbstractFactoryDemo                                                     98.2%
  PatternKit.Examples.ApiGateway.Demo                                                                             97.9%
  PatternKit.Examples.ApiGateway.MiniRouter                                                                       96.6%
  PatternKit.Examples.ApiGateway.Request                                                                            75%
  PatternKit.Examples.ApiGateway.Response                                                                          100%
  PatternKit.Examples.ApiGateway.Responses                                                                         100%
  PatternKit.Examples.AsyncStateDemo.ConnectionStateDemo                                                          93.5%
  PatternKit.Examples.BridgeDemo.BridgeDemo                                                                       96.7%
  PatternKit.Examples.Chain.AuthLoggingDemo                                                                       95.2%
  PatternKit.Examples.Chain.CardProcessors                                                                         100%
  PatternKit.Examples.Chain.CardTenderStrategy                                                                    77.7%
  PatternKit.Examples.Chain.CashTenderStrategy                                                                     100%
  PatternKit.Examples.Chain.ChainStage                                                                             100%
  PatternKit.Examples.Chain.CharityRoundUpRule                                                                      50%
  PatternKit.Examples.Chain.ConfigDriven.Bundle1OffEach                                                           14.2%
  PatternKit.Examples.Chain.ConfigDriven.CardTender                                                               72.2%
  PatternKit.Examples.Chain.ConfigDriven.Cash2Pct                                                                 16.6%
  PatternKit.Examples.Chain.ConfigDriven.CashTender                                                               90.9%
  PatternKit.Examples.Chain.ConfigDriven.CharityRoundUp                                                            100%
  PatternKit.Examples.Chain.ConfigDriven.ConfigDrivenPipelineBuilderExtensions                                    94.2%
  PatternKit.Examples.Chain.ConfigDriven.ConfigDrivenPipelineDemo                                                  100%
  PatternKit.Examples.Chain.ConfigDriven.Loyalty5Pct                                                                20%
  PatternKit.Examples.Chain.ConfigDriven.NickelCashOnly                                                           77.7%
  PatternKit.Examples.Chain.ConfigDriven.PipelineOptions                                                           100%
  PatternKit.Examples.Chain.Customer                                                                               100%
  PatternKit.Examples.Chain.DeviceBus                                                                              100%
  PatternKit.Examples.Chain.GenericProcessor                                                                       100%
  PatternKit.Examples.Chain.HttpRequest                                                                            100%
  PatternKit.Examples.Chain.IRoundingRule                                                                          100%
  PatternKit.Examples.Chain.LineItem                                                                               100%
  PatternKit.Examples.Chain.MediatedTransactionPipelineDemo                                                        100%
  PatternKit.Examples.Chain.NickelCashOnlyRule                                                                     100%
  PatternKit.Examples.Chain.NoopCharityTracker                                                                     100%
  PatternKit.Examples.Chain.RoundingPipeline                                                                       100%
  PatternKit.Examples.Chain.Tender                                                                                 100%
  PatternKit.Examples.Chain.TenderRouterFactory                                                                   91.3%
  PatternKit.Examples.Chain.TransactionContext                                                                     100%
  PatternKit.Examples.Chain.TransactionPipeline                                                                    100%
  PatternKit.Examples.Chain.TransactionPipelineBuilder                                                            92.3%
  PatternKit.Examples.Chain.TxResult                                                                               100%
  PatternKit.Examples.CompositeDemo.CompositeDemo                                                                  100%
  PatternKit.Examples.EnterpriseDemo.EnterpriseOrderDemo                                                          97.1%
  PatternKit.Examples.FacadeDemo.FacadeDemo                                                                        100%
  PatternKit.Examples.FlyweightDemo.FlyweightDemo                                                                 96.9%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.BackgroundJobsModule                     100%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.CorporateApp                             100%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.CorporateApplication                    21.4%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.CorporateApplicationBuilder             52.6%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.CorporateApplicationBuilderExtensions   94.7%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.CorporateApplicationDemo                27.2%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.CorporateAppState                        100%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.InMemoryJobScheduler                     100%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.MessagingModule                          100%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.NotificationOptions                        0%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.ObservabilityModule                      100%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.QueueNotificationPublisher               100%
  PatternKit.Examples.Generators.Builders.CorporateApplicationBuilderDemo.SecretsProvider                          100%
  PatternKit.Examples.Generators.Factories.ApplicationOrchestrator                                                   0%
  PatternKit.Examples.Generators.Factories.BackgroundWorker                                                        100%
  PatternKit.Examples.Generators.Factories.ConsoleMetricsSink                                                      100%
  PatternKit.Examples.Generators.Factories.MemoryCacheProvider                                                     100%
  PatternKit.Examples.Generators.Factories.OrchestratorStepFactory                                                13.4%
  PatternKit.Examples.Generators.Factories.SeedDataStep                                                            100%
  PatternKit.Examples.Generators.Factories.ServiceModuleBootstrap                                                  100%
  PatternKit.Examples.Generators.Factories.ServiceModules                                                           44%
  PatternKit.Examples.Generators.Factories.StartWorkersStep                                                        100%
  PatternKit.Examples.Generators.Factories.WarmCacheStep                                                           100%
  PatternKit.Examples.Generators.Memento.EditorStateDemo                                                             0%
  PatternKit.Examples.Generators.Memento.EditorStateHistory                                                          0%
  PatternKit.Examples.Generators.Memento.EditorStateMemento                                                          0%
  PatternKit.Examples.Generators.Memento.GameStateDemo                                                               0%
  PatternKit.Examples.Generators.Memento.GameStateHistory                                                            0%
  PatternKit.Examples.Generators.Memento.GameStateMemento                                                            0%
  PatternKit.Examples.Generators.Strategies.IntParser                                                               60%
  PatternKit.Examples.Generators.Strategies.OrderRouter                                                           95.2%
  PatternKit.Examples.Generators.Strategies.ScoreLabeler                                                           100%
  PatternKit.Examples.Generators.Visitors.Document                                                                   0%
  PatternKit.Examples.Generators.Visitors.DocumentActionVisitorBuilder                                               0%
  PatternKit.Examples.Generators.Visitors.DocumentAsyncActionVisitorBuilder                                          0%
  PatternKit.Examples.Generators.Visitors.DocumentAsyncVisitorBuilder<T>                                             0%
  PatternKit.Examples.Generators.Visitors.DocumentProcessingDemo                                                     0%
  PatternKit.Examples.Generators.Visitors.DocumentVisitorBuilder<T>                                                  0%
  PatternKit.Examples.Generators.Visitors.MarkdownDocument                                                           0%
  PatternKit.Examples.Generators.Visitors.PdfDocument                                                                0%
  PatternKit.Examples.Generators.Visitors.SpreadsheetDocument                                                        0%
  PatternKit.Examples.Generators.Visitors.WordDocument                                                               0%
  PatternKit.Examples.InterpreterDemo.InterpreterDemo                                                             93.1%
  PatternKit.Examples.IteratorDemo.IteratorDemo                                                                   98.8%
  PatternKit.Examples.MediatorDemo.AppMediator                                                                     100%
  PatternKit.Examples.MediatorDemo.AuditLogHandler                                                                 100%
  PatternKit.Examples.MediatorDemo.BoxHelper                                                                        25%
  PatternKit.Examples.MediatorDemo.CountUpCmd                                                                      100%
  PatternKit.Examples.MediatorDemo.CountUpHandler                                                                  100%
  PatternKit.Examples.MediatorDemo.EchoCmd                                                                         100%
  PatternKit.Examples.MediatorDemo.EchoHandler                                                                     100%
  PatternKit.Examples.MediatorDemo.LoggingBehavior<T1, T2>                                                         100%
  PatternKit.Examples.MediatorDemo.MediatorAssemblyScanner                                                         100%
  PatternKit.Examples.MediatorDemo.MediatorDemoSink                                                                100%
  PatternKit.Examples.MediatorDemo.MediatorRegistry                                                                100%
  PatternKit.Examples.MediatorDemo.PingCmd                                                                         100%
  PatternKit.Examples.MediatorDemo.PingHandler                                                                     100%
  PatternKit.Examples.MediatorDemo.ServiceCollectionExtensions                                                    83.3%
  PatternKit.Examples.MediatorDemo.SumCmd                                                                          100%
  PatternKit.Examples.MediatorDemo.SumCmdBehavior                                                                  100%
  PatternKit.Examples.MediatorDemo.SumHandler                                                                      100%
  PatternKit.Examples.MediatorDemo.UserCreated                                                                     100%
  PatternKit.Examples.MediatorDemo.WelcomeEmailHandler                                                             100%
  PatternKit.Examples.MementoDemo.MementoDemo                                                                     83.5%
  PatternKit.Examples.Messaging.CreateUser                                                                           0%
  PatternKit.Examples.Messaging.DispatcherUsageExamples                                                              0%
  PatternKit.Examples.Messaging.EmailSent                                                                            0%
  PatternKit.Examples.Messaging.OrderPlaced                                                                          0%
  PatternKit.Examples.Messaging.PagedItem                                                                            0%
  PatternKit.Examples.Messaging.PagedRequest                                                                         0%
  PatternKit.Examples.Messaging.SearchQuery                                                                          0%
  PatternKit.Examples.Messaging.SearchResult                                                                         0%
  PatternKit.Examples.Messaging.SendEmail                                                                            0%
  PatternKit.Examples.Messaging.SourceGenerated.ComprehensiveMediatorDemo                                            0%
  PatternKit.Examples.Messaging.SourceGenerated.CreateCustomerCommand                                                0%
  PatternKit.Examples.Messaging.SourceGenerated.CreateCustomerHandler                                                0%
  PatternKit.Examples.Messaging.SourceGenerated.Customer                                                             0%
  PatternKit.Examples.Messaging.SourceGenerated.CustomerCreatedEvent                                                 0%
  PatternKit.Examples.Messaging.SourceGenerated.GetCustomerHandler                                                   0%
  PatternKit.Examples.Messaging.SourceGenerated.GetCustomerQuery                                                     0%
  PatternKit.Examples.Messaging.SourceGenerated.GetOrdersByCustomerHandler                                           0%
  PatternKit.Examples.Messaging.SourceGenerated.GetOrdersByCustomerQuery                                             0%
  PatternKit.Examples.Messaging.SourceGenerated.InMemoryCustomerRepository                                           0%
  PatternKit.Examples.Messaging.SourceGenerated.InMemoryLogger                                                       0%
  PatternKit.Examples.Messaging.SourceGenerated.InMemoryOrderRepository                                              0%
  PatternKit.Examples.Messaging.SourceGenerated.InMemoryProductRepository                                            0%
  PatternKit.Examples.Messaging.SourceGenerated.LoggingBehavior<T1, T2>                                              0%
  PatternKit.Examples.Messaging.SourceGenerated.MediatorServiceCollectionExtensions                                  0%
  PatternKit.Examples.Messaging.SourceGenerated.NotifyInventoryHandler                                               0%
  PatternKit.Examples.Messaging.SourceGenerated.Order                                                                0%
  PatternKit.Examples.Messaging.SourceGenerated.OrderItem                                                            0%
  PatternKit.Examples.Messaging.SourceGenerated.OrderPlacedEvent                                                     0%
  PatternKit.Examples.Messaging.SourceGenerated.PaymentProcessedEvent                                                0%
  PatternKit.Examples.Messaging.SourceGenerated.PerformanceBehavior<T1, T2>                                          0%
  PatternKit.Examples.Messaging.SourceGenerated.PlaceOrderCommand                                                    0%
  PatternKit.Examples.Messaging.SourceGenerated.PlaceOrderHandler                                                    0%
  PatternKit.Examples.Messaging.SourceGenerated.ProcessPaymentCommand                                                0%
  PatternKit.Examples.Messaging.SourceGenerated.ProcessPaymentHandler                                                0%
  PatternKit.Examples.Messaging.SourceGenerated.ProductionDispatcher                                                 0%
  PatternKit.Examples.Messaging.SourceGenerated.ProductSearchResult                                                  0%
  PatternKit.Examples.Messaging.SourceGenerated.RecordPaymentAuditHandler                                            0%
  PatternKit.Examples.Messaging.SourceGenerated.SearchProductsHandler                                                0%
  PatternKit.Examples.Messaging.SourceGenerated.SearchProductsQuery                                                  0%
  PatternKit.Examples.Messaging.SourceGenerated.SendOrderConfirmationHandler                                         0%
  PatternKit.Examples.Messaging.SourceGenerated.SendWelcomeEmailHandler                                              0%
  PatternKit.Examples.Messaging.SourceGenerated.TransactionBehavior<T1, T2>                                          0%
  PatternKit.Examples.Messaging.SourceGenerated.UpdateCustomerStatsHandler                                           0%
  PatternKit.Examples.Messaging.SourceGenerated.ValidationBehavior<T1, T2>                                           0%
  PatternKit.Examples.Messaging.UserCreated                                                                          0%
  PatternKit.Examples.Messaging.UserRegistered                                                                       0%
  PatternKit.Examples.ObserverDemo.EventHub<T>                                                                     100%
  PatternKit.Examples.ObserverDemo.LineItem                                                                        100%
  PatternKit.Examples.ObserverDemo.ObservableList<T>                                                                47%
  PatternKit.Examples.ObserverDemo.ObservableVar<T>                                                                100%
  PatternKit.Examples.ObserverDemo.ProfileViewModel                                                                100%
  PatternKit.Examples.ObserverDemo.PropertyChangedHub                                                              100%
  PatternKit.Examples.ObserverDemo.ReactiveTransaction                                                            95.4%
  PatternKit.Examples.ObserverDemo.UserEvent                                                                       100%
  PatternKit.Examples.PatternShowcase.PatternShowcase                                                             91.2%
  PatternKit.Examples.PointOfSale.CustomerInfo                                                                     100%
  PatternKit.Examples.PointOfSale.Demo                                                                            99.6%
  PatternKit.Examples.PointOfSale.OrderLineItem                                                                    100%
  PatternKit.Examples.PointOfSale.PaymentProcessorDemo                                                            95.7%
  PatternKit.Examples.PointOfSale.PaymentReceipt                                                                   100%
  PatternKit.Examples.PointOfSale.PromotionConfig                                                                  100%
  PatternKit.Examples.PointOfSale.PurchaseOrder                                                                    100%
  PatternKit.Examples.PointOfSale.ReceiptLineItem                                                                  100%
  PatternKit.Examples.PointOfSale.StoreLocation                                                                    100%
  PatternKit.Examples.Pricing.ApiPricingSource                                                                     100%
  PatternKit.Examples.Pricing.CharityRoundUpRule                                                                   100%
  PatternKit.Examples.Pricing.Coupon                                                                               100%
  PatternKit.Examples.Pricing.DbPricingSource                                                                      100%
  PatternKit.Examples.Pricing.DefaultSourceRouting                                                                83.3%
  PatternKit.Examples.Pricing.FilePricingSource                                                                    100%
  PatternKit.Examples.Pricing.LineItem                                                                             100%
  PatternKit.Examples.Pricing.Location                                                                             100%
  PatternKit.Examples.Pricing.LoyaltyMembership                                                                    100%
  PatternKit.Examples.Pricing.NickelCashOnlyRule                                                                   100%
  PatternKit.Examples.Pricing.PercentLoyaltyRule                                                                   100%
  PatternKit.Examples.Pricing.PricingContext                                                                       100%
  PatternKit.Examples.Pricing.PricingDemo                                                                         56.7%
  PatternKit.Examples.Pricing.PricingPipeline                                                                      100%
  PatternKit.Examples.Pricing.PricingPipelineBuilder                                                               100%
  PatternKit.Examples.Pricing.PricingResult                                                                        100%
  PatternKit.Examples.Pricing.RegionCategoryTaxPolicy                                                              100%
  PatternKit.Examples.Pricing.Sku                                                                                 85.7%
  PatternKit.Examples.Pricing.SourceRouter                                                                        92.3%
  PatternKit.Examples.PrototypeDemo.PrototypeDemo                                                                  100%
  PatternKit.Examples.ProxyDemo.ProxyDemo                                                                         94.5%
  PatternKit.Examples.Singleton.DeviceRegistry                                                                     100%
  PatternKit.Examples.Singleton.PosAppState                                                                        100%
  PatternKit.Examples.Singleton.PosAppStateDemo                                                                    100%
  PatternKit.Examples.Singleton.PricingCache                                                                       100%
  PatternKit.Examples.Singleton.StoreConfig                                                                        100%
  PatternKit.Examples.StateDemo.OrderStateDemo                                                                     100%
  PatternKit.Examples.Strategies.Coercion.Coercer<T>                                                              83.3%
  PatternKit.Examples.Strategies.Coercion.CoercerExtensions                                                        100%
  PatternKit.Examples.Strategies.Composed.ChannelPolicy                                                            100%
  PatternKit.Examples.Strategies.Composed.ChannelPolicyFactory                                                     100%
  PatternKit.Examples.Strategies.Composed.ComposedStrategies                                                      94.2%
  PatternKit.Examples.Strategies.Composed.SendContext                                                              100%
  PatternKit.Examples.Strategies.Composed.SendResult                                                               100%
  PatternKit.Examples.TemplateDemo.AsyncDataPipeline                                                               100%
  PatternKit.Examples.TemplateDemo.DataProcessor                                                                   100%
  PatternKit.Examples.TemplateDemo.TemplateAsyncFluentDemo                                                         100%
  PatternKit.Examples.TemplateDemo.TemplateFluentDemo                                                               90%
  PatternKit.Examples.TemplateDemo.TemplateMethodDemo                                                              100%
  PatternKit.Examples.VisitorDemo.Card                                                                             100%
  PatternKit.Examples.VisitorDemo.Cash                                                                             100%
  PatternKit.Examples.VisitorDemo.CountersHandler                                                                  100%
  PatternKit.Examples.VisitorDemo.Demo                                                                             100%
  PatternKit.Examples.VisitorDemo.GiftCard                                                                         100%
  PatternKit.Examples.VisitorDemo.ReceiptRendering                                                                 100%
  PatternKit.Examples.VisitorDemo.Routing                                                                          100%
  PatternKit.Examples.VisitorDemo.StoreCredit                                                                      100%
  PatternKit.Examples.VisitorDemo.Tender                                                                           100%
  PatternKit.Examples.VisitorDemo.Unknown                                                                          100%

PatternKit.Generators                                                                                             94.1%
  PatternKit.Generators.Builders.BuilderGenerator                                                                 96.3%
  PatternKit.Generators.Factories.FactoriesGenerator                                                              86.6%
  PatternKit.Generators.MementoGenerator                                                                          94.8%
  PatternKit.Generators.Messaging.DispatcherGenerator                                                             98.1%
  PatternKit.Generators.StrategyGenerator                                                                         93.9%
  PatternKit.Generators.VisitorGenerator                                                                          99.4%

PatternKit.Generators.Abstractions                                                                                67.9%
  PatternKit.Generators.Builders.BuilderRequiredAttribute                                                          100%
  PatternKit.Generators.Builders.GenerateBuilderAttribute                                                          100%
  PatternKit.Generators.Factories.FactoryCaseAttribute                                                             100%
  PatternKit.Generators.Factories.FactoryClassAttribute                                                            100%
  PatternKit.Generators.Factories.FactoryClassKeyAttribute                                                         100%
  PatternKit.Generators.Factories.FactoryMethodAttribute                                                           100%
  PatternKit.Generators.GenerateStrategyAttribute                                                                  100%
  PatternKit.Generators.MementoAttribute                                                                             0%
  PatternKit.Generators.MementoStrategyAttribute                                                                     0%
  PatternKit.Generators.Messaging.GenerateDispatcherAttribute                                                        0%
  PatternKit.Generators.Visitors.GenerateVisitorAttribute                                                            0%

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +352 to +366
if (type.IsRecord)
{
typeKeyword = type.TypeKind == TypeKind.Struct
? "record struct"
: "record";
}
else
{
typeKeyword = type.TypeKind switch
{
TypeKind.Interface => "interface",
TypeKind.Struct => "struct",
_ => "class"
};
}
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.

Copilot uses AI. Check for mistakes.
@JerrettDavis JerrettDavis merged commit c658faa into main Jan 22, 2026
17 checks passed
@JerrettDavis JerrettDavis deleted the copilot/create-visitor-pattern-generator branch January 22, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator: Create Visitor Pattern

2 participants