Site: http://blogs.msdn.com/b/bclteam/ Link: http://blogs.msdn.com/bclteam/rss.xml
by BCL Team via BCL Team Blog on 11/11/2011 11:47:00 PM
This post discusses features in the preview version of MEF, and some details may change between now and the full release. The latest MEF preview includes a new assembly, System.ComponentModel.Composition.Web.Mvc.CodePlex.dll, that simplifies the task of building flexible, testable and maitainable ASP.NET MVC web applications. To achieve this it: provides dependency injection for Controller classes, defines a simple convention for identifying and configuring MEF parts, maps the lifetime of part ...
[ read more ]
by BCL Team via BCL Team Blog on 11/3/2011 11:49:00 PM
This post discusses features in the preview version of MEF, and some details may change between now and the full release. One of the big advances made in the new MEF preview is a convention-driven programming model aimed at eliminating repetitive attribute usage. In this new model, the MEF attributes like Export and Import have a new role as the clean and powerful mechanism for overriding the registration conventions. Configuration by exception The power in convention-driven rules is that they ...
by BCL Team via BCL Team Blog on 11/1/2011 6:14:00 PM
This post discusses features in the preview version of MEF, and some details may change between now and the full release. MEF ‘version 1’ uses attributes to describe how a type should be handled for composition purposes. [Export, PartCreationPolicy(CreationPolicy.NonShared)] public class HomeController : Controller { [ImportingConstructor] public HomeController(/* Dependencies here */) { … } public ActionResult Index() { … } } ...
by BCL Team via BCL Team Blog on 10/27/2011 11:15:00 PM
The MEF team has been quietly at work for some time getting the finishing touches on another developer preview. You can download the new source and .NET 4.0-compatible binaries from the Codeplex site. This preview is another step towards the next supported release, which will be made as part of .NET 4.5. Highlights of the new version are: Support for generic parts A new convention-based registration API (attributes optional!) New scoping features that use ExportFactory and CompositionScopeDefin ...
by BCL Team via BCL Team Blog on 6/6/2011 8:56:00 PM
Memory mapped files are segments of virtual memory that are directly mapped to a physical file on disk, byte-by-byte. This technology has a number of benefits over traditional stream based I/O, such as performance during random access to large files, or the ability to share the mapped memory between different threads and processes. The .NET framework provides built-in support for memory mapped files starting from version 4. In most cases using memory mapped files in .NET is as easy as using trad ...
by BCL Team via BCL Team Blog on 5/16/2011 1:34:00 AM
The composite formatting feature in the .NET Framework makes it easy to left-align or right-align a value in a fixed-width field. If the alignment component of a format item in a composite format string is negative, its corresponding argument is left-aligned. If the alignment component is positive, its corresponding argument is right-aligned. For instance, the following example assigns random numbers to an eleven-element array and displays their values. In the output, the array index is left-ali ...
by BCL Team via BCL Team Blog on 4/14/2011 12:19:00 AM
Frequently, particularly when dealing with remote data collection devices, an application receives string data containing date and time information that must be converted to either DateTime or DateTimeOffset values. In these cases, the most commonly used parsing methods, the overloads of the DateTime.Parse or DateTimeOffset.Parse methods, all throw a FormatException when they attempt to perform the conversion, and their corresponding TryParse overloads all return false and assign a data and time ...
by BCL Team via BCL Team Blog on 3/29/2011 4:55:00 AM
Regular expressions in the .NET Framework support a number of grouping constructs, which allow a regular expression pattern to be grouped into one or more subexpressions. Grouping constructs are essential for creating backreferences, as well as for defining a subexpression to which a quantifier is applied. The Performance Impact of Capturing Groups The most commonly used grouping constructs in the .NET Framework regular expression language are (subexpression), which defines a numbered capturing ...
by BCL Team via BCL Team Blog on 11/28/2010 8:05:00 PM
Every year again comes the DST change... And every year again do we need to work with customers on helping them understand some legacy design decisions, and how to work around these ghosts of the past. Recently, around the end of October and the start of November the daylight saving time (DST) period finished in most areas of the northern hemisphere. As if it was an attempt to make up for the oncoming cold weather, we set our clocks back and got an extra hour of sleep. (In the southern hemisph ...
by BCL Team via BCL Team Blog on 10/12/2010 1:18:00 AM
Hi Everyone! My name is Greg, I joined the NetFx Base Class Libraries (BCL) team a few months ago, and I am really excited about my work on some very cool new framework features. Before joining the BCL team I was working in academic research in complex systems, network theory and artificial life at Monash University in Australia, and previously I was running a small software development and consulting company with clients in Germany and the UK. Besides adding some awesome new stuff to the next r ...
by BCL Team via BCL Team Blog on 7/29/2010 11:21:29 PM
First, I’d like to thank everybody for their comments on the Zip APIs. It’s great to know that I’m working on something that a lot of people will hopefully find useful. I’ll try to address the themes that came up in the comments. Streams A lot of the comments mentioned support for streams. The API does support creating a ZipArchive with a stream as the backing store, and input from streams. The following code sample takes the contents of instream and writes a Zip archive to outstream containin ...
by BCL Team via BCL Team Blog on 6/28/2010 9:37:00 PM
Before getting started, I’ll introduce myself. My name is Richard Lee, and I’m a developer intern on the BCL for the summer. I’ve only been here for a few weeks, but it’s been great working here. The people, the environment, and my project are all great. Speaking of which, my project is to add general purpose .NET APIs for reading and writing Zip files, which we’re considering adding to the next version of the .NET Framework. The most common Zip tasks are extracting ...
by BCL Team via BCL Team Blog on 6/25/2010 8:29:00 AM
The .NET Framework’s regular expression implementation is a traditional Nondeterministic Finite Automaton (NFA) engine. Perhaps the most significant feature of NFA engines is that they place the responsibility for crafting efficient, high-performance regular expressions on the developer. (For more information about the .NET Framework’s implementation of an NFA engine, see Details of Regular Expression Behavior in the MSDN Library.) With their support for such features as backreferences and backt ...
by BCLTeam via BCL Team Blog on 5/17/2010 1:00:00 PM
The .NET Framework's regular expression implementation is a traditional Nondeterministic Finite Automaton (NFA) engine. Perhaps the most significant feature of NFA engines is that they place the responsibility for crafting efficient, high-performance regular expressions on the developer. (For more information about the .NET Framework's implementation of an NFA engine, see Details of Regular Expression Behavior in the MSDN Library.) With their support for such features as backreferences and backt ...
by BCLTeam via BCL Team Blog on 4/28/2010 8:50:00 PM
A number of recent customer comments have made it clear that some confusion surrounds the use of constructors with value types. Most common are the complaints that we've failed to document a constructor for a particular value type. In one case, though, a customer asked that we remove the documentation on constructors for value types, since he or she was certain that they are not supported by the .NET Framework. Just as you can define parameterized constructors for reference types, you can defin ...
by BCLTeam via BCL Team Blog on 10/21/2009 10:58:00 PM
Visual Studio 2010 and .NET Framework 4 Beta 2 are now available to download. .NET 4 Beta 2 contains several new BCL features and enhancements in addition to what was included in .NET 4 Beta 1. Many of these improvements were added in large part due to specific feedback and suggestions reported by customers through Microsoft Connect. Summary of New BCL Functionality in .NET 4 Beta 2 Complex Number Location IObservable<T> Stream.CopyTo Guid.TryParse, Version.TryParse, and Enum. ...
by BCLTeam via BCL Team Blog on 7/8/2009 4:47:00 AM
For readers who are interested in the work that goes into designing a feature, I wrote an article for MSDN Magazine that appears in this month’s issue. Check out CLR Inside Out: Building Tuple which introduces the new Tuple type as well as discusses the design work we did behind it. I’d love to hear feedback on what you think about the article and if you’d like to see more behind the scenes design articles in the future. I’d also love to answer any questions about the design or why w ...
by BCL Team via BCL Team Blog on 7/8/2009 4:47:00 AM
by BCLTeam via BCL Team Blog on 11/12/2008 2:36:00 AM
This blog post is to provide a bit more detail about the Code Contracts feature that was recently announced at the PDC and in Justin’s blog entry, and that can be found in the Visual Studio 2010 and .NET Framework 4.0 CTP. I’ll include some information on what can be found in the CTP, some of the history and design decisions we made while developing the feature, and some places to get more information. Both of the announcements mentioned above give details about why we added this fea ...
by BCLTeam via BCL Team Blog on 10/25/2008 6:51:00 AM
Melitta, Kim, and I will be at PDC next week, along with several other members of the CLR team. We’ll mostly be hanging out in the lounges chatting with folks and answering questions. We’ll also be at the Ask-the-Experts night on Wednesday, so if you’ll be at PDC next week, stop by and say hi! We love chatting with customers and listening to your feedback and suggestions. This year’s PDC has tons of different sessions on a vast array of .NET technologies including ASP.NET, WCF, ...
by BCLTeam via BCL Team Blog on 10/6/2008 6:29:00 PM
A breaking change? We recently heard from a customer who observed different sorting behavior in .NET FX 3.5 SP1 compared to 3.5 RTM. The different behavior was demonstrated with the following code. The class StringWrapper provided a custom sort in which nulls (null StringWrapper references) were moved to the end of the array. To achieve this, StringWrapper implemented IComparable<StringWrapper> and in its CompareTo method, nulls were always greater than non-nulls.public class MyClass { ...
by BCLTeam via BCL Team Blog on 11/30/2007 7:39:00 PM
The CLR Team has been working with the Parallel Computing Platform Team for the past year on some innovative ideas in parallel computing. Yesterday, the Parallel Computing Platform Team announced the Parallel Computing Developer Center along with their first Community Technology Preview (CTP) of Parallel Extensions to the .NET Framework. We encourage you to download this early release CTP and provide feedback so that we can grow this technology together. Parallel Extensions is ...
by BCLTeam via BCL Team Blog on 7/12/2007 2:00:00 PM
Thanks all for the feedback on A Brief History of DateTime. Thanks Justin for responding to most of this. I can elaborate on some of the issues raised: >> (3) Was there any consideration given in the design process around making DateTimeOffset an (immutable) reference type? We did not really consider this because unless something is going to be of an unpredictable size, there is not much benefit of an immutable reference type over a value type. Also, since we wanted to replace many D ...
by BCLTeam via BCL Team Blog on 6/26/2007 3:00:00 PM
Those of you who are already using Silverlight 1.1 Alpha may have seen that the familiar non-generic collections were all marked as obsolete. This includes almost everything under the System.Collections namespace. You shouldn’t be too surprised. We’ve been telling you for a while that you should not be using these anymore and to instead use the generic collections in the System.Collections.Generic namespace. See the following blog post for more details on how and why to convert your non-generic ...
by BCLTeam via BCL Team Blog on 6/25/2007 10:51:28 PM
As you know generics were only introduced to the .NET Framework in version 2.0. Originally we had a lot of collections in the System.Collections namespace that can store objects. In version 2.0 we added the System.Collections.Generic namespace to support generic collections that can store any specific type. If you have legacy code or even if you kept using the old non-generic collections for other reasons you may want to consider converting your code to use the generic collections instead. Here ...
by BCLTeam via BCL Team Blog on 6/14/2007 8:48:47 PM
One thing we haven't publicized much on this blog yet is a new date time structure we've added in .NET 3.5 called DateTimeOffset (currently available as part of .NET Framework 3.5 Beta 1). Kathy mentioned it on her blog a while back and Daniel Moth recently posted about it as well. DateTimeOffset DateTimeOffset is a new date time data structure that specifies an exact point in time relative to the UTC time zone. It is made up of a date time and offset relative to t ...
by BCLTeam via BCL Team Blog on 6/12/2007 4:31:00 PM
DateTime.ToUniversalTime converts the value of the current DateTime object to Coordinated Universal Time (UTC). When the converted value is either too large or too small to fit into a DateTime object then MaxValue or MinValue is returned, respectively. Returning MaxValue and MinValue for these overflow edge cases is fine for the vast majority of applications that do not care about the edge cases near “23:59:59.9999999, December 31, 9999” and “00:00:00.0000000, January 1, 0001”. However, for appl ...
by BCLTeam via BCL Team Blog on 6/11/2007 8:13:00 PM
System.TimeZoneInfo (currently available as part of .NET Framework 3.5 Beta 1) contains methods for checking if a DateTime instance represents an ambiguous or invalid time in a specific time zone. These methods are particularly useful for validating user-supplied points in time. Background Information Time zones that adjust their time for Daylight Saving Time (in most cases by moving the clock time back or forward by 1 hour) have gaps and repeats in the timeline — wherever the clock time was mov ...
by BCLTeam via BCL Team Blog on 6/7/2007 8:40:00 PM
The main feature of the System.TimeZoneInfo class (previously named System.TimeZone2 in CTPs prior to .NET Framework 3.5 Beta 1) is to enable .NET developers to seamlessly work with Windows time zones in their applications. This includes enabling .NET applications to take advantage of the new Windows Vista Dynamic Daylight Saving Time functionality, which allows the operating system to store historically accurate time zone information (this includes both past and future time zone data). With the ...
by BCLTeam via BCL Team Blog on 5/31/2007 6:22:00 PM
System.String contains the static methods ‘Compare’ and ‘Equals’ which are used for string comparison. public static int Compare(string strA, string strB) public static bool Equals(string a, string b) These two methods perform two very different kinds of comparisons. Developers routinely confuse String.Compare with String.Equals and use the methods interchangeably. The use of the wrong method can lead to security and globalization issues. So what’s the difference? String.Compar ...
by BCLTeam via BCL Team Blog on 5/30/2007 2:17:00 AM
So here is another BCL refresher on the topic of floating point types in the BCL. Believe it or not, we have 3 different floating point types: Single (float) Double and Decimal. Each has their own characteristics and abilities and so let’s try to learn a little bit about them and what we can do with them. So here’s a question: how is a number like 231.312 represented in bits? There are a few techniques one can use. One way to represent this number in binary is to shift it so it becomes 231 ...
by BCLTeam via BCL Team Blog on 5/21/2007 2:33:00 PM
Developers using System.Text.RegularExpressions.Regex with the RegexOptions.Compiled flag may notice performance degradation in their 2.0 apps when running on 64-Bit .NET Framework 2.0. The performance problem occurs in the Regex(String pattern, RegexOptions options) constructor when instantiating very large, un-optimized regular expressions and while specifying the RegexOptions.Compiled flag: private static Regex nonwords = new Regex(@"\b(" +@"a|aboard|about|above|absent|acc ...
by BCLTeam via BCL Team Blog on 5/16/2007 3:00:00 PM
We often get asked about the capabilities of the .NET compression classes in System.IO.Compression. I'd like to clarify what they currently support and mention some partial workarounds for formats that aren't supported. The .NET compression libraries support at the core only one type of compression format, which is Deflate. The Deflate format is specified by the RFC 1951 specification and a straightforward implementation of that is in our DeflateStream class. Other compression formats, such as z ...
by BCLTeam via BCL Team Blog on 4/27/2007 12:27:50 AM
Many people told me that they would like to see more blog entries. Not only about the new cool stuff that's coming but also about the old established stuff that's maybe a tad forgotten. So, with the BCL refresher series we're going to go back to talk about existing APIs that are useful and remind you just what you can do with the current BCL. Debugging your application is one of the most time-consuming tasks developers have to master. More often than not developers are facing with tough hard-to- ...
by BCLTeam via BCL Team Blog on 3/27/2007 1:04:00 AM
For now, our suggested workaround for users that encounter the MAX_PATH issue is to rearrange directories so that the names are shorter. This may sound like a cop out, but this is ultimately easier on users because of (1) limited tool support (i.e. Explorer doesn't work with long paths) and (2) getting the full System.IO functionality for long paths results in a significant code delta for users. However, if you really want to work with paths longer than MAX_PATH you can, and this part of the ser ...
by BCLTeam via BCL Team Blog on 3/10/2007 1:25:00 AM
TraceListener is an abstract class representing a listener object that is used to log event that a TraceSource is producing. In .NET 2.0 we have a few existing implementations such as ConsoleTraceListener for logging events to the standard console and TextWriterTraceListener that is used for logging events to a text file. In our new version of the .NET Framework code-named "Orcas" we introduce a new type of TraceListener. (You can download the latest CTP here) This new trace listener introduces ...
by BCLTeam via BCL Team Blog on 1/17/2007 5:44:00 AM
Have you ever needed a really huge number? So big it just couldn't fit into any other base-type in the framework? Well, no problem anymore, just use the new BigInteger type. You can now have the ability to use integers of any arbitrary size, so they can exponentiate until the cows come home... or memory runs out, whichever comes first :-) So, what's so "Big" about BigInteger? I saw some people wondering whether we should have called this new type UnboundedInteger instead of BigIntege ...
by BCLTeam via BCL Team Blog on 12/7/2006 8:24:00 PM
The Orcas October Community Technology Preview (CTP) includes new types that make it easy for developers to use pipes from managed code. Pipes are used for inter-process communication (IPC) between processes running on the same machine, or processes running on any other Windows machine within a network. We've added support for both anonymous and named pipes. The new pipe types can be found in System.Core.dll within the System.IO namespace. Note that after the October CTP went o ...
by BCLTeam via BCL Team Blog on 11/9/2006 6:43:00 PM
HashSet<T> is in our latest CTP, and you can find it in the System.Collections.Generic namespace. The naming discussion over the last month has motivated me to recap some naming highlights for HashSet, so hang in til the end if you’re interested. HashSet is an unordered collection containing unique elements. It has the standard collection operations Add, Remove, Contains, but since it uses a hash-based implementation, these operation are O(1). (As opposed to List<T> for example, whic ...
by BCLTeam via BCL Team Blog on 10/27/2006 1:36:00 AM
I’ve seen several questions over the last month or two about refreshing the status of certain properties on the Process and ServiceProcess classes. I’d like to take this opportunity to take a look at an example from both these classes and see how we can resolve these issues. Issue One: Process.MainWindowHandle resturns 0, even though a window is created A user found that even though they waited for the UI Window of their application to be displayed, they were getting a MainWindowHandle of ...
by BCLTeam via BCL Team Blog on 10/19/2006 6:29:00 PM
The .NET Framework System.Text.RegularExpressions.Regex class maintains a cache of parsed regular expressions. The cache improves the performance of methods that create regular expressions, as the Regex class is able to avoid the cost of re-parsing and re-compiling existing regular expressions. The cache does not affect the performance of match operations on the same input string, as match results are not cached. As part of the .NET Framework 2.0 Redistributable, the BCL team m ...
by BCLTeam via BCL Team Blog on 10/12/2006 7:48:00 PM
One of our customers wondered recently if we represent negative zero in Decimal. At first glance, it doesn’t look to be the case as seen below; Decimal zero = Decimal.Zero; Decimal negativeZero_1 = new Decimal(0, 0, 0, true, 0); Decimal negativeZero_2 = -0.0m; Decimal negativeZero_3 = Decimal.Negate(Decimal.Zero); Console.WriteLine("Negative Zero: {0}, {1}, {2} Positive Zero: {3}", negativeZero_1, negativeZero ...
by BCLTeam via BCL Team Blog on 10/10/2006 3:00:00 PM
The SerialPort class requires some “warming up” time for our users coming from VB6 or other non-.NET backgrounds. One of the main reasons is that SerialPort and its underlying BaseStream are designed to behave similarly to other .NET streams, which (for example) means that Read() may not act as you’d expect. And of course there are other issues that developers occasionally run into. The following are our top 5 SerialPort tips resulting from bugs we frequently we run into. Listed along with each ...
by BCLTeam via BCL Team Blog on 10/3/2006 5:40:00 PM
Extended Time Zone support is one of the most requested features in the BCL. System.TimeZone provides some basic support for converting from your machine Time Zone to UTC and vice versa, but it doesn’t have support to convert… say from Pacific Standard Time to Eastern Standard Time. In the “Orcas” September CTP, you’ll see that the BCL team has added a new class named “System.TimeZone2” that will allow you to: - Convert a DateTime from one ti ...
by BCLTeam via BCL Team Blog on 9/8/2006 6:55:00 PM
If you have ever tried to read performance counter data on a Windows 2003 machine as a non admin user you will have likely seen an exception like the following: System.UnauthorizedAccessException: Access to the registry key 'Global' is denied. at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str) at Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity) at ...
by BCLTeam via BCL Team Blog on 9/5/2006 5:37:00 PM
An internal discussion came up recently on the performance difference of lookups in Hashtable versus NameValueCollection. Benchmarks revealed that NVC lookups were ~2-8 times slower than Hashtable. For example, when doing 40,000 lookups on a collection size of 100,000, NameValueCollection is about 2.6x worse: NameValueCollection time: 0.050 sec Hashtable time: 0.019 sec This leads to the question of whether NameValueCollection and Hashtable have different asymptotic beha ...
by BCLTeam via BCL Team Blog on 8/1/2006 12:00:00 PM
I have seen a few recent posts floating around the user community where users have been writing complicated code to get some very simple information such as a timestamp into their traces. As a follow up to this, I’d like to describe the TraceOptions enum and show how it can be used provide some useful information. When a trace event occurs, the data is actually cached in an instance of the TraceEventCache class. When logging to file (we will use the TextWriterTraceListener in ...
by BCLTeam via BCL Team Blog on 7/20/2006 1:02:00 PM
Another set of functionality we may want to add in Orcas are classes which can be an integer of arbitrary length, and a double of arbitrary precision (which could essentially be the arbitrary length integer with a decimal offset). Aside from this type itself, we are interested in what related functionality you would be looking for. What functions do you wish we had in System.Math that you could use on one of these types? What types of conversions are you looking for (aside from con ...
by BCLTeam via BCL Team Blog on 7/14/2006 2:53:00 PM
If you’re trying to transfer the access rights from one file to another, the obvious way seems to be getting the FileSecurity object from one file and applying it to another through the Get/SetAccessControl methods. The following code sample attempts to apply the ACLs from fileA to fileB using this technique. string fileA = @"C:\temp\fileA.txt"; string fileB = @"C:\temp\fileB.txt"; // First attempt FileSecurity securityA = File.GetAccessControl(fileA); File.SetAccessControl(fileB, ...
by BCLTeam via BCL Team Blog on 7/5/2006 6:32:00 PM
The Base Class Libraries is exploring scenarios related to Time Zone support and we are very likely to have a solution for this problem in the next release. We have already received a lot of great feedback from an earlier post. There are several high level scenarios where we have already received considerable feedback that they are in high demand and would be broadly used: - Enumerating a set of time zones -   ...
by BCLTeam via BCL Team Blog on 6/23/2006 12:11:00 PM
SafeHandle is the preferred mechanism for controlling the lifetime of an OS resource (such as a handle to a file, semaphore, or block of memory*) and guaranteeing that the resource is eventually freed. Using some advanced reliability features (ie, constrained execution regions & critical finalization), SafeHandle lets you easily encapsulate OS resources without worrying about leaks caused by async exceptions. This increased resiliency is crucial for server availability. For ...
by BCLTeam via BCL Team Blog on 6/20/2006 5:18:00 PM
I recently got assigned a question on one of the MSDN forums about obtaining the Parent Process of a child. This is a fairly often asked question, I’ve seen it on the System.Diagnostics FAQ page. The interesting twist to this however, was that sometimes more than one instance of a particular image name will exist on a machine at a given time. For example, I can launch multiple instances of notepad.exe, some perhaps from cmd.exe and others from explorer.exe. Is there an ea ...
by BCLTeam via BCL Team Blog on 6/15/2006 12:00:00 PM
Before we get to the meat of this blog post, I want to take a moment to introduce myself. My name is Matt Ellis and I’m working this summer as an intern on the Base Class Libraries team. I’m really enjoying my time here, and it’s pretty amazing to be working on a team whose work affects so many developers around the world! One feature we are considering adding to a future release on the .NET Framework is a library to help developers writing applications that use command line a ...
by BCLTeam via BCL Team Blog on 6/6/2006 3:24:00 PM
I’ve seen this question come up a few times and the solution is hard to infer, especially given that the logical place you go to, the Process class, doesn’t have a property to reveal this information. We could look into adding it to Process class at some point. Win32 reveals this information via a performance counter. You can query the “% Processor time” windows counter for a process that you are interested in as follows: foreach (Process proc in Process.GetProcesses()) { &nb ...
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.