MapsterMapper / MapsterMapper/Mapster
DateTimeOffset to DateTime throws Mapster.CompileException
@andrerav is already working on this.
Since Feb 19, 2022.
- Dominant language
- C#
- Stars
- 5.2k
- Forks
- 410
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Really useful package (thank you!), but I've encountered a small problem when mapping classes containing a DateTimeOffset.
Mapster throws a CompileException ("Error while compiling source").
Not sure if I'm supposed to handle this mapping manually somehow? But seems like this could be handled automatically.
Repro example:
```
public class ExampleSource
{
public DateTimeOffset DateOfBirth { get; set; }
}
public class ExampleTarget
{
public DateTime DateOfBirth { get; set; }
}
public static void Test()
{
try
{
ExampleSource source = new ExampleSource() { DateOfBirth = DateTimeOffset.UtcNow };
ExampleTarget target = source.Adapt();
Console.WriteLine(target.DateOfBirth);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
```
Expected output: Today's date/time
Actual output: "Error while compiling" (Mapster.CompileException)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.