Skip to content

Commit

Permalink
Merge branch 'master' into renovate/jetbrains
Browse files Browse the repository at this point in the history
  • Loading branch information
RLittlesII committed Aug 3, 2022
2 parents 5183162 + 7d19eed commit fea5555
Show file tree
Hide file tree
Showing 12 changed files with 257 additions and 7 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,3 @@ jobs:
with:
name: 'nuget'
path: 'artifacts/nuget/'
Publish:
needs:
- Build
secrets:
RSG_NUGET_API_KEY: '${{ secrets.RSG_NUGET_API_KEY }}'
RSG_AZURE_DEVOPS: '${{ secrets.RSG_AZURE_DEVOPS }}'
uses: RocketSurgeonsGuild/actions/.github/workflows/publish-nuget.yml@v0.3.2
22 changes: 22 additions & 0 deletions .nuspec/MicrosoftDependencyInjection.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata>
<id>Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection</id>
<version>$version$</version>
<authors>RLittlesII</authors>
<owners>Rocket Surgeons Guild</owners>
<copyright>Copyright Rodney Littles, II © 2021</copyright>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ReactiveUI base view model abstractions.</description>
<projectUrl>https://github.com/RocketSurgeonsGuild/Airframe.git</projectUrl>
<repository type="git" url="https://github.com/RocketSurgeonsGuild/Airframe"/>
<iconUrl>https://raw.githubusercontent.com/RocketSurgeonsGuild/graphics/master/png/social-square-thrust-rounded.png</iconUrl>
<tags>MicrosoftDependencyInjection Xamarin MVVM</tags>
</metadata>
<files>
<file src="..\src\MicrosoftDependencyInjection\bin\$configuration$\netstandard2.0\Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.dll" target="lib\netstandard2.0" />
<file src="..\src\MicrosoftDependencyInjection\bin\$configuration$\netstandard2.0\Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.pdb" target="lib\netstandard2.0" />
<file src="..\src\MicrosoftDependencyInjection\bin\$configuration$\net6.0\Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.dll" target="lib\net6.0" />
<file src="..\src\MicrosoftDependencyInjection\bin\$configuration$\net6.0\Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection.pdb" target="lib\net6.0" />
</files>
</package>
8 changes: 8 additions & 0 deletions Airframe.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuspec", ".nuspec", "{0FF5
.nuspec\Core.nuspec = .nuspec\Core.nuspec
.nuspec\Shiny.nuspec = .nuspec\Shiny.nuspec
.nuspec\Timers.nuspec = .nuspec\Timers.nuspec
.nuspec\MicrosoftDependencyInjection.nuspec = .nuspec\MicrosoftDependencyInjection.nuspec
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = ".build", ".build\.build.csproj", "{8322904C-5A48-4A92-A5EA-2AF91F8C4595}"
Expand Down Expand Up @@ -73,6 +74,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Performance", "benchmarks\Performance\Performance.csproj", "{F1D890A7-A606-4659-BC44-643B6D54B66C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicrosoftDependencyInjection", "src\MicrosoftDependencyInjection\MicrosoftDependencyInjection.csproj", "{F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Airframe.Shiny.Tests", "test\Airframe.Shiny.Tests\Airframe.Shiny.Tests.csproj", "{63623831-9DA6-4563-BC94-F9B4007CFE89}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Airframe.Data.Tests", "test\Airframe.Data.Tests\Airframe.Data.Tests.csproj", "{5EC834CA-0341-465E-AE65-A6C181FF303B}"
Expand Down Expand Up @@ -145,6 +148,10 @@ Global
{F1D890A7-A606-4659-BC44-643B6D54B66C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1D890A7-A606-4659-BC44-643B6D54B66C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1D890A7-A606-4659-BC44-643B6D54B66C}.Release|Any CPU.Build.0 = Release|Any CPU
{F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8F14442-7FE5-41DE-8C57-3D9D0DDE246D}.Release|Any CPU.Build.0 = Release|Any CPU
{63623831-9DA6-4563-BC94-F9B4007CFE89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63623831-9DA6-4563-BC94-F9B4007CFE89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63623831-9DA6-4563-BC94-F9B4007CFE89}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -181,6 +188,7 @@ Global
{4C29DC6C-1251-4B3F-8F2C-447F24230E56} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77}
{DCA948A5-DCE2-4F0E-B011-5BCC5D9C206F} = {BC256BE7-7896-4159-BB31-9F3D22860391}
{F1D890A7-A606-4659-BC44-643B6D54B66C} = {0AF062D9-82F6-4384-B01A-137DF8A880D1}
{F8F14442-7FE5-41DE-8C57-3D9D0DDE246D} = {BC256BE7-7896-4159-BB31-9F3D22860391}
{63623831-9DA6-4563-BC94-F9B4007CFE89} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77}
{5EC834CA-0341-465E-AE65-A6C181FF303B} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77}
{903C1B9D-F4F8-4540-8F46-E8EB8F15EAA5} = {843C3844-BA79-40AE-B102-F5AFA0F4AD77}
Expand Down
2 changes: 2 additions & 0 deletions directory.packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
<PackageVersion Include="GitVersion.CommandLine.DotNetCore" Version="5.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="3.1.10" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="3.1.10" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.10" />
<PackageVersion Include="Newtonsoft.Json" Version="11.0.2" />
<PackageVersion Include="ReactiveUI" Version="13.3.2" />
Expand Down
89 changes: 89 additions & 0 deletions src/MicrosoftDependencyInjection/DependencyInjectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Extensions for <see cref="Microsoft.Extensions.DependencyInjection"/>.
/// </summary>
public static class DependencyInjectionExtensions
{
/// <summary>
/// Configures the <see cref="IOptions{TOptions}"/> for the service collection.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <typeparam name="T">The option type.</typeparam>
/// <returns>The service collection with options registered.</returns>
public static IServiceCollection ConfigureOptions<T>(this IServiceCollection serviceCollection)
where T : class
{
serviceCollection
.AddOptions<T>()
.Configure((T settings, IConfiguration config) => config.Bind(settings));

return serviceCollection;
}

/// <summary>
/// Configures the app settings for the service collection.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <param name="configuration">The configuration.</param>
/// <returns>The service collection with ReactiveUI dependencies registered.</returns>
public static IServiceCollection ConfigureAppSettings(
this IServiceCollection serviceCollection,
IConfiguration configuration)
{
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true)
.AddJsonFile("appsettings.dev.json", optional: true);

serviceCollection.AddSingleton<IConfiguration>(_ => builder.AddConfiguration(configuration).Build());

return serviceCollection;
}

/// <summary>
/// Adds the <see cref="IPlatformInitializer"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <param name="platformInitializer">The platform initializer.</param>
/// <returns>The service collection with platform dependencies registered.</returns>
public static IServiceCollection AddPlatform(this IServiceCollection serviceCollection, IPlatformInitializer platformInitializer) =>
platformInitializer.Initialize(serviceCollection);

/// <summary>
/// Adds the <see cref="IPlatformInitializer"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <param name="target">The target that owns the platform initializer.</param>
/// <param name="startup">The startup.</param>
/// <typeparam name="TTarget">The target type.</typeparam>
/// <returns>The service collection with platform dependencies registered.</returns>
public static IServiceCollection AddPlatform<TTarget>(this IServiceCollection serviceCollection, TTarget target, Func<TTarget, IPlatformInitializer> startup) =>
startup(target).Initialize(serviceCollection);

/// <summary>
/// Registers an <see cref="IApplicationStartup"/> to the service collection.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <param name="options">The startup options.</param>
/// <typeparam name="T">The startup type.</typeparam>
/// <returns>The service collection with startup dependencies registered.</returns>
public static IServiceCollection AddStartup<T>(this IServiceCollection serviceCollection, Action<StartupOption>? options = null)
where T : class, IApplicationStartup
{
serviceCollection.AddTransient<IApplicationStartup, T>();

if (options != null)
{
var startupOption = new StartupOption(serviceCollection);
options.Invoke(startupOption);
}

return serviceCollection;
}
}
}
17 changes: 17 additions & 0 deletions src/MicrosoftDependencyInjection/IPlatformInitializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Extensions.DependencyInjection;

namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Represents an initializer for a specific platform.
/// </summary>
public interface IPlatformInitializer
{
/// <summary>
/// Initialize the platform.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <returns>The service collection with platform dependencies registered.</returns>
public IServiceCollection Initialize(IServiceCollection serviceCollection);
}
}
17 changes: 17 additions & 0 deletions src/MicrosoftDependencyInjection/IServiceCollectionModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Extensions.DependencyInjection;

namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Interface that represents a module that groups registrations to the <see cref="IServiceCollection"/>.
/// </summary>
public interface IServiceCollectionModule
{
/// <summary>
/// Loads the provided <see cref="IServiceCollection"/> with <see cref="ServiceDescriptor"/>.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <returns>The service collection with dependencies registered.</returns>
IServiceCollection Load(IServiceCollection serviceCollection);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<Nullable>enable</Nullable>
<AssemblyName>Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection</AssemblyName>
<RootNamespace>Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions src/MicrosoftDependencyInjection/ServiceCollectionModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Extensions.DependencyInjection;

namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Represents a module to register dependencies against an <see cref="IServiceCollection"/>.
/// </summary>
public abstract class ServiceCollectionModule : IServiceCollectionModule
{
/// <inheritdoc />
IServiceCollection IServiceCollectionModule.Load(IServiceCollection serviceCollection) => Load(serviceCollection);

/// <summary>
/// Loads the provided <see cref="IServiceCollection"/> with <see cref="ServiceDescriptor"/>.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <returns>The service collection with dependencies registered.</returns>
protected abstract IServiceCollection Load(IServiceCollection serviceCollection);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.Extensions.DependencyInjection;

namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Extension methods for registering an <see cref="IServiceCollectionModule"/>.
/// </summary>
public static class ServiceCollectionModuleExtensions
{
/// <summary>
/// Adds the provided <see cref="IServiceCollectionModule"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <param name="module">The module.</param>
/// <typeparam name="T">The type.</typeparam>
/// <returns>The service collection with dependencies registered.</returns>
public static IServiceCollection AddModule<T>(this IServiceCollection serviceCollection, T module)
where T : IServiceCollectionModule => module.Load(serviceCollection);

/// <summary>
/// Adds the provided <see cref="IServiceCollectionModule"/> to the <see cref="IServiceCollection"/>.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <typeparam name="T">The type.</typeparam>
/// <returns>The service collection with dependencies registered.</returns>
public static IServiceCollection AddModule<T>(this IServiceCollection serviceCollection)
where T : IServiceCollectionModule, new() => new T().Load(serviceCollection);
}
}
32 changes: 32 additions & 0 deletions src/MicrosoftDependencyInjection/StartupOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.Extensions.DependencyInjection;

namespace Rocket.Surgery.Airframe.Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Represents a startup options configurator.
/// </summary>
public class StartupOption
{
private readonly IServiceCollection _serviceCollection;

/// <summary>
/// Initializes a new instance of the <see cref="StartupOption"/> class.
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
public StartupOption(IServiceCollection serviceCollection) =>
_serviceCollection = serviceCollection;

/// <summary>
/// Adds an <see cref="IStartupOperation"/> to the container.
/// </summary>
/// <typeparam name="T">The operation type.</typeparam>
/// <returns>The option configuration.</returns>
public StartupOption AddOperation<T>()
where T : class, IStartupOperation
{
_serviceCollection.AddTransient<IStartupOperation, T>();

return this;
}
}
}
3 changes: 3 additions & 0 deletions src/Synthetic/Drinks/DrinkType.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Diagnostics.CodeAnalysis;

namespace Rocket.Surgery.Airframe.Synthetic
{
/// <summary>
/// Enumeration representing espresso drink types.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:Documentation text should end with a period", Justification = "enum")]
public enum DrinkType
{
/// <summary>
Expand Down

0 comments on commit fea5555

Please sign in to comment.