Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 21, 2025

The WrapperElementsGenerator was returning IncrementalValuesProvider<ISymbol>, which isn't cacheable, causing the pipeline to trigger on every build of the bunit.web project.

Changes

Introduced cacheable record types

  • ElementInterfacesData: Holds immutable array of element type info
  • ElementTypeInfo: Stores Name, FullyQualifiedName, and MetadataName as strings

Implemented collect-and-execute pattern

  • Collect phase: Select extracts minimal type information into records during compilation
  • Execute phase: Combine merges cached data with CompilationProvider to retrieve full symbols only when needed
  • Symbols are reconstructed via GetTypeByMetadataName() using cached metadata names

Added defensive checks

  • Interface name processing now validates length before stripping 'I' prefix

Before

var angleSharpAssemblyReference = context
    .CompilationProvider
    .Select((compilation, cancellationToken) => {
        // Returns ISymbol directly - not cacheable
        return compilation.GetAssemblyOrModuleSymbol(meta);
    });

context.RegisterSourceOutput(angleSharpAssemblyReference, GenerateWrapperTypes);

After

var elementInterfaces = context
    .CompilationProvider
    .Select((compilation, cancellationToken) => {
        // Returns cacheable record with strings only
        return new ElementInterfacesData(
            types.Select(t => new ElementTypeInfo(
                t.Name,
                t.ToDisplayString(GeneratorConfig.SymbolFormat),
                GetMetadataName(t)
            )).ToImmutableArray());
    });

var withCompilation = elementInterfaces.Combine(context.CompilationProvider);
context.RegisterSourceOutput(withCompilation, GenerateWrapperTypes);

The generator now caches only hashable data, enabling incremental compilation to skip regeneration when AngleSharp assembly hasn't changed.

Original prompt

This section details on the original issue you should resolve

<issue_title>WrapperElementsGenerator cachable</issue_title>
<issue_description>In its current shape the WrapperElementsGenerator does return IncrementalValuesProvider<ISymbol>.
As this isn't cacheable the pipeline get's triggered with every new build of the bunit.web project.

To tackle this we need a collect and execute phase where in the collect phase we retrieve all elements and store them into our own record type so hashing across runs is stable.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 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 self-assigned this Nov 21, 2025
Copilot AI and others added 3 commits November 21, 2025 16:20
Co-authored-by: linkdotnet <26365461+linkdotnet@users.noreply.github.com>
…mbine

Co-authored-by: linkdotnet <26365461+linkdotnet@users.noreply.github.com>
Co-authored-by: linkdotnet <26365461+linkdotnet@users.noreply.github.com>
Copilot AI changed the title [WIP] Add caching to WrapperElementsGenerator implementation Make WrapperElementsGenerator cacheable using collect-and-execute pattern Nov 21, 2025
Copilot AI requested a review from linkdotnet November 21, 2025 16:34
Copilot finished work on behalf of linkdotnet November 21, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WrapperElementsGenerator cachable

2 participants