Skip to content

Commit

Permalink
Releases/1.7.1 (#202)
Browse files Browse the repository at this point in the history
* Bugs/200 (#201)

* Updating documentation example

* Adding failing test, re: #200

* Support for mapping between Dictionaries of Lists

* Extending test coverage

* Updating NuGet packages

* Updating release notes + version number

* Updating package description / Adding v1.7.1 NuGet package
  • Loading branch information
SteveWilkes committed Aug 9, 2020
1 parent c87deb7 commit 9034fb3
Show file tree
Hide file tree
Showing 26 changed files with 115 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<Reference Include="AgileObjects.NetStandardPolyfills, Version=1.4.1.0, Culture=neutral, PublicKeyToken=06131ac1c008ad4e, processorArchitecture=MSIL">
<HintPath>..\packages\AgileObjects.NetStandardPolyfills.1.4.1\lib\net40\AgileObjects.NetStandardPolyfills.dll</HintPath>
</Reference>
<Reference Include="AgileObjects.ReadableExpressions, Version=2.5.0.0, Culture=neutral, PublicKeyToken=9f54ad81db69da8e, processorArchitecture=MSIL">
<HintPath>..\packages\AgileObjects.ReadableExpressions.2.5.0\lib\net40\AgileObjects.ReadableExpressions.dll</HintPath>
<Reference Include="AgileObjects.ReadableExpressions, Version=2.5.1.0, Culture=neutral, PublicKeyToken=9f54ad81db69da8e, processorArchitecture=MSIL">
<HintPath>..\packages\AgileObjects.ReadableExpressions.2.5.1\lib\net40\AgileObjects.ReadableExpressions.dll</HintPath>
</Reference>
<Reference Include="AutoMapper, Version=7.0.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.7.0.1\lib\net45\AutoMapper.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion AgileMapper.PerformanceTester.Net461/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AgileObjects.NetStandardPolyfills" version="1.4.1" targetFramework="net461" />
<package id="AgileObjects.ReadableExpressions" version="2.5.0" targetFramework="net461" />
<package id="AgileObjects.ReadableExpressions" version="2.5.1" targetFramework="net461" />
<package id="AutoMapper" version="7.0.1" targetFramework="net452" />
<package id="Expressmapper" version="1.9.1" targetFramework="net452" requireReinstallation="true" />
<package id="Mapster" version="3.3.1" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageReference Include="DynamicLanguageRuntime" Version="1.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PackageReference Include="NUnit3TestAdapter" Version="3.7.0">
<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 @@ -36,7 +36,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Reference Include="System" />
<PackageReference Include="EntityFramework" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="Effort" Version="2.2.10" />
<PackageReference Include="EntityFramework" Version="5.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Reference Include="System" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="Effort.EF6" Version="2.2.10" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.6" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion AgileMapper.UnitTests/AgileMapper.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public void ShouldNotCreateDictionaryAsFallbackComplexType()
[Fact]
public void ShouldFlattenAComplexTypeCollectionToANestedObjectDictionaryImplementation()
{
var source = new PublicField<ICollection<Customer>>()
var source = new PublicField<ICollection<Customer>>
{
Value = new[]
{
Expand Down Expand Up @@ -339,6 +339,64 @@ public void ShouldFlattenAComplexTypeCollectionToANestedObjectDictionaryImplemen

}

// See https://github.com/agileobjects/AgileMapper/issues/200
[Fact]
public void ShouldMapListDictionaries()
{
var source = new PublicField<Dictionary<string, List<string>>>
{
Value = new Dictionary<string, List<string>>
{
["a"] = new List<string> { "b" }
}
};

var result = Mapper.Map(source)
.ToANew<PublicProperty<Dictionary<string, List<string>>>>();

var resultDictionary = result
.ShouldNotBeNull()
.Value
.ShouldNotBeNull();

resultDictionary.ShouldHaveSingleItem();
resultDictionary["a"].ShouldHaveSingleItem().ShouldBe("b");
}

[Fact]
public void ShouldMapArrayDictionaries()
{
var source = new PublicField<Dictionary<string, int[]>>
{
Value = new Dictionary<string, int[]>
{
["1"] = new[] { 1 },
["2"] = new[] { 1, 2 },
["3"] = new[] { 1, 2, 3 },
}
};

var result = Mapper.Map(source)
.ToANew<PublicProperty<Dictionary<string, long[]>>>();

var resultDictionary = result
.ShouldNotBeNull()
.Value
.ShouldNotBeNull();

resultDictionary.Count.ShouldBe(3); ;
resultDictionary["1"].ShouldHaveSingleItem().ShouldBe(1L);

resultDictionary["2"].Length.ShouldBe(2);
resultDictionary["2"][0].ShouldBe(1L);
resultDictionary["2"][1].ShouldBe(2L);

resultDictionary["3"].Length.ShouldBe(3);
resultDictionary["3"][0].ShouldBe(1L);
resultDictionary["3"][1].ShouldBe(2L);
resultDictionary["3"][2].ShouldBe(3L);
}

#region Helper Members

private static class Issue97
Expand Down
17 changes: 4 additions & 13 deletions AgileMapper/AgileMapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,15 @@

<PackageId>AgileObjects.AgileMapper</PackageId>
<Title>AgileMapper</Title>
<Description>A zero-configuration, highly-configurable object-object mapper with viewable execution plans. Projects queries, transforms, deep clones, updates and merges via extension methods, or a static or instance API. Targets .NET Standard 1.0+ and .NET 3.5+</Description>
<Description>A zero-configuration, highly-configurable, unopinionated object mapper with viewable execution plans. Flattens, unflattens, deep clones, merges, updates and projects queries. Targets .NET 3.5+ and .NET Standard 1.0+</Description>
<PackageTags>Mapper, Mapping, Mappings, ViewModel, DTO, NetStandard</PackageTags>
<PackageProjectUrl>https://github.com/AgileObjects/AgileMapper</PackageProjectUrl>
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.0' ">1.6.1</NetStandardImplicitPackageVersion>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.0' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>./Icon.png</PackageIcon>
<PackageReleaseNotes>- Support for configuring complete sub-mappings, re: #176
- Support for configuring sequential data sources, re: #184
- Support for configuring alternate data sources, re: #133, #173
- Including ToTarget data sources in mapping plan validation, re: #184
- Fixing enumerable target ToTarget data sources, re: #173
- Fixing caching of custom method struct creation factory
- Erroring if configured data sources conflict with ignored source members
- Improving configuration error messages
- Surfacing mapping plan Expressions
- Updating to ReadableExpressions v2.5
- Performance improvements
<PackageReleaseNotes>- Fixing Dictionary-of-collections mapping, re: #200
- Updating to ReadableExpressions v2.5.1
</PackageReleaseNotes>
</PropertyGroup>

Expand All @@ -44,7 +35,7 @@

<ItemGroup>
<PackageReference Include="AgileObjects.NetStandardPolyfills" Version="1.4.1" />
<PackageReference Include="AgileObjects.ReadableExpressions" Version="2.5.0" />
<PackageReference Include="AgileObjects.ReadableExpressions" Version="2.5.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
Expand Down
3 changes: 2 additions & 1 deletion AgileMapper/Caching/ArrayCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
_keys[_length] = key;
}

_values[_length++] = value;
_values[_length] = value;
_length++;
}

return value;
Expand Down
33 changes: 20 additions & 13 deletions AgileMapper/Members/Dictionaries/DictionaryEntrySourceMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ internal class DictionaryEntrySourceMember : IQualifiedMember
matchedTargetMember,
parent)
{
var entryMember = Member.RootSource(entryType);
_childMembers = new[] { entryMember };

IsEnumerable = entryMember.IsEnumerable;
IsSimple = !IsEnumerable && entryMember.IsSimple;
}

private DictionaryEntrySourceMember(DictionaryEntrySourceMember parent, Member childMember)
Expand All @@ -42,26 +47,28 @@ private DictionaryEntrySourceMember(DictionaryEntrySourceMember parent, Member c
Func<string> pathFactory,
QualifiedMember matchedTargetMember,
DictionarySourceMember parent,
Member[] childMembers = null)
Member[] childMembers)
: this(type, pathFactory, matchedTargetMember, parent)
{
Type = type;
_pathFactory = pathFactory;
_matchedTargetMember = matchedTargetMember;
Parent = parent;
_childMembers = childMembers ?? new[] { Member.RootSource(type) };

if (childMembers == null)
{
IsEnumerable = _childMembers.First().IsEnumerable;
IsSimple = !IsEnumerable && _childMembers.First().IsSimple;
return;
}
_childMembers = childMembers;

var leafMember = childMembers.Last();
IsEnumerable = leafMember.IsEnumerable;
IsSimple = leafMember.IsSimple;
}

private DictionaryEntrySourceMember(
Type type,
Func<string> pathFactory,
QualifiedMember matchedTargetMember,
DictionarySourceMember parent)
{
Type = type;
_pathFactory = pathFactory;
_matchedTargetMember = matchedTargetMember;
Parent = parent;
}

public DictionarySourceMember Parent { get; }

public bool IsRoot => false;
Expand Down
7 changes: 5 additions & 2 deletions AgileMapper/Members/Dictionaries/DictionarySourceMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal class DictionarySourceMember : IQualifiedMember
{
private readonly IQualifiedMember _wrappedSourceMember;
private readonly QualifiedMember _matchedTargetMember;
private IQualifiedMember _elementMember;

public DictionarySourceMember(IQualifiedMemberContext context)
: this(context.SourceMember, context.TargetMember)
Expand Down Expand Up @@ -94,8 +95,10 @@ public DictionarySourceMember(IQualifiedMember wrappedSourceMember, QualifiedMem

public IQualifiedMember GetElementMember()
{
return EntryMember.IsEnumerable
? EntryMember.GetElementMember()
return _elementMember ??= EntryMember.IsEnumerable
? IsEntireDictionaryMatch
? EntryMember
: EntryMember.GetElementMember()
: EntryMember.GetInstanceElementMember();
}

Expand Down
2 changes: 1 addition & 1 deletion AgileMapper/Members/Sources/ElementMembersSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public IQualifiedMember GetSourceMember()
=> GetTargetMember();

public QualifiedMember GetTargetMember()
=> _targetMember ?? (_targetMember = _enumerableMapperData.TargetMember.GetElementMember());
=> _targetMember ??= _enumerableMapperData.TargetMember.GetElementMember();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Linq.Expressions;
#endif
using DataSources;
using AgileObjects.AgileMapper.Extensions.Internal;
using Extensions.Internal;
using TypeConversion;
using Members;

Expand Down
6 changes: 3 additions & 3 deletions AgileMapper/ObjectPopulation/MappingExpressionFactoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ private void AddPopulationsAndCallbacks(MappingCreationContext context)
{
AddPopulationsAndCallbacks(this, context, (factory, ctx) =>
{
factory.AddObjectPopulation(context);
factory.AddObjectPopulation(ctx);
context.MappingExpressions.AddRange(
GetConfiguredToTargetDataSourceMappings(context, sequential: true));
ctx.MappingExpressions.AddRange(
GetConfiguredToTargetDataSourceMappings(ctx, sequential: true));
});
}

Expand Down
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/AgileObjects/AgileMapper</RepositoryUrl>
<Version>1.7.0</Version>
<AssemblyVersion>1.7.0.0</AssemblyVersion>
<FileVersion>1.7.0.0</FileVersion>
<Version>1.7.1</Version>
<AssemblyVersion>1.7.1.0</AssemblyVersion>
<FileVersion>1.7.1.0</FileVersion>
</PropertyGroup>

</Project>
Binary file added NuGet/AgileObjects.AgileMapper.1.7.1.nupkg
Binary file not shown.

0 comments on commit 9034fb3

Please sign in to comment.