Skip to content

Commit

Permalink
support keyed services
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Nov 16, 2023
1 parent a25206e commit 9a56fd7
Show file tree
Hide file tree
Showing 18 changed files with 452 additions and 391 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
with:
fetch-depth: 0

- name: Install .NET Core
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Calculate Version
run: |
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Injectio.Attributes/Injectio.Attributes.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions src/Injectio.Attributes/RegisterAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ protected RegisterAttribute()
/// <seealso cref="P:Microsoft.Extensions.DependencyInjection.ServiceDescriptor.ServiceType"/>
public Type? ServiceType { get; set; }

#if NET8_0_OR_GREATER
/// <summary>
/// Gets or sets the key of the service.
/// </summary>
/// <value>The service key.</value>
/// <seealso cref="P:Microsoft.Extensions.DependencyInjection.ServiceDescriptor.ServiceKey "/>
public object? ServiceKey { get; set; }
#endif

/// <summary>
/// Name of a factory method to create new instances of the service implementation
Expand Down
11 changes: 3 additions & 8 deletions src/Injectio.Generators/EquatableArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Injectio.Generators;

public readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IEnumerable<T>
public readonly struct EquatableArray<T> : IReadOnlyCollection<T>, IEquatable<EquatableArray<T>>
where T : IEquatable<T>
{
public static readonly EquatableArray<T> Empty = new(Array.Empty<T>());
Expand All @@ -27,20 +27,15 @@ public bool Equals(EquatableArray<T> array)

public override bool Equals(object obj)
{
return obj is EquatableArray<T> array && Equals(array);
return obj is EquatableArray<T> array && Equals(this, array);
}

public override int GetHashCode()
{
if (_array is null)
return 0;

HashCode hashCode = default;

foreach (T item in _array)
hashCode.Add(item);

return hashCode.ToHashCode();
return HashCode.Seed.CombineAll(_array);
}

public ReadOnlySpan<T> AsSpan()
Expand Down
Loading

0 comments on commit 9a56fd7

Please sign in to comment.