Skip to content

Commit

Permalink
Updated packages. (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored Jun 7, 2022
1 parent d3e7bf1 commit a05be15
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 21 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ protected override IEnumerable<object> GetEqualityComponents()
}
```

### ```PrimitiveValueObject<TValueObject, TValue```

A specialized **Value Object** that only holds a single primitive, string or enum value.

### Collections

There are implementations of ```IList<T>```, ```ISet<T>``` and ```IDictionary<TKey, TValue>``` that determine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PackageReference Include="GitVersion.MsBuild" Version="5.10.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void UsePrimitiveValueObject(this ModelBuilder modelBuilder)
foreach(PropertyInfo property in properties)
{
Type enumerationType = property.PropertyType;
Type valueType = enumerationType.GetValueType();
Type valueType = enumerationType.GetPrimitiveValueObjectValueType();

Type converterTypeTemplate = typeof(PrimitiveValueObjectConverter<,>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PackageReference Include="GitVersion.MsBuild" Version="5.10.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected override JsonConverter ResolveContractConverter(Type objectType)
{
if(objectType.IsPrimitiveValueObject())
{
Type valueType = objectType.GetValueType();
Type valueType = objectType.GetPrimitiveValueObjectValueType();
Type converterTypeTemplate = typeof(PrimitiveValueObjectConverter<,>);
Type converterType = converterTypeTemplate.MakeGenericType(objectType, valueType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PackageReference Include="GitVersion.MsBuild" Version="5.10.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PackageReference Include="GitVersion.MsBuild" Version="5.10.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2022.1.0" />
<PackageReference Include="MongoDB.Driver" Version="2.15.1" />
<PackageReference Include="MongoDB.Driver" Version="2.16.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void Apply(BsonMemberMap memberMap)

if(memberType.IsPrimitiveValueObject())
{
Type valueType = memberType.GetValueType();
Type valueType = memberType.GetPrimitiveValueObjectValueType();
Type serializerTypeTemplate = typeof(PrimitiveValueObjectSerializer<,>);
Type serializerType = serializerTypeTemplate.MakeGenericType(memberType, valueType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override bool CanConvert(Type typeToConvert)
/// <inheritdoc />
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
Type valueType = typeToConvert.GetValueType();
Type valueType = typeToConvert.GetPrimitiveValueObjectValueType();
Type converterTypeTemplate = typeof(PrimitiveValueObjectConverter<,>);
Type converterType = converterTypeTemplate.MakeGenericType(typeToConvert, valueType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PackageReference Include="GitVersion.MsBuild" Version="5.10.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
5 changes: 4 additions & 1 deletion src/Fluxera.ValueObject/Collections/ValueSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ public bool Add(T item)
/// <inheritdoc />
void ICollection<T>.Add(T item)
{
this.Add(item!);
if(item != null)
{
this.Add(item);
}
}

/// <inheritdoc />
Expand Down
6 changes: 3 additions & 3 deletions src/Fluxera.ValueObject/Fluxera.ValueObject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fluxera.Guards" Version="6.0.22" />
<PackageReference Include="Fluxera.Utilities" Version="6.0.16" />
<PackageReference Include="GitVersion.MsBuild" Version="5.10.1">
<PackageReference Include="Fluxera.Guards" Version="6.1.0" />
<PackageReference Include="Fluxera.Utilities" Version="6.1.0" />
<PackageReference Include="GitVersion.MsBuild" Version="5.10.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
3 changes: 2 additions & 1 deletion src/Fluxera.ValueObject/PrimitiveValueObjectConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static TypeConverter CreateActualConverter(Type primitiveValueObjectType
throw new InvalidOperationException($"The type '{primitiveValueObjectType}' is not a primitive value-object.");
}

Type valueType = primitiveValueObjectType.GetValueType();
Type valueType = primitiveValueObjectType.GetPrimitiveValueObjectValueType();
Type actualConverterType = typeof(PrimitiveValueObjectConverter<,>).MakeGenericType(primitiveValueObjectType, valueType);
return (TypeConverter)Activator.CreateInstance(actualConverterType);
}
Expand All @@ -54,6 +54,7 @@ internal sealed class PrimitiveValueObjectConverter<TValueObject, TValue> : Type
where TValueObject : PrimitiveValueObject<TValueObject, TValue>
where TValue : IComparable
{
// ReSharper disable once StaticMemberInGenericType
private static TypeConverter ValueConverter { get; } = GetIdValueConverter();

private static TypeConverter GetIdValueConverter()
Expand Down
4 changes: 2 additions & 2 deletions src/Fluxera.ValueObject/PrimitiveValueObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static bool IsPrimitiveValueObject(this Type type)
/// </summary>
/// <param name="type"></param>
/// <returns>The type of the value.</returns>
public static Type GetValueType(this Type type)
public static Type GetPrimitiveValueObjectValueType(this Type type)
{
do
{
Expand All @@ -54,7 +54,7 @@ public static Type GetValueType(this Type type)
}
while(type is not null);

return null!;
return null;
}
}
}
2 changes: 1 addition & 1 deletion src/Fluxera.ValueObject/PropertyAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal sealed class PropertyAccessor
{
private static readonly ConcurrentDictionary<Type, PropertyAccessor[]> PropertyAccessorsMap = new ConcurrentDictionary<Type, PropertyAccessor[]>();

private static readonly MethodInfo CallInnerDelegateMethod = typeof(PropertyAccessor).GetMethod(nameof(CallInnerDelegate), BindingFlags.NonPublic | BindingFlags.Static)!;
private static readonly MethodInfo CallInnerDelegateMethod = typeof(PropertyAccessor).GetMethod(nameof(CallInnerDelegate), BindingFlags.NonPublic | BindingFlags.Static);

private PropertyAccessor(string propertyName, Func<object, object> getterFunc)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fluxera.ValueObject/ValueObjectEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public bool Equals(TValueObject firstObject, TValueObject secondObject)
return false;
}

return firstObject!.Equals(secondObject);
return firstObject.Equals(secondObject);
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="Bogus" Version="34.0.2" />
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Fluxera.Guards" Version="6.0.22" />
<PackageReference Include="Fluxera.Guards" Version="6.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
Expand Down

0 comments on commit a05be15

Please sign in to comment.