Skip to content

Commit bd79138

Browse files
authored
fix: Revert "push to 10.1.0" (#1015)
1 parent d856061 commit bd79138

3 files changed

Lines changed: 1 addition & 66 deletions

File tree

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<!-- Properties related to build/pack -->
44
<IsPackable>false</IsPackable>
5-
<Version>10.0.12</Version>
5+
<Version>10.1.0-pre02</Version>
66
<MapsterPluginsTFMs>netstandard2.0;net10.0;net9.0;net8.0</MapsterPluginsTFMs>
77
<MapsterTFMs>netstandard2.0;net10.0;net9.0;net8.0</MapsterTFMs>
88
<MapsterEFCoreTFMs>net10.0;net9.0;net8.0</MapsterEFCoreTFMs>

src/Mapster.Tests/WhenIgnoringConditionally.cs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -172,43 +172,6 @@ public void IgnoreIf_Apply_To_RecordType()
172172
dto.Name.ShouldBeNull();
173173
}
174174

175-
// Regression test for https://github.com/MapsterMapper/Mapster/issues/1007
176-
// Unlike SimpleRecord above (which maps every member through the primary
177-
// constructor), NativeRecord is a real C# `record` whose Name property is
178-
// NOT part of the primary constructor — it's a plain settable auto-property.
179-
// Members mapped that way go through RecordTypeAdapter.RecordInlineExpression,
180-
// a separate code path from constructor-argument mapping, which used to
181-
// ignore member.Ignore.Condition entirely.
182-
[TestMethod]
183-
public void IgnoreIf_Apply_To_RecordType_Property_Not_In_Constructor_Map()
184-
{
185-
TypeAdapterConfig<SimplePoco, NativeRecord>.NewConfig()
186-
.IgnoreIf((src, dest) => src.Name == "TestName", dest => dest.Name)
187-
.Compile();
188-
189-
var poco = new SimplePoco { Id = 1, Name = "TestName" };
190-
var dto = TypeAdapter.Adapt<SimplePoco, NativeRecord>(poco);
191-
192-
dto.Id.ShouldBe(1);
193-
dto.Name.ShouldBeNull();
194-
}
195-
196-
[TestMethod]
197-
public void IgnoreIf_Apply_To_RecordType_Property_Not_In_Constructor_MapToTarget()
198-
{
199-
TypeAdapterConfig<SimplePoco, NativeRecord>.NewConfig()
200-
.IgnoreIf((src, dest) => src.Name == "TestName", dest => dest.Name)
201-
.Compile();
202-
203-
var poco = new SimplePoco { Id = 1, Name = "TestName" };
204-
var dto = new NativeRecord { Id = 999, Name = "DtoName" };
205-
206-
var result = TypeAdapter.Adapt(poco, dto);
207-
208-
result.Id.ShouldBe(1);
209-
result.Name.ShouldBe("DtoName");
210-
}
211-
212175
#endregion
213176

214177

@@ -239,12 +202,6 @@ public SimpleRecord(int id, string name)
239202
}
240203
}
241204

242-
public record NativeRecord
243-
{
244-
public int Id { get; set; }
245-
public string Name { get; set; }
246-
}
247-
248205
#endregion
249206

250207
}

src/Mapster/Adapters/RecordTypeAdapter.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,6 @@ protected override Expression CreateInstantiationExpression(Expression source, E
103103
}
104104
}
105105

106-
// IgnoreIf(...) support — unlike ClassAdapter (which drops the whole
107-
// member statement into an `if (!condition) { ... }` block), record
108-
// members are bound inline inside a MemberInit, so the condition is
109-
// expressed as a ternary: keep the computed value when the condition
110-
// is false, otherwise fall back to whatever the member should be left
111-
// as (the existing destination value for MapToTarget, or the type's
112-
// default value when constructing a brand-new instance).
113-
if (arg.MapType != MapType.Projection && member.Ignore.Condition != null)
114-
{
115-
var conditionDestination = destination ?? arg.DestinationType.CreateDefault();
116-
var conditionBody = member.Ignore.IsChildPath
117-
? member.Ignore.Condition.Body
118-
: member.Ignore.Condition.Apply(arg.MapType, source, conditionDestination);
119-
var notIgnored = ExpressionEx.Not(conditionBody);
120-
121-
var fallback = arg.MapType == MapType.MapToTarget && destination != null
122-
? member.DestinationMember.GetExpression(destination)
123-
: member.DestinationMember.Type.CreateDefault();
124-
125-
adapt = Expression.Condition(notIgnored, adapt, fallback);
126-
}
127-
128106
//special null property check for projection
129107
//if we don't set null to property, EF will create empty object
130108
//except collection type & complex type which cannot be null

0 commit comments

Comments
 (0)