Skip to content

Commit

Permalink
Updated packages. (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored Jun 12, 2024
1 parent 89b70a4 commit 5cbcdc8
Show file tree
Hide file tree
Showing 32 changed files with 149 additions and 145 deletions.
2 changes: 1 addition & 1 deletion samples/Sample.API/Sample.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Fluxera.StronglyTypedId.SystemTextJson" Version="8.1.1" />
<PackageReference Include="Fluxera.StronglyTypedId.SystemTextJson" Version="8.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample.Domain/Sample.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Fluxera.ComponentModel.Annotations" Version="8.2.0" />
<PackageReference Include="Fluxera.StronglyTypedId" Version="8.1.1" />
<PackageReference Include="Fluxera.StronglyTypedId" Version="8.3.1" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Fluxera.Utilities" Version="8.2.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

<ItemGroup>
<PackageReference Include="Fluxera.Guards" Version="8.1.1" />
<PackageReference Include="Fluxera.Entity" Version="8.3.1" />
<PackageReference Include="Fluxera.Extensions.Validation.Abstractions" Version="8.3.1" />
<PackageReference Include="Fluxera.Entity" Version="8.3.2" />
<PackageReference Include="Fluxera.Extensions.Validation.Abstractions" Version="8.3.2" />
<PackageReference Include="Fluxera.Linq.Expressions" Version="8.2.0" />
<PackageReference Include="Fluxera.Utilities" Version="8.2.0" />
<PackageReference Include="Fluxera.ValueObject" Version="8.1.1" />
<PackageReference Include="Fluxera.ValueObject" Version="8.2.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public static void UseStronglyTypedIdValueGenerator(this EntityTypeBuilder entit
}

/// <summary>
/// Configure the <see cref="EntityTypeBuilder" /> to use the <see cref="SequentialGuidStringValueGenerator" /> for
/// string IDs.
/// Configure the <see cref="EntityTypeBuilder" /> to use the <see cref="SequentialGuidStringValueGenerator" />
/// for string IDs.
/// </summary>
/// <param name="entityTypeBuilder"></param>
public static void UseSequentialGuidStringIdValueGenerator(this EntityTypeBuilder entityTypeBuilder)
Expand All @@ -89,7 +89,7 @@ public static void UseSequentialGuidStringIdValueGenerator(this EntityTypeBuilde
}

/// <summary>
/// Disables the delete cascading for references aggregate roots.
/// Disables delete cascading for references aggregate roots.
/// </summary>
/// <param name="entityTypeBuilder"></param>
public static void UseReferences(this EntityTypeBuilder entityTypeBuilder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fluxera.Enumeration.EntityFrameworkCore" Version="8.1.1" />
<PackageReference Include="Fluxera.Enumeration.EntityFrameworkCore" Version="8.2.0" />
<PackageReference Include="Fluxera.Guards" Version="8.1.1" />
<PackageReference Include="Fluxera.StronglyTypedId.EntityFrameworkCore" Version="8.1.1" />
<PackageReference Include="Fluxera.ValueObject.EntityFrameworkCore" Version="8.1.1" />
<PackageReference Include="Fluxera.StronglyTypedId.EntityFrameworkCore" Version="8.3.1" />
<PackageReference Include="Fluxera.ValueObject.EntityFrameworkCore" Version="8.2.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[PublicAPI]
public class StronglyTypedIdValueGenerator<TStronglyTypedId, TValue> : ValueGenerator<TStronglyTypedId>
where TStronglyTypedId : StronglyTypedId<TStronglyTypedId, TValue>
where TValue : IComparable
where TValue : IComparable, IComparable<TValue>, IEquatable<TValue>
{
private readonly SequentialGuidValueGenerator sequentialGuidValueGenerator = new SequentialGuidValueGenerator();

Expand All @@ -32,12 +32,12 @@ public override TStronglyTypedId Next(EntityEntry entry)
if(typeof(TValue) == typeof(string))
{
Guid guid = this.sequentialGuidValueGenerator.Next(entry);
result = Activator.CreateInstance(typeof(TStronglyTypedId), new object[] { guid.ToString("D") });
result = Activator.CreateInstance(typeof(TStronglyTypedId), [guid.ToString("D")]);
}
else if(typeof(TValue) == typeof(Guid))
{
Guid guid = this.sequentialGuidValueGenerator.Next(entry);
result = Activator.CreateInstance(typeof(TStronglyTypedId), new object[] { guid });
result = Activator.CreateInstance(typeof(TStronglyTypedId), [guid]);
}
else
{
Expand Down
19 changes: 12 additions & 7 deletions src/Fluxera.Repository.InMemory/InMemoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Fluxera.Entity;
Expand Down Expand Up @@ -408,7 +409,7 @@ private TKey GenerateKey()
{
Type valueType = keyType.GetStronglyTypedIdValueType();
object value = this.GenerateKey(valueType);
object key = Activator.CreateInstance(typeof(TKey), new object[] { value });
object key = Activator.CreateInstance(typeof(TKey), [value]);
return (TKey)key;
}

Expand All @@ -430,18 +431,22 @@ private object GenerateKey(Type keyType)

if(keyType == typeof(int))
{
IStronglyTypedId<TKey, int> pkValue = this.Store.LastOrDefault().Key as IStronglyTypedId<TKey, int>;
TKey key = this.Store.LastOrDefault().Key;
PropertyInfo property = typeof(TKey).GetProperty("Value");
int? value = property?.GetValue(key) as int?;

int nextInt = (pkValue?.Value ?? 0) + 1;
return nextInt;
int next = (value ?? 0) + 1;
return next;
}

if(keyType == typeof(long))
{
IStronglyTypedId<TKey, long> pkValue = this.Store.LastOrDefault().Key as IStronglyTypedId<TKey, long>;
TKey key = this.Store.LastOrDefault().Key;
PropertyInfo property = typeof(TKey).GetProperty("Value");
long? value = property?.GetValue(key) as int?;

long nextInt = (pkValue?.Value ?? 0) + 1;
return nextInt;
long next = (value ?? 0) + 1;
return next;
}

throw new InvalidOperationException("A key could not be generated. The in-memory repository only supports guid, string, int and long for keys.");
Expand Down
7 changes: 3 additions & 4 deletions src/Fluxera.Repository.LiteDB/BsonMapperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public static BsonMapper UseRepositoryDefaults(this BsonMapper bsonMapper)
Guard.Against.Null(bsonMapper);

bsonMapper.UseSpatial();
//mapper.UseTemporal();
bsonMapper.UseEnumeration();
bsonMapper.UsePrimitiveValueObject();
bsonMapper.UseStronglyTypedId();
Expand Down Expand Up @@ -63,15 +62,15 @@ public static BsonMapper UseReferences(this BsonMapper bsonMapper)

foreach(Type aggregateRootType in aggregateRootTypes)
{
object entityBuilder = entityMethod?.MakeGenericMethod(aggregateRootType).Invoke(bsonMapper, Array.Empty<object>());
object entityBuilder = entityMethod?.MakeGenericMethod(aggregateRootType).Invoke(bsonMapper, []);
MethodInfo idMethod = entityBuilder?.GetType().GetMethod("Id");

// Configure the ID property to use.
PropertyInfo keyProperty = GetPrimaryKeyProperty(aggregateRootType);
LambdaExpression keyPropertyExpression = CreatePropertyExpression(aggregateRootType, keyProperty);
entityBuilder = idMethod?
.MakeGenericMethod(keyProperty.PropertyType)
.Invoke(entityBuilder, new object[] { keyPropertyExpression, true });
.Invoke(entityBuilder, [keyPropertyExpression, true]);

// Configure reference properties.
foreach(PropertyInfo referenceProperty in EnumerateReferenceProperties(aggregateRootType))
Expand Down Expand Up @@ -113,7 +112,7 @@ private static object ConfigureReferenceProperty(object entityBuilder, Type aggr
LambdaExpression referenceExpression = CreatePropertyExpression(aggregateRootType, property);
entityBuilder = dbRefMethod?
.MakeGenericMethod(propertyType)
.Invoke(entityBuilder, new object[] { referenceExpression, collectionName });
.Invoke(entityBuilder, [referenceExpression, collectionName]);

return entityBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fluxera.Enumeration.LiteDB" Version="8.1.1" />
<PackageReference Include="Fluxera.Spatial.LiteDB" Version="8.1.0" />
<PackageReference Include="Fluxera.StronglyTypedId.LiteDB" Version="8.1.1" />
<PackageReference Include="Fluxera.ValueObject.LiteDB" Version="8.1.1" />
<PackageReference Include="Fluxera.Enumeration.LiteDB" Version="8.2.0" />
<PackageReference Include="Fluxera.Spatial.LiteDB" Version="8.1.1" />
<PackageReference Include="Fluxera.StronglyTypedId.LiteDB" Version="8.3.1" />
<PackageReference Include="Fluxera.ValueObject.LiteDB" Version="8.2.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/Fluxera.Repository.LiteDB/LiteContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected override void DisposeManaged()
}

/// <summary>
/// Configures the options to use for this context instance over it's lifetime.
/// Configures the options to use for this context instance over its lifetime.
/// </summary>
protected abstract void ConfigureOptions(LiteContextOptions options);

Expand Down
2 changes: 1 addition & 1 deletion src/Fluxera.Repository.LiteDB/LiteRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ private TKey GenerateKey()
"A key could not be generated. The LiteDB repository only supports guid or string as type for strongly-typed keys.");
}

object instance = Activator.CreateInstance(keyType, new object[] { keyValue });
object instance = Activator.CreateInstance(keyType, [keyValue]);
return (TKey)instance;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static IRepositoryBuilder AddLiteRepository(this IRepositoryBuilder build
/// <summary>
/// Adds a LiteDB repository for the given repository name. The repository options
/// are configured using the options builder configure action. Additional LiteDB
/// related mappings can be configures using the mapper configuration action.
/// related mappings can be configured using the mapper configuration action.
/// </summary>
/// <param name="builder"></param>
/// <param name="repositoryName"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

<ItemGroup>
<PackageReference Include="Fluxera.ComponentModel.Annotations" Version="8.2.0" />
<PackageReference Include="Fluxera.Enumeration.MongoDB" Version="8.1.1" />
<PackageReference Include="Fluxera.Spatial.MongoDB" Version="8.1.0" />
<PackageReference Include="Fluxera.StronglyTypedId.MongoDB" Version="8.1.1" />
<PackageReference Include="Fluxera.ValueObject.MongoDB" Version="8.1.1" />
<PackageReference Include="Fluxera.Enumeration.MongoDB" Version="8.2.0" />
<PackageReference Include="Fluxera.Spatial.MongoDB" Version="8.1.1" />
<PackageReference Include="Fluxera.StronglyTypedId.MongoDB" Version="8.3.1" />
<PackageReference Include="Fluxera.ValueObject.MongoDB" Version="8.2.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Apply(BsonMemberMap memberMap)
Type serializerTypeTemplate = typeof(AggregateRootReferenceSerializer<,>);
Type serializerType = serializerTypeTemplate.MakeGenericType(memberType, idType);

IBsonSerializer serializer = (IBsonSerializer)Activator.CreateInstance(serializerType, new object[] { referenceSerializer });
IBsonSerializer serializer = (IBsonSerializer)Activator.CreateInstance(serializerType, [referenceSerializer]);
memberMap.SetSerializer(serializer);
}

Expand All @@ -57,7 +57,7 @@ public void Apply(BsonMemberMap memberMap)
Type serializerTypeTemplate = typeof(AggregateRootReferenceSerializer<,>);
Type serializerType = serializerTypeTemplate.MakeGenericType(elementType, idType);

IBsonSerializer aggregateRootSerializer = (IBsonSerializer)Activator.CreateInstance(serializerType, new object[] { referenceSerializer });
IBsonSerializer aggregateRootSerializer = (IBsonSerializer)Activator.CreateInstance(serializerType, [referenceSerializer]);

serializer = listSerializer.WithChildSerializer(aggregateRootSerializer);
memberMap.SetSerializer(serializer);
Expand Down Expand Up @@ -88,7 +88,7 @@ private IBsonSerializer GetReferenceSerializer(Type memberType, string databaseN
Type serializerTypeTemplate = typeof(StronglyTypedIdReferenceSerializer<,>);
Type serializerType = serializerTypeTemplate.MakeGenericType(memberType, valueType);

serializer = (IBsonSerializer)Activator.CreateInstance(serializerType, new object[] { databaseName, collectionName });
serializer = (IBsonSerializer)Activator.CreateInstance(serializerType, [databaseName, collectionName]);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// </summary>
public class StronglyTypedIdReferenceSerializer<TStronglyTypedId, TValue> : SerializerBase<TStronglyTypedId>
where TStronglyTypedId : StronglyTypedId<TStronglyTypedId, TValue>
where TValue : notnull, IComparable
where TValue : IComparable, IComparable<TValue>, IEquatable<TValue>
{
private readonly IBsonSerializer serializer;

Expand Down Expand Up @@ -50,7 +50,7 @@ public override TStronglyTypedId Deserialize(BsonDeserializationContext context,

if(value is not null)
{
id = (TStronglyTypedId)Activator.CreateInstance(typeof(TStronglyTypedId), new object[] { value });
id = (TStronglyTypedId)Activator.CreateInstance(typeof(TStronglyTypedId), [value]);
}

return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using global::MongoDB.Bson.Serialization.IdGenerators;

/// <summary>
/// Represents an Id generator for strongly-typed IDs.
/// An <see cref="IIdGenerator"/> for strongly-typed IDs.
/// </summary>
public class StronglyTypedIdGenerator : IIdGenerator
{
Expand Down Expand Up @@ -44,7 +44,7 @@ public object GenerateId(object container, object document)
}
}

object id = Activator.CreateInstance(this.idType, new object[] { value });
object id = Activator.CreateInstance(this.idType, [value]);
return id;
}

Expand Down
20 changes: 10 additions & 10 deletions src/Fluxera.Repository/Fluxera.Repository.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@

<ItemGroup>
<PackageReference Include="Fluxera.ComponentModel.Annotations" Version="8.2.0" />
<PackageReference Include="Fluxera.DomainEvents.MediatR" Version="8.3.1" />
<PackageReference Include="Fluxera.Entity" Version="8.3.1" />
<PackageReference Include="Fluxera.Enumeration" Version="8.1.1" />
<PackageReference Include="Fluxera.Extensions.Caching" Version="8.3.1" />
<PackageReference Include="Fluxera.Extensions.Common" Version="8.3.1" />
<PackageReference Include="Fluxera.Extensions.DependencyInjection" Version="8.3.1" />
<PackageReference Include="Fluxera.Extensions.Validation" Version="8.3.1" />
<PackageReference Include="Fluxera.Spatial" Version="8.1.0" />
<PackageReference Include="Fluxera.StronglyTypedId" Version="8.1.1" />
<PackageReference Include="Fluxera.ValueObject" Version="8.1.1" />
<PackageReference Include="Fluxera.DomainEvents.MediatR" Version="8.3.2" />
<PackageReference Include="Fluxera.Entity" Version="8.3.2" />
<PackageReference Include="Fluxera.Enumeration" Version="8.2.0" />
<PackageReference Include="Fluxera.Extensions.Caching" Version="8.3.2" />
<PackageReference Include="Fluxera.Extensions.Common" Version="8.3.2" />
<PackageReference Include="Fluxera.Extensions.DependencyInjection" Version="8.3.2" />
<PackageReference Include="Fluxera.Extensions.Validation" Version="8.3.2" />
<PackageReference Include="Fluxera.Spatial" Version="8.1.1" />
<PackageReference Include="Fluxera.StronglyTypedId" Version="8.3.1" />
<PackageReference Include="Fluxera.ValueObject" Version="8.2.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public InterceptionOptionsBuilder(IServiceCollection services)
/// <inheritdoc />
public IInterceptionOptionsBuilder AddInterceptorsFromAssemblies(IEnumerable<Assembly> assemblies)
{
assemblies ??= Enumerable.Empty<Assembly>();
assemblies ??= [];

foreach(Assembly assembly in assemblies)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Fluxera.Repository/Options/RepositoryOptionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public RepositoryOptionsBuilder(IServiceCollection services, string repositoryNa

public IRepositoryOptionsBuilder UseFor(IEnumerable<Assembly> assemblies)
{
assemblies ??= Enumerable.Empty<Assembly>();
assemblies ??= [];

foreach(Assembly assembly in assemblies)
{
Expand All @@ -54,7 +54,7 @@ public IRepositoryOptionsBuilder UseFor(Assembly assembly)

public IRepositoryOptionsBuilder UseFor(IEnumerable<Type> types)
{
types ??= Enumerable.Empty<Type>();
types ??= [];

foreach(Type type in types)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected override void AddRepositoryUnderTest(IRepositoryBuilder repositoryBuil
repositoryBuilder.AddEntityFrameworkRepository<RepositoryContext>(repositoryName, configureOptions.Invoke);
}

// TODO: Add Invoice/InvoiceItem tests here to check if referenced entites are add/updated
// TODO: Add Invoice/InvoiceItem tests here to check if referenced entities are add/updated
//[Test]
//public async Task ShouldAddEntity()
//{
Expand Down
8 changes: 4 additions & 4 deletions tests/Fluxera.Repository.UnitTests.Core/AddTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task ShouldAddItem()
public async Task ShouldAddItems()
{
Person[] persons =
{
[
new Person
{
Name = "Tester"
Expand All @@ -64,7 +64,7 @@ public async Task ShouldAddItems()
{
Name = "Tester"
}
};
];
await this.PersonRepository.AddRangeAsync(persons);
await this.UnitOfWork.SaveChangesAsync();

Expand Down Expand Up @@ -98,7 +98,7 @@ public async Task ShouldAddItemWithStronglyTypedId()
public async Task ShouldAddItemsStronglyTypedId()
{
Employee[] employees =
{
[
new Employee
{
Name = "Tester"
Expand All @@ -107,7 +107,7 @@ public async Task ShouldAddItemsStronglyTypedId()
{
Name = "Tester"
}
};
];
await this.EmployeeRepository.AddRangeAsync(employees);
await this.UnitOfWork.SaveChangesAsync();

Expand Down
Loading

0 comments on commit 5cbcdc8

Please sign in to comment.