Skip to content

Commit 105bebf

Browse files
authored
Merge branch 'pakrym:main' into NonTransientValueTypeError
2 parents a8cb822 + 97cc56a commit 105bebf

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.10.1
2+
- Marked a few more generated classes with `GeneratedCodeAttribute` (https://github.com/pakrym/jab/pull/164).
3+
14
## 0.10.0
25
- Added support for [named services](https://github.com/pakrym/jab#named-services).
36
- Marked generated code with `GeneratedCodeAttribute` (https://github.com/pakrym/jab/pull/160).

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ IService service = c.GetService<IService>();
139139
When using with `TransientAttribute` the factory method would be invoked for every service resolution.
140140
When used with `SingletonAttribute` it would only be invoked the first time the service is requested.
141141

142+
Similar to constructors, factories support parameter injection:
143+
144+
```
145+
[ServiceProvider]
146+
[Transient(typeof(IService), Factory = nameof(MyServiceFactory))]
147+
[Transient(typeof(SomeOtherService))]
148+
internal partial class MyServiceProvider {
149+
public IService MyServiceFactory(SomeOtherService other) => new ServiceImplementation(other);
150+
}
151+
```
152+
142153
### Scoped Services
143154

144155
Scoped services are created once per service provider scope. To create a scope use the `CreateScope()` method of the service provider.

src/Jab/Attributes.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public ScopedAttribute(Type serviceType, Type implementationType)
141141
#if JAB_ATTRIBUTES_PACKAGE
142142
public
143143
#else
144+
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
144145
internal
145146
#endif
146147
class FromNamedServicesAttribute : Attribute
@@ -280,6 +281,7 @@ interface INamedServiceProvider<T>
280281
#if JAB_ATTRIBUTES_PACKAGE
281282
public
282283
#else
284+
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
283285
internal
284286
#endif
285287
static class JabHelpers
@@ -294,4 +296,4 @@ public static InvalidOperationException CreateServiceNotFoundException(Type type
294296
}
295297
}
296298

297-
#endif
299+
#endif

0 commit comments

Comments
 (0)