Skip to content

Add Static Extensions (And fix a bug in cycle-detection)#27

Open
carl-andersson-at-westermo wants to merge 4 commits into
mainfrom
static-extensions
Open

Add Static Extensions (And fix a bug in cycle-detection)#27
carl-andersson-at-westermo wants to merge 4 commits into
mainfrom
static-extensions

Conversation

@carl-andersson-at-westermo
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

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

Adds C# 14 “static extension” based resolution generation alongside existing dictionary-based resolution, and updates cycle detection + collection/reentrancy behaviors with new tests/benchmarks.

Changes:

  • Generate C# 14 static-extension Resolve(container?) APIs (gated on parse options) and adjust generated container internals to support them.
  • Replace cycle detection logic with a DFS-based graph walk and add tests for cross-array reentrancy + base/child array merging.
  • Update benchmarks to compare dictionary vs static-extension resolution paths; bump several projects to net10.0 / LangVersion=preview.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Tests/TestWebApp/TestWebApp.csproj Bumps test web app TFM to net10.0.
Tests/TestData/Inheritor/Types.cs Adds split-array implementations for base/child merge tests (plus an extra using).
Tests/TestData/Inheritor/Inheritor.csproj Enables LangVersion=preview for the Inheritor test-data project.
Tests/TestData/Inherited/Types.cs Adds cross-array reentrancy + split-array test types.
Tests/FactoryGenerator.Tests/InjectionDetectionTests.cs Adds tests covering cross-array reentrancy + array merging across container hierarchies.
Tests/FactoryGenerator.Extensions.AspNetCore.Tests/FactoryGenerator.Extensions.AspNetCore.Tests.csproj Bumps AspNetCore extension tests to net10.0.
FactoryGenerator/FactoryGenerator.cs Implements static-extension generation, adjusts collection naming, and rewrites cycle detection.
FactoryGenerator.Extensions.AspNetCore/FactoryGenerator.Extensions.AspNetCore.csproj Bumps extension library TFM to net10.0.
Benchmarking/Benchmarks/Program.cs Adds static-extension benchmarks and uses BenchmarkSwitcher.
Benchmarking/Benchmarks/Benchmarks.csproj Bumps benchmarks to net10.0 + LangVersion=preview.

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


<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

net10.0 requires a .NET SDK that supports that TFM, but the repo CI workflows currently install dotnet-version: 9.0.x (see .github/workflows/build.yml and benchmark.yml). With this change, CI/builds will fail unless the workflows (and any local tooling expectations) are updated to use a compatible SDK, or the project stays on net9.0/net8.0.

Suggested change
<TargetFramework>net10.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

Copilot uses AI. Check for mistakes.

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

This project now targets net10.0, but CI currently installs .NET SDK 9.0.x in .github/workflows/build.yml. Unless the workflows are updated to install a .NET 10 SDK (or the project targets a framework supported by SDK 9), the test build will fail.

Suggested change
<TargetFramework>net10.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

Copilot uses AI. Check for mistakes.

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

Changing the package TFM from net8.0 to net10.0 is a breaking change for consumers on net8/net9. If the only requirement is C# 14 static-extension generation (a compiler feature), consider multi-targeting (e.g., net8.0;net10.0) or keeping net8.0 and controlling language features via LangVersion/SDK selection. Also note CI currently installs .NET SDK 9.0.x, so it will need updating to build net10.0.

Suggested change
<TargetFramework>net10.0</TargetFramework>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>

Copilot uses AI. Check for mistakes.
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The benchmark project now targets net10.0, but .github/workflows/benchmark.yml installs .NET SDK 9.0.x. The benchmark job will fail unless the workflow is updated to install a compatible SDK (or the project targets a framework supported by SDK 9).

Suggested change
<TargetFramework>net10.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

Copilot uses AI. Check for mistakes.
Comment thread FactoryGenerator/FactoryGenerator.cs
Comment thread Tests/TestData/Inheritor/Types.cs Outdated
Comment on lines +1 to +2
using System.Runtime.InteropServices;
using FactoryGenerator.Attributes;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

using System.Runtime.InteropServices; appears unused in this file. Removing it will avoid unnecessary usings/warnings.

Suggested change
using System.Runtime.InteropServices;
using FactoryGenerator.Attributes;
using FactoryGenerator.Attributes;

Copilot uses AI. Check for mistakes.
Comment thread Benchmarking/Benchmarks/Program.cs Outdated
Comment thread FactoryGenerator/FactoryGenerator.cs
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.

2 participants