Skip to content

Commit

Permalink
replace dependency Microsoft.Extensions.DependencyInjection by Micros…
Browse files Browse the repository at this point in the history
…oft.Extensions.DependencyInjection.Abstractions
  • Loading branch information
phmatray committed Feb 11, 2024
1 parent 2481906 commit 250f0a9
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
37 changes: 17 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ Write code, not commands. MasterCommander provides a simple, consistent interfac
* [Roadmap (next features)](#roadmap-next-features)
* [📥 Installation](#-installation)
* [📋 Prerequisites](#-prerequisites)
* [From NuGet](#from-nuget)
* [From Source](#from-source)
* [🚀 We use the latest C# features](#-we-use-the-latest-c-features)
* [🚀 From Source](#-from-source)
* [We use the latest C# features](#we-use-the-latest-c-features)
* [📦 NuGet Packages](#-nuget-packages)
* [🧪 Tests Specifications](#-tests-specifications)
* [📊 Code Quality](#-code-quality)
* [❓ Issues and Feature Requests](#-issues-and-feature-requests)
* [🧪 Tests Specifications](#-tests-specifications)
* [🤝 Contributing](#-contributing)
* [🌟 Contributors](#-contributors)
* [How to contribute?](#how-to-contribute)
* [Contributors](#contributors)
* [❓ Issues and Feature Requests](#-issues-and-feature-requests)
* [✉️ Contact](#-contact)
* [📜 License](#-license)
<!-- TOC -->
Expand Down Expand Up @@ -123,15 +123,15 @@ To use MasterCommander, ensure you have the following installed on your system:
- Docker (optional)
- Node.js and npm (optional)

### From NuGet
#### We use the latest C# features

To install MasterCommander, you can use the NuGet package manager. Run the following command in your terminal:
This library targets .NET 8.0 and uses the latest C# features. It is written in C# 12.0 and uses the new `init`
properties, `record` types, `switch` expressions, `using` declarations and more.

```shell
dotnet add package MasterCommander --version 1.0.0-alpha.0.40
```
I invite you to read the [C# 12.0 documentation](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-12) to
learn more about these features.

### From Source
### 🚀 From Source

You can also build MasterCommander from source. Follow these steps to get started:

Expand All @@ -140,16 +140,13 @@ You can also build MasterCommander from source. Follow these steps to get starte
3. Run the application with `dotnet run` from within the source directory.
4. Or... open the project in Visual Studio (or JetBrains Rider) and run the application from the IDE.

### 📦 NuGet Packages

### 🚀 We use the latest C# features

This library targets .NET 8.0 and uses the latest C# features. It is written in C# 12.0 and uses the new `init`
properties, `record` types, `switch` expressions, `using` declarations and more.

I invite you to read the [C# 12.0 documentation](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-12) to
learn more about these features.
To install MasterCommander, you can use the NuGet package manager. Run the following command in your terminal:

### 📦 NuGet Packages
```shell
dotnet add package MasterCommander --version 1.0.0-alpha.0.40
```

| Package Name | NuGet Version Badge | NuGet Downloads Badge | Package Explorer |
|--------------------------------------|----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|
Expand Down
4 changes: 2 additions & 2 deletions docs/master-commander/MainExtensions.RegisterAppServices().md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
Provides extension methods for setting up application services.

```csharp
public static MasterCommander.Core.Services.IProjectInitializationService RegisterAppServices();
public static Microsoft.Extensions.DependencyInjection.ServiceCollection RegisterAppServices();
```

#### Returns
[IProjectInitializationService](IProjectInitializationService.md 'MasterCommander.Core.Services.IProjectInitializationService')
[Microsoft.Extensions.DependencyInjection.ServiceCollection](https://docs.microsoft.com/en-us/dotnet/api/Microsoft.Extensions.DependencyInjection.ServiceCollection 'Microsoft.Extensions.DependencyInjection.ServiceCollection')
The project initialization service.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
<NoWarn>IDE0005</NoWarn>
</PropertyGroup>

<!-- Project references -->
<ItemGroup>
<ProjectReference Include="..\..\library\MasterCommander\MasterCommander.csproj" />
</ItemGroup>

<!-- Dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions src/demo/MasterCommander.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
// See the LICENSE file in the project root for full license information.

using MasterCommander;
using MasterCommander.Core.Services;
using Microsoft.Extensions.DependencyInjection;

// create a new .NET solution and console application
await MainExtensions
.RegisterAppServices()
.BuildServiceProvider()
.GetRequiredService<IProjectInitializationService>()
.InitializeConsoleProjectAsync();
5 changes: 2 additions & 3 deletions src/library/MasterCommander/MainExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class MainExtensions
/// Provides extension methods for setting up application services.
/// </summary>
/// <returns>The project initialization service.</returns>
public static IProjectInitializationService RegisterAppServices()
public static ServiceCollection RegisterAppServices()
{
var services = new ServiceCollection();

Expand All @@ -28,8 +28,7 @@ public static IProjectInitializationService RegisterAppServices()
// Register higher-level services
services.AddScoped<IProjectInitializationService, ProjectInitializationService>();

var serviceProvider = services.BuildServiceProvider();
return serviceProvider.GetRequiredService<IProjectInitializationService>();
return services;
}

private static void ConfigureDirectoryService(IServiceCollection services)
Expand Down
6 changes: 2 additions & 4 deletions src/library/MasterCommander/MasterCommander.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
</PackageReference>
</ItemGroup>

<!-- Dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="CliWrap" />
<PackageReference Include="Spectre.Console" />
</ItemGroup>
Expand Down

0 comments on commit 250f0a9

Please sign in to comment.