[BUG] Error CS0104 : `DateOnly` is an ambiguous reference between `System.Text.Json.DateOnly` and `System.DateOnly`
Describe the bug
Because DateOnly is present on both the System and System.Text.Json namespace.
Existing code needs to be de-conflicted by including the full namespace.
To Reproduce
using System.Text.Json;
using System;
namespace TestApp
{
class Test
{
public DateOnly Date { get; set; }
}
internal static class Program
{
static void Main(string[] args)
{
Console.WriteLine(JsonSerializer.Serialize(new Test()));
}
}
}
Expected behavior
DateOnly is only present on System.
Workaround
As a workaround, I'll copy the DateOnlyConverter code and not using the Portable.System.DateTimeOnly.Json package.
Now I understand the problem completely, and I can confirm - it was a terrible idea to add a helper DateOnly (and TimeOnly) structs needed only for the code-generation scenarios into the widely used System.Text.Json namespace.
It's not a big problem to move these types into a separate namespace, but because it's a breaking change, I should think about how I can help users who already depend on these types to simplify migration.
@all-contributors please add @Swimburger for bug
It's not a big problem to move these types into a separate namespace, but because it's a breaking change, I should think about how I can help users who already depend on these types to simplify migration.
That makes total sense. Thank you for the update.