Skip to content

Extract Di lifetime parsing primitives for Captive Dependency (#232)#238

Open
Skymly wants to merge 1 commit into
mainfrom
feature/232-di-lifetime-primitives
Open

Extract Di lifetime parsing primitives for Captive Dependency (#232)#238
Skymly wants to merge 1 commit into
mainfrom
feature/232-di-lifetime-primitives

Conversation

@Skymly

@Skymly Skymly commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduce DesignPatterns.Analyzers.Di with shared Lifetime and LifetimeResolution primitives (expression + invocation-argument resolution).
  • Wire CaptiveDependencyAnalyzer to those primitives and remove duplicated private ResolveLifetime logic.
  • Add InternalsVisibleTo plus unit tests for lifetime-resolution edge cases; keep existing Captive Dependency Verify behaviour frozen.

Test plan

  • dotnet test tests/DesignPatterns.Analyzers.Tests --filter FullyQualifiedName~DiLifetimeResolutionTests
  • dotnet test tests/DesignPatterns.Analyzers.Tests --filter FullyQualifiedName~CaptiveDependency|FullyQualifiedName~FactoryDelegateCaptive
  • dotnet test DesignPatterns.slnx -c Release
  • CI green on this PR

Closes #232

Made with Cursor

…cy (#232).

Move Lifetime parsing into Analyzers.Di so Captive Dependency stops duplicating ResolveLifetime logic, with InternalsVisibleTo unit tests for edge cases.

@Skymly Skymly left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review (#232)

Spec

  • DesignPatterns.Analyzers.Di exposes Lifetime + LifetimeResolution (TryResolve / TryResolveArgument)
  • CaptiveDependencyAnalyzer uses the shared primitives; private ResolveLifetime* removed on covered paths
  • InternalsVisibleTo(DesignPatterns.Analyzers.Tests)
  • Unit tests cover constant / unknown / named / positional / omitted-argument cases (not only Verify)
  • Captive Dependency Verify behaviour frozen; CI green (build-test, build-test-net48, samples, pack)

Out of scope as designed: registration map (#233+), LifetimeMismatchAnalyzer still keeps its private copy (#236).

Standards / notes

  • Extraction matches agreed seams; internal + IVT is the right visibility for analyzer primitives.
  • No behaviour change beyond the move — good for a freeze ticket.
  • Minor nit (non-blocking): DiLifetimeResolutionTests repeats the Holder.Register fixture three times — fine to tidy later when #236 lands and more call sites share the helper.

Verdict

LGTM — ready to merge.

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.

Di lifetime parsing primitives + InternalsVisibleTo

1 participant