Sven's Blog

MemoryStream ms = new MemoryStream(MyBrain); // Management and technology considerations

Subscriptions

<July 2010>
SuMoTuWeThFrSa
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

News

Welcome to my spot on the 'Net. I am the Principal Consultant at Adduxis, a management and IT consulting firm. This blog will provide you with some (hopefully) useful information and links to tidbits found on the Internet.

Navigation

Post Categories

Microsoft Bloggers

Thursday, April 07, 2005 - Posts

VS 2005 bloat

Not that I generally tend to complain about features I don't use, but I really wonder who suggested the following feature.

Classes (in code view) in the editor (at least for VB.NET) now have an active properties window, i.e. there actually are properties listed for classes. Actually, there are possible attributes listed for classes. To be 100% correct and complete, there are only 3 attributes listed: COM Class, COM Visible and Serializable.

You can set either of these attributes to False or True, which will result in a code change. So if you have this code

Public Class Test
End Class

And you change the COM Visible property to False, this is what you get

<SYSTEM.RUNTIME.INTEROPSERVICES.COMVISIBLE(FALSE)> Public Class Test
End Class

Here's why I have a gripe with this feature

  • It requires you to use the mouse to enter code in a code editor window. Bad idea if you ask me.
  • It doesn't care which Imports have already been declared, it always uses the fully qualified class name for the attribute.
    So even if you already have typed
    Imports System.Runtime.InteropServices
    the generator will still insert the entire string as indicated above. Too much clutter for no good reason.
  • It's not customizable. For example, I want a line break after each Attribute, but it doesn't look like it's possible to configure that.
  • And perhaps above all, COM Visible is False by default (I have experienced this oddity after converting an assembly designed for COM Interop to .NET 2.0), yet in the Properties window, it is set to True if the attribute is not used to decorate the class, indicating that that's the default value.
  • Why only these three attributes? Because they are the most used ones? Bad reasoning, because everyone knows the most used attributes and can type them easily. The ones that would require use of a code generator are the more complicated ones. If you ask me, the attributes for Code Access Security would have been better candidates for inclusion in that list. And anyway, are the COM attributes really used that frequently?

posted Thursday, April 07, 2005 10:43 PM by SvenAelterman with 0 Comments

.NET 2.0: Nullable types in VB.NET

After reading two blog posts ([1], [2]) about Nullable Types and consulting the beta documentation for .NET 2.0, here is what works in VB.NET (and not more than that from what I can gather):

Dim i As System.Nullable(Of Integer)
i = 10      ' Nothing new here | pun intended ;o)
i = Nothing   ' OK, so this is new... no more boxing/unboxing required then I guess
If (i.HasValue) Then
  Console.WriteLine(i)
Else
  Console.WriteLine("Undefined")
End If
Dim j As Integer
j = i      ' Works only if i actually has a value...
i = j      ' Works always. Obviously, because j, being a regular value type, always has a value, even if unassigned.

No ? to indicate a nullable type (or other shorthand), no ?? operator to choose between the value of the nullable type instance or an alternative, etc. Hopefully in a future version.

[1]: Paul Vick's blog entry

[2]: VB.NET Team blog entry

posted Thursday, April 07, 2005 10:16 PM by SvenAelterman with 0 Comments

Powered by Community Server, by Telligent Systems