@@ -539,6 +539,40 @@ public void NotSelfCreationTypeMappingToSelfWithOutError()
539539 resultJ . RootElement . GetProperty ( "key" ) . ToString ( ) . ShouldBe ( "value" ) ;
540540 }
541541
542+ /// <summary>
543+ /// https://github.com/MapsterMapper/Mapster/issues/927
544+ /// </summary>
545+ [ TestMethod ]
546+ public void MappingToReadOnlyInterfaceUsingIgnoreNulValuesWithoutError ( )
547+ {
548+ var config = new TypeAdapterConfig ( ) ;
549+ config
550+ . NewConfig < IDto927 , IDomain934 > ( )
551+ . IgnoreNullValues ( true ) ;
552+
553+ Should . NotThrow ( ( ) => {
554+
555+ config . Compile ( ) ;
556+ } ) ;
557+ }
558+
559+ /// <summary>
560+ /// https://github.com/MapsterMapper/Mapster/issues/927
561+ /// </summary>
562+ [ TestMethod ]
563+ public void MappingToReadOnlyRecordUsingIgnoreNulValuesWithoutError ( )
564+ {
565+ var config = new TypeAdapterConfig ( ) ;
566+ config
567+ . NewConfig < IDto927 , Domain927 > ( )
568+ . IgnoreNullValues ( true ) ;
569+
570+ Should . NotThrow ( ( ) => {
571+
572+ config . Compile ( ) ;
573+ } ) ;
574+ }
575+
542576 #region NowNotWorking
543577
544578 /// <summary>
@@ -993,5 +1027,26 @@ class InsiderWithCtorDestYx
9931027 public AutoCtorDestYx X { set ; get ; }
9941028 }
9951029
1030+ public interface IDto927
1031+ {
1032+ string Id { get ; set ; }
1033+ string Value { get ; set ; }
1034+ IList < string > ValueList { get ; set ; }
1035+ }
1036+
1037+ public interface IDomain934
1038+ {
1039+ string Id { get ; }
1040+ string Value { get ; }
1041+ IList < string > ValueList { get ; }
1042+ }
1043+
1044+ public record Domain927
1045+ {
1046+ string Id { get ; }
1047+ string Value { get ; }
1048+ IList < string > ValueList { get ; }
1049+ }
1050+
9961051 #endregion TestClasses
9971052}
0 commit comments