Skip to content

Commit 2eebee8

Browse files
committed
Feat: Update TUnit to version 0.19.86 and add type annotations
Updated TUnit package references across all projects from version 0.19.82 to 0.19.86. Added `DynamicallyAccessedMembers` annotations for dependency injection extensions to improve compatibility with trimming and enhance runtime safety.
1 parent 6153192 commit 2eebee8

File tree

9 files changed

+18
-16
lines changed

9 files changed

+18
-16
lines changed

src/CodeOfChaos.Extensions.DependencyInjection/IServiceCollectionExtensions.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
// ---------------------------------------------------------------------------------------------------------------------
22
// Imports
33
// ---------------------------------------------------------------------------------------------------------------------
4+
using System.Diagnostics.CodeAnalysis;
5+
46
// ReSharper disable once CheckNamespace
57
namespace Microsoft.Extensions.DependencyInjection;
68
// ---------------------------------------------------------------------------------------------------------------------
79
// Code
810
// ---------------------------------------------------------------------------------------------------------------------
911
public static class IServiceCollectionExtensions {
1012
#region AddServiceIfNotExists
11-
public static IServiceCollection AddServiceIfNotExists<TService, TImplementation>(
13+
public static IServiceCollection AddServiceIfNotExists<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(
1214
this IServiceCollection services,
1315
ServiceLifetime lifetime
1416
)
@@ -32,24 +34,24 @@ ServiceLifetime lifetime
3234
return services;
3335
}
3436

35-
public static IServiceCollection AddSingletonIfNotExists<TService, TImplementation>(this IServiceCollection services)
37+
public static IServiceCollection AddSingletonIfNotExists<TService,[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(this IServiceCollection services)
3638
where TService : class
3739
where TImplementation : class, TService =>
3840
AddServiceIfNotExists<TService, TImplementation>(services, ServiceLifetime.Singleton);
3941

40-
public static IServiceCollection AddScopedIfNotExists<TService, TImplementation>(this IServiceCollection services)
42+
public static IServiceCollection AddScopedIfNotExists<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(this IServiceCollection services)
4143
where TService : class
4244
where TImplementation : class, TService =>
4345
AddServiceIfNotExists<TService, TImplementation>(services, ServiceLifetime.Scoped);
4446

45-
public static IServiceCollection AddTransientIfNotExists<TService, TImplementation>(this IServiceCollection services)
47+
public static IServiceCollection AddTransientIfNotExists<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(this IServiceCollection services)
4648
where TService : class
4749
where TImplementation : class, TService =>
4850
AddServiceIfNotExists<TService, TImplementation>(services, ServiceLifetime.Transient);
4951
#endregion
5052

5153
#region AddKeyedServiceIfNotExists
52-
public static IServiceCollection AddKeyedServiceIfNotExists<TService, TImplementation>(
54+
public static IServiceCollection AddKeyedServiceIfNotExists<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(
5355
this IServiceCollection services,
5456
object key,
5557
ServiceLifetime lifetime
@@ -76,23 +78,23 @@ ServiceLifetime lifetime
7678
}
7779

7880
// Direct keyed lifetime overloads
79-
public static IServiceCollection AddKeyedSingletonIfNotExists<TService, TImplementation>(
81+
public static IServiceCollection AddKeyedSingletonIfNotExists<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(
8082
this IServiceCollection services,
8183
object key
8284
)
8385
where TService : class
8486
where TImplementation : class, TService =>
8587
AddKeyedServiceIfNotExists<TService, TImplementation>(services, key, ServiceLifetime.Singleton);
8688

87-
public static IServiceCollection AddKeyedScopedIfNotExists<TService, TImplementation>(
89+
public static IServiceCollection AddKeyedScopedIfNotExists<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(
8890
this IServiceCollection services,
8991
object key
9092
)
9193
where TService : class
9294
where TImplementation : class, TService =>
9395
AddKeyedServiceIfNotExists<TService, TImplementation>(services, key, ServiceLifetime.Scoped);
9496

95-
public static IServiceCollection AddKeyedTransientIfNotExists<TService, TImplementation>(
97+
public static IServiceCollection AddKeyedTransientIfNotExists<TService, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TImplementation>(
9698
this IServiceCollection services,
9799
object key
98100
)

tests/Tests.CodeOfChaos.Extensions.Analyzers/Tests.CodeOfChaos.Extensions.Analyzers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="CodeOfChaos.Testing.TUnit" Version="0.9.0" />
14-
<PackageReference Include="TUnit" Version="0.19.82" />
14+
<PackageReference Include="TUnit" Version="0.19.86" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

tests/Tests.CodeOfChaos.Extensions.AspNetCore/Tests.CodeOfChaos.Extensions.AspNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
1515
<PackageReference Include="Moq" Version="4.20.72"/>
16-
<PackageReference Include="TUnit" Version="0.19.82" />
16+
<PackageReference Include="TUnit" Version="0.19.86" />
1717
<PackageReference Include="Bogus" Version="35.6.3" />
1818
</ItemGroup>
1919

tests/Tests.CodeOfChaos.Extensions.DependencyInjection.Generators/Tests.CodeOfChaos.Extensions.DependencyInjection.Generators.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.13.0"/>
2121
<PackageReference Include="Moq" Version="4.20.72"/>
2222
<PackageReference Include="System.Formats.Asn1" Version="9.0.4" />
23-
<PackageReference Include="TUnit" Version="0.19.82" />
23+
<PackageReference Include="TUnit" Version="0.19.86" />
2424
</ItemGroup>
2525

2626
<ItemGroup>

tests/Tests.CodeOfChaos.Extensions.DependencyInjection/Tests.CodeOfChaos.Extensions.DependencyInjection.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
1616
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4" />
1717
<PackageReference Include="Moq" Version="4.20.72"/>
18-
<PackageReference Include="TUnit" Version="0.19.82" />
18+
<PackageReference Include="TUnit" Version="0.19.86" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

tests/Tests.CodeOfChaos.Extensions.EntityFrameworkCore/Tests.CodeOfChaos.Extensions.EntityFrameworkCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
1515
<PackageReference Include="Moq" Version="4.20.72"/>
16-
<PackageReference Include="TUnit" Version="0.19.82" />
16+
<PackageReference Include="TUnit" Version="0.19.86" />
1717
<PackageReference Include="Bogus" Version="35.6.3" />
1818
</ItemGroup>
1919

tests/Tests.CodeOfChaos.Extensions.FluentValidation/Tests.CodeOfChaos.Extensions.FluentValidation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
1515
<PackageReference Include="Moq" Version="4.20.72"/>
16-
<PackageReference Include="TUnit" Version="0.19.82" />
16+
<PackageReference Include="TUnit" Version="0.19.86" />
1717
<PackageReference Include="Bogus" Version="35.6.3" />
1818
</ItemGroup>
1919

tests/Tests.CodeOfChaos.Extensions.Serilog/Tests.CodeOfChaos.Extensions.Serilog.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
1515
<PackageReference Include="Moq" Version="4.20.72"/>
16-
<PackageReference Include="TUnit" Version="0.19.82" />
16+
<PackageReference Include="TUnit" Version="0.19.86" />
1717
<PackageReference Include="Bogus" Version="35.6.3" />
1818
</ItemGroup>
1919

tests/Tests.CodeOfChaos.Extensions/Tests.CodeOfChaos.Extensions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
1515
<PackageReference Include="Moq" Version="4.20.72"/>
16-
<PackageReference Include="TUnit" Version="0.19.82" />
16+
<PackageReference Include="TUnit" Version="0.19.86" />
1717
<PackageReference Include="Bogus" Version="35.6.3" />
1818
</ItemGroup>
1919

0 commit comments

Comments
 (0)