Since the installed of a Windows update on 14.9.2017 we have problems creating certain structs in our release builds. I have noticed that compiled code on computers without that update runs as expected ("Wrong start: 1.1.1990..."), on computer with the update in question installed, the code is not working correctly ("Wrong start: 1.1.2000..."). This happens in all versions of the .NET Frameworks starting from version 4.x.
class Program
{
static void Main(string[] args)
{
DateTime start1 = new DateTime(1990, 1, 1, 6, 0, 0);
DateTime end1 = new DateTime(2000, 1, 1, 6, 0, 0);
var r2 = new DateTimeRange(start1, end1);
var r3 = new Range<DateTime>(r2.From, r2.To);
Console.WriteLine($"Wrong start: {r3.From}, correct start: {start1}");
Console.ReadLine();
}
}
public struct DateTimeRange
{
private Range<DateTime> m_range;
public DateTimeRange(DateTime from, DateTime to)
{
m_range = new Range<DateTime>(from, to);
}
public DateTime From
{
get { return m_range.From; }
}
public DateTime To
{
get { return m_range.To; }
}
}
public struct Range<T> where T : struct
{
private T m_from;
private T m_to;
public Range(T from, T to)
{
m_from = from;
m_to = to;
}
public T From
{
get { return m_from; }
}
public T To
{
get { return m_to; }
}
}