Skip to content

Commit a9fbd21

Browse files
committed
Fix warnings
1 parent 510de3f commit a9fbd21

File tree

4 files changed

+43
-19
lines changed

4 files changed

+43
-19
lines changed

Source/Boxed.Mapping/AsyncImmutableMapperExtensions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public static async Task<TDestination[]> MapArrayAsync<TSourceCollection, TSourc
140140
}
141141
#endif
142142

143+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
143144
#if NET6_0_OR_GREATER
144145
int count;
145146
if (sourceCount.HasValue)
@@ -148,7 +149,6 @@ public static async Task<TDestination[]> MapArrayAsync<TSourceCollection, TSourc
148149
}
149150
else if (!source.TryGetNonEnumeratedCount(out count))
150151
{
151-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
152152
count = source.Count();
153153
}
154154

@@ -374,10 +374,10 @@ public static async Task<TDestination[]> MapArrayAsync<TSource, TDestination>(
374374
}
375375
#endif
376376

377+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
377378
#if NET6_0_OR_GREATER
378379
if (!source.TryGetNonEnumeratedCount(out var count))
379380
{
380-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
381381
count = source.Count();
382382
}
383383

@@ -454,10 +454,10 @@ public static async Task<TDestinationCollection> MapCollectionAsync<TSourceColle
454454
}
455455
#endif
456456

457+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
457458
#if NET6_0_OR_GREATER
458459
if (!source.TryGetNonEnumeratedCount(out var count))
459460
{
460-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
461461
count = source.Count();
462462
}
463463

@@ -682,10 +682,10 @@ public static async Task<Collection<TDestination>> MapCollectionAsync<TSource, T
682682
}
683683
#endif
684684

685+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
685686
#if NET6_0_OR_GREATER
686687
if (!source.TryGetNonEnumeratedCount(out var count))
687688
{
688-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
689689
count = source.Count();
690690
}
691691

@@ -911,10 +911,10 @@ public static async Task<HashSet<TDestination>> MapHashSetAsync<TSource, TDestin
911911
}
912912
#endif
913913

914+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
914915
#if NET6_0_OR_GREATER
915916
if (!source.TryGetNonEnumeratedCount(out var count))
916917
{
917-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
918918
count = source.Count();
919919
}
920920

@@ -1298,10 +1298,10 @@ public static async Task<List<TDestination>> MapListAsync<TSource, TDestination>
12981298
}
12991299
#endif
13001300

1301+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
13011302
#if NET6_0_OR_GREATER
13021303
if (!source.TryGetNonEnumeratedCount(out var count))
13031304
{
1304-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
13051305
count = source.Count();
13061306
}
13071307

@@ -1528,10 +1528,10 @@ public static async Task<ObservableCollection<TDestination>> MapObservableCollec
15281528
}
15291529
#endif
15301530

1531+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
15311532
#if NET6_0_OR_GREATER
15321533
if (!source.TryGetNonEnumeratedCount(out var count))
15331534
{
1534-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
15351535
count = source.Count();
15361536
}
15371537

Source/Boxed.Mapping/AsyncMapperExtensions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public static async Task<TDestination[]> MapArrayAsync<TSourceCollection, TSourc
142142
}
143143
#endif
144144

145+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
145146
#if NET6_0_OR_GREATER
146147
int count;
147148
if (sourceCount.HasValue)
@@ -150,7 +151,6 @@ public static async Task<TDestination[]> MapArrayAsync<TSourceCollection, TSourc
150151
}
151152
else if (!source.TryGetNonEnumeratedCount(out count))
152153
{
153-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
154154
count = source.Count();
155155
}
156156

@@ -356,10 +356,10 @@ public static async Task<TDestination[]> MapArrayAsync<TSource, TDestination>(
356356
}
357357
#endif
358358

359+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
359360
#if NET6_0_OR_GREATER
360361
if (!source.TryGetNonEnumeratedCount(out var count))
361362
{
362-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
363363
count = source.Count();
364364
}
365365

@@ -431,10 +431,10 @@ public static async Task<TDestinationCollection> MapCollectionAsync<TSourceColle
431431
}
432432
#endif
433433

434+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
434435
#if NET6_0_OR_GREATER
435436
if (!source.TryGetNonEnumeratedCount(out var count))
436437
{
437-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
438438
count = source.Count();
439439
}
440440

@@ -639,10 +639,10 @@ public static async Task<Collection<TDestination>> MapCollectionAsync<TSource, T
639639
}
640640
#endif
641641

642+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
642643
#if NET6_0_OR_GREATER
643644
if (!source.TryGetNonEnumeratedCount(out var count))
644645
{
645-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
646646
count = source.Count();
647647
}
648648

@@ -844,10 +844,10 @@ public static async Task<HashSet<TDestination>> MapHashSetAsync<TSource, TDestin
844844
}
845845
#endif
846846

847+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
847848
#if NET6_0_OR_GREATER
848849
if (!source.TryGetNonEnumeratedCount(out var count))
849850
{
850-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
851851
count = source.Count();
852852
}
853853

@@ -1211,10 +1211,10 @@ public static async Task<List<TDestination>> MapListAsync<TSource, TDestination>
12111211
}
12121212
#endif
12131213

1214+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
12141215
#if NET6_0_OR_GREATER
12151216
if (!source.TryGetNonEnumeratedCount(out var count))
12161217
{
1217-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
12181218
count = source.Count();
12191219
}
12201220

@@ -1421,10 +1421,10 @@ public static async Task<ObservableCollection<TDestination>> MapObservableCollec
14211421
}
14221422
#endif
14231423

1424+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
14241425
#if NET6_0_OR_GREATER
14251426
if (!source.TryGetNonEnumeratedCount(out var count))
14261427
{
1427-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
14281428
count = source.Count();
14291429
}
14301430

Source/Boxed.Mapping/ImmutableMapperExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ public static TDestination[] MapArray<TSource, TDestination>(
297297
}
298298
#endif
299299

300+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
300301
#if NET6_0_OR_GREATER
301302
if (!source.TryGetNonEnumeratedCount(out var count))
302303
{
303-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
304304
count = source.Count();
305305
}
306306

@@ -884,9 +884,9 @@ public static List<TDestination> MapList<TSource, TDestination>(
884884
/// <c>null</c>.</exception>
885885
#pragma warning disable CA1002 // Do not expose generic lists
886886
public static List<TDestination> MapList<TSource, TDestination>(
887-
#pragma warning restore CA1002 // Do not expose generic lists
888887
this IImmutableMapper<TSource, TDestination> mapper,
889888
Collection<TSource> source)
889+
#pragma warning restore CA1002 // Do not expose generic lists
890890
{
891891
#if NET6_0_OR_GREATER
892892
ArgumentNullException.ThrowIfNull(mapper);
@@ -927,9 +927,9 @@ public static List<TDestination> MapList<TSource, TDestination>(
927927
/// <c>null</c>.</exception>
928928
#pragma warning disable CA1002 // Do not expose generic lists
929929
public static List<TDestination> MapList<TSource, TDestination>(
930-
#pragma warning restore CA1002 // Do not expose generic lists
931930
this IImmutableMapper<TSource, TDestination> mapper,
932931
TSource[] source)
932+
#pragma warning restore CA1002 // Do not expose generic lists
933933
{
934934
#if NET6_0_OR_GREATER
935935
ArgumentNullException.ThrowIfNull(mapper);
@@ -970,9 +970,9 @@ public static List<TDestination> MapList<TSource, TDestination>(
970970
/// <c>null</c>.</exception>
971971
#pragma warning disable CA1002 // Do not expose generic lists
972972
public static List<TDestination> MapList<TSource, TDestination>(
973-
#pragma warning restore CA1002 // Do not expose generic lists
974973
this IImmutableMapper<TSource, TDestination> mapper,
975974
IEnumerable<TSource> source)
975+
#pragma warning restore CA1002 // Do not expose generic lists
976976
{
977977
#if NET6_0_OR_GREATER
978978
ArgumentNullException.ThrowIfNull(mapper);
@@ -989,10 +989,10 @@ public static List<TDestination> MapList<TSource, TDestination>(
989989
}
990990
#endif
991991

992+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
992993
#if NET6_0_OR_GREATER
993994
if (!source.TryGetNonEnumeratedCount(out var count))
994995
{
995-
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
996996
count = source.Count();
997997
}
998998

Source/Boxed.Mapping/MapperExtensions.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ public static TDestination[] MapArray<TSourceCollection, TSource, TDestination>(
161161
/// <c>null</c>.</exception>
162162
public static TDestination[] MapArray<TSource, TDestination>(
163163
this IMapper<TSource, TDestination> mapper,
164+
#pragma warning disable CA1002 // Do not expose generic lists
164165
List<TSource> source)
166+
#pragma warning restore CA1002 // Do not expose generic lists
165167
where TDestination : new()
166168
{
167169
#if NET6_0_OR_GREATER
@@ -312,6 +314,7 @@ public static TDestination[] MapArray<TSource, TDestination>(
312314
}
313315
#endif
314316

317+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
315318
#if NET6_0_OR_GREATER
316319
if (!source.TryGetNonEnumeratedCount(out var count))
317320
{
@@ -324,6 +327,7 @@ public static TDestination[] MapArray<TSource, TDestination>(
324327
#endif
325328
var i = 0;
326329
foreach (var sourceItem in source)
330+
#pragma warning restore CA1851 // Possible multiple enumerations of 'IEnumerable' collection
327331
{
328332
var destinationItem = Factory<TDestination>.CreateInstance();
329333
mapper.Map(sourceItem, destinationItem);
@@ -396,7 +400,9 @@ public static TDestinationCollection MapCollection<TSourceCollection, TSource, T
396400
/// <c>null</c>.</exception>
397401
public static Collection<TDestination> MapCollection<TSource, TDestination>(
398402
this IMapper<TSource, TDestination> mapper,
403+
#pragma warning disable CA1002 // Do not expose generic lists
399404
List<TSource> source)
405+
#pragma warning restore CA1002 // Do not expose generic lists
400406
where TDestination : new()
401407
{
402408
#if NET6_0_OR_GREATER
@@ -566,7 +572,9 @@ public static Collection<TDestination> MapCollection<TSource, TDestination>(
566572
/// <c>null</c>.</exception>
567573
public static HashSet<TDestination> MapHashSet<TSource, TDestination>(
568574
this IMapper<TSource, TDestination> mapper,
575+
#pragma warning disable CA1002 // Do not expose generic lists
569576
List<TSource> source)
577+
#pragma warning restore CA1002 // Do not expose generic lists
570578
where TDestination : new()
571579
{
572580
#if NET6_0_OR_GREATER
@@ -732,7 +740,9 @@ public static HashSet<TDestination> MapHashSet<TSource, TDestination>(
732740
/// <c>null</c>.</exception>
733741
public static ImmutableArray<TDestination> MapImmutableArray<TSource, TDestination>(
734742
this IMapper<TSource, TDestination> mapper,
743+
#pragma warning disable CA1002 // Do not expose generic lists
735744
List<TSource> source)
745+
#pragma warning restore CA1002 // Do not expose generic lists
736746
where TDestination : new() =>
737747
ImmutableArray.Create(mapper.MapArray(source));
738748

@@ -800,7 +810,9 @@ public static ImmutableArray<TDestination> MapImmutableArray<TSource, TDestinati
800810
/// <c>null</c>.</exception>
801811
public static ImmutableList<TDestination> MapImmutableList<TSource, TDestination>(
802812
this IMapper<TSource, TDestination> mapper,
813+
#pragma warning disable CA1002 // Do not expose generic lists
803814
List<TSource> source)
815+
#pragma warning restore CA1002 // Do not expose generic lists
804816
where TDestination : new() =>
805817
ImmutableList.Create(mapper.MapArray(source));
806818

@@ -867,9 +879,11 @@ public static ImmutableList<TDestination> MapImmutableList<TSource, TDestination
867879
/// <returns>A list of <typeparamref name="TDestination"/>.</returns>
868880
/// <exception cref="ArgumentNullException">The <paramref name="mapper"/> or <paramref name="source"/> is
869881
/// <c>null</c>.</exception>
882+
#pragma warning disable CA1002 // Do not expose generic lists
870883
public static List<TDestination> MapList<TSource, TDestination>(
871884
this IMapper<TSource, TDestination> mapper,
872885
List<TSource> source)
886+
#pragma warning restore CA1002 // Do not expose generic lists
873887
where TDestination : new()
874888
{
875889
#if NET6_0_OR_GREATER
@@ -910,9 +924,11 @@ public static List<TDestination> MapList<TSource, TDestination>(
910924
/// <returns>A list of <typeparamref name="TDestination"/>.</returns>
911925
/// <exception cref="ArgumentNullException">The <paramref name="mapper"/> or <paramref name="source"/> is
912926
/// <c>null</c>.</exception>
927+
#pragma warning disable CA1002 // Do not expose generic lists
913928
public static List<TDestination> MapList<TSource, TDestination>(
914929
this IMapper<TSource, TDestination> mapper,
915930
Collection<TSource> source)
931+
#pragma warning restore CA1002 // Do not expose generic lists
916932
where TDestination : new()
917933
{
918934
#if NET6_0_OR_GREATER
@@ -953,9 +969,11 @@ public static List<TDestination> MapList<TSource, TDestination>(
953969
/// <returns>A list of <typeparamref name="TDestination"/>.</returns>
954970
/// <exception cref="ArgumentNullException">The <paramref name="mapper"/> or <paramref name="source"/> is
955971
/// <c>null</c>.</exception>
972+
#pragma warning disable CA1002 // Do not expose generic lists
956973
public static List<TDestination> MapList<TSource, TDestination>(
957974
this IMapper<TSource, TDestination> mapper,
958975
TSource[] source)
976+
#pragma warning restore CA1002 // Do not expose generic lists
959977
where TDestination : new()
960978
{
961979
#if NET6_0_OR_GREATER
@@ -996,9 +1014,11 @@ public static List<TDestination> MapList<TSource, TDestination>(
9961014
/// <returns>A list of <typeparamref name="TDestination"/>.</returns>
9971015
/// <exception cref="ArgumentNullException">The <paramref name="mapper"/> or <paramref name="source"/> is
9981016
/// <c>null</c>.</exception>
1017+
#pragma warning disable CA1002 // Do not expose generic lists
9991018
public static List<TDestination> MapList<TSource, TDestination>(
10001019
this IMapper<TSource, TDestination> mapper,
10011020
IEnumerable<TSource> source)
1021+
#pragma warning restore CA1002 // Do not expose generic lists
10021022
where TDestination : new()
10031023
{
10041024
#if NET6_0_OR_GREATER
@@ -1016,6 +1036,7 @@ public static List<TDestination> MapList<TSource, TDestination>(
10161036
}
10171037
#endif
10181038

1039+
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
10191040
#if NET6_0_OR_GREATER
10201041
if (!source.TryGetNonEnumeratedCount(out var count))
10211042
{
@@ -1027,6 +1048,7 @@ public static List<TDestination> MapList<TSource, TDestination>(
10271048
var destination = new List<TDestination>(source.Count());
10281049
#endif
10291050
foreach (var sourceItem in source)
1051+
#pragma warning restore CA1851 // Possible multiple enumerations of 'IEnumerable' collection
10301052
{
10311053
var destinationItem = Factory<TDestination>.CreateInstance();
10321054
mapper.Map(sourceItem, destinationItem);
@@ -1049,7 +1071,9 @@ public static List<TDestination> MapList<TSource, TDestination>(
10491071
/// <c>null</c>.</exception>
10501072
public static ObservableCollection<TDestination> MapObservableCollection<TSource, TDestination>(
10511073
this IMapper<TSource, TDestination> mapper,
1074+
#pragma warning disable CA1002 // Do not expose generic lists
10521075
List<TSource> source)
1076+
#pragma warning restore CA1002 // Do not expose generic lists
10531077
where TDestination : new()
10541078
{
10551079
#if NET6_0_OR_GREATER

0 commit comments

Comments
 (0)