Skip to content

ActivatorUtilities.CreateFactory created breaking change from version 4.2.2 to 5.0.1 - #239

Merged
khellang merged 1 commit into
khellang:masterfrom
mesies:feature/235
Dec 23, 2024
Merged

ActivatorUtilities.CreateFactory created breaking change from version 4.2.2 to 5.0.1#239
khellang merged 1 commit into
khellang:masterfrom
mesies:feature/235

Conversation

@mesies

Copy link
Copy Markdown

This PR was created to solve #235, on the premise that upgrade from 4.2.2 to 5.0.1 should have no breaking changes,

The reason for the issue is that for example Decorator3 does not request IDecoratedService but requests a concrete class that implements IDecoratedService.
This behavior is supported by ActivatorUtilities.CreateInstance since it uses the IServiceProvider to inject constructor arguments,
but ActivatorUtilities.CreateFactory expects the contructor to have IDecoratedService, which is not the case in this example.

publicclassDecorated:IDecoratedService{publicDecorated(IServiceinjectedService=null){InjectedService=injectedService;}publicIServiceInjectedService{get;}}publicclassDecorator3:IDecoratedService{publicDecorator3(Decoratedinner){Inner=inner??thrownewArgumentNullException(nameof(inner));}publicDecoratedInner{get;}}

Thanks for all the hard work!
Let me know what you think

@khellang
khellang merged commit 698a4bb into khellang:masterDec 23, 2024
@khellang

Copy link
Copy Markdown
Owner

Thank you @mesies! 🙏🏻

Sign up for freeto 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

@mesies@khellang