Skip to content

Commit

Permalink
Improved readme
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed May 13, 2024
1 parent 6b5b0fa commit aa75463
Show file tree
Hide file tree
Showing 81 changed files with 2,568 additions and 2,961 deletions.
27 changes: 12 additions & 15 deletions build/ReadmeTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,29 +269,35 @@ private async Task GenerateExamples(IEnumerable<(string GroupName, Dictionary<st
await examplesWriter.WriteLineAsync($"#### {description}");
await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync($"[![CSharp](https://img.shields.io/badge/C%23-code-blue.svg)](../{vars[SourceKey].Replace('\\', '/')})");
await examplesWriter.WriteLineAsync("");
var header = vars[HeaderKey];
if (!string.IsNullOrWhiteSpace(header))
{
await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync(header);
await examplesWriter.WriteLineAsync("");
}

await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync("```c#");
await examplesWriter.WriteLineAsync(vars[BodyKey]);
await examplesWriter.WriteLineAsync("```");
await examplesWriter.WriteLineAsync("");

var footer = vars[FooterKey];
if (!string.IsNullOrWhiteSpace(footer))
{
await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync(footer);
await examplesWriter.WriteLineAsync("");
}

var exampleName = Path.GetFileNameWithoutExtension(vars[SourceKey]);
await AddClassDiagram(logsDirectory, exampleName, examplesWriter);

await AddExample(logsDirectory, $"Pure.DI.UsageTests.*.{exampleName}.*.g.cs", examplesWriter);

await examplesWriter.WriteLineAsync("");

await AddClassDiagram(logsDirectory, exampleName, examplesWriter);
await examplesWriter.WriteLineAsync("");

await examplesWriter.FlushAsync();
}
}
Expand All @@ -302,17 +308,12 @@ private static async Task AddClassDiagram(string logsDirectory, string exampleNa
var classDiagramFile = Path.Combine(logsDirectory, exampleName + ".Mermaid");
if (File.Exists(classDiagramFile))
{
await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync("<details open>");
await examplesWriter.WriteLineAsync("<summary>Class Diagram</summary>");
await examplesWriter.WriteLineAsync("Class diagram:");
await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync("```mermaid");
var classDiagram = await File.ReadAllTextAsync(classDiagramFile);
await examplesWriter.WriteLineAsync(classDiagram);
await examplesWriter.WriteLineAsync("```");
await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync("</details>");
await examplesWriter.WriteLineAsync("");
}
}

Expand All @@ -323,8 +324,7 @@ private static async Task AddExample(string logsDirectory, string exampleSearchP
{
var ns = string.Join('.', Path.GetFileName(generatedCodeFile).Split('.').Reverse().Skip(3).Reverse()) + ".";
var name = Path.GetFileName(generatedCodeFile).Split('.').Reverse().Skip(2).FirstOrDefault() ?? "Generated";
await examplesWriter.WriteLineAsync("<details>");
await examplesWriter.WriteLineAsync($"<summary>Pure.DI-generated partial class {name}</summary><blockquote>");
await examplesWriter.WriteLineAsync("The following partial class will be generated:");
await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync("```c#");
var generatedCode = await File.ReadAllTextAsync(generatedCodeFile);
Expand Down Expand Up @@ -369,9 +369,6 @@ private static async Task AddExample(string logsDirectory, string exampleSearchP
.Replace("(MethodImplOptions)0x8", "MethodImplOptions.NoInlining")));
await examplesWriter.WriteLineAsync(generatedCode);
await examplesWriter.WriteLineAsync("```");
await examplesWriter.WriteLineAsync("");
await examplesWriter.WriteLineAsync("</blockquote></details>");
await examplesWriter.WriteLineAsync("");
}
}

Expand Down
6 changes: 1 addition & 5 deletions readme/ArrayDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ classDiagram

### Generated code

<details>
<summary>Pure.DI-generated partial class Array</summary><blockquote>
The following partial class will be generated:

```c#
partial class Array
Expand Down Expand Up @@ -221,6 +220,3 @@ partial class Array
}
}
```

</blockquote></details>

6 changes: 1 addition & 5 deletions readme/EnumDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ classDiagram

### Generated code

<details>
<summary>Pure.DI-generated partial class Enum</summary><blockquote>
The following partial class will be generated:

```c#
partial class Enum
Expand Down Expand Up @@ -230,6 +229,3 @@ partial class Enum
}
}
```

</blockquote></details>

6 changes: 1 addition & 5 deletions readme/FuncDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ classDiagram

### Generated code

<details>
<summary>Pure.DI-generated partial class Func</summary><blockquote>
The following partial class will be generated:

```c#
partial class Func
Expand Down Expand Up @@ -207,6 +206,3 @@ partial class Func
}
}
```

</blockquote></details>

6 changes: 1 addition & 5 deletions readme/SingletonDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ classDiagram

### Generated code

<details>
<summary>Pure.DI-generated partial class Singleton</summary><blockquote>
The following partial class will be generated:

```c#
partial class Singleton
Expand Down Expand Up @@ -212,6 +211,3 @@ partial class Singleton
}
}
```

</blockquote></details>

6 changes: 1 addition & 5 deletions readme/TransientDetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ classDiagram

### Generated code

<details>
<summary>Pure.DI-generated partial class Transient</summary><blockquote>
The following partial class will be generated:

```c#
partial class Transient
Expand Down Expand Up @@ -202,6 +201,3 @@ partial class Transient
}
}
```

</blockquote></details>

67 changes: 31 additions & 36 deletions readme/a-few-partial-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

The setting code for one Composition can be located in several methods and/or in several partial classes.


```c#
interface IDependency;

Expand Down Expand Up @@ -41,41 +42,7 @@ var composition = new Composition();
var service = composition.Root;
```

<details open>
<summary>Class Diagram</summary>

```mermaid
classDiagram
class Composition {
<<partial>>
+IService Root
+ T ResolveᐸTᐳ()
+ T ResolveᐸTᐳ(object? tag)
+ object Resolve(Type type)
+ object Resolve(Type type, object? tag)
}
Dependency --|> IDependency :
class Dependency {
+Dependency()
}
Service --|> IService :
class Service {
+Service(IDependency dependency)
}
class IDependency {
<<interface>>
}
class IService {
<<interface>>
}
Service *-- Dependency : IDependency
Composition ..> Service : IService Root
```

</details>

<details>
<summary>Pure.DI-generated partial class Composition</summary><blockquote>
The following partial class will be generated:

```c#
partial class Composition
Expand Down Expand Up @@ -217,5 +184,33 @@ partial class Composition
}
```

</blockquote></details>
Class diagram:

```mermaid
classDiagram
class Composition {
<<partial>>
+IService Root
+ T ResolveᐸTᐳ()
+ T ResolveᐸTᐳ(object? tag)
+ object Resolve(Type type)
+ object Resolve(Type type, object? tag)
}
Dependency --|> IDependency :
class Dependency {
+Dependency()
}
Service --|> IService :
class Service {
+Service(IDependency dependency)
}
class IDependency {
<<interface>>
}
class IService {
<<interface>>
}
Service *-- Dependency : IDependency
Composition ..> Service : IService Root
```

91 changes: 43 additions & 48 deletions readme/accumulators.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Accumulators allow you to accumulate instances of certain types and lifetimes.


```c#
interface IAccumulating;

Expand Down Expand Up @@ -40,53 +41,7 @@ accumulator[2].ShouldBeOfType<Service>();

```

<details open>
<summary>Class Diagram</summary>

```mermaid
classDiagram
class Composition {
<<partial>>
+ValueTupleᐸIServiceˏMyAccumulatorᐳ Root
+ T ResolveᐸTᐳ()
+ T ResolveᐸTᐳ(object? tag)
+ object Resolve(Type type)
+ object Resolve(Type type, object? tag)
}
class MyAccumulator
class ValueTupleᐸIServiceˏMyAccumulatorᐳ {
+ValueTuple(IService item1, MyAccumulator item2)
}
AbcDependency --|> IDependency :
class AbcDependency {
+AbcDependency()
}
XyzDependency --|> IDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.XyzDependency)
class XyzDependency {
+XyzDependency()
}
Service --|> IService :
class Service {
+Service(IDependency dependency1, IDependency dependency2, IDependency dependency3)
}
class IDependency {
<<interface>>
}
class IService {
<<interface>>
}
ValueTupleᐸIServiceˏMyAccumulatorᐳ *-- Service : IService
ValueTupleᐸIServiceˏMyAccumulatorᐳ *-- MyAccumulator : MyAccumulator
Service *-- AbcDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.AbcDependency) IDependency
Service o-- "Singleton" XyzDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.XyzDependency) IDependency
Service o-- "PerBlock" AbcDependency : IDependency
Composition ..> ValueTupleᐸIServiceˏMyAccumulatorᐳ : ValueTupleᐸIServiceˏMyAccumulatorᐳ Root
```

</details>

<details>
<summary>Pure.DI-generated partial class Composition</summary><blockquote>
The following partial class will be generated:

```c#
partial class Composition
Expand Down Expand Up @@ -267,5 +222,45 @@ partial class Composition
}
```

</blockquote></details>
Class diagram:

```mermaid
classDiagram
class Composition {
<<partial>>
+ValueTupleᐸIServiceˏMyAccumulatorᐳ Root
+ T ResolveᐸTᐳ()
+ T ResolveᐸTᐳ(object? tag)
+ object Resolve(Type type)
+ object Resolve(Type type, object? tag)
}
class MyAccumulator
class ValueTupleᐸIServiceˏMyAccumulatorᐳ {
+ValueTuple(IService item1, MyAccumulator item2)
}
AbcDependency --|> IDependency :
class AbcDependency {
+AbcDependency()
}
XyzDependency --|> IDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.XyzDependency)
class XyzDependency {
+XyzDependency()
}
Service --|> IService :
class Service {
+Service(IDependency dependency1, IDependency dependency2, IDependency dependency3)
}
class IDependency {
<<interface>>
}
class IService {
<<interface>>
}
ValueTupleᐸIServiceˏMyAccumulatorᐳ *-- Service : IService
ValueTupleᐸIServiceˏMyAccumulatorᐳ *-- MyAccumulator : MyAccumulator
Service *-- AbcDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.AbcDependency) IDependency
Service o-- "Singleton" XyzDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.XyzDependency) IDependency
Service o-- "PerBlock" AbcDependency : IDependency
Composition ..> ValueTupleᐸIServiceˏMyAccumulatorᐳ : ValueTupleᐸIServiceˏMyAccumulatorᐳ Root
```

Loading

0 comments on commit aa75463

Please sign in to comment.