-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: extension method parameters for existing target mappings (#923)
- Loading branch information
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Riok.Mapperly.Tests.Mapping; | ||
|
||
[UsesVerify] | ||
public class ExtensionMethodTest | ||
{ | ||
[Fact] | ||
public Task ExtensionMapMethodShouldWork() | ||
{ | ||
var source = TestSourceBuilder.MapperWithBodyAndTypes( | ||
"static partial B MapToB(this A source);", | ||
"class A { public int Value { get; set; } }", | ||
"class B { public int Value { get; set; } }" | ||
); | ||
|
||
return TestHelper.VerifyGenerator(source); | ||
} | ||
|
||
[Fact] | ||
public Task ExtensionUpdateMethodShouldWork() | ||
{ | ||
var source = TestSourceBuilder.MapperWithBodyAndTypes( | ||
"static partial void MapToB(this A source, B target);", | ||
"class A { public int Value { get; set; } }", | ||
"class B { public int Value { get; set; } }" | ||
); | ||
|
||
return TestHelper.VerifyGenerator(source); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ly.Tests/_snapshots/ExtensionMethodTest.ExtensionMapMethodShouldWork#Mapper.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//HintName: Mapper.g.cs | ||
// <auto-generated /> | ||
#nullable enable | ||
public partial class Mapper | ||
{ | ||
static partial global::B MapToB(this global::A source) | ||
{ | ||
var target = new global::B(); | ||
target.Value = source.Value; | ||
return target; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...Tests/_snapshots/ExtensionMethodTest.ExtensionUpdateMethodShouldWork#Mapper.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//HintName: Mapper.g.cs | ||
// <auto-generated /> | ||
#nullable enable | ||
public partial class Mapper | ||
{ | ||
static partial void MapToB(this global::A source, global::B target) | ||
{ | ||
target.Value = source.Value; | ||
} | ||
} |
86408ce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'SourceGeneratorBenchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
2
.Riok.Mapperly.Benchmarks.SourceGeneratorBenchmarks.Compile
1056186.494603737
ns (± 128084.18180303885
)121785.33090444711
ns (± 503.2236580394965
)8.67
Riok.Mapperly.Benchmarks.SourceGeneratorBenchmarks.LargeCompile
27317760.004464287
ns (± 199329.46088073996
)1011824.0924479166
ns (± 8624.974365186443
)27.00
This comment was automatically generated by workflow using github-action-benchmark.