Support generic imports.#717
Conversation
|
@microsoft-github-policy-service agree |
AArnott
left a comment
There was a problem hiding this comment.
Thanks for sharing this. I think it's shaping up.
| export such as `[Export(typeof(IOptionsFactory<>))]`. VS MEF supports this for the direct import and | ||
| for the `Lazy<T>`, `ExportFactory<T>`, and `ImportMany` (`IEnumerable<T>` / `T[]`) forms. | ||
|
|
||
| Importing a type parameter *directly* — where the import type is the bare parameter itself, e.g. | ||
| `[Import] T` — is honored by .NET MEF and NuGet MEF but **not** by VS MEF. Those runtimes resolve |
There was a problem hiding this comment.
I find the doc a little confusing.
VS MEF supports this for the direct import and for the
Lazy<T>
This makes it sound like importing T ("direct import") and Lazy<T> is allowed. But then in the next paragraph you say T can't be directly imported.
And then you say nothing about Lazy<T> not being importable, but I strongly suspect Lazy<T> cannot be imported, since that would have the same ambiguous graph impact as importing T, right?
There was a problem hiding this comment.
yeah, I double checked (to make sure there's no bug hidden) but this just was confusing wording that slipped through my review. Lazy/ExportFactory/IEnumerable/Array are just the expected special-cased variants in addition over the direct import, but of course with the same constraints as the direct import. I'd probably just drop the explicit enumeration of alternatives and leave it with the initial example?
| export such as `[Export(typeof(IOptionsFactory<>))]`. VS MEF supports this for the direct import and | |
| for the `Lazy<T>`, `ExportFactory<T>`, and `ImportMany` (`IEnumerable<T>` / `T[]`) forms. | |
| Importing a type parameter *directly* — where the import type is the bare parameter itself, e.g. | |
| `[Import] T` — is honored by .NET MEF and NuGet MEF but **not** by VS MEF. Those runtimes resolve | |
| export such as `[Export(typeof(IOptionsFactory<>))]`. | |
| Importing a type parameter *directly* — where the import type is the bare parameter itself, e.g. | |
| `[Import] T` — is honored by .NET MEF and NuGet MEF but **not** by VS MEF. Those runtimes resolve |
Fixes #457
As mentioned, mostly AI generated. The approach makes sense to me. I left the original generated comments intact during cleanup since they might help understanding during review, if further cleanup or other refactoring is desired let me know and I'll work on that. If the approach isn't desireable thats fine too, I just wanted to get this is out of my backlog ;)