From 00f03fcd9d88f5147f4c3f89f0f34453a7dbbe42 Mon Sep 17 00:00:00 2001 From: Nikolay Pianikov <nikolayp@mail.ru> Date: Fri, 29 Nov 2024 10:21:19 +0300 Subject: [PATCH] Minor --- README.md | 48 ++++++++++++++++++++------ readme/FooterTemplate.md | 40 +++++++++++++++++++-- readme/ReadmeTemplate.md | 8 ----- src/Pure.DI.Core/Features/Default.g.cs | 2 +- 4 files changed, 77 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index c4d6554e4..bac6c8123 100644 --- a/README.md +++ b/README.md @@ -102,14 +102,6 @@ DI.Setup(nameof(Composition)) > [!NOTE] > In fact, the `Bind().As(Singleton).To<Random>()` binding is unnecessary since _Pure.DI_ supports many .NET BCL types out of the box, including [Random](https://github.com/DevTeam/Pure.DI/blob/27a1ccd604b2fdd55f6bfec01c24c86428ddfdcb/src/Pure.DI.Core/Features/Default.g.cs#L289). It was added just for the example of using the _Singleton_ lifetime. -The Pure.DI source code generator works like this: - -```mermaid -flowchart TD - setups[DI setups analysis] --> types["`Types analysis - constructors/methods/properties/fields`"] --> deps[Creating a dependency graph] --> verification[Dependency graph verification] --> code[Code generation] -``` - The above code specifies the generation of a partial class named *__Composition__*, this name is defined in the `DI.Setup(nameof(Composition))` call. This class contains a *__Root__* property that returns a graph of objects with an object of type *__Program__* as the root. The type and name of the property is defined by calling `Root<Program>("Root")`. The code of the generated class looks as follows: ```c# @@ -367,13 +359,13 @@ partial class Composition } ``` -</details> - The _compositionTypeName_ parameter can be omitted - if the setup is performed inside a partial class, then the composition will be created for this partial class - for the case of a class with composition kind `CompositionKind.Global`, see [this example](readme/global-compositions.md) +</details> + <details> <summary>Setup arguments</summary> @@ -860,6 +852,42 @@ Then documentation for the composition root: </details> +<details> +<summary>Code generation workflow</summary> + +```mermaid +flowchart TD + start@{ shape: circle, label: "Starting code generation" } + setups[DI setups analysis] + types["`Types analysis + constructors/methods/properties/fields`"] + subgraph dep[Dependency graph] + option[Selecting a next dependency set] + creating[Creating a dependency graph variant] + verification{Verification} + end + codeGeneration[Code generation] + compilation[Compilation] + finish@{ shape: dbl-circ, label: "Completing code generation" } + failed@{ shape: dbl-circ, label: "Compilation failed" } + + start --> setups + setups -->|Has problems| failed + setups --> types + types --> |Has problems| failed + types --> option + option --> creating + option --> |There are no other options| failed + creating --> verification + verification -->|Has problems| option + verification -->|Correct| codeGeneration + codeGeneration --> finish + finish --> compilation + compilation --> |Has problems| failed +``` + +</details> + ## NuGet packages | | | | diff --git a/readme/FooterTemplate.md b/readme/FooterTemplate.md index b6b0bc471..1c02ec353 100644 --- a/readme/FooterTemplate.md +++ b/readme/FooterTemplate.md @@ -62,13 +62,13 @@ partial class Composition } ``` -</details> - The _compositionTypeName_ parameter can be omitted - if the setup is performed inside a partial class, then the composition will be created for this partial class - for the case of a class with composition kind `CompositionKind.Global`, see [this example](readme/global-compositions.md) +</details> + <details> <summary>Setup arguments</summary> @@ -555,6 +555,42 @@ Then documentation for the composition root: </details> +<details> +<summary>Code generation workflow</summary> + +```mermaid +flowchart TD + start@{ shape: circle, label: "Starting code generation" } + setups[DI setups analysis] + types["`Types analysis + constructors/methods/properties/fields`"] + subgraph dep[Dependency graph] + option[Selecting a next dependency set] + creating[Creating a dependency graph variant] + verification{Verification} + end + codeGeneration[Code generation] + compilation[Compilation] + finish@{ shape: dbl-circ, label: "Completing code generation" } + failed@{ shape: dbl-circ, label: "Compilation failed" } + + start --> setups + setups -->|Has problems| failed + setups --> types + types --> |Has problems| failed + types --> option + option --> creating + option --> |There are no other options| failed + creating --> verification + verification -->|Has problems| option + verification -->|Correct| codeGeneration + codeGeneration --> finish + finish --> compilation + compilation --> |Has problems| failed +``` + +</details> + ## NuGet packages | | | | diff --git a/readme/ReadmeTemplate.md b/readme/ReadmeTemplate.md index 5aab452dd..61cdff148 100644 --- a/readme/ReadmeTemplate.md +++ b/readme/ReadmeTemplate.md @@ -62,14 +62,6 @@ DI.Setup(nameof(Composition)) > [!NOTE] > In fact, the `Bind().As(Singleton).To<Random>()` binding is unnecessary since _Pure.DI_ supports many .NET BCL types out of the box, including [Random](https://github.com/DevTeam/Pure.DI/blob/27a1ccd604b2fdd55f6bfec01c24c86428ddfdcb/src/Pure.DI.Core/Features/Default.g.cs#L289). It was added just for the example of using the _Singleton_ lifetime. -The Pure.DI source code generator works like this: - -```mermaid -flowchart TD - setups[DI setups analysis] --> types["`Types analysis - constructors/methods/properties/fields`"] --> deps[Creating a dependency graph] --> verification[Dependency graph verification] --> code[Code generation] -``` - The above code specifies the generation of a partial class named *__Composition__*, this name is defined in the `DI.Setup(nameof(Composition))` call. This class contains a *__Root__* property that returns a graph of objects with an object of type *__Program__* as the root. The type and name of the property is defined by calling `Root<Program>("Root")`. The code of the generated class looks as follows: ```c# diff --git a/src/Pure.DI.Core/Features/Default.g.cs b/src/Pure.DI.Core/Features/Default.g.cs index 71e942c12..3c9977e8e 100644 --- a/src/Pure.DI.Core/Features/Default.g.cs +++ b/src/Pure.DI.Core/Features/Default.g.cs @@ -111,9 +111,9 @@ private static void Setup() .To(_ => global::System.Buffers.ArrayPool<TT>.Shared) #endif .Bind<global::System.Collections.Generic.IList<TT>>() + .Bind<global::System.Collections.Generic.ICollection<TT>>() .Bind<global::System.Collections.Generic.List<TT>>() .To((TT[] arr) => new global::System.Collections.Generic.List<TT>(arr)) - .Bind<global::System.Collections.Generic.ICollection<TT>>() .Bind<global::System.Collections.ObjectModel.Collection<TT>>() .To((TT[] arr) => new global::System.Collections.ObjectModel.Collection<TT>(arr)) #if NETSTANDARD || NET || NETCOREAPP || NET45_OR_GREATER