.Net


There are several important concepts related to new dynamic types in C# 4.0 which could be a bit confusing without correct understanding of boxing/unboxing of value types that happens during the dynamic binding.

Here is good example from Sam Ng’s blog:

public struct S
{
    public int i;
}

public class D
{
    public S s;
    public static void Main()
    {
        dynamic d = new D();
        d.s = default(S);
        d.s.i = 10;
        Console.WriteLine(d.s.i);
    } 

We would intuitively expect the value ‘10′ to be printed in the console. However, the value ‘0′ is printed instead. Core thing is any of the dotted expressions were to bind to a value type, that value will be boxed (and hence a copy would be made), and further dots into it would be made on the copy of the value, and not the initial value as would be expected.

The guys from C# team currently on the way of investigation if it’s reasonable to add any smart compile time logic to handle things like this for dynamic usage. But from my perspective main thing is to understand the reason for this – real value type was unboxed during dotted expression and modified, but wasn’t(!) boxed again.

During last couple of days I had to make lots of TFS tasks with my colleagues in Dev Centre. Part of them was bulk of administrative tasks to assign correct permissions to different areas of the TFS such as Source Control, Share Point, Reports and other. All this areas have independent roles and permissions configuration and it’s not really easy using standard tools to give the same permissions to someone in these different sub-areas. What we’ve discovered was the TFS Administrator tool on CodePlex that allows you easily to manage multiple permission sets for different projects and users. We found this as fast enough way for tasks we have, and I could recommend it to use in such scenarios.

TFS Administrator Screenshot

TFS Administrator Screen shot

They are similiar but very different technologies. Astoria or what is now called at Microsoft ADO.NET Data Services is a programming library that will allow data to be passed through RESTful web services. You develop these web services to be run against data you have access to. ADO.NET Data Services is now included in the .NET 3.5 SP1 updates.

SQL Server Data Services is a new service provided by Microsoft. The following is a decription:

“SQL Server Data Services (SSDS) are highly scalable, on-demand data storage and query processing utility services. Built on robust SQL Server database and Windows Server technologies, these services provide high availability, security and support standards-based web interfaces for easy programming and quick provisioning.”

SQL Server Data Services is very similair to Amazon S3 service.

If you are including scripts in your ASP.NET pages, don’t forget that you CANNOT put script tag like this

<script type=”text/javascript” src=”somescript.js” />

because browser will not recognise this as correct markup and probably all your stuff after this tag will not be correctly put to the DOM model.

You need to use this instead:

<script type=”text/javascript” src=”somescript.js”></script>

Is someone told me that they’re fully XHTML compatible? :)

I’ve noticed one problem while added new classes to my MVC project. Whenever I add new class from VS templates -> Class, both Visual Studio and Resharper Intellisense is not working for such file. After some investigation I found that problem exists because of BuildAction property that wasn’t set correctly for this CS file.

So what you need to do, if you have the same problem, is to change BuildAction property of class file from “Content” to “Compile”.

First preview of ASP.NET AJAX 4.0 has been released today.

List of new feature:

  • Client-side template rendering
  • Declarative instantiation of behaviors and controls
  • DataView control
  • Markup extensions
  • Bindings

I’m personally most excited with Client-side templates approach that was first time introduced by Nikhil Kothari at the MIX earlier this year. This client-side templating framework allows you in simple manner separate HTML markup blocks which contains templates from JavaScript code that generates page content on callbacks, Web-service method’s call, JSON requests etc. So the other good thing is that designer can see and change view and styling of this blocks in design-time without JS “decoding”.

I was so surprised this morning about latest Windows update from Microsoft:

Critical Update for Microsoft Silverlight 2 (KB955011)

Installation date: 17/07/2008 10:49 AM

Update type: Important

This update for Microsoft Silverlight 2 includes stability, media streaming, and auto-update improvements as well as improved support for Firefox 3.

They are so good to change their thoughts and thinking about Firefox support as CRITICAL. WOW!

This part of code:

<% foreach (Review r in ViewData.PreviousReviews)

{%>

<li><%=Html.RenderUserControl(“~/Views/MyContribution/PreviousReview.ascx”, r)%></li>

<%}%>

Generates multiple controls with SAME id property. It’s wrong in my opinion. So when you trying to access them from client script or server side code by getElementById() or FindControl() you will always hae access only to first one, because all other controls have the same identity!

So I need to use some additional syntax to fight this:

<% foreach (Review r in ViewData.PreviousReviews)

{%>

<li><%=Html.RenderUserControl(“~/Views/MyContribution/PreviousReview.ascx”, r, new {ID = “cr” + r.ReviewId})%></li>

<%}%>

In contrast in standard ASP.NET when we generates multiple controls (in repeater for example) without identities, they automatically receive different auto-generated id.

There are several interesting downloads currently available from Microsoft Download Center:

1. Microsoft SQL Server protocol documentation – technical specifications for protocols that are implemented and used in Microsoft SQL Server 2008

2. Microsoft Office File Format documentation – Microsoft Office 2007 file formats specifications

3. Extensible Application Markup Language (XAML) specification

It’s almost 3 weeks since I’ve started my work for new company. One thing you usually need to go through when you starting you developer’s activities at new place is new coding style, name conventions and other style rules which are different from one company to another. In last 4 years I was working in several project teams and there are always some differences in these side things I was faced to.

Another interesting thing, that in my current company we work in virtual office environment, conception that adds some new advantages, but has some features you should be ready for. In addition to slightly different communication manner, principles of creating project teams and changeable working environment you have some extra portion of mixed programming styles and subjective views on best practices from different developers and team leads.

Involuntarily you start to thinking if there any real way to produce some “common” rules for different teams. My experience says that only way when such thing happens when these rules are strongly dictated by someone. In friendly teams any attempt to do this meets personal preferences of each team member. There are some key points which we use to make some compromise:

  1. What are most teams doing already?
  2. Which option is the most readable (highly subjective)?
  3. Which option will be the easiest to maintain over time?

You can find some reasoning of this stuff here Jason Allor here.

Actually, another possible way to “generate” code style conventions is to commit this work to some tool or development environment. Surely, in this case there should be good reason to “believe” this tool – competent and authoritative source or creators of those rules. In case of C# there some work already done by Microsoft guys like Jason which can be helpful for other teams and project groups. Formerly internal Microsoft tool StyleCop, now announced as “Microsoft Source Analysis for C#” call to possibly be powerful thing to produce well-styled and maintainable code.

Next Page »