Archive

Archive for January, 2009

Snippet Designer 1.1 Released

January 5th, 2009
Comments Off

I just released Snippet Designer 1.1.  This is not a major release but just some bug fixes and often requested changes to make the snippet designer more useful.

 

Some of the most notable changes are:

  1. Languages Service are turned OFF by default now.  Since I was unable to figure out a way to host the C# and VB language services in the snippet editor without causing fake errors in projects I decided to give the users an option to turn them on or off.  If you are ok with the fake error you can turn this back on but since it really annoyed me I have it off.  I plan in a future release to provide some basic color coding outside of the language service so you can at least have color coded code.
  2. Many more aspects of the plug in are now configurable through the options menu under Snippet Designer.  you can now set the location of the snippet index, set preferences for which snippet languages you would like to appear in the snippet explorer.
  3. Several bug fixes to how the highlighting of replacements works and performance improvements with it also.

 

Hopefully these changes will make it much more useful so please download it and try it out here

 

 

The future…

My plans for the future are still up in the air but some of the things I would like to add are:

  1. More bug fixes and more feature enhancements suggested by many helpful users on the Snippet Designer Codeplex page.
  2. Ability to color code snippets without using the language service.  I have a few options here I have been looking at.
  3. Create a website to host snippets and allow you to consume and publish from Visual Studio to this website.

I don’t know how much time I will have to commit to any of these but hopefully I will be able to get more work done on this.

 

Thanks!

Snippet Designer 1.1 Released

January 5th, 2009
Comments Off

I just released Snippet Designer 1.1.  This is not a major release but just some bug fixes and often requested changes to make the snippet designer more useful.

 

Some of the most notable changes are:

  1. Languages Service are turned OFF by default now.  Since I was unable to figure out a way to host the C# and VB language services in the snippet editor without causing fake errors in projects I decided to give the users an option to turn them on or off.  If you are ok with the fake error you can turn this back on but since it really annoyed me I have it off.  I plan in a future release to provide some basic color coding outside of the language service so you can at least have color coded code.
  2. Many more aspects of the plug in are now configurable through the options menu under Snippet Designer.  you can now set the location of the snippet index, set preferences for which snippet languages you would like to appear in the snippet explorer.
  3. Several bug fixes to how the highlighting of replacements works and performance improvements with it also.

 

Hopefully these changes will make it much more useful so please download it and try it out here

 

 

The future…

My plans for the future are still up in the air but some of the things I would like to add are:

  1. More bug fixes and more feature enhancements suggested by many helpful users on the Snippet Designer Codeplex page.
  2. Ability to color code snippets without using the language service.  I have a few options here I have been looking at.
  3. Create a website to host snippets and allow you to consume and publish from Visual Studio to this website.

I don’t know how much time I will have to commit to any of these but hopefully I will be able to get more work done on this.

 

Thanks!

Author: MattManela Categories: Personal, Snippet Designer, Visual Studio Tags:

Inline Regular Expression Options

January 1st, 2009
Comments Off

I was using attributes from the System.ComponentModel.DataAnnotations   namespace for model validation.  This namespace includes a few very useful validation attributes such as

    1. Required Attribute – Validates the field has a value
    2. Range Attribute – Validates the field is within a given range
    3. RegularExpression Attribute – Validates the field matches a given regular expression.

 

The regular expression attribute is very useful since you can describe exactly what format you want a string property to be in.  While using this though I ran into a problem.  The attribute doesn’t let you specify RegexOptions.  This was an issue for me since I wanted to use the regex to validate that the users input was between 5 and 200 characters long , so I had attribute that property as such:

   1: [RegularExpression(@".{5,200}")]
   2: public string Text{get;set;}

 

However this doesn’t work since by default the wildcard . does not match new lines (which I am allowing in the input).  The way to fix this is to specify the RegexOptions.SingleLine option to either the Regex constructor or Match function.  The problem is I have no way of doing that here, and there is no argument on the attribute constructor to specify those options.  I was considering overriding the attribute to create one that allows specifying the attribute but then I stumbled upon this:

Regular Expression Options

You are able to specify the regex option inside of the regular expression text! (which I thought was a huge discovery until my co-worker said he knew this all along but never let me know!). 

So I just changed the expression to look like this:

   1: [RegularExpression(@"(?s).{5,200}")]
   2: public string Text{get; set;}

The (?s) is the inline regex option definition so say I want this in SingleLine mode! And now the validation works the way I wanted!

Author: MattManela Categories: C#, Regular Expression Tags:

Inline Regular Expression Options

January 1st, 2009
Comments Off

I was using attributes from the System.ComponentModel.DataAnnotations   namespace for model validation.  This namespace includes a few very useful validation attributes such as

    1. Required Attribute – Validates the field has a value
    2. Range Attribute – Validates the field is within a given range
    3. RegularExpression Attribute – Validates the field matches a given regular expression.

 

The regular expression attribute is very useful since you can describe exactly what format you want a string property to be in.  While using this though I ran into a problem.  The attribute doesn’t let you specify RegexOptions.  This was an issue for me since I wanted to use the regex to validate that the users input was between 5 and 200 characters long , so I had attribute that property as such:

   1: [RegularExpression(@".{5,200}")]
   2: public string Text{get;set;}

 

However this doesn’t work since by default the wildcard . does not match new lines (which I am allowing in the input).  The way to fix this is to specify the RegexOptions.SingleLine option to either the Regex constructor or Match function.  The problem is I have no way of doing that here, and there is no argument on the attribute constructor to specify those options.  I was considering overriding the attribute to create one that allows specifying the attribute but then I stumbled upon this:

Regular Expression Options

You are able to specify the regex option inside of the regular expression text! (which I thought was a huge discovery until my co-worker said he knew this all along but never let me know!). 

So I just changed the expression to look like this:

   1: [RegularExpression(@"(?s).{5,200}")]
   2: public string Text{get; set;}

The (?s) is the inline regex option definition so say I want this in SingleLine mode! And now the validation works the way I wanted!

Author: MattManela Categories: C#, Regular Expression Tags: