Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Discussions

Andrew Davey Andrew Davey www.​aboutcode.​net
  • basic C# question

    littleguru wrote:
    new EventHandler is a delegate. In .NET you can't directly give to the event a method. This doesn't work:

    btn.Click += btn_Click;



    Um, yes you can in C# 2.0. I use it all the time Smiley It makes the code much cleaner to read.

  • Tier Splitting C# Class Screencast

    littleguru wrote:
    
    Yay! I would love to have a look at your generator. Must be a nice thing Smiley


    LOL well actually the code looks totally awful at the moment. This is mostly due to the fact that writing C# code from C# is not that easy using the CSParser. The API is a bit inconsistent. It's very tempting to write a better abstraction over the top to simplify things.

    At the moment it's like building an XML document using the procedural DOM, rather than XLINQ's new expression building model. Basically yuck! Smiley

    I'm sure given some hardcore refactoring I can sort things out.

  • Tier Splitting C# Class Screencast

    littleguru wrote:
    Is the tool available from somewhere?


    Not yet. It is still very alpha. I basically want to gauge peoples' interest. In the past I've spent a lot of time setting up open source projects only to get hardly any use or feedback. In addition, I am self employed, so just giving away a potentially very valuable tool may not be a great use of my dev time.

    Perhaps a business model to consider is making the macro expander free and open, then selling actual macros that do stuff. This way 3rd parties can write their own macros as well.

  • Tier Splitting C# Class Screencast

    If I get the time free, I'll record some more screencasts showing what else can be done with my macro expansion tool.

    For example:

    • Data access layer generation
    • Automatic interface implementation (e.g. INotifyPropertyChanged)
    • Mixins
  • Tier Splitting C# Class Screencast

    evildictaitor wrote:
    What is tier splitting?


    By "tier" I mean a place where code runs. For example, the client tier, the web app server tier, etc.

    So tier splitting is about taking a class and making certain parts of it run in different tiers. For example, I want the "Save" method of my business object to run on the server where it can access the database. However, the rest of the time it needs to be usable by the client tier to do business logic, validation, etc.

  • Tier Splitting C# Class Screencast

    I'd love for Channel 9 to offer a way to upload and host screencasts/video from niners.

  • Tier Splitting C# Class Screencast

    I just uploaded a new screencast demonstrating my C# tier splitting tool.
    Check it out here: http://www.aboutcode.net/2007/08/25/Tier+Splitting+C+Screencast.aspx

    I don't mean this to be spam, I really want to get some feedback from developers and start a discussion around the topic.
    Cheers!

  • .NET Developers in Bristol, UK

    YnnamTenob wrote:
    I thought developers were supposed to be introverts. What do you want to talk about, code, blog, eat and sleep that's all you need.

    Ah, but I'm a great developer. Great developers talk... LOTS Big Smile

  • .NET Developers in Bristol, UK

    I recently moved to Bristol in the UK. I'm keen to know if there are any .NET developer meetings/user groups. Even if there are only a few people who want to meet up for a coffee and talk code for an hour, that would be excellent start!

  • C# Syntactic Macros

    After a late night hacking session, I finally have a working syntactic macro system for C#! It is comprised of a VS custom tool that uses the CSparser. The end result allows me to do this:

    using System;
    [Macro(AutoClass)]
    public interface IModel
    {
      string FirstName { get; set; }
      string Surname { get; set; }
      int ID { get; }
      event EventHandler FirstNameChanged;
      event EventHandler SurnameChanged;
    }

    The CustomTool property of the IModel.cs file is set to "MacroExpander" and the Build action is set to None. This then generates a new file "under" the source file, called for example "IModel.generated.cs". This generated file contains the original interface (minus the bogus attribute) and a new class called "Model" that provides a stanard implementation of IModel. It includes private fields, a constructor, properties, events and event raising methods. The class is partial so you can still create a file called "Model.cs" alongside the interface and implement any methods. In addition, if you enter implementations of the interface properties/events in Model.cs then the generated class will not contain them. So it is easy to generate the 80% of standard members and custom write the others as required.

    The sharp-minded out there will note that "AutoClass" is a parameter passed to the Macro attribute. The expansion process is able to load any IMacro implementation I care to write. The macro implementation is handed the parsed source tree and allowed to modify it as required. After all macros have expanded, the source tree is converted back to CS source text and outputted from the VS custom tool. This generated file is compiled by VS as usual.

    I'm going to start using this AutoClass macro to generate most of my Model code (in the Model-View-Presenter architecture). Anywhere else I need code generation at this level I can create more macros easily.

    If people are interested in seeing this product released in some way please get in contact. I will perhaps get a screen cast made up to show it in action.

    I'll post details on my blog: http://www.aboutcode.net/