Skip to content

Commit f678d12

Browse files
committed
refactoring and
del empty lines
1 parent 531f0ed commit f678d12

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

src/Mapster.Core/Utils/RecordTypeIdentityHelper.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using System.Reflection;
5-
using System.Text;
6-
using System.Threading.Tasks;
74

85
namespace Mapster.Utils
96
{
@@ -17,18 +14,18 @@ private static bool IsRecordСonstructor(Type type)
1714
{
1815
var ctors = type.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).ToList();
1916

17+
if (ctors.Count < 2)
18+
return false;
19+
2020
var isRecordTypeCtor = type.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)
2121
.Where(x => x.IsFamily == true || (type.IsSealed && x.IsPrivate == true)) // add target from Sealed record
2222
.Any(x => x.GetParameters()
2323
.Any(y => y.ParameterType == type));
2424

25-
26-
if (ctors.Count >= 2 && isRecordTypeCtor)
25+
if (isRecordTypeCtor)
2726
return true;
2827

29-
3028
return false;
31-
3229
}
3330

3431
private static bool IsIncludedRecordCloneMethod(Type type)
@@ -44,9 +41,7 @@ public static bool IsRecordType(Type type)
4441
if (IsRecordСonstructor(type) && IsIncludedRecordCloneMethod(type))
4542
return true;
4643

47-
4844
return false;
4945
}
50-
5146
}
5247
}

src/Mapster.Tests/WhenMappingRecordRegression.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ TestClassPublicCtr SomemapWithDynamic(object source)
221221
public void ImplicitOperatorCurrentWorkFromClass()
222222
{
223223
var guid = Guid.NewGuid();
224-
225224
var pocoWithGuid1 = new PocoWithGuid { Id = guid };
226225
var pocoWithId2 = new PocoWithId { Id = new Id(guid) };
227226

@@ -231,7 +230,6 @@ public void ImplicitOperatorCurrentWorkFromClass()
231230
pocoWithId1.Id.ToString().Equals(guid.ToString()).ShouldBeTrue();
232231
pocoWithGuid2.Id.Equals(guid).ShouldBeTrue();
233232

234-
235233
var _result = pocoWithId1.Adapt(pocoWithGuid2);
236234

237235
_result.Id.ToString().Equals(guid.ToString()).ShouldBeTrue(); // Guid value transmitted
@@ -240,8 +238,6 @@ public void ImplicitOperatorCurrentWorkFromClass()
240238

241239
}
242240

243-
#region NowNotWorking
244-
245241
[TestMethod]
246242
public void DetectFakeRecord()
247243
{
@@ -252,6 +248,8 @@ public void DetectFakeRecord()
252248
object.ReferenceEquals(_destination, _result).ShouldBeTrue();
253249
}
254250

251+
#region NowNotWorking
252+
255253
/// <summary>
256254
/// https://github.com/MapsterMapper/Mapster/issues/430
257255
/// </summary>
@@ -313,7 +311,6 @@ class PocoWithId
313311
class Id
314312
{
315313
private readonly Guid _guid;
316-
317314
public Id(Guid id) => _guid = id;
318315

319316
public static implicit operator Id(Guid value) => new(value);

0 commit comments

Comments
 (0)