From 3c41c84991d68693cb34f349c33a6868e0987853 Mon Sep 17 00:00:00 2001 From: Tim M <49349513+TimothyMakkison@users.noreply.github.com> Date: Tue, 9 May 2023 08:03:45 +0100 Subject: [PATCH] fix: prevent throw throw being generated. (#415) --- .../Descriptors/Mappings/UserDefinedNewInstanceMethodMapping.cs | 2 +- ...ctionaryWithPrivateCtorShouldDiagnostic#Mapper.g.verified.cs | 2 +- ...ClassToClassPrivateCtorShouldDiagnostic#Mapper.g.verified.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Riok.Mapperly/Descriptors/Mappings/UserDefinedNewInstanceMethodMapping.cs b/src/Riok.Mapperly/Descriptors/Mappings/UserDefinedNewInstanceMethodMapping.cs index 018b28c035..882c6675db 100644 --- a/src/Riok.Mapperly/Descriptors/Mappings/UserDefinedNewInstanceMethodMapping.cs +++ b/src/Riok.Mapperly/Descriptors/Mappings/UserDefinedNewInstanceMethodMapping.cs @@ -46,7 +46,7 @@ public override IEnumerable BuildBody(TypeMappingBuildContext c { if (_delegateMapping == null) { - return new[] { ThrowStatement(ThrowNotImplementedException()).WithLeadingTrivia(TriviaList(Comment(NoMappingComment))), }; + return new[] { ExpressionStatement(ThrowNotImplementedException()).WithLeadingTrivia(TriviaList(Comment(NoMappingComment))), }; } // if reference handling is enabled and no reference handler parameter is declared diff --git a/test/Riok.Mapperly.Tests/_snapshots/DictionaryTest.DictionaryToCustomDictionaryWithPrivateCtorShouldDiagnostic#Mapper.g.verified.cs b/test/Riok.Mapperly.Tests/_snapshots/DictionaryTest.DictionaryToCustomDictionaryWithPrivateCtorShouldDiagnostic#Mapper.g.verified.cs index a06b59a465..b4ea23ffce 100644 --- a/test/Riok.Mapperly.Tests/_snapshots/DictionaryTest.DictionaryToCustomDictionaryWithPrivateCtorShouldDiagnostic#Mapper.g.verified.cs +++ b/test/Riok.Mapperly.Tests/_snapshots/DictionaryTest.DictionaryToCustomDictionaryWithPrivateCtorShouldDiagnostic#Mapper.g.verified.cs @@ -5,6 +5,6 @@ public partial class Mapper private partial global::A Map(global::System.Collections.Generic.IDictionary source) { // Could not generate mapping - throw throw new System.NotImplementedException(); + throw new System.NotImplementedException(); } } diff --git a/test/Riok.Mapperly.Tests/_snapshots/ObjectPropertyConstructorResolverTest.ClassToClassPrivateCtorShouldDiagnostic#Mapper.g.verified.cs b/test/Riok.Mapperly.Tests/_snapshots/ObjectPropertyConstructorResolverTest.ClassToClassPrivateCtorShouldDiagnostic#Mapper.g.verified.cs index 3fccc5a0ac..9a17873286 100644 --- a/test/Riok.Mapperly.Tests/_snapshots/ObjectPropertyConstructorResolverTest.ClassToClassPrivateCtorShouldDiagnostic#Mapper.g.verified.cs +++ b/test/Riok.Mapperly.Tests/_snapshots/ObjectPropertyConstructorResolverTest.ClassToClassPrivateCtorShouldDiagnostic#Mapper.g.verified.cs @@ -5,6 +5,6 @@ public partial class Mapper private partial global::B Map(global::A source) { // Could not generate mapping - throw throw new System.NotImplementedException(); + throw new System.NotImplementedException(); } }