SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Siegfried Pammer

What happened to Alt+Ins in SharpDevelop 4.0?

If you have tried SharpDevelop 4.0 already, you might have noticed that the Alt+Ins code generator is "missing". It is a useful feature, but we did not reimplement it in SharpDevelop 4.0 in WPF, because we wanted to improve the UI. We have moved the commands from one dialog to various menu items, which are available when right-clicking on a variable, method, property or class.

1. Implement Abstract Class

Simply click on the name of the class in which you want to implement the abstract class and choose “Implement abstract class” from the refactoring context menu.

2. Implement Interface

Just as implementing abstract classes, use the menu item from the refactoring menu.

3. Overriding Single Abstract or Virtual Methods

To activate this feature simply type “override” in a class and press the spacebar. Then the code completion window presents a list of available overridable methods and properties to override.

4. Special Case: Override ToString()

A special case of override code completion is “override ToString()”.

Triggering this code completion item inserts a small smart dialog right into the editor:

Select the fields you want to use and press the OK button. The resulting code looks like this:

5. Special Case: Override Equals() and GetHashCode()

Another special case of override code completion is “Override Equals() and GetHashCode()”. It can be invoked by selecting either Equals() or GetHashCode() from the code completion list. The inserted dialog looks like this:

Add operator overloads adds the overloads for comparison operators.

Surround with #region adds #region and #endregion around the generated code.

After pressing OK, the result looks like this:

6. Generate Property or Getter

Generating properties or getters is easily done by selecting either “Create getter” or “Create property” from the refactoring menu. It will create code like the following:

class TestClass
{
    int myInt;
    
    public int MyInt {
        get { return myInt; }
    }
    
    string myString;
    
    public string MyString {
        get { return myString; }
        set { myString = value; }
    }
}

7. Generate Constructor

Using the ctor-Snippet allows you to create a constructor. When executed again, it offers a dialog where you can specify additional options, like adding a range check or a check for null:

You can change the order of variables by moving them up and down using the buttons on the right. Pressing OK inserts:

public TestClass(int myInt, string myString)
{
    if (myInt < lower || myInt > upper)
        throw new ArgumentOutOfRangeException("myInt", myInt, "Value must be between " + lower + " and " + upper);
    if (myString == null)
        throw new ArgumentNullException("myString");
    this.myInt = myInt;
    this.myString = myString;
}

Summary

We hope that you will like the way the useful Alt+Ins features work in SharpDevelop 4.0. If you have any questions or ideas, please feel free to write a comment or use the forums. In the next blog post I will explain another new feature: Code Snippets.

Published Apr 09 2010, 09:50 PM by siegi44
Filed under:

Comments

 

darkcloud said:

I have not tried SD4, but better these changes be good for alt+ins.

Alt+ins and ctrl+g are the top features that i am using

April 12, 2010 12:12 PM
 

martinkonicek said:

Very very useful features, especially the new feature Generate Constructor!

May 25, 2010 12:04 PM
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.