What are the new features of C# v4.0? [duplicate] - visual-studio-2010

This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
New Cool Features of C# 4.0
Hello,
There are several(many) questions at SO about "what do you want in C# v4.0?". This question is different,I'm not asking you what you'd like to see in the new version of Microsoft's baby,but what is already in there since Microsoft Visual Studio 2010 Beta 1 is already out.
I myself found only optional parameters implemented in VS2010.
void foo(int a,int b = 10)
{
if(b != 10) throw new Exception();
}
void Main(string[] args)
{
foo(5);
foo(5,6);
}
Its very hard for me to find every single thing in that huge language,because I don't know what's planned to be implemented.All I've seen is those "What do you want in C# 4?" questions,which doesn't help my progress to grow up.
What new feature have you found in VS2010 Beta1?

In C# Future page # MSDN you'll find a documentation of the new features which were added to the Beta1 version of C# 4.0, along with samples.

You are really asking two separate questions:
What new feature have you found in
Vs2010 Beta1?
This would be new IDE features, not language features. I do not know much about these, but I do know that the IDE has been rewritten in WPF and will have better support for multi-monitor. There is an article about other new features here. If you are doing XML/XSLT, the new XSLT debugging feature is neat.
What new features are in C# 4.0 ?
The biggest new feature is propably dynamic programming via the "dynamic" keyword. There are also optional parameters, which you mention yourself.
Beyond that, the most important new feature is likely to be contravariance and covariance in generics. I will not try to explain it here, since it would be quite lengthy, but do see Eric Lippert's blog for a thorough explanation. He has a whole series on the subject, and it gets explained in detail.

Related

How to add custom coloring scheme to a specific pattern? [duplicate]

This question already has an answer here:
How do I make my own method similar to String.Format using Composite Formatting in C#
(1 answer)
Closed 7 years ago.
On Visual Studio, when using
string.Format("bla {0}", someparameter);
the part of parameter "{0}" is colored green, and ReSharper (an external tool) is notifying on missing parameter when it's not supplied with the method.
In my project i use a lot of debug logs as follows:
_log.Debug("bla {0}", someparameter);
and i want to add the same kind of styling as mentioned above, with coloring, and perhaps an external tool as ReSharper to identify missing parameters.
The motivation is to avoid awkward issues in which i missed some parameter, or wrote the same parameter place holder twice
technical information:
I'm using Visual Studio 2015 RC (recently upgraded from VS 2012)
and ReSharper 9.1.
You can: _log.Debug(string.format("Text {0})", params[]));

What has happened to Dynamic LINQ?

I have a need to use dynamic LINQ where I can use variables in place of field names. Now I have done some googling and found that there is a sample for VS2008 where we can get this functionality.
My question is what has happened to this DLINQ ? It's been 4 years and I wonder whether it's made it into framework proper or some other new solutions have been invented to replace this? I only have my interest in DLINQ now so it is rather difficult to find further info on google, beside not knowing what exactly I am looking for other than 'better incarnation of DLINQ'. Can anyone shed some light?
This was never an "official" part of LINQ so has never been included in the framework.
The source was freely available and versions of it have appeared in CodePlex and on GitHub
The GitHub source appears to be the origin of the Nuget package
I've resurrected Dynamic LINQ, adding support for .NET 4.0/4.5, added support documentation (a work in progress), and added lots of new features.
Here is the link to the docs page, and from there, you can find the NuGet package and GitHub Project

Looking for a Bug-workflow VS Extension

My company will move to TFS sometime next year but is currently relying on a patchwork solution involving Bugzilla (2.2), code commenting and build-user inboxes for managing bugfix workflow. I've been looking at writing some VS extensions (or using code snippets) to help automate and standardize this. I currently have a code snippet for standardized comments along with the "email code snippet" extension for emailing comments (which include build instructions) off to build-user inboxes. It's better than we had, but well short efficient.
The question: Are there any extensions, combination of extensions, or combinations of available extension code out there that does this sort of thing. Using visual Studio 2010 but constrained to Bugzilla 2.2. This will be a < 1yr solution, so a minimum of cost and complexity is a must.

Is it really worth purchasing R# for VS2010?

I heard that R#5.0 (still in beta) will support VS 2010. My question is
VS2010 == VS2008 + ReSharper ?
I know there are many improvements to VS2010, so I 'm not sure weather is it really worth purchasing the R#5.0 for VS2010?
Well, I haven't explored VS 2010 new refactoring features that much, but its my understanding that VS has some but definitely not all of resharpers features implemented (From MSDN):
Navigate To
You can use the Navigate
To feature to search for a symbol or
file in the source code.
Navigate To lets you find a specific
location in the solution or explore
elements in the solution. It helps you
pick a good set of matching results
from a query.
You can search for keywords that are
contained in a symbol by using Camel
casing and underscore characters to
divide the symbol into keywords.
For more information, see How to:
Search for Objects, Definitions, and
References (Symbols).
Generate From Usage
The Generate From
Usage feature lets you use classes and
members before you define them. You
can generate a stub for any undefined
class, constructor, method, property,
field, or enum that you want to use
but have not yet defined. You can
generate new types and members without
leaving your current location in code,
This minimizes interruption to your
workflow.
Generate From Usage supports
programming styles such as test-first
development.
IntelliSense Suggestion Mode
IntelliSense now provides two
alternatives for IntelliSense
statement completion, completion mode
and suggestion mode. Use suggestion
mode for situations where classes and
members are used before they are
defined.
In suggestion mode, when you type in
the editor and then commit the entry,
the text you typed is inserted into
the code. When you commit an entry in
completion mode, the editor shows the
entry that is highlighted on the
members list.
When an IntelliSense window is open,
you can press CTRL+ALT+SPACEBAR to
toggle between completion mode and
suggestion mode.
So I guess it would depend on which of Resharpers features you want to use. If you are satisfied with the above which is certainly great improvements, then you don't need Resharper.
On the performance question, well it might perform better because of tighter integration.
Personally the above leaves me still needing a lot of features like (just the ones i can think of right now - might be more):
There are as far as I can tell only about 6 refactorings, where resharper currently has more than 30
No import type completion, which i use ALL the time. One shortcut adds to references and adds import statement
No smart completion
Change namespace to follow navigation structure and update all references with one shortcut
Goto is more advanced in R# you can go to inheritors and bases,
file member, recent files and edits and theres the fast goto feature
Resharpers static analysis is far more comprehensive than what you get from VS
So what do you need? (I am definitely not giving up Resharper)
Peter,
Best person that can answer this question is yourself. What I suggest is you download it, learn it (and note I said learn it, not just play with it). Then decide. However, I'll warn you that it's quite addictive.
My question is VS2010 == VS2008 + ReSharper ?
Oh hell no. VS2010 has more features than VS2008, and some of those feature ideas were stolen from ReSharper, but vanilla VS2010 is still a long way behind VS2010 + ReSharper 5 or even VS2008 + ReSharper 5.
From a quick glance at my 31 Days of ReSharper blog posts (written back in the R# 2.5 days), here are just a few ReSharper features that are still not present in VS2010: (Please correct me if VS2010 does have any of these -- I haven't actually used it that much without ReSharper!)
Unused code highlighted in gray and with quick-fixes to delete the unused code for you (this is just one of many hints and warnings R# does that VS does not)
Visual indication of where you have hints, warnings, and errors in a source file (colored stripe next to the vertical scroll bar)
Integrated unit-test runner that's not locked down to only MS's test framework
Shared settings for code formatting, code templates, etc. -- check these settings into version control, and they'll be picked up automatically by other computers (no manual export/import)
Go To Type -- a pop-up window where you can enter a type name (or part of the name) and jump straight to the right source file
Navigate to derived types / overriding methods
Code Structure View -- view a list of members in your type, and drag/drop to reorder them in your source code
R# will suggest variable names for you
You can invoke an Intellisense dropdown that shows types from all namespaces (and then it adds the using for you)
It's eerily good at guessing what you meant when you tell it to fix an error for you
Remove unused braces and Invert If
Generate Code (I particularly like Generate Equals and GetHashCode, even though I use them very rarely)
Viral Rename (if you rename a type, it'll also suggest that you rename any variables that were named after the type)
And best of all, Safe Delete.
Safe Delete rocks.
And that's just the features that R# had in 2.5 when I wrote the 31 Days of ReSharper. They've added plenty of new features since (I just don't have a comprehensive list handy). A couple of my favorites are the background solution-wide analysis, which will tell you in nearly real-time if you have compiler errors anywhere in your solution, and Inspect > Value Origin, which is just wicked cool.
If your having to ask the question, my guess is that you're not using ReSharper to its full potential. Personally I find that R# writes most of my code for me and I feel like a noob using visual studio without it.
YES. unequivocably YES.
After migrating to Visual Studio 2010 we asked our development team if buying Resharper upgrades is worth the investment. The votes were unanimous: yes!
Btw: we use VS2010 Premium and the devteam has its own budget.
Why don't you try out the R# 5 betas and then you can decide if you're using enough of its features to justify purchasing it.
http://confluence.jetbrains.net/display/ReSharper/ReSharper+5.0+Nightly+Builds
ReSharper has been around long enough that developers might purchase the upgrade just out of habit! :)
I recall that when VS2008 was released, R# wasn't quite ready, and there was griping among the .NET community about it. "Must...have...ReSharper!". Heh. Jetbrains appear to be on top of it this time though.

Is Linq to NHibernate in the 2.1 Alpha release?

So the nHibernate 2.1 Alpha came out a few days ago, but the announcement on sourceforge doesn't mention the additional features. In particular, it doesn't mention whether LINQ is included. I know that I've read that LINQ would be part of 2.1, but that was 6 months ago. Anybody know if LINQ is in 2.1 or what new features are? There's no documenation about 2.1 alpha features on the official site.
LinqToNHibernate is being written by Steve Strong at IMeta. Steve is attempting an amazing task by changing the way NHibernate parses HQL from the string based system to an abstract syntax tree. To be fair he does have a head start as this is being done in Hibernate using ANTLR which he is porting to .Net. It still baffles my mind what he is undertaking. I must say well done to IMeta for giving Steve the time to work on this.
If you want to see how far he is going you can check the uNhAddIns repository.
There is also a workable LinqToNHibernate provider which you'll find in NHContrib I am using this on a few projects and it works well but isn't in active development now and does break down if you attempt complex Linq queries

Resources