Skip to content

Commit b2de934

Browse files
committed
Change: Package Updates & code cleanup
1 parent ebc6b9b commit b2de934

39 files changed

+212
-223
lines changed

src/CodeOfChaos.Types.DataSeeder/CodeOfChaos.Types.DataSeeder.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@
2323
</PropertyGroup>
2424

2525
<ItemGroup Label="InternalsVisibleTo">
26-
<InternalsVisibleTo Include="Tests.CodeOfChaos.Types.DataSeeder" />
27-
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
26+
<InternalsVisibleTo Include="Tests.CodeOfChaos.Types.DataSeeder"/>
27+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2"/>
2828
</ItemGroup>
2929

3030
<ItemGroup>
31-
<None Include="../../LICENSE" Pack="true" PackagePath="" Visible="false" />
32-
<None Include="../../README.md" Pack="true" PackagePath="" Visible="false" />
33-
<None Include="../../assets/icon.png" Pack="true" PackagePath="" Visible="false" />
31+
<None Include="../../LICENSE" Pack="true" PackagePath="" Visible="false"/>
32+
<None Include="../../README.md" Pack="true" PackagePath="" Visible="false"/>
33+
<None Include="../../assets/icon.png" Pack="true" PackagePath="" Visible="false"/>
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.2" />
38-
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.2" />
37+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.2"/>
38+
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.2"/>
3939
</ItemGroup>
4040

4141
</Project>

src/CodeOfChaos.Types.DataSeeder/ISeeder.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ namespace CodeOfChaos.Types;
1111
/// </summary>
1212
public interface ISeeder {
1313
bool ShouldSeed { get; }
14-
14+
1515
// -----------------------------------------------------------------------------------------------------------------
1616
// Methods
1717
// -----------------------------------------------------------------------------------------------------------------
1818
/// <summary>
19-
/// Initiates the seeding process for the implementing class.
19+
/// Initiates the seeding process for the implementing class.
2020
/// </summary>
2121
/// <param name="serviceProvider">
22-
/// An instance of <see cref="IServiceProvider" /> used to resolve dependencies during the seeding process.
22+
/// An instance of <see cref="IServiceProvider" /> used to resolve dependencies during the seeding process.
2323
/// </param>
2424
/// <param name="ct">
25-
/// A <see cref="CancellationToken" /> to observe while waiting for the task to complete. Defaults to
26-
/// <see cref="CancellationToken.None" />.
25+
/// A <see cref="CancellationToken" /> to observe while waiting for the task to complete. Defaults to
26+
/// <see cref="CancellationToken.None" />.
2727
/// </param>
2828
/// <returns>A <see cref="Task" /> that represents the asynchronous operation.</returns>
2929
/// <remarks>
30-
/// This method orchestrates the seeding process, ensuring any required dependencies are resolved via the provided
31-
/// <c>serviceProvider</c>. If the implementation detects that seeding is unnecessary,
32-
/// it will gracefully conclude the operation. If any steps in the seeding process require cancellation,
33-
/// they will respect the provided <c>CancellationToken</c>.
30+
/// This method orchestrates the seeding process, ensuring any required dependencies are resolved via the provided
31+
/// <c>serviceProvider</c>. If the implementation detects that seeding is unnecessary,
32+
/// it will gracefully conclude the operation. If any steps in the seeding process require cancellation,
33+
/// they will respect the provided <c>CancellationToken</c>.
3434
/// </remarks>
3535
Task StartAsync(IServiceProvider serviceProvider, CancellationToken ct = default);
3636

src/CodeOfChaos.Types.DataSeeder/OneTimeDataSeederService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@ public async Task StartAsync(CancellationToken ct = default) {
7575
while (seederGroup.SeederTypes.TryDequeue(out Type? seederType)) {
7676
AsyncServiceScope scope = serviceProvider.CreateAsyncScope();
7777
IServiceProvider scopeProvider = scope.ServiceProvider;
78-
78+
7979
// Because of checks by the SeederGroup struct we know that the seeder inherits from ISeeder and thus is not null
80-
var seeder = (ISeeder) scopeProvider.GetRequiredService(seederType);
81-
Task seederTask = seeder.StartAsync(scopeProvider, ct);
82-
80+
var seeder = (ISeeder)scopeProvider.GetRequiredService(seederType);
81+
Task seederTask = seeder.StartAsync(scopeProvider, ct);
82+
8383
// Because our scope has to be gracefully disposed, we add the scope here
8484
seederTasks.Add((seederTask, scope));
8585
}
8686

8787
logger.LogDebug("ExecutionStep {step} : {count} Seeder(s) found, executing...", i++, seederTasks.Count);
8888
await Task.WhenAll(seederTasks.Select(t => t.Item1));
89-
89+
9090
// Gracefully dispose the scope
9191
foreach (AsyncServiceScope scope in seederTasks.Select(t => t.Item2)) {
9292
await scope.DisposeAsync();

src/CodeOfChaos.Types.DataSeeder/Seeder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace CodeOfChaos.Types;
1313
/// a base class for seeding operations with pre-seeding validation logic.
1414
/// </summary>
1515
public abstract class Seeder : ISeeder {
16-
public bool ShouldSeed { get; private set; } = false;
17-
16+
public bool ShouldSeed { get; private set; }
17+
1818
/// <inheritdoc />
1919
public async Task StartAsync(IServiceProvider serviceProvider, CancellationToken ct = default) {
2020
ShouldSeed = await ShouldSeedAsync(ct);

src/CodeOfChaos.Types.DataSeeder/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public static IServiceCollection AddOneTimeDataSeeder<TDataSeeder>(this IService
8989
}
9090
)
9191
);
92+
9293
return services;
9394
}
9495
}

src/CodeOfChaos.Types.TypedValueStore/CodeOfChaos.Types.TypedValueStore.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
</PropertyGroup>
2424

2525
<ItemGroup>
26-
<None Include="../../LICENSE" Pack="true" PackagePath="" Visible="false" />
27-
<None Include="../../README.md" Pack="true" PackagePath="" Visible="false" />
28-
<None Include="../../assets/icon.png" Pack="true" PackagePath="" Visible="false" />
26+
<None Include="../../LICENSE" Pack="true" PackagePath="" Visible="false"/>
27+
<None Include="../../README.md" Pack="true" PackagePath="" Visible="false"/>
28+
<None Include="../../assets/icon.png" Pack="true" PackagePath="" Visible="false"/>
2929
</ItemGroup>
3030

3131
</Project>

src/CodeOfChaos.Types.TypedValueStore/IValueContainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ namespace CodeOfChaos.Types;
99
// ---------------------------------------------------------------------------------------------------------------------
1010
public interface IValueContainer {
1111
Type UnderlyingType { get; }
12-
12+
1313
bool TryGetAsValue<T>([NotNullWhen(true)] out T? output) where T : notnull;
1414
T GetAsValue<T>() where T : notnull;
15-
15+
1616
object? GetBoxedValue();
1717
}

src/CodeOfChaos.Types.TypedValueStore/TypedValueStore.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,23 @@ public void AddOrUpdate<T>(TKey key, T value) where T : notnull => _storage
110110
.AddOrUpdate(key, new ValueContainer<T>(value), updateValueFactory: (_, _) => new ValueContainer<T>(value));
111111

112112
/// <summary>
113-
/// Adds the specified key and value to the store if the key does not already exist. If the key already exists,
114-
/// retrieves the existing value associated with the key.
113+
/// Adds the specified key and value to the store if the key does not already exist. If the key already exists,
114+
/// retrieves the existing value associated with the key.
115115
/// </summary>
116116
/// <typeparam name="T">
117-
/// The type of the value associated with the specified key. Must be a non-nullable type.
117+
/// The type of the value associated with the specified key. Must be a non-nullable type.
118118
/// </typeparam>
119119
/// <param name="key">
120-
/// The key to be checked or added to the store. Must not be null.
120+
/// The key to be checked or added to the store. Must not be null.
121121
/// </param>
122122
/// <param name="valueFactory">
123-
/// A function that produces the value to add if the key does not already exist. Must not be null.
123+
/// A function that produces the value to add if the key does not already exist. Must not be null.
124124
/// </param>
125125
/// <returns>
126-
/// The value associated with the specified key. This will either be the existing value if the key was already in
127-
/// the store, or the newly added value obtained from the value factory if the key was not present.
126+
/// The value associated with the specified key. This will either be the existing value if the key was already in
127+
/// the store, or the newly added value obtained from the value factory if the key was not present.
128128
/// </returns>
129-
public T GetOrAdd<T>(TKey key, Func<T> valueFactory) where T : notnull => _storage.GetOrAdd(key, _ => new ValueContainer<T>(valueFactory())).GetAsValue<T>();
129+
public T GetOrAdd<T>(TKey key, Func<T> valueFactory) where T : notnull => _storage.GetOrAdd(key, valueFactory: _ => new ValueContainer<T>(valueFactory())).GetAsValue<T>();
130130

131131
/// <summary>
132132
/// Attempts to retrieve a value of the specified type associated with the given key.
@@ -149,6 +149,7 @@ public bool TryGetValue<T>(TKey key, [NotNullWhen(true)] out T? value) where T :
149149

150150
public T GetValue<T>(TKey key) where T : notnull {
151151
if (_storage.TryGetValue(key, out IValueContainer? container)) return container.GetAsValue<T>();
152+
152153
throw new KeyNotFoundException();
153154
}
154155

src/CodeOfChaos.Types.TypedValueStore/ValueContainer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace CodeOfChaos.Types;
1010
public readonly record struct ValueContainer<T>(T Value) : IValueContainer where T : notnull {
1111
private readonly Lazy<Type> _lazyUnderlyingType = new(() => typeof(T));
1212
public Type UnderlyingType => _lazyUnderlyingType.Value;
13-
13+
1414
public bool TryGetAsValue<T1>([NotNullWhen(true)] out T1? output) where T1 : notnull {
1515
switch (Value) {
1616
case T1 castedValue:
@@ -21,13 +21,13 @@ public bool TryGetAsValue<T1>([NotNullWhen(true)] out T1? output) where T1 : not
2121
return false;
2222
}
2323
}
24-
24+
2525
public T1 GetAsValue<T1>() where T1 : notnull {
2626
return Value switch {
2727
T1 castedValue => castedValue,
2828
_ => throw new InvalidCastException($"Value of type {UnderlyingType} cannot be casted to {typeof(T1)}")
2929
};
3030
}
31-
31+
3232
public object? GetBoxedValue() => Value;
3333
}

src/CodeOfChaos.Types.UnitOfWork.Contracts/CodeOfChaos.Types.UnitOfWork.Contracts.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
7+
88
<RootNamespace>CodeOfChaos.Types.UnitOfWork</RootNamespace>
99

1010
<!-- Main package name -->
@@ -24,14 +24,14 @@
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27-
<None Include="../../LICENSE" Pack="true" PackagePath="" Visible="false" />
28-
<None Include="../../README.md" Pack="true" PackagePath="" Visible="false" />
29-
<None Include="../../assets/icon.png" Pack="true" PackagePath="" Visible="false" />
27+
<None Include="../../LICENSE" Pack="true" PackagePath="" Visible="false"/>
28+
<None Include="../../README.md" Pack="true" PackagePath="" Visible="false"/>
29+
<None Include="../../assets/icon.png" Pack="true" PackagePath="" Visible="false"/>
3030
</ItemGroup>
31-
31+
3232
<ItemGroup>
33-
<PackageReference Include="CodeOfChaos.Extensions.DependencyInjection" Version="0.36.4" />
34-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
33+
<PackageReference Include="CodeOfChaos.Extensions.DependencyInjection" Version="0.36.4"/>
34+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2"/>
3535
</ItemGroup>
3636

3737
</Project>

0 commit comments

Comments
 (0)