Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Oct 24, 2023
1 parent 4b04b5c commit 52db216
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 74 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,13 @@ Specifies whether the generated code should be formatted. This option consumes a

</details>

## NuGet packages

| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |

## Requirements for development environments

- [.NET SDK 6.0.4xx or newer](https://dotnet.microsoft.com/download/dotnet/6.0)
Expand Down
2 changes: 1 addition & 1 deletion build/ReadmeTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private static async Task AddContent(string sourceFile, TextWriter readmeWriter,

private async Task GenerateExamples(IEnumerable<(string GroupName, Dictionary<string, string>[] SampleItems)> examples, TextWriter readmeWriter, string logsDirectory)
{
var packageVersion = (_settings.VersionOverride ?? Tools.GetNextVersion(new NuGetRestoreSettings("Pure.DI"), _settings.VersionRange)).ToString();
var packageVersion = (_settings.VersionOverride ?? Tools.GetNextVersion(new NuGetRestoreSettings("Pure.DI"), _settings.VersionRange, 0)).ToString();
foreach (var readmeFile in Directory.EnumerateFiles(Path.Combine(ReadmeDir), "*.md"))
{
if (readmeFile.EndsWith("Template.md", StringComparison.InvariantCultureIgnoreCase))
Expand Down
4 changes: 2 additions & 2 deletions build/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ internal static partial class Tools
{
private static readonly Regex ReleaseRegex = CreateReleaseRegex();

public static NuGetVersion GetNextVersion(NuGetRestoreSettings settings, VersionRange versionRange) =>
public static NuGetVersion GetNextVersion(NuGetRestoreSettings settings, VersionRange versionRange, int incrementValue = 1) =>
GetService<INuGet>()
.Restore(settings.WithHideWarningsAndErrors(true).WithVersionRange(versionRange).WithNoCache(true))
.Where(i => i.Name == settings.PackageId)
.Select(i => i.NuGetVersion)
.Select(i => i.Release != string.Empty
? GetNextRelease(versionRange, i)
: new NuGetVersion(i.Major, i.Minor, i.Patch + 1))
: new NuGetVersion(i.Major, i.Minor, i.Patch + incrementValue))
.Max() ?? new NuGetVersion(2, 0, 0);

private static NuGetVersion GetNextRelease(VersionRangeBase versionRange, NuGetVersion version)
Expand Down
9 changes: 5 additions & 4 deletions readme/BlazorServerApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like t
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
9 changes: 5 additions & 4 deletions readme/BlazorServerAppPageTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like t
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
9 changes: 5 additions & 4 deletions readme/BlazorWebAssemblyApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) lo
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
9 changes: 5 additions & 4 deletions readme/BlazorWebAssemblyAppPageTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) lo
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
7 changes: 7 additions & 0 deletions readme/FooterTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,13 @@ Specifies whether the generated code should be formatted. This option consumes a

</details>

## NuGet packages

| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |

## Requirements for development environments

- [.NET SDK 6.0.4xx or newer](https://dotnet.microsoft.com/download/dotnet/6.0)
Expand Down
9 changes: 5 additions & 4 deletions readme/GrpcService.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ The [project file](/samples/GrpcService/GrpcService.csproj) looks like this:
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
9 changes: 5 additions & 4 deletions readme/GrpcServicePageTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ The [project file](/samples/GrpcService/GrpcService.csproj) looks like this:
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
9 changes: 5 additions & 4 deletions readme/WebAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this:
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
9 changes: 5 additions & 4 deletions readme/WebAPIPageTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this:
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
9 changes: 5 additions & 4 deletions readme/WebApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ The [project file](/samples/WebApp/WebApp.csproj) looks like this:
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
9 changes: 5 additions & 4 deletions readme/WebAppPageTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ The [project file](/samples/WebApp/WebApp.csproj) looks like this:
</Project>
```

It contains 2 additional links to NuGet packages:
It contains 2 additional references to NuGet packages:

[![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI)

[![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS)
| | |
|------------|-------------------------------------------------------------------------------------------------|
| Pure.DI | [![NuGet](https://buildstats.info/nuget/Pure.DI)](https://www.nuget.org/packages/Pure.DI) |
| Pure.DI.MS | [![NuGet](https://buildstats.info/nuget/Pure.DI.MS)](https://www.nuget.org/packages/Pure.DI.MS) |
3 changes: 2 additions & 1 deletion samples/ShroedingersCat/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ internal partial class Composition
{
// In fact, this code is never run, and the method can have any name or be a constructor, for example,
// and can be in any part of the compiled code because this is just a hint to set up an object graph.
// Here the setup is part of the generated class, just as an example.
// [Conditional("DI")] attribute avoids generating IL code for the method that follows it.
// Since this method is needed only at the compile time.
[Conditional("DI")]
private static void Setup() =>
DI.Setup(nameof(Composition))
Expand Down
37 changes: 22 additions & 15 deletions samples/ShroedingersCatNativeAOT/Program.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
#pragma warning disable CA1050
#pragma warning disable CS8321
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedMemberInSuper.Global

using System.Diagnostics;
using Pure.DI;
using static Pure.DI.Lifetime;

// Composition root
new Composition().Root.Run();
return;

// In fact, this code is never run, and the method can have any name or be a constructor, for example,
// and can be in any part of the compiled code because this is just a hint to set up an object graph.
DI.Setup("Composition")
// Models a random subatomic event that may or may not occur
.Bind<Random>().As(Singleton).To<Random>()
// Represents a quantum superposition of 2 states: Alive or Dead
.Bind<State>().To(ctx =>
{
ctx.Inject<Random>(out var random);
return (State)random.Next(2);
})
// Represents schrodinger's cat
.Bind<ICat>().To<ShroedingersCat>()
// Represents a cardboard box with any content
.Bind<IBox<TT>>().To<CardboardBox<TT>>()
// Composition Root
.Root<Program>("Root");
// [Conditional("DI")] attribute avoids generating IL code for the method that follows it.
// Since this method is needed only at the compile time.
[Conditional("DI")]
static void Setup() =>
DI.Setup("Composition")
// Models a random subatomic event that may or may not occur
.Bind<Random>().As(Singleton).To<Random>()
// Represents a quantum superposition of 2 states: Alive or Dead
.Bind<State>().To(ctx =>
{
ctx.Inject<Random>(out var random);
return (State)random.Next(2);
})
// Represents schrodinger's cat
.Bind<ICat>().To<ShroedingersCat>()
// Represents a cardboard box with any content
.Bind<IBox<TT>>().To<CardboardBox<TT>>()
// Composition Root
.Root<Program>("Root");

public interface IBox<out T>
{
Expand Down
37 changes: 22 additions & 15 deletions samples/ShroedingersCatTopLevelStatements/Program.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
#pragma warning disable CA1050
#pragma warning disable CS8321
// ReSharper disable UnusedMember.Global
// ReSharper disable UnusedMemberInSuper.Global

using Pure.DI;
using System.Diagnostics;
using static Pure.DI.Lifetime;

// Composition root
new Composition().Root.Run();
return;

// In fact, this code is never run, and the method can have any name or be a constructor, for example,
// and can be in any part of the compiled code because this is just a hint to set up an object graph.
DI.Setup("Composition")
// Models a random subatomic event that may or may not occur
.Bind<Random>().As(Singleton).To<Random>()
// Represents a quantum superposition of 2 states: Alive or Dead
.Bind<State>().To(ctx =>
{
ctx.Inject<Random>(out var random);
return (State)random.Next(2);
})
// Represents schrodinger's cat
.Bind<ICat>().To<ShroedingersCat>()
// Represents a cardboard box with any content
.Bind<IBox<TT>>().To<CardboardBox<TT>>()
// Composition Root
.Root<Program>("Root");
// [Conditional("DI")] attribute avoids generating IL code for the method that follows it.
// Since this method is needed only at the compile time.
[Conditional("DI")]
static void Setup() =>
DI.Setup("Composition")
// Models a random subatomic event that may or may not occur
.Bind<Random>().As(Singleton).To<Random>()
// Represents a quantum superposition of 2 states: Alive or Dead
.Bind<State>().To(ctx =>
{
ctx.Inject<Random>(out var random);
return (State)random.Next(2);
})
// Represents schrodinger's cat
.Bind<ICat>().To<ShroedingersCat>()
// Represents a cardboard box with any content
.Bind<IBox<TT>>().To<CardboardBox<TT>>()
// Composition Root
.Root<Program>("Root");

public interface IBox<out T>
{
Expand Down

0 comments on commit 52db216

Please sign in to comment.