-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inconsistent handling of mixed nullable contexts (#1558)
Allow using non-null returning mapping methods when target type does allow nulls
- Loading branch information
Showing
4 changed files
with
70 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
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
36 changes: 36 additions & 0 deletions
36
...PropertyNullableTest.MixedNullableContextsWithDerivedTypesShouldWork#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,36 @@ | ||
//HintName: Mapper.g.cs | ||
// <auto-generated /> | ||
#nullable enable | ||
public partial class Mapper | ||
{ | ||
[global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")] | ||
public partial global::BBase Map(global::ABase src) | ||
{ | ||
return src switch | ||
{ | ||
global::A x => MapToB(x), | ||
_ => throw new System.ArgumentException($"Cannot map {src.GetType()} to BBase as there is no known derived type mapping", nameof(src)), | ||
}; | ||
} | ||
|
||
[global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")] | ||
private global::B MapToB(global::A source) | ||
{ | ||
var target = new global::B() | ||
{ | ||
Objects = MapToListOfBBase(source.Objects), | ||
}; | ||
return target; | ||
} | ||
|
||
[global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "0.0.1.0")] | ||
private global::System.Collections.Generic.List<global::BBase?> MapToListOfBBase(global::System.Collections.Generic.IReadOnlyCollection<global::ABase> source) | ||
{ | ||
var target = new global::System.Collections.Generic.List<global::BBase?>(source.Count); | ||
foreach (var item in source) | ||
{ | ||
target.Add(Map(item)); | ||
} | ||
return target; | ||
} | ||
} |
027445d
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
3
.Riok.Mapperly.Benchmarks.SourceGeneratorBenchmarks.Compile
2145646.79734375
ns (± 188621.84193937102
)120741.05671574519
ns (± 1678.1529391966976
)17.77
Riok.Mapperly.Benchmarks.SourceGeneratorBenchmarks.LargeCompile
49375820.53928571
ns (± 1383372.9771022343
)1277208.939174107
ns (± 7926.104374412328
)38.66
This comment was automatically generated by workflow using github-action-benchmark.