This (bad) code here behaves differently for Windows and macOS:
usingSystem;usingSystem.Globalization;classProgram{privatestaticCultureInfo_parsingCulture;staticvoidMain(string[]args){_parsingCulture=(CultureInfo)CultureInfo.InvariantCulture.Clone();_parsingCulture.DateTimeFormat.Calendar=newAsnUTCTimeCalendar();}privateclassAsnUTCTimeCalendar:GregorianCalendar{publicoverrideintToFourDigitYear(intyear)=>(year<50?2000:1900)+year;}}On Windows, this throws an exception:
System.InvalidOperationException: Cannot set sub-classed Program+UTCTimeCalendar object to System.Globalization.DateTimeFormatInfo object.
On macOS, an exception is not thrown and it "works".
I understand why the Windows version is throwing, but I was surprised that it did not on macOS. I think the correct behavior is that all platforms should throw the exception.
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
This (bad) code here behaves differently for Windows and macOS:
On Windows, this throws an exception:
On macOS, an exception is not thrown and it "works".
I understand why the Windows version is throwing, but I was surprised that it did not on macOS. I think the correct behavior is that all platforms should throw the exception.
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64