diff --git a/src/Mapster.Tests/WhenMappingWithOpenGenerics.cs b/src/Mapster.Tests/WhenMappingWithOpenGenerics.cs index 7abb5e1f..118f1c75 100644 --- a/src/Mapster.Tests/WhenMappingWithOpenGenerics.cs +++ b/src/Mapster.Tests/WhenMappingWithOpenGenerics.cs @@ -33,6 +33,23 @@ public void Setting_From_OpenGeneric_Has_No_SideEffect() var cCopy = c.Adapt(config); } + /// + /// https://github.com/MapsterMapper/Mapster/issues/925 + /// + [TestMethod] + public void Compile_With_Open_Generic_Mapping_Does_Not_Throw() + { + var config = new TypeAdapterConfig(); + config.ForType(typeof(ClassA<>), typeof(ClassB<>)); + + Should.NotThrow(() => config.Compile()); + + var classA = new ClassA { Variable = 15 }; + var classB = classA.Adapt>(config); + + classB.Variable.ShouldBe(15); + } + [TestMethod] public void MapOpenGenericsUseInherits() { @@ -102,5 +119,15 @@ class A { public string AProperty { get; set; } } class B { public string BProperty { get; set; } } class C { public string BProperty { get; set; } } + + class ClassA + { + public T? Variable { get; set; } + } + + class ClassB + { + public T? Variable { get; set; } + } } }