Welcome to MSDN Blogs Sign in | Join | Help

What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

Visual Studio 2010 and .NET Framework 4 Beta 1 are available for download.  .NET 4 Beta 1 contains new functionality and improvements throughout the framework.  In this post I’ll discuss the changes specific to the BCL.

Many of the features listed below were previously announced when we released the .NET Framework 4 CTP back in November of last year.  I’ve included these features again below for completeness.  New functionality in Beta 1 that wasn’t present in the CTP is denoted as such.

  • Code Contracts
    System.Diagnostics.Contracts provides a language-agnostic way to express coding assumptions in .NET programs.  The contracts take the form of pre-conditions, post-conditions, and object invariants.  Contracts act as checked documentation of your external and internal APIs.  The contracts are used to improve testing via runtime checking, enable static contract verification, and could be used in documentation generation.  We partnered with Microsoft Research to deliver this feature in .NET 4.  More information and links to the tools are available on the Code Contracts DevLabs site.
    (new in Beta 1) The latest release of the tools works with Visual Studio 2010 Beta 1.

  • Parallel Extensions
    The Parallel Computing Platform team worked with us to add the Task Parallel Library (TPL), Coordination Data Structures, and Parallel LINQ (PLINQ) to the BCL in .NET 4.  This includes an improved ThreadPool scheduling algorithm for tasks, Task and Task<T>, the static Parallel class, concurrent collections in System.Collections.Concurrent, and other coordination data structures such as Lazy<T>, CountdownEvent, Barrier, SemaphoreSlim, SpinLock, SpinWait, and ManualResetEventSlim.  More information is available over at the PFX team’s blog.

  • BigInteger
    System.Numerics.BigInteger is an arbitrary-precision integer data type.  BigInteger supports all the standard integer operations, including bit manipulation.  It can be used from any .NET language, and some of the new .NET languages—such as F# and IronPython—have support built-in to the language.  We partnered with the Microsoft Solver Foundation team to deliver this in .NET 4. 

  • Variance annotations (new in Beta 1)
    C# and VB now support safe co- and contra-variance for generic interface and delegate types.  Co-variance means that a generic of a type, e.g. an IEnumerable<String>, can be treated as a generic of any supertype, e.g. an IEnumerable<Object>.  Contra-variance means that a generic of a type, e.g. an Action<Object>, can be treated as a generic of a subtype, e.g. an Action<String>.  In C#, co-variance is annotated with the “out” keyword and contra-variance is annotated with the “in” keyword.  VB has similar “In” and “Out” keywords.  We’ve annotated several interfaces and delegates in the BCL for variance, including: IEnumerable<T>, IEnumerator<T>, IComparer<T>, IEqualityComparer<T>, IComparable<T>, the Action and Func delegates, Predicate<T>, Comparison<T>, EventHandler<TEventArgs>, and Converter<TInput, TOutput>.

  • Tuples (new in Beta 1)
    We’ve added common Tuple types in the BCL to facilitate language interoperability and to reduce duplication in the framework.  A tuple is a simple generic data structure that holds an ordered set of items of heterogeneous types.  Tuples are supported natively in languages such as F# and IronPython, but are also easy to use from any .NET language such as C# and VB.

  • SortedSet<T> (new in Beta 1)
    We’ve added a SortedSet<T> collection along with a new ISet<T> interface.  SortedSet<T> uses a self-balancing tree which maintains data in sorted order for performance guarantees with insertion, deletion, and searches.  Both the new SortedSet<T> and the existing HashSet<T> implement ISet<T>.

  • File System Enumeration Improvements (new in Beta 1)
    System.IO.Directory and System.IO.DirectoryInfo have new APIs for enumerating the file system that return IEnumerable<T>s instead of arrays.  These new APIs are more efficient than the array-based APIs because they do not need to allocate a (potentially large) array and you can access the first results immediately instead of waiting for the entire array to be created and returned.  We’ve also added new convenience APIs for efficiently reading, writing, and appending lines from/to a text file using IEnumerable<String>.  These new APIs are useful in LINQ scenarios where you may want to quickly and efficiently query the contents of a text file and write out the results to a log file without allocating any arrays.

  • MemoryMappedFiles
    System.IO.MemoryMappedFiles exposes the memory mapping functionality provided by Windows as first-class managed APIs.  Memory mapped files can be used to efficiently edit very large files and can also be used to create shared memory for inter-process communication.  Along with this feature, we’re introducing System.IO.UnmanagedMemoryAccessor, a new class that enables random access to unmanaged memory similar to how UnmanagedMemoryStream enables sequential access to such memory.

  • Registry Improvements (new in Beta 1)
    We’ve added support to Microsoft.Win32.RegistryKey for accessing alternate registry views (32bit and 64bit views) on 64bit Windows.  We’ve also added the ability to create volatile keys—keys that are stored in memory and are not persisted when the hive unloads (which typically happens on reboot).  In addition, we’ve added new extensibility APIs that take and return a SafeRegistryHandle to make it easier to interoperate with Win32 registry APIs that do not have managed wrappers.

  • Globalization data updated to Unicode 5.1 (new in Beta 1)
    Culture data in .NET 4 has been updated, including updating the character information to Unicode 5.1.  We have also added support for new cultures, including new neutral cultures.

  • ResourceManager Improvements
    The ResourceManager in System.Resources has been improved to respect the user’s preferred UI languages when looking for localized resources, instead of only using the CurrentUICulture’s parent chain.  This means if the user has specified in Windows that she prefers French and Spanish, the ResourceManager will look for French and Spanish resources before falling back to the neutral resources.  This change is present in Silverlight 2 as well as .NET 4.

  • Compression Improvements
    The compression algorithms in System.IO.Compression have been improved in .NET 4.  DeflateStream and GZipStream no longer inflate already compressed data.  This means that in many cases you’ll see better compression ratios when using these streams on .NET 4.  We’ve also removed the 4 GB size limit, so you can now compress streams over 4 GB in length.

You can learn more about what’s new in the BCL in .NET Framework 4 on Channel9: Inside .NET 4: Meet the BCL Team.

We hope you enjoy the new functionality and improvements in Beta 1.  Be sure to let us know if you run into any issues or if you have any further suggestions.  And look out for even more improvements and refinements in the next preview release of .NET Framework 4.

Published Friday, May 22, 2009 6:31 PM by BCLTeam
Filed under: ,

Comments

# What&#8217;s New in the BCL in .NET 4 Beta 1 [Justin Van Patten] | Microsoft Share Point

Saturday, May 23, 2009 6:55 AM by Khurram Aziz

# Visual Studio 2010 Beta 1

Visual Studio 2010 Beta 1 is available to try. Don't forget to download the Visual Studio 2010 and .NET

Saturday, May 23, 2009 3:48 PM by Joteke's Blog

# What's new in the BCL in .NET 4 Beta 1 (from BCL Team blog)

Saturday, May 23, 2009 5:34 PM by DotNetShoutout

# What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten] - BCL Team Blog

Thank you for submitting this cool story - Trackback from DotNetShoutout

Saturday, May 23, 2009 9:05 PM by gOODiDEA.NET

# Interesting Finds: 2009 05.18 ~ 05.24

.NET What's New in the BCL in .NET 4 Beta 1 How CLR maps SEH exceptions to managed exception types Announcing

Saturday, May 23, 2009 9:07 PM by gOODiDEA

# Interesting Finds: 2009 05.18 ~ 05.24

.NETWhat'sNewintheBCLin.NET4Beta1HowCLRmapsSEHexceptionstomanagedexception...

Sunday, May 24, 2009 3:09 AM by progg.ru

# Что нового в BCL .NET 4 Beta 1

Thank you for submitting this cool story - Trackback from progg.ru

Sunday, May 24, 2009 1:02 PM by Jason Haley

# Interesting Finds: May 24, 2009

Interesting Finds: May 24, 2009

Tuesday, May 26, 2009 11:45 AM by Stefan Wenig

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

Variance annotations: this is great! but why don't you add additional interfaces that enable covariance for more complete collections?

e.g., IList<T> has T in input and output positions, so it cannot be covariant. however, IEnumerable<> is very limited, so whenever I need covariance, I'd have to cast to IEnumerable<T> and just enumerate that list.

you could provide additional interfaces such as IReadonlyCollection<out T> or IReadonlyList<out T> that use T only in output positions, so we could get covariance AND the ability to clear list, access them by position, get a count and everything _without_ doing a (slow) enumeration.

Whether ICollection<T> would inherit from IReadonlyCollection<T> is a matter of compatibility (some reflection-based code may rely on the current inheritance hierarchy), but at least additional interfaces sure would not hurt.

(As a side note I find it interesting that in all interfaces up to IList<T>, there are only two methods that are not covariant by nature: Add and Insert. E.g., ignoring the static type system for a moment, Remove(T obj) is perfectly covariant: trying to remove an object of the wrong type should have the exact same effect as trying to remove an object of the correct type that's just not in the collection. Only Add and Insert could get us into additional trouble at runtime. Obviously, that's nothing a static type system can easily account for, but a specialized ICovariantList<T> could easily provide object-Typed methods for those instances. But then again, it's probably the most straightforward way to just use the non-generic ICollection/IList interfaces for such stuff...)

Tuesday, May 26, 2009 3:42 PM by Omer Mor

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

I noticed that the Tuple with the TRest parameter is enforcing that TRest is ITuple in runtime, instead of declaring the type parameter as TRest : ITuple.

Is there any good reason behind that ?

Omer Mor.

Tuesday, May 26, 2009 6:26 PM by pminaev

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

>>> I noticed that the Tuple with the TRest parameter is enforcing that TRest is ITuple in runtime, instead of declaring the type parameter as TRest : ITuple. Is there any good reason behind that ?

Well, there's no interface ITuple. And even if there was, nothing would restrict someone else from implementing it, either (it would have to be public to be used in a generic constraint).

# New and Notable 323

Agile Agility at Scale: Become as Agile as You Can Be: Scott Ambler talks about his new ebook; The goal of the Agility at Scale: Become as Agile as You Can Be ebook is to get people thinking outside of the box a bit when it comes to agile development

Wednesday, May 27, 2009 6:08 PM by Luiz

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

Hi,

Where i can found a list of ALL changes in the .NET Framework 4.0 ?

Thanks!

Thursday, May 28, 2009 3:19 PM by lewellen

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

It's really great that you folks got BigInteger in there. I look forward to seeing the System.Numerics namespace evolve.

Friday, May 29, 2009 10:11 PM by ComponentGear.com Feed

# This Week on C9: Bing, Changes to .NET FX 4.0, & play Apple IIe games on your Xbox

This week on Channel 9, Brian and Dan discuss the top developer news including: - Bing - Microsoft&#39;s

Saturday, May 30, 2009 7:48 AM by Vijay Santhanam

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

Why is BigInteger is Numerics namespace? shouldn't it be where Int32 and the others are?

Tuesday, June 02, 2009 5:52 PM by matt_hargett

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

I'm now curious about what has been *removed*. One of Java's primary problems is not getting rid of obsolete and error-prone APIs, causing bloat. Both the CLR via C# and the Framework Design Guidelines books call out various mistakes about in the design of certain BCL types and methods. (I love the brutal honesty in these books, much more helpful than the kiss-ass approach of Effective Java.)

When will the issues called out in the aforementioned books be resolved in the BCL? I'd be willing to sacrifice a minor amount of compilation backward-compatibility to eliminate bad examples and anti-patterns that end up creeping into users' designs.

Thanks for the post!

Wednesday, June 03, 2009 1:29 AM by Mike DePouw

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

very informative blog post, thanks!

Saturday, June 06, 2009 5:26 PM by Blog del CIIN

# .NET Fx 4.0: Listado de novedades en la BCL!

Muchas son las novedades que tenemos en la BCL (Base Class Library) de .NET Framework 4.0…y para conocerlas

Friday, June 12, 2009 7:47 AM by 出会い

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

ヒマだょ…誰かかまってぉ…会って遊んだりできる人募集!とりあえずメール下さい☆ uau-love@docomo.ne.jp

Sunday, June 14, 2009 6:49 AM by 家出掲示板

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

カワイイ子ほど家出してみたくなるようです。家出掲示板でそのような子と出会ってみませんか?彼女たちは夕食をおごってあげるだけでお礼にHなご奉仕をしてくれちゃったりします

Monday, June 15, 2009 7:16 AM by 右脳左脳

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

あなたは右脳派?もしくは左脳派?隠されたあなたの性格分析が3分で出来ちゃう診断サイトの決定版!合コンや話のネタにも使える右脳左脳チェッカーを試してみよう

Tuesday, June 16, 2009 8:00 AM by セレブラブ

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

セレブラブでは性欲のある男性を募集しています。セフレパートナーを探している20代・30代の女性たちが多数登録されています。セレブと遊びたい、Hがしたいという方は無料登録からどうぞ

Wednesday, June 17, 2009 7:37 AM by 逆援助

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

セレブ達は一般の人達とは接する機会もなく、その出会う唯一の場所が「逆援助倶楽部」です。 男性はお金、女性はSEXを要求する場合が多いようです。これは女性に圧倒的な財力があるから成り立つことの出来る関係ではないでしょうか?

Thursday, June 18, 2009 6:42 AM by 救援部

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

貴方のオ○ニーライフのお手伝い、救援部でHな見せたがり女性からエロ写メ、ムービーをゲットしよう!近所の女の子なら実際に合ってHな事ができちゃうかも!?夏に向けて開放的になっている女の子と遊んじゃおう

Friday, June 19, 2009 7:06 AM by LellMaypery

# Скачал буду тестить

На другом сайте это уже я читала.[url=komsomolsk-na.ru ] [/url].[url=http://9990086.ru ] [/url]Интересный сайт,[url=gorno-altajsk.ru ] [/url]спасибо

Sunday, June 21, 2009 5:31 AM by 家出

# re: What's New in the BCL in .NET 4 Beta 1 [Justin Van Patten]

家出中でネットカフェやマンガ喫茶にいる女の子たちは、お金が無くなり家出掲示板で今晩泊めてくれる男性を探しています。ご飯を食べさせてあげたり泊めてあげることで彼女たちはHなお礼をしてくれる事が多いようです

New Comments to this post are disabled
 
Page view tracker