So I went through the 17meg file looking for the changes I found most interesting. So here they are… in no particular order.
- SQL Server connection string now supports an option called ‘application intention’ – lets you specify whether you intend on performing any modifications. All the documentation I could find on this topic talks about primary/secondary replicas and denying access to secondary replicas if the intention isn’t read-only – but it seems like a great opportunity for a simple approach to reducing attack-surface.
- MethodImpl attribute has gained a new option ‘AggressiveInlining’ – documentation says the method will be inlined if possible.
- New assembly mode Preferred32bit – documentation seems to suggest that this is the new Require32bit, only it won’t break when Microsoft releases an OS with no WOW64 mode… or maybe that if you invoke it from a 64bit context it will still load…
- Reflection.TypeInfo – this is a bit of a strange one. In .Net 4.5 Core, it is practically ‘the’ place to go to get all your type reflection information needs, it has most of the APIs they removed from Type, and some simpler methods and properties for working via reflection. In .Net 4.5 Full, it still has those simpler methods/properties, but all the APIs are still back on Type instead.
- Regular expressions now have an option for ‘match timeout’ to stop runaway regular expressions with infinite recursive backtracking or similar.
- Threading.Tasks.DataFlow – a higher-level approach to defining how threads send data to each other, rather than writing your own queue or thread-pool. Apparently it has been released as a CTP before and is based off of an existing part of the c++ TPL.
- Threading.Volatile.Read/Write – Documentation here is that this provides volatile semantics to visual basic, but apparently also for array elements in c#. I think there might be some use for it in crazy corner cases to implement ‘partial’ volatile as well to improve performance.
- WeakReference<T> – typed weak references. Does not support trying to take a reference to a struct (oddly enough)! But it does provide a combined test and retrieve method to avoid calling IsAlive only to receive nothing from GetValue.
- Windows.Shell.WindowChrome – WPF gets access to custom Aero UI features. Now I too can create really annoying glass windows…
- Runtime.ProfileOptimization.StartProfile – this could be my new favourite. Putting this at the start of application causes method JITs to be recorded, and if the application has been run more than once, it also causes a background thread to spin up and JIT methods from the previous recording, speeding up the application start-up so long as the application behaviour is relatively predictable.
- IReadOnlyList – a read only interface for List<T> (but not IList<T>…). This interface is covariant so it can be cast, but it also cannot have the Contains or IndexOf methods. (The CopyTo method is missing for no apparent reason, except that maybe it might as well be an extension method.)
- IReadOnlyDictionary – a read only interface for Dictionary<TKey, TValue> (but not IDictionary<TKey,TValue>). This interface is not covariant or contravariant in any way, despite only ever taking the key as an input parameter and the value as an output parameter. I wonder if that is an oversight. There is also an IDictionary wrapper which presents this interface – presumably to ensure someone doesn’t just cast away your read-only-ness.
- CultureInfo.DefaultThreadCurrentCulture – appears you can change which culture new threads get given – very nice in some areas I can imagine.
- Zip file support through Compression.ZipArchive, and supposedly gzip compression which is significantly improved.
- IProgress<T> – little interface with just one method Report(T progress). Progress<T>, a default implementation which raises an event which report is called. Odd little thing, not sure what it is doing…
- New interop types – IInspectable and HString. These are apparently windows runtime types…
- Monitor.IsEntered – just in case you forgot? (Guess threading code can get complicated at times…)
- Threading.Timeout.InfiniteTimeSpan – finally, no more converting -1ms and hoping it works?
- Improved virtualization support in WPF. (Pixel level scrolling and pre-post caching.) (Much more interesting than the ribbon!)
- Async support is everywhere… not just streams/web requests/dns queries/database access – it is also in xml parsing (presumably to support the scenario where the underlying stream is a file).
Edit: watching some talks I discover that something that didn’t seem interesting at the time actually is. ThreadLocal<T> had an IEnumerable<T> GetValues method added to it. This actually lets you see all of the values currently allocated across all threads. Not sure how often I’ll use it, but it is cool.
Thanks Tilps. Nice list.
Thanks for this useful list, Tilps.
About your comment regarding the fact that WeakReference cannot take structs – it is because structs are allocated on the stack, and weak references are meant to allow the GC to free memory when needed – and the GC manages the heap.
Structs are freed deterministically when the method in which they are allocated in is removed from the stack frame.
(Of course, structs will be reside on the heap when being held as a member in a class, but that is another case and the class itself should be used as target to WeakReference)
Ofir.
Yes, I guess my writing can be unclear at times, but that (oddly enough) aside was attempting to make it clear that the comment was a touch sarcastic – WeakReferences to structs would indeed make very little sense.
It was more interesting because often using generics is partly about providing a better experience with structs – and in this case they are explicitly excluded. (With good reason!)