I spent the last year (part time) to migrate my existing (and successful) Windows 8.1 app to Windows 10 UWP. Now, just before releasing it to the store, I tested the app in the "Release" build mode (which triggers .NET Native). Everything seemed to work until I - by chance - noted a subtle but serious (because data-compromising) bug. It took me two days to reduce it to these three lines of code:
var array1 = new int[1, 1];
var array2 = (int[,])array1.Clone();
array2[0, 0] = 666;
if (array1[0, 0] != array2[0, 0]) {
ApplicationView.GetForCurrentView().Title = "OK.";
} else {
ApplicationView.GetForCurrentView().Title = "Bug.";
}
In Debug mode, cloning the 2D array means modifying one array item does not affect the other array. In Release mode, modifying one array changes the other, too. (I am using the latest VS 2017.)
Now, I realized that using .NET Native 1.6 (which is not the default in VS 2017), solves this particular issue.
But I lost the faith in .NET Native. How many bugs are still introduced by .NET Native into my app? My Windows 8.1 app runs fast and smoothly without .NET Native. So why should I have to use .NET Native which seems to be full of bugs? (I got to know a lot of .NET Native bugs in the last two days.)
Recently, project "UWP Desktop Bridge" has allowed to publish traditional desktop apps to the App Store (they do not have to use .NET Native). So why do I have to use .NET Native?
Is there a way to skip .NET Native totally? If not, can I configure the .NET Native compiler to behave not so destructive?
Clone()
. Always. It's never been adequately defined. UseArray.Copy()
here instead. – Comorin