@@ -161,7 +161,9 @@ public static TDestination[] MapArray<TSourceCollection, TSource, TDestination>(
161
161
/// <c>null</c>.</exception>
162
162
public static TDestination [ ] MapArray < TSource , TDestination > (
163
163
this IMapper < TSource , TDestination > mapper ,
164
+ #pragma warning disable CA1002 // Do not expose generic lists
164
165
List < TSource > source )
166
+ #pragma warning restore CA1002 // Do not expose generic lists
165
167
where TDestination : new ( )
166
168
{
167
169
#if NET6_0_OR_GREATER
@@ -312,6 +314,7 @@ public static TDestination[] MapArray<TSource, TDestination>(
312
314
}
313
315
#endif
314
316
317
+ #pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
315
318
#if NET6_0_OR_GREATER
316
319
if ( ! source . TryGetNonEnumeratedCount ( out var count ) )
317
320
{
@@ -324,6 +327,7 @@ public static TDestination[] MapArray<TSource, TDestination>(
324
327
#endif
325
328
var i = 0 ;
326
329
foreach ( var sourceItem in source )
330
+ #pragma warning restore CA1851 // Possible multiple enumerations of 'IEnumerable' collection
327
331
{
328
332
var destinationItem = Factory < TDestination > . CreateInstance ( ) ;
329
333
mapper . Map ( sourceItem , destinationItem ) ;
@@ -396,7 +400,9 @@ public static TDestinationCollection MapCollection<TSourceCollection, TSource, T
396
400
/// <c>null</c>.</exception>
397
401
public static Collection < TDestination > MapCollection < TSource , TDestination > (
398
402
this IMapper < TSource , TDestination > mapper ,
403
+ #pragma warning disable CA1002 // Do not expose generic lists
399
404
List < TSource > source )
405
+ #pragma warning restore CA1002 // Do not expose generic lists
400
406
where TDestination : new ( )
401
407
{
402
408
#if NET6_0_OR_GREATER
@@ -566,7 +572,9 @@ public static Collection<TDestination> MapCollection<TSource, TDestination>(
566
572
/// <c>null</c>.</exception>
567
573
public static HashSet < TDestination > MapHashSet < TSource , TDestination > (
568
574
this IMapper < TSource , TDestination > mapper ,
575
+ #pragma warning disable CA1002 // Do not expose generic lists
569
576
List < TSource > source )
577
+ #pragma warning restore CA1002 // Do not expose generic lists
570
578
where TDestination : new ( )
571
579
{
572
580
#if NET6_0_OR_GREATER
@@ -732,7 +740,9 @@ public static HashSet<TDestination> MapHashSet<TSource, TDestination>(
732
740
/// <c>null</c>.</exception>
733
741
public static ImmutableArray < TDestination > MapImmutableArray < TSource , TDestination > (
734
742
this IMapper < TSource , TDestination > mapper ,
743
+ #pragma warning disable CA1002 // Do not expose generic lists
735
744
List < TSource > source )
745
+ #pragma warning restore CA1002 // Do not expose generic lists
736
746
where TDestination : new ( ) =>
737
747
ImmutableArray . Create ( mapper . MapArray ( source ) ) ;
738
748
@@ -800,7 +810,9 @@ public static ImmutableArray<TDestination> MapImmutableArray<TSource, TDestinati
800
810
/// <c>null</c>.</exception>
801
811
public static ImmutableList < TDestination > MapImmutableList < TSource , TDestination > (
802
812
this IMapper < TSource , TDestination > mapper ,
813
+ #pragma warning disable CA1002 // Do not expose generic lists
803
814
List < TSource > source )
815
+ #pragma warning restore CA1002 // Do not expose generic lists
804
816
where TDestination : new ( ) =>
805
817
ImmutableList . Create ( mapper . MapArray ( source ) ) ;
806
818
@@ -867,9 +879,11 @@ public static ImmutableList<TDestination> MapImmutableList<TSource, TDestination
867
879
/// <returns>A list of <typeparamref name="TDestination"/>.</returns>
868
880
/// <exception cref="ArgumentNullException">The <paramref name="mapper"/> or <paramref name="source"/> is
869
881
/// <c>null</c>.</exception>
882
+ #pragma warning disable CA1002 // Do not expose generic lists
870
883
public static List < TDestination > MapList < TSource , TDestination > (
871
884
this IMapper < TSource , TDestination > mapper ,
872
885
List < TSource > source )
886
+ #pragma warning restore CA1002 // Do not expose generic lists
873
887
where TDestination : new ( )
874
888
{
875
889
#if NET6_0_OR_GREATER
@@ -910,9 +924,11 @@ public static List<TDestination> MapList<TSource, TDestination>(
910
924
/// <returns>A list of <typeparamref name="TDestination"/>.</returns>
911
925
/// <exception cref="ArgumentNullException">The <paramref name="mapper"/> or <paramref name="source"/> is
912
926
/// <c>null</c>.</exception>
927
+ #pragma warning disable CA1002 // Do not expose generic lists
913
928
public static List < TDestination > MapList < TSource , TDestination > (
914
929
this IMapper < TSource , TDestination > mapper ,
915
930
Collection < TSource > source )
931
+ #pragma warning restore CA1002 // Do not expose generic lists
916
932
where TDestination : new ( )
917
933
{
918
934
#if NET6_0_OR_GREATER
@@ -953,9 +969,11 @@ public static List<TDestination> MapList<TSource, TDestination>(
953
969
/// <returns>A list of <typeparamref name="TDestination"/>.</returns>
954
970
/// <exception cref="ArgumentNullException">The <paramref name="mapper"/> or <paramref name="source"/> is
955
971
/// <c>null</c>.</exception>
972
+ #pragma warning disable CA1002 // Do not expose generic lists
956
973
public static List < TDestination > MapList < TSource , TDestination > (
957
974
this IMapper < TSource , TDestination > mapper ,
958
975
TSource [ ] source )
976
+ #pragma warning restore CA1002 // Do not expose generic lists
959
977
where TDestination : new ( )
960
978
{
961
979
#if NET6_0_OR_GREATER
@@ -996,9 +1014,11 @@ public static List<TDestination> MapList<TSource, TDestination>(
996
1014
/// <returns>A list of <typeparamref name="TDestination"/>.</returns>
997
1015
/// <exception cref="ArgumentNullException">The <paramref name="mapper"/> or <paramref name="source"/> is
998
1016
/// <c>null</c>.</exception>
1017
+ #pragma warning disable CA1002 // Do not expose generic lists
999
1018
public static List < TDestination > MapList < TSource , TDestination > (
1000
1019
this IMapper < TSource , TDestination > mapper ,
1001
1020
IEnumerable < TSource > source )
1021
+ #pragma warning restore CA1002 // Do not expose generic lists
1002
1022
where TDestination : new ( )
1003
1023
{
1004
1024
#if NET6_0_OR_GREATER
@@ -1016,6 +1036,7 @@ public static List<TDestination> MapList<TSource, TDestination>(
1016
1036
}
1017
1037
#endif
1018
1038
1039
+ #pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
1019
1040
#if NET6_0_OR_GREATER
1020
1041
if ( ! source . TryGetNonEnumeratedCount ( out var count ) )
1021
1042
{
@@ -1027,6 +1048,7 @@ public static List<TDestination> MapList<TSource, TDestination>(
1027
1048
var destination = new List < TDestination > ( source . Count ( ) ) ;
1028
1049
#endif
1029
1050
foreach ( var sourceItem in source )
1051
+ #pragma warning restore CA1851 // Possible multiple enumerations of 'IEnumerable' collection
1030
1052
{
1031
1053
var destinationItem = Factory < TDestination > . CreateInstance ( ) ;
1032
1054
mapper . Map ( sourceItem , destinationItem ) ;
@@ -1049,7 +1071,9 @@ public static List<TDestination> MapList<TSource, TDestination>(
1049
1071
/// <c>null</c>.</exception>
1050
1072
public static ObservableCollection < TDestination > MapObservableCollection < TSource , TDestination > (
1051
1073
this IMapper < TSource , TDestination > mapper ,
1074
+ #pragma warning disable CA1002 // Do not expose generic lists
1052
1075
List < TSource > source )
1076
+ #pragma warning restore CA1002 // Do not expose generic lists
1053
1077
where TDestination : new ( )
1054
1078
{
1055
1079
#if NET6_0_OR_GREATER
0 commit comments