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
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
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;
littleguru wrote:
Yay! I would love to have a look at your generator. Must be a nice thing
littleguru wrote:Is the tool available from somewhere?
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:
evildictaitor wrote:What is tier splitting?
I'd love for Channel 9 to offer a way to upload and host screencasts/video from niners.
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!
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.
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!
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/