Archive

Archive for June, 2007

GSoC WinForms Designer Report 4

June 25th, 2007

Summary

This week I was really struggling to get this Design-Time CodeDom Serialization code done. I think I’ve got my head around most of the architecture and how the different bits and peaces fit together, so hopefully the next week will be much more productive than this week.

Repository Data

Start of week revision: 40
End of week revision: 43
Visual ChangeSet: http://monodt.i-nz.net/changeset?old_path=trunk&old=40&new_path=trunk&new=43
Plain Text ChangeSet: http://monodt.i-nz.net/changeset?format=diff&new=43&old=40&new_path=trunk&old_path=trunk
Details

1) I have been researching even more on the System.ComponentModel.Design.Serialization namespace.

2) I have implemented the following class library classes from the same namespace:

  • SerializerAbsoluteContext.cs
  • MemberCodeDomSerializer.cs
  • CodeDomSerializerBase.cs - no Resources serialization and no deserialization.
  • CodeDomSerializer.cs - stubbed

Next Week

  • Research on and implement:
    • CodeDomSerializer
    • CodeDomSerializerException
    • CollectionCodeDomSerializer
    • TypeCodeDomSerializer
    • EventCodeDomSerializer : MemberCodeDomSerializer
    • PropertyCodeDomSerializer : MemberCodeDomSerializer
    • FieldCodeDomSerializer : MemberCodeDomSerializer

Coding

SlickEdit C# Helper Macros

June 21st, 2007

Yesterday I created a few macros to generate some C# code for me in my editor of choice SlickEdit . I have decided to start a page on my SlickEdit “hackings” , where you can download the C# helper macros and possibly more in the future.

For a given class:

public class Test
{
    public void SomeMethod (Type variableName)
    {
    }
}

cs_generate_property (_str access=”public”)

Generates a property from the variable under cursor. The property is placed just below the method body in which the variable is. This command also generates a class field just below the class signature. The command defaults to public properties, but the access could be set as an optional parameter.

public class Test
{
    private Type _variableName;

    public void SomeMethod (Type variableName)
    {
    }

    public Type VariableName {
        get { return _variableName; }
        set { _variableName = value; }
    }
}

cs_generate_argument_null_check ()

Generates a null check and ArgumentNullException throw for the method parameter under cursor in the beginning of the method body.

public class Test
{
    public void SomeMethod (Type variableName)
    {
        if (variableName == null)
            throw new ArgumentNullException ("variableName");
    }
}

cs_generate_field_from_local ()

Generates a class field from the variable under cursor just after the class signature in the form of “_variableName”

public class Test
{
    private Type _variableName;

    public void SomeMethod (Type variableName)
    {
    }
}

Coding

GSoC WinForms Designer Report 3

June 15th, 2007

Summary

I am sending my report earlier in, because I will be out of town for the weekend.

This week I have been researching on the logic and workings of the Design-Time Serialization and I’ve got scared. Seriously now. I have implemented a bunch of classes in the System.ComponentModel.Design.Serialization namespace. I have laid the foundations for building the CodeDom* part of the Design-Time Serialization. I am looking forward to implementing it, so I can start generating code!

Repository Data

Start of week revision: 35
End of week revision: 40
Plain Text ChangeSet (~2000 lines): http://monodt.i-nz.net/changeset?format=diff&new=40&old=35&new_path=trunk&old_path=trunk
Visual ChangeSet: http://monodt.i-nz.net/changeset?old_path=trunk&old=35&new_path=trunk&new=40

Details

1.) As planned I have been researching on the System.ComponentModel.Design.Serialization namespace, which resulted a few pretty diagrams (and not only).

2.) I have implemented the following class library classes from the same namespace:

  • ComponentSerializationService.cs
  • ObjectStatementCollection.cs
  • RootContext.cs
  • StatementContext.cs
  • ExpressionContext.cs
  • SerializationStore.cs
  • MemberRelationship.cs
  • MemberRelationshipService.cs
  • BasicDesignerLoader.cs
  • ContextStack - Refactored and updated to 2.0
  • CodeDomDesignerLoader.cs - implemented just the explicit INameCreationService interface.

3.) I did some refactoring in the loading/unloading behaviour of the design surface to result better interaction between the DesignerHost, DesignSurface and DesignerLoader.

Next Week

  • Research on and implement:
    • CodeDomSerializer
    • CodeDomSerializerBase
    • CodeDomSerializerException
    • CollectionCodeDomSerializer
    • MemberCodeDomSerializer
    • InstanceDescriptor
    • TypeCodeDomSerializer

Coding

GSoC WinForms Designer Report 2

June 11th, 2007

Introduction

That was one hell of a week and I am glad I have achieved all I had planned and even a bit more.

I have tested, fixed and refactored what I define to be the core designer and host code. This is everything but the visual user manipulation on the design-time surface. I am ready to proceed to the the design-time serialization, which is the 3rd very important component of the core code. Essentially as my first deliverable for the Mid-Term review I am planning on delivering the core code and as a second deliverable at the end of theGSoC I will deliver a basic frontend to it.

On the base of the work done this week I have refined my schedule.

Repository Data

Start of week revision: 19
End of week revision: 35
Plain Text ChangeSet (~5000 lines): http://monodt.i-nz.net/changeset?format=diff&new=35&old=35&new_path=trunk&old_path=tags%2Fgsoc-begin
Visual ChangeSet: http://monodt.i-nz.net/changeset?old_path=%2Ftags%2Fgsoc-begin&old=&new_path=%2Ftrunk&new=

Details

0.) In the beginning of the week I have spent some time to create an infrastructure for design-time testing and mainly to make my life easier. It has been implemented in the form of a DesignerTestHelper class, which allowed me to easily setup tests’ SetUp/TearOff, initialize a design surface and use helper methods to interact with it. Most importantly it allowed me to do some hacks to test on 1.1 as well (All of the hosting/services code is 2.0, where as the designers are 1.1+2.0).

I have stumbled upon a number of problems with testing the design-time code in the NUnit environment.

  • Drag and drop registration on win32 required running the test in a STA “environment”, which took me a while to figure out how to do.
  • Multi-Threaded tests - I had a lot of problems with that in NUnit and ended up refactoring to single-threaded based tests. I suspect I will have to give the issue a bit of more thought when it comes up to testing the visual behaviour (e.g win32 message routing), if I have to.
  • I get some exceptions on TearDown of some tests (I think 2), more than likely due to some internal MS design-time behaviour, of which I am not aware.

1.) I have covered the core winforms designers stack with unit tests:

  • ComponentDesigner (ITreeDesigner, IDesignerFilter)
  • ControlDesigner
  • ParentControlDesigner
  • ScrollableControlDesigner
  • DocumentDesigner

2.) I have covered the design surface (host) and its services (listed by interface name) with unit tests:

  • DesignSurface (IServiceContainer)
  • IDesignerHost
  • IContainer
  • ISite
  • INestedSite
  • INestedContainer
  • IDictionaryService
  • ITypeDescriptorFilterService

3) The following are new implementations:

  • NestedContainer
  • NestedContainerTest.cs
  • DesignModeNestedContainer and DesignModeNestedSite
  • ReferenceService
  • ComponentDesignerTest.cs
  • ControlDesignerTest.cs
  • DesignSurfaceTest.cs
  • DocumentDesignerTest.cs
  • ParentControlDesignerTest.cs

4) The tests resulted:

  • A lot of refactoring and a lot of MS behavioural compatibility fixes.
  • I have found that bits of information from MSDN2 on different classes is wrong and fixed that.
  • Complete code review.
  • A very nice way to get my head around a lot of different small bits that were not clean before.
  • They all pass on Mono and MSNET.

5) On the base of the work done this week I have refined my schedule.

Next Week

I won’t have as much time to spend on the project next week, due to personal stuff, which hopefully will take about 2 days. On top of everything today I passed out and hit my head while falling of the chair in a lab, where I went for a blood probe. I’ve been having a terrible headache and haven’t been feeling very well today (Monday), so I haven’t managed to achieve anything but write this report .And no, I do not get sick from seeing mine or others blood, so passing out today was something I wasn’t expecting to happen.

  • Research on Design-Time Serialization and more specifically on the:
    • Interaction between SerializationManager - DesignerLoader - Serializer
    • Code reuse in the specialized serializers (ImageListCodeDomSerializer, CollectionCodeDomSerializer, etc)
  • Classes to look at:
    • DesignerSerializationManager
    • DesignerLoader
    • BasicDesignerLoader
    • CodeDomDesignerLoader
    • CodeDomSerializerBase
    • CodeDomSerializer
  • Begin writing unit tests for the above.

Coding

“Freedom”input Blutooth Keyboards - DO NOT BUY ONE!

June 4th, 2007

DO NOT BUY ONE!!!!!!!

I was waiting for my plane at the Manchester airport yesterday and I had to waste 2 hours. I decided to get a bluetooth keyboard for my Nokia N800, so at least I can do some productive work. Fortunately there was a Dixons shop in the free duty area and I headed directly in and grabbed a what at the time seemed to be a very decent piece of BT keyboard with HID and SPP compatible with all major devices. Well the n800 wasn’t listed but it’s a HID bt device, so it should have worked out of the box.

I opened the box and read the quick setup guide and I was quite surprised to read extremely important information which is not mentioned on the packagingOne can only ever use the keyboard with 2 devices, because the keyboard is locked and requires a special driver. Each piece of hardware you want to use it on has to be registered on the web site via 2 unique codes, supplied in the box, so you end up with 2 unique unlock keys specific for the 2 pieces of hardware. What a fraud, lock-up and scam!

I went back and returned the keyboard and got full money refund from Dixons. It’s such a sad world we live in.

Coding