Log in

No account? Create an account
Dennis Gorelik
25 May 2018 @ 05:16 pm
Several days ago Microsoft released new update to Windows 10.
That update changed how this code works:
new Uri(baseUri, relativeUrl)

The difference is in how this code works in case if baseUri is malformed.

Prior to Windows 10 update this code crashed with System.NullReferenceException
After the update -- the same code no longer crashes.
public void CompatibilityTest()
	Uri baseUri = new Uri("https://jobs.web.cern.ch/content/cern-jobs-insight/what-are-we-doing-while-you%E2%80%99re-waiting");
	const string badUrl = "https:/jobs.web.cern.ch/content/cern-jobs-insight/what-are-we-doing-while-you%E2%80%99re-waiting";
	var result = new Uri(baseUri, badUrl);

Note malformed "https:/" in badUrl.

Currently my Windows 10 machine has .NET Framework 4.7.03056 [1]
With the most recent Windows 10 update this code successfully puts into result variable:

However on Windows Server with .NET Framework 4.7.02053 the same code crashes with NullReferenceException.

What do you think is the correct behavior for malformed baseUri input: try to guess correct baseUrl path or crash with NullReferenceException?

My guess is that Microsoft finally decided to properly fix this "malformed input" bug (and not longer crash).
If my guess is correct - then in the following versions of .NET Framework this NullReferenceException crash would disappear even on Windows Server platform.

[1] You may determine what .NET Framework version installed by running regedit:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full

... or by opening: Visual Studio - Help - About Microsoft Visual Studio

[2] .NET targetFramework mess

Originally posted at: https://dennisgorelik.dreamwidth.org/153390.html