-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #68 - Mapster modifies underlying collection which is being itera…
…ted over, when TypeAdapterConfig.GlobalSettings.Compile() is called
- Loading branch information
Showing
6 changed files
with
67 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace Mapster.Tests | ||
{ | ||
[TestFixture] | ||
public class WhenCompilingConfig | ||
{ | ||
[TearDown] | ||
public void TearDown() | ||
{ | ||
TypeAdapterConfig.GlobalSettings.Clear(); | ||
} | ||
|
||
[Test] | ||
public void Compile_Success_When_Contain_Collection() | ||
{ | ||
TypeAdapterConfig<SrcItem, DestItem>.ForType(); | ||
|
||
//Validate globally | ||
TypeAdapterConfig<MainSrc, MainDest>.ForType() | ||
.Map(d => d.DestItems, s => s.SrcItems); | ||
|
||
TypeAdapterConfig.GlobalSettings.Compile(); | ||
} | ||
|
||
class MainSrc | ||
{ | ||
public int SrcId { get; set; } | ||
public List<SrcItem> SrcItems { get; set; } | ||
} | ||
class MainDest | ||
{ | ||
public int DestId { get; set; } | ||
public List<DestItem> DestItems { get; set; } | ||
} | ||
class SrcItem | ||
{ | ||
public int ItemId { get; set; } | ||
public string StringData { get; set; } | ||
} | ||
class DestItem | ||
{ | ||
public int ItemId { get; set; } | ||
public string StringData { get; set; } | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"projects": [ ], | ||
"sdk": { | ||
"version": "1.0.0-preview1-002702" | ||
"version": "1.0.0-preview2-003121" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters