You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Repurpose older [Service<T>] to allow specifying a service type
We add an analyzer that will flag the previous usage as an error (requiring the removal of the T or setting it to the actual service to register). This should prevent bumps and rebuilds without notice.
Since the attributes don't have run-time impact but are rather purely compile-time, bumping but not building (i.e. via a transitive dependency, say or direct copying), would not cause runtime failures because the registrations in the previously compile assembly would remain as they were.
This unlocks a very useful scenario to trim down the amount of registered interfaces.
Fixes#281
Copy file name to clipboardExpand all lines: readme.md
+24-5Lines changed: 24 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,8 @@ public interface IMyService
52
52
53
53
The `ServiceLifetime` argument is optional and defaults to [ServiceLifetime.Singleton](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicelifetime?#fields).
54
54
55
-
> NOTE: The attribute is matched by simple name, so you can define your own attribute
55
+
> [!NOTE]
56
+
> The attribute is matched by simple name, so you can define your own attribute
56
57
> in your own assembly. It only has to provide a constructor receiving a
"Open generic service implementations are not supported for convention-based registration.",
26
24
"Only the concrete (closed) implementations of the open generic interface will be registered. Register open generic services explicitly using the built-in service collection methods.",
0 commit comments