Filter
Exclude
Time range
-
Near
I think what she meant is using the "Fluent validation dependency injection" package to scan and auto registers all implementation of Abstractvalidator<T> in an assembly to the Servicecollection. You can then inject Ivalidator<T> into your handlers instead of new() it up.
9
1,397
How can you make application setup clearer than ever? You only need one C# feature: Extension methods. Application configuration is first thing that we do when budling is started. Program.cs start to grow and at some point we get big ball of mud. But, this is avoidable. That's where the ServiceCollection extension pattern comes in. It helps organize your service configurations into modular, readable, and testable chunks. No more giant method chains or confusing blocks of setup code. Just readable configuration easy to extend when is needed. ♻️ Repost to help others. ➕ Follow me(@pavle_dav) for more posts like this.
2
1
10
383
Replying to @kanesoko
まだリファクタリングさせてるだけで中を見てないのです。グローバル変数とDBの接続を.NETのServiceCollectionで管理しろと指示してます。とりあえずそうしとけばログ仕込んで追えるようにはなるかなぁと
1
2
35
Our old ServiceCollection implementation prevented concurrent tests and risked memory leaks under certain conditions. This change also lets you take more control of creation if you need. Thanks to Tom Longhust, the creator of TUnit for this contribution (github.com/thomhurst)
2
342
23 Dec 2025
We’re excited to share that Nagarro ranked #2 in the APAC region for Atlassian Service Collection QPE. QPE is a high-impact, co-selling challenge that rewards partners who consistently generate high-quality, BANT-qualified pipeline and execute focused GTM plays around service management. This recognition reflects our teams’ ability to: ✔️ Build strong partner-sourced pipeline ✔️ Identify net-new and cross-sell opportunities ✔️ Collaborate closely with @Atlassian teams ✔️ Execute with speed and discipline Proud of the team for driving momentum when it mattered most. 🚀 #ServiceCollection #QPE #FluidicIntelligence
1
2
23
1,249
🚨This is the most critical one for Lambda: Avoid Generic Host, Dependency Injection (ServiceCollection), and ConfigurationBuilder. Technically they work, but the overhead is huge: • Generic Host alone: Adds ~70-80 ms • DIY ServiceCollection/ConfigBuilder: Still adds ~30 ms
1
4
88
🧪2-3 days I’ve been experimenting with .NET AWS Lambda Native AOT (.NET 8) No matter how much you follow the NativeAOT best practices (no reflection, source-generated JSON & regex, assembly trimming without warnings)… once you pull in Host or ServiceCollection, ConfigurationBuilder and OpenTelemetry (which alone adds ~15ms/request)... 🥶Your cold start Init Duration won’t drop below ~150ms.
3
10
4,040
𝗛𝗲𝗿𝗲'𝘀 𝗵𝗼𝘄 𝘁𝗼 𝗺𝗮𝗸𝗲 𝗶𝘁 𝗰𝗹𝗲𝗮𝗻𝗲𝗿 𝗮𝗻𝗱 𝗺𝗼𝗿𝗲 𝗿𝗲𝗮𝗱𝗮𝗯𝗹𝗲 Program.cs file. Really easy. One of the first things we do when building an application is configuration: • Logging • Database and ORM • CORS • Authentication • DI services • API bindings All of this goes into the Program.cs file - and things get out of hand fast. That's where the ServiceCollection Extension Pattern comes in. It helps organize your service configurations into modular, readable, and testable chunks. No more giant method chains or confusing blocks of setup code. I wrote a full TheCodeMan.net Newsletter issue on this with examples. Read here 👉thecodeman.net/posts/the-ser… ____ Thousands of developers fixed EF Core performance - with just one method. 👉entityframework-extensions.n… #dotnet
2
13
89
4,565
Replying to @TheCodeMan__
ServiceCollection scope in DelegatingHandlers. Complete bonkers.
3
748
𝗧𝗶𝗿𝗲𝗱 𝗼𝗳 𝘀𝗰𝗿𝗼𝗹𝗹𝗶𝗻𝗴 𝗮 𝗺𝗲𝘀𝘀𝘆 𝗮𝗻𝗱 𝗹𝗼𝗻𝗴 Program.cs 𝗳𝗶𝗹𝗲? 𝗛𝗲𝗿𝗲'𝘀 𝗵𝗼𝘄 𝘁𝗼 𝗺𝗮𝗸𝗲 𝗶𝘁 𝗰𝗹𝗲𝗮𝗻𝗲𝗿 𝗮𝗻𝗱 𝗺𝗼𝗿𝗲 𝗿𝗲𝗮𝗱𝗮𝗯𝗹𝗲. One of the first things we do when building an application is configuration: • Logging • Database and ORM • CORS • Authentication • DI services • API bindings All of this goes into the Program.cs file - and things get out of hand fast. That's where the ServiceCollection Extension Pattern comes in. It helps organize your service configurations into modular, readable, and testable chunks. No more giant method chains or confusing blocks of setup code. I wrote a full TheCodeMan.net Newsletter issue on this with examples. Read here 👉 thecodeman.net/posts/the-ser… #dotnet
12
96
5,057
23 Feb 2025
F# DIコンテナ Resultコンピュテーション式を導入 open System open Microsoft.Extensions.DependencyInjection open FSharp.Reflection // Resultコンピュテーション式の定義 type ResultBuilder() = member _.Return(x) = Ok x member _.Bind(m, k) = Result.bind k m member _.ReturnFrom(m) = m let result = ResultBuilder() // 依存関係のインターフェースと実装 type IFoo = abstract member DoFoo : unit -> string type IBar = abstract member DoBar : unit -> string type IBaz = abstract member DoBaz : unit -> string type IQux = abstract member DoQux : unit -> string type FooImpl() = interface IFoo with member _.DoFoo() = "Foo!" type BarImpl() = interface IBar with member _.DoBar() = "Bar!" type BazImpl() = interface IBaz with member _.DoBaz() = "Baz!" type QuxImpl() = interface IQux with member _.DoQux() = "Qux!" // DI解決のインターフェース type IDependencyResolver = abstract Resolve<'a> : unit -> 'a option abstract ResolveAll<'a> : unit -> 'a seq type DependencyResolver(sp: IServiceProvider) = interface IDependencyResolver with member _.Resolve<'a>() = match sp.GetService(typeof<'a>) with | null -> None | service -> Some(service :?> 'a) member _.ResolveAll<'a>() = sp.GetServices(typeof<'a>) |> Seq.cast<'a> // スコープ管理 type ScopedServices private (sp: IServiceProvider) = member _.CreateResolver() = DependencyResolver(sp) :> IDependencyResolver interface IDisposable with member _.Dispose() = match sp with | :? IDisposable as d -> d.Dispose() | _ -> () static member Create(configure: IServiceCollection -> IServiceProvider) = let services = ServiceCollection() configure services |> ignore new ScopedServices(services.BuildServiceProvider()) // 依存関係の解決ヘルパー let private resolveDependency (resolver: IDependencyResolver) (t: Type) = let resolveMethod = typedefof<IDependencyResolver>.GetMethod("Resolve").MakeGenericMethod(t) match resolveMethod.Invoke(resolver, [||]) with | null -> None | opt when opt.GetType().IsGenericType && opt.GetType().GetGenericTypeDefinition() = typedefof<obj option> -> let someValue = opt.GetType().GetProperty("Value").GetValue(opt) if someValue = null then None else Some someValue | _ -> None // inject関数 let inject (resolver: IDependencyResolver) (f: 'tuple -> int -> int -> int -> 'result) = let funcType = f.GetType() if not (FSharpType.IsFunction funcType) then Error(sprintf "Invalid function type: %s is not a function" funcType.FullName) else let (domainType, _) = FSharpType.GetFunctionElements(funcType) if not (FSharpType.IsTuple domainType) then Error(sprintf "Invalid function domain type: %s is not a tuple" domainType.FullName) else let paramTypes = FSharpType.GetTupleElements(domainType) let resolvedArgs = paramTypes |> Array.map (resolveDependency resolver) match resolvedArgs |> Array.tryFind Option.isNone with | Some _ -> let missingDeps = paramTypes |> Array.mapi (fun i t -> if resolvedArgs.[i].IsNone then Some(string t) else None) |> Array.choose id |> Array.toList Error(sprintf "Failed to resolve dependencies for %A: %s" f (String.concat ", " missingDeps)) | None -> let tuple = FSharpValue.MakeTuple(resolvedArgs |> Array.map Option.get, domainType) |> unbox<'tuple> Ok(fun x y z -> f tuple x y z) // ビジネスロジック関数(異なる引数と戻り値型) let processWithThree (deps: IFoo * IBar * IBaz) x y z = let (foo, bar, baz) = deps sprintf "%s %s %s (x=%d, y=%d, z=%d)" (foo.DoFoo()) (bar.DoBar()) (baz.DoBaz()) x y z let processWithFour (deps: IFoo * IBar * IBaz * IQux) x y z = x y z // intを返す let processWithTwo (deps: IBar * IQux) x y z = let (bar, qux) = deps (bar.DoBar(), qux.DoQux()) // (string * string)を返す // ビジネスロジック(成功ケースのみ) let businessLogic p3Fn p4Fn p2Fn x y z = let p3Result = p3Fn x y z let p4Result = p4Fn x y z let p2Result = p2Fn x y z sprintf "All succeeded - p3: %s, p4: %d (sum), p2: %A" p3Result p4Result p2Result // DI設定 let configureServices (services: IServiceCollection) useQux = services.AddTransient<IFoo, FooImpl>() |> ignore services.AddTransient<IBar, BarImpl>() |> ignore services.AddTransient<IBaz, BazImpl>() |> ignore if useQux then services.AddTransient<IQux, QuxImpl>() |> ignore services.BuildServiceProvider() [<EntryPoint>] let main argv = let useQux = Environment.GetEnvironmentVariable("USE_QUX") = "true" use services = ScopedServices.Create(fun sc -> configureServices sc useQux) let resolver = services.CreateResolver() let result = result { let! p3 = inject resolver processWithThree let! p4 = inject resolver processWithFour let! p2 = inject resolver processWithTwo return businessLogic p3 p4 p2 42 58 100 } match result with | Ok output -> printfn "%s" output | Error err -> printfn "Business Logic Failed:\n%s" err 0

1
61
.NET: How to Configure JsonSerializerOptions Correctly in a Builder ServiceCollection by @jaliyaudagedara jaliyaudagedara.blogspot.com… #aspnetcore
2
32
2,087
Messy and long Program.cs file? 𝐇𝐨𝐰 𝐭𝐨 𝐢𝐧𝐜𝐫𝐞𝐚𝐬𝐞 𝐭𝐡𝐞 𝐫𝐞𝐚𝐝𝐚𝐛𝐢𝐥𝐢𝐭𝐲 𝐨𝐟 𝐲𝐨𝐮𝐫 𝐜𝐨𝐧𝐟𝐢𝐠𝐮𝐫𝐚𝐭𝐢𝐨𝐧 𝐜𝐨𝐝𝐞? You can use 𝐓𝐡𝐞 𝐒𝐞𝐫𝐯𝐢𝐜𝐞𝐂𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧 𝐄𝐱𝐭𝐞𝐧𝐬𝐢𝐨𝐧 𝐏𝐚𝐭𝐭𝐞𝐫𝐧. When creating an application, the first thing we do is configure it. We configure: logging, connect the database with ORM, and configure CORS. We define the method of authentication, DI services, and various bindings. The IServiceCollection interface represents a contract for a collection of service descriptors, providing an abstraction to add, remove, and retrieve services. This interface becomes very important in the Program.cs class. Here, we inject all of the necessary services that our application requires. Depending on the application's complexity, we can have many configurations. How to configure such things properly? By using the Service Collection Extension pattern. I wrote a Newsletter issue about this. If you want to read it, join TheCodeMan.net by the end of the day. There are 13k engineers already. #Dotnet
9
51
2,535
Messy and long Program.cs file? 𝐇𝐨𝐰 𝐭𝐨 𝐢𝐧𝐜𝐫𝐞𝐚𝐬𝐞 𝐭𝐡𝐞 𝐫𝐞𝐚𝐝𝐚𝐛𝐢𝐥𝐢𝐭𝐲 𝐨𝐟 𝐲𝐨𝐮𝐫 𝐜𝐨𝐧𝐟𝐢𝐠𝐮𝐫𝐚𝐭𝐢𝐨𝐧 𝐜𝐨𝐝𝐞? You can use The ServiceCollection Extension Pattern. When creating an application, the first thing we do is configure it. We configure: logging, connect the database with ORM, and configure CORS. We define the method of authentication, DI services, and various bindings. The IServiceCollection interface represents a contract for a collection of service descriptors, providing an abstraction to add, remove, and retrieve services. This interface becomes very important in the Program.cs class. Here, we inject all of the necessary services that our application requires. Depending on the application's complexity, we can have many configurations. How to configure such things properly? By using the Service Collection Extension pattern. I wrote about this here: stefandjokic.tech/posts/the-… If you like this type of content, be sure you're subscribed to my .NET Pro Weekly Newsletter, and along with 11k engineers get extra content for free every Monday. Join here: stefandjokic.tech/ #dotnet
1
11
67
4,592
Messy and long Program.cs file? How to increase the readability of your configuration code? You can use The ServiceCollection Extension Pattern. When creating an application, the first thing we do is configure it. We configure: logging, connect the database with ORM, and configure CORS. We define the method of authentication, DI services, and various bindings. The IServiceCollection interface represents a contract for a collection of service descriptors, providing an abstraction to add, remove, and retrieve services. This interface becomes very important in the Program.cs class. Here, we inject all of the necessary services that our application requires. Depending on the application's complexity, we can have many configurations. How to configure such things properly? If you'd like to learn, please be sure you're subscribed to my .NET Pro Weekly Newsletter. In about 2 hours, I will explain how to do that through practical examples. Join here: stefandjokic.tech/ #Dotnet
2
6
66
4,502
さすがかずき師匠やで。ServiceCollectionも Host も使わず説明するのさすがやなぁ。確かにいきなりやと難しく感じるやろな。このブログとそこにあるリンクのブログ読んだらコレおすすめな。learn.microsoft.com/ja-jp/do…

1300いいね! | DI (依存性注入) って何のためにするのかわからない人向けに頑張って説明してみる by @okazuki bit.ly/3Q6x0Wu
2
15
3,913
Replying to @ItisArshia
اگر نمی‌خواهی سرویس ثبت کنی و فقط دسترسی در سطح کلاس و انتزاع داشته باشی یعنی فقط در جای که استفاده میکنید تزریق وابستگی نداره ، این پکیج نصب کن (بیشتر توی console, WPF اینا استفاده میشه) Microsoft.Exetentions.DepedencyInjction از کلاس ServiceCollection استفاده کن
2
34
Replying to @samafshari
Don't get bogged down in the use of the term "Service" (this is just a naming decision by MS.Extensions where everything is a service: ServiceCollection, ServiceProvider etc). Using DI to create instances has a LOT of advantage and can make for a clean architecture for apps
2
4
233
Change the ServiceLifetime after the service has been added to the @dotnet ServiceCollection from @RealSwimburger isaacl.dev/duw

4
9
1,559
Change ServiceLifetime after Adding to the .NET ServiceCollection - swimburger.net/blog/dotnet/c… @RealSwimburger

1
1
4
1,894