Skip to content

Mark RegisterGeneratedFactory obsolete - #1366

Merged
alistairjevans merged 6 commits into
developfrom
feature/1297
Feb 7, 2023
Merged

Mark RegisterGeneratedFactory obsolete#1366
alistairjevans merged 6 commits into
developfrom
feature/1297

Conversation

@tillig

@tillig tillig commented Feb 4, 2023

Copy link
Copy Markdown
Member

Fix #1297.

This marks RegisterGeneratedFactory extensions and GeneratedFactoryActivatorData with an [Obsolete] attribute indicating folks should upgrade to use Func<T> or delegate factories. Tests for the feature remain, but the obsolete warnings are suppressed around the tests so we don't see them during the build.

While I was here I picked up a couple of optimizations based on Roslyn analyzers:

  • Use conditional assignment
  • Use local function
  • Make struct readonly

@codecov

codecov Bot commented Feb 4, 2023

Copy link
Copy Markdown

Codecov Report

Base: 78.22% // Head: 78.15% // Decreases project coverage by -0.07% ⚠️

Coverage data is based on head (75261ae) compared to base (b545b42).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1366      +/-   ##
===========================================
- Coverage    78.22%   78.15%   -0.07%     
===========================================
  Files          197      197              
  Lines         5653     5636      -17     
  Branches      1147     1149       +2     
===========================================
- Hits          4422     4405      -17     
  Misses         716      716              
  Partials       515      515              
Impacted Files Coverage Δ
src/Autofac/Builder/RegistrationExtensions.cs 35.71% <ø> (ø)
src/Autofac/Core/Resolving/SegmentedStack.cs 78.12% <ø> (ø)
src/Autofac/Core/ServiceRegistration.cs 28.57% <ø> (ø)
...eneratedFactories/GeneratedFactoryActivatorData.cs 71.42% <ø> (ø)
...actories/GeneratedFactoryRegistrationExtensions.cs 100.00% <ø> (ø)
...tofac/Core/Registration/ServiceRegistrationInfo.cs 77.35% <100.00%> (-1.02%) ⬇️
...nning/OpenGenericScanningRegistrationExtensions.cs 87.01% <100.00%> (-0.33%) ⬇️
...eatures/Scanning/ScanningRegistrationExtensions.cs 68.42% <100.00%> (-0.81%) ⬇️
src/Autofac/ModuleRegistrationExtensions.cs 59.01% <100.00%> (-2.53%) ⬇️
src/Autofac/RegistrationExtensions.Conditional.cs 77.77% <100.00%> (-4.05%) ⬇️
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@alistairjevans alistairjevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great, only thing I noticed was a possible instance of a missing static on two of the new local methods.

Comment thread src/Autofac/Features/Scanning/ScanningRegistrationExtensions.cs Outdated

@alistairjevans alistairjevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👩‍🚀

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.

Discussion: RegisterGeneratedFactory becoming obsolete

2 participants