-
-
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 inconsistent handling of mixed nullable contexts
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; | ||
} | ||
} |