Comments (6)
I think Func<B>
is definitely wrong - I don't want to be putting diagnostics on perfectly valid user code, because somewhere else decided to register it with StrongInject. Registration code should change to reflect business code, not the other way round.
[Register(typeof(A))]
is an option, but it's kind of weird. Firstly there's not always a clear place to put it (e.g. different assemblies, multiple locations which register the same type, etc.). Secondly the same registration on a module might be used by multiple containers, only one of which leads to an issue, so there's nothing wrong with the registration. Thirdly it doesn't even fully solve your problem. The same type might have multiple delegate arguments, and you would have to suppress them all together.
Also the complexity of this change is very high. We have to associate every InstanceSource with a unique location and put the diagnostic there. I don't really want to do this for something which I'm just not really sure is the correct solution semantically.
I understand the problem that you're trying to solve. I just don't really have a good solution.
from stronginject.
If that feels like the wrong place, maybe it would be better to place it on the attribute which registered the type declaring the parameter.
from stronginject.
Neither of those feel like the right place as both could be in a completely separate assembly.
from stronginject.
What about leaving the current behavior as a fallback in the case where it's not all in the same assembly?
from stronginject.
Even then, philosophically it feels the wrong place.
Consider the following two modules:
public record A(Func<B> b);
public record B();
[Register(typeof(A))]
public class Module1{}
[Register(typeof(B), Scope.SingleInstance)]
public class Module2{}
On it's own both of those modules are absolutely fine. It's only when we put the two together in a container that we have a problem.
from stronginject.
I'd see Func<B>
as a logical place in that scenario, even though it would only appear when something in the same project puts the two modules together.
from stronginject.
Related Issues (20)
- Inject Func<Owned<T>> parameters HOT 1
- [Feature/Idea] Support for primary constructor generator HOT 2
- Innermost hasAwaitStarted catch block is a no-op and could be omitted HOT 3
- Update xamarin sample to maui
- 'registerAs' parameter for FactoryAttribute HOT 9
- IOwned<out T> HOT 4
- Convenience methods for creating Owned<T> instances HOT 3
- Permitting null instead of empty delegate for Owned<T> and AsyncOwned<T> HOT 2
- Add diagnostic if any registered method return types are by ref.
- Circular dependency check is too restrictive for delegates HOT 23
- Separate Microsoft DI from Asp.Net Core HOT 2
- Convert to IIncrementalGenerator HOT 18
- Retrieving design-time info about registrations HOT 5
- StrongInject Source Generator API HOT 1
- Confusing use of the term 'delegate parameters' in the readme HOT 2
- Support decorator factories that aren't gratuitously generic HOT 4
- Misleading info in README HOT 2
- Generic interface registration HOT 1
- asp.net middleware support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stronginject.