Eric should write a blog post on…


I've been tracking topics I wanted to cover in various methods (excel spreadsheets, Post-It (tm) notes, “post-it compatible” notes, writing on my hand, and graffiti in my office).


It's been hard to keep all of those straight, so I'd like to centralize them in a blog post. If you have a question that you'd like me to answer, please add a comment to this post with your question.


I'll put a link on the top-level web page of my blog, so that you can easily get to it. I'll try to put some of my own ideas there as well.


 


Comments (48)

  1. Eric, a while ago I had a discussion with someone on the csharp list about abstract statics, blah blah–but someone in that discussion mentioned the concept of contracts applied to attributes (enforcing the presence of attributes on subclasses). Is that anywhere in the books?

  2. Shawn says:

    This is not a request for a blog entry per se, but a general question. I’ve been writing plugins for a while and have publicly posted my sources on planet-source-code and other places since well before any others showed up (both COM and .NET). In .NET, it’ a real problem (IMHO) that we have to load an assembly into its own AppDomain so we can dynamically unload for whatever reason. In framework 2.0, will we have the ability to arbitrarily unload an assembly that we dynamically loaded in the first place?

    Thanks,

    Shawn

  3. Eric says:

    New things you can do with Whidbey collections and anonymous methods…

  4. Grant says:

    I’d like to see a list of C++ STL containers and algorithms and what the equivalents are in the updated class library using the new generics features.

  5. In researching proper exception handling techniques, I was reviewing Richters book and he has numerous comments on "issues" with some aspects of exception handling in the current framework (Chap 18, "Whats wrong with the FCL").

    Some examples include: exceptions not being propogated back up properly, expections being swallowed, etc…

    Is exception handling in the FCL code being reviewed/updated for Whidbey? How do you see changes in framework exception handling affecting existing code?

  6. moo says:

    Where do you see C# and the CLR in 5 years time? What has ECMA / ISO standardization achieved today and where will it be in 5 years?

    What will be the state of the runtime no other platforms in 5 years?

    Crystal ball time 😀

  7. Why C# doesn’t allow us to call another contructor after running some of our own code first?

  8. moo says:

    Why not call a normal private method instead of a constructor? Anything that has to be initizlied in a ctor can go into a private method.

  9. moo says:

    C#, the CLR and ECMA/ISO standardization.

    What is Microsoft doing to clear the FUD of proprietry vs standards?

    http://www.theregister.co.uk/content/4/35481.html

    Yeah I know its the Register and theyre FUD, but alot of people think C# and the CLR is like VB and Java, vendor lockin with proprietry technologies.

    Maybe it would take some other submissions to the ECMA to get approved or maybe make it more OPEN to new ideas from anybody to get changes made to the langauge and runtime.

    This will be probably the largest hurdle of acceptance.

  10. Rune Huseby says:

    Why a base constructor is allowed to call into derived methods, causing member methods to be called before the class is constructed. Having isConstructed-members is rally annoying

  11. Jack Mayhoff [MSFT] says:

    Where do you see C# going outside the scope of its normal use. We will have C# inside SQL Server? On the Command Prompot (MS-DOS)? In the toaster? Replacing Windows Scripting Host?

    Replacing .Bat files? C#Script to replace JavaScript?

    ???

    Profit!!

  12. Jack Mayhoff [MSFT] says:

    .NET languages becoming scripting alternatives, would there be a subset of C# for C# scripting to be an alternative to VBS and I guess this would mean Windows Scripting Host would get an upgrade to have its own mini CLR, right?

    If there is such a subset of C# for scripting (if its not gona be fully functional) would this be ECMA/ISO standardized like the full C# or would it be proprietry?

  13. Eric says:

    Talk about overloading the assignment operator

  14. Jack Mayhoff [MSFT] says:

    Why cant we have literal characters aswell as strings?

    char[] blah = (‘\’);

    becomes..

    char[] blah = (@”);

  15. Jack Mayhoff [MSFT] says:

    It would be nice if the compiler like having fields that are declared but never used, how about extending that to indicate methods and properties that are declared but never used?

    This could then be highlighted on the IDE visually and the object browser.

  16. Jack Mayhoff [MSFT] says:

    Property limitations.

    We can use a get_prop as a retval yet we cannot use a set_pro as a ref argument, this would be nice and save lines like..

    int tempVal = 0;

    someFn(ref tempVal);

    SomeObj.Prop = tempVal;

    we could then just do

    someFn(ref SomeObj.Prop);

    Why cant the compiler just do that and we can type one line instead of 3, the compiler can make the tempVal for us.

    Seems more NATURAL to me to use a set_prop this way.

  17. Jack Mayhoff [MSFT] says:

    Is it true future attributes to HIDE things from the debugger are being added to the language?

    If so, TARDLICIOUS! Now I can HIDE my bugs from the testers!

  18. Niall & Zubs says:

    I would find it very useful if Eric could comment on the issues raised in Paul Wilson’s blog ".Net Memory Management and Garbage Collection" (http://weblogs.asp.net/pwilson/archive/2004/02/14/73033.aspx)

    My organisation is having a very similar problem to this, and we are very stuck on how to deal with it. I have read tonnes of material on working sets, trimming working sets, etc. I’ve verified that we don’t have memory leaks in our app – the managed heap has very little in it, but on our customer’s Citrix environment, our app sometimes has working sets around 250MB, when the managed heap is around 10-20MB.

    I’ve found it very hard to get definitive information, from a reliable source, on what seems to be a semi-known about problem of memory that has been garbage collected, but not actually returned to the OS. It would be great if Eric could shed some light on this issue.

  19. .. says:

    Doesnt the CLR actually hold onto the memory until some external process requires it, it does this so it can reallocate that memory without the performance overhead.

    Right?

  20. Niall says:

    It seems that it does. However, when on a Citrix environment, holding onto ~250MB of RAM when the managed heap is around 10-20MB seems a little excessive!

  21. Ferris Beuller says:

    Why doesn’t the runtime set objects to null when theyve been destructed? Won’t this mitigate the risk of UEs by accessing a non valid object?

  22. Ferris Beuller says:

    Why can the serializer not serialize types that implement IDictionary? SortedList cannot be serialized.

    This throws the InvalidOperationException with innerexception of

    {"The type System.Collections.SortedList is not supported because it

    implements IDictionary." }

    Means I have to start wrapping all my types into momentos for serialization. Time wasted for a workaround.

  23. Ok… so I’ll suggest it here too… I didn’t even realize this link existed…

    I can think of one thing that I would like to see added Post-Whidbey… actually I wish it was in Whidbey… const reference parameters!

    With the increase in components available … and the idea that we should be fine with black boxes… I want some safety when I pass a variable into a black box. I want to know that when a function returns, my variable didn’t change. I want the compiler watching my back… not just when I call a function, but when I write it. I like the idea that I cna declare my intention not to change a variable, and then allow the compiler to verify that fact to me. Call me crazy.

    Here is a more detailed blogpost I made on the subject. http://schweitn.blogspot.com/2004_02_01_schweitn_archive.html#107782132911035587

  24. Rich Salz says:

    How about adding Python’s "import … as …" construct? It gets you the benefit of a shorthand name, but can still avoid naming conflicts brought about by importing two packages into the top-level.

  25. Rich Salz says:

    How about "fallthrough" as a language statement, rather than "goto case …." ? I’d like to see "goto case" go away, since fallthrough probably captures most uses.

  26. Juan Felipe Machado says:

    I was writing a comment on the "What’s wrong with this code" post and this question arises:

    Why structs are NOT inmutable in C#? I really hate this hard to find bug:

    public struct S

    {

    public int X;

    public void ChangeX(int y)

    {

    X = y;

    }

    }

    public S[] arr = new S[5];

    for (int i = 0; i < 5; ++i)

    {

    arr[i].ChangeX(i);

    }

    for (int i = 0; i < 5; ++i)

    {

    Console.WriteLine(S[i].X.ToString());

    }

  27. Rick Byers says:

    Since readability was a big design goal of C#, did the C# team consider supporting keyword parameter passing, in addition to traditional positional paremeter passing (like Ada, Smalltalk, Python, etc.)? What arguments does the C# team see as for and against supporting keyword parameter passing?

    Personally, I find some method invocations that take many parameters, or have multiple parameters of the same type to be much more readble if keyword parameter passing is used. For example:

    AppDomain.CreateDomain( "foo", null, "c:myApp", "bin", false )

    – vs –

    AppDomain.CreateDomain(

    friendlyName = "foo",

    securityInfo = null,

    appBasePath = "c:myApp",

    appRelativeSearchPath = "bin",

    shadowCopyFiles = false );

    I’m certainly not advocating using this style in all cases, or even that C# would definitely benefit from this feature (can always just use named temporary variables intead). Just curious what the arguments are.

  28. Daren says:

    The pros and cons of using staic methods.

  29. Mirroring forms says:

    "ExStyle = CP.ExStyle | WS_EX_LAYOUTRTL" masses up the redrawing capability of the form. How to solve this problem

  30. bg says:

    its just over a year since u did a post on unit testing and c#, do you still test this way ? what have you learnt over the last year that may help someone who is about to start using unit testing?

    tia

    bg

  31. iqbal haider jafri says:

    any way through which Table Oriented Programming can be implemented using C#

  32. M Knight says:

    From this( http://www.artima.com/intv/generics3.html ) interview with Anders Hejlsberg:

    —–

    When you think about it, constraints are a pattern matching mechanism. You want to be able to say, "This type parameter must have a constructor that takes two arguments, implement operator+, have this static method, has these two instance methods, etc." The question is, how complicated do you want this pattern matching mechanism to be?

    —–

    In the future, will this type of complex constraints be allowed?

  33. Hello says:

    Just implement it in C# then it will be implemented

  34. Casting vs ToString() says:

    if I haev a bunch of Strings in a collection am I better of casting to String or using ToString

    i.e. String MyString = Mycollection[0]as String

    or String MyString = Mycollection[0].ToString()

    It strikes me that the second one might be more effecient as no type checking is needed and it would just call through to a function that would return ‘this’, although it does look less intuitive

  35. Mahavir says:

    Your Article helped me finish my Paper today !

  36. I’m using Visual Studio 2003.

    I’m trying to use an enum characterized with the [Flags] Attribute in a Web Component. It works fine in the IDE alloweing me to select or-ed values and gives feedback in the designer. However, running the web application (the aspx) only singular values of the enum are accepted. Or-ed values generate errors.

    Extracts from my test project:

    [FlagsAttribute]

    public enum xColors {

    Red = 1,

    Green = 2,

    Yellow = 3,

    Blue = 4

    }

    private xColors xcolor;

    [Bindable(false), DefaultValue(xColors.Red),

    RefreshProperties(System.ComponentModel.RefreshProperties.All),

    Description("Combinable colors property.")]

    public xColors CompoziteColors {

    get { return xcolor ; }

    set { xcolor = value; }

    }

    This:

    <cc1:ColorLabel id="ColorLabel5" style="Z-INDEX: 101; LEFT: 453px; POSITION: absolute; TOP: 82px"

    runat="server" CompoziteColors="Green"></cc1:ColorLabel></form>

    works, but this:

    <cc1:ColorLabel id="ColorLabel5" style="Z-INDEX: 101; LEFT: 453px; POSITION: absolute; TOP: 82px"

    runat="server" CompoziteColors="Green, Blue"></cc1:ColorLabel></form>

    works only in the IDE – the browser reports an error.

    More info (project files) if you send me an email at

    horiatu@pathcom.com

  37. John Rusk says:

    Eric,

    This is not not exactly something to write a post on… It would be cool if, when you do write a post based on something in this list, you could add a hyperlink to this list, pointing at the article that you wrote.

    (It would be even better if the hyperlink could be slotted into the original comment in this list, but your blogging software may not support that.)

  38. Jan Bannister says:

    Just wondering why they isn’t support for specifying a public getter and a private setter (or any such combination).

    It would be very useful for properties that should be read only but that should trigger an even after they change.

    Jan

  39. Keith Hill says:

    Jan, this feature will be availabe in C# 2.0 a.k.a. Whidbey. Related to Properties, I have a suggestion. C# already supports the "Event" keyword to cause the compiler to create a backing delegate and add/remove methods. So why not do the same for properties. That is I want to do this for my vanilla properties:

    class App {

    public Property string Name;

    }

    the compiler would automatically expand this to:

    class App {

    private string _name;

    public string Name {

    get { return _name; }

    set { _name = value; }

    }

    If I need to do anything out of the ordinary like different accessibilty for get vs. set then I can implement the get/set methods my self just like I can punt on the "Event" keyword and implement my own add/remove methods.

  40. GuyIncognito says:

    Should our custom exceptions be derived from System.ApplicationException or System.Exception? I’ve heard both sides of the story and now I want to hear it from the horse’s mouth.

  41. AlexCode says:

    As you guys introduced the new variable declaration inside the For loop block, it would be a nice "add-in" if it could also take typed arrays like:

    For int i = new int(){2,10,33}

    ‘Code

    Next

  42. Thomas Eyde says:

    A better way to write and maintain code documentation.

    I don’t like to litter my code with xml tagged comments. Wouldn’t it be better if a documentation project could be assigned to the code project. Then the tool could syncronize the documentation with the code when classes moves between namespaces, name changing, deletions and so on? When the tool can’t keep up, then just show the affected documents as out of sync.

    Comments should be reserved for describing why something is done in a certain way when good naming is not enough, or pointers to resources which describes special algorithms used.

    Documentation as usage scenarios and sample code has nothing to do in source code.

  43. Thomas Eyde says:

    Why the partial keyword is necessary on partial classes. Isn’t the compiler advanced enough to understand that a new class with an existing name should be merged into the existing class?

  44. Eric Wilson says:

    What all the settings on the C# project’s Configuration Properties/Advanced tab (File Alignement, Base Address, etc) are used for and when you would want to change them from something other than the defaults.

  45. Eric Wilson says:

    A friend of my said that static methods are slightly more efficent because you don’t have to pass the "this" pointer to the method. Is this true?

Skip to main content