@@ -14,6 +14,7 @@ public interface IRuntimeFeature
1414}
1515public class Features < TFeature >
1616{
17+ static List < TFeature > . Enumerator ? Empty ;
1718 private List < TFeature > _features ;
1819 public int Count => _features ? . Count ?? 0 ;
1920 /// <summary>
@@ -49,7 +50,7 @@ private int IndexOf(Type featureType)
4950 for ( ; index < Count && _features [ index ] . GetType ( ) != featureType ; index ++ ) ;
5051 return index ;
5152 }
52- public List < TFeature > . Enumerator GetEnumerator ( ) => _features . GetEnumerator ( ) ;
53+ public List < TFeature > . Enumerator GetEnumerator ( ) => _features ? . GetEnumerator ( ) ?? ( Empty ??= new List < TFeature > ( ) . GetEnumerator ( ) ) ;
5354}
5455public static class FeatureExtensions
5556{
@@ -65,21 +66,13 @@ public static IMappingExpression<TSource, TDestination> SetFeature<TSource, TDes
6566 }
6667 internal static void Configure ( this Features < IGlobalFeature > features , MapperConfiguration mapperConfiguration )
6768 {
68- if ( features . Count == 0 )
69- {
70- return ;
71- }
7269 foreach ( var feature in features )
7370 {
7471 feature . Configure ( mapperConfiguration ) ;
7572 }
7673 }
7774 public static void ReverseTo ( this Features < IMappingFeature > features , Features < IMappingFeature > reversedFeatures )
7875 {
79- if ( features . Count == 0 )
80- {
81- return ;
82- }
8376 foreach ( var feature in features )
8477 {
8578 var reverse = feature . Reverse ( ) ;
@@ -91,21 +84,13 @@ public static void ReverseTo(this Features<IMappingFeature> features, Features<I
9184 }
9285 internal static void Configure ( this Features < IMappingFeature > features , TypeMap typeMap )
9386 {
94- if ( features . Count == 0 )
95- {
96- return ;
97- }
9887 foreach ( var feature in features )
9988 {
10089 feature . Configure ( typeMap ) ;
10190 }
10291 }
10392 internal static void Seal ( this Features < IRuntimeFeature > features , IGlobalConfiguration configuration )
10493 {
105- if ( features . Count == 0 )
106- {
107- return ;
108- }
10994 foreach ( var feature in features )
11095 {
11196 feature . Seal ( configuration ) ;
0 commit comments