{"id":436,"date":"2011-09-16T05:43:07","date_gmt":"2011-09-16T05:43:07","guid":{"rendered":"http:\/\/www.themissingdocs.net\/wordpress\/?p=436"},"modified":"2011-09-16T05:43:07","modified_gmt":"2011-09-16T05:43:07","slug":"net-4-5-the-little-things","status":"publish","type":"post","link":"https:\/\/www.themissingdocs.net\/?p=436","title":{"rendered":".Net 4.5 &#8211; Changes I find interesting"},"content":{"rendered":"<p>So I went through the 17meg file looking for the changes I found most interesting.\u00a0 So here they are&#8230; in no particular order.<\/p>\n<ul>\n<li>SQL Server connection string now supports an option called &#8216;application intention&#8217; &#8211; lets you specify whether you intend on performing any modifications.\u00a0 All the documentation I could find on this topic talks about primary\/secondary replicas and denying access to secondary replicas if the intention isn&#8217;t read-only &#8211; but it seems like a great opportunity for a simple approach to reducing attack-surface.<\/li>\n<li>MethodImpl attribute has gained a new option &#8216;AggressiveInlining&#8217; &#8211; documentation says the method will be inlined if possible.<\/li>\n<li>New assembly mode Preferred32bit &#8211; documentation seems to suggest that this is the new Require32bit, only it won&#8217;t break when Microsoft releases an OS with no WOW64 mode&#8230; or maybe that if you invoke it from a 64bit context it will still load&#8230;<\/li>\n<li>Reflection.TypeInfo &#8211; this is a bit of a strange one.\u00a0 In .Net 4.5 Core, it is practically &#8216;the&#8217; 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.\u00a0 In .Net 4.5 Full, it still has those simpler methods\/properties, but all the APIs are still back on Type instead.<\/li>\n<li>Regular expressions now have an option for &#8216;match timeout&#8217; to stop runaway regular expressions with infinite recursive backtracking or similar.<\/li>\n<li>Threading.Tasks.DataFlow &#8211; a higher-level approach to defining how threads send data to each other, rather than writing your own queue or thread-pool.\u00a0 Apparently it has been released as a CTP before and is based off of an existing part of the c++ TPL.<\/li>\n<li>Threading.Volatile.Read\/Write &#8211; Documentation here is that this provides volatile semantics to visual basic, but apparently also for array elements in c#.\u00a0 I think there might be some use for it in crazy corner cases to implement &#8216;partial&#8217; volatile as well to improve performance.<\/li>\n<li>WeakReference&lt;T&gt; &#8211; typed weak references.\u00a0 Does not support trying to take a reference to a struct (oddly enough)!\u00a0 But it does provide a combined test and retrieve method to avoid calling IsAlive only to receive nothing from GetValue.<\/li>\n<li>Windows.Shell.WindowChrome &#8211; WPF gets access to custom Aero UI features.\u00a0 Now I too can create really annoying glass windows&#8230;<\/li>\n<li>Runtime.ProfileOptimization.StartProfile &#8211; this could be my new favourite.\u00a0 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.<\/li>\n<li>IReadOnlyList &#8211; a read only interface for List&lt;T&gt; (but not IList&lt;T&gt;&#8230;).\u00a0 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.)<\/li>\n<li>IReadOnlyDictionary &#8211; a read only interface for Dictionary&lt;TKey, TValue&gt; (but not IDictionary&lt;TKey,TValue&gt;).\u00a0 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.\u00a0 I wonder if that is an oversight.\u00a0 There is also an IDictionary wrapper which presents this interface &#8211; presumably to ensure someone doesn&#8217;t just cast away your read-only-ness.<\/li>\n<li>CultureInfo.DefaultThreadCurrentCulture &#8211; appears you can change which culture new threads get given &#8211; very nice in some areas I can imagine.<\/li>\n<li>Zip file support through Compression.ZipArchive, and supposedly gzip compression which is significantly improved.<\/li>\n<li>IProgress&lt;T&gt; &#8211; little interface with just one method Report(T progress). Progress&lt;T&gt;, a default implementation which raises an event which report is called. Odd little thing, not sure what it is doing&#8230;<\/li>\n<li>New interop types &#8211; IInspectable and HString.\u00a0 These are apparently windows runtime types&#8230;<\/li>\n<li>Monitor.IsEntered &#8211; just in case you forgot? (Guess threading code can get complicated at times&#8230;)<\/li>\n<li>Threading.Timeout.InfiniteTimeSpan &#8211; finally, no more converting -1ms and hoping it works?<\/li>\n<li>Improved virtualization support in WPF. (Pixel level scrolling and pre-post caching.) (Much more interesting than the ribbon!)<\/li>\n<li>Async support is everywhere&#8230; not just streams\/web requests\/dns queries\/database access &#8211; it is also in xml parsing (presumably to support the scenario where the underlying stream is a file).<\/li>\n<\/ul>\n<p>Edit: watching some talks I discover that something that didn&#8217;t seem interesting at the time actually is.\u00a0 ThreadLocal&lt;T&gt; had an IEnumerable&lt;T&gt; GetValues method added to it.\u00a0 This actually lets you see all of the values currently allocated across all threads.\u00a0 Not sure how often I&#8217;ll use it, but it is cool.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I went through the 17meg file looking for the changes I found most interesting.\u00a0 So here they are&#8230; in no particular order. SQL Server connection string now supports an option called &#8216;application intention&#8217; &#8211; lets you specify whether you intend on performing any modifications.\u00a0 All the documentation I could find on this topic talks &hellip; <a href=\"https:\/\/www.themissingdocs.net\/?p=436\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">.Net 4.5 &#8211; Changes I find interesting<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-436","post","type-post","status-publish","format-standard","hentry","category-net-stuff"],"_links":{"self":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts\/436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=436"}],"version-history":[{"count":0,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=\/wp\/v2\/posts\/436\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.themissingdocs.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}