Quantcast
Channel: Visual Studio and tools – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 239

Visual Studio and Delphi: Getting a new GUID in the code editor

$
0
0

Earlier this week, I already wrote about different idioms in different IDEs.

Here is another one, again a feature I don’t use often: getting a fresh GUID in the IDE.

Visual Studio

Most often you need it as part of your AssemblyInfo.cs file:

[assembly: ComVisible(false)]
[assembly: Guid("5F36D50A-CF90-4677-82D3-07DC1E88AE43")]

Note may you need a Guid attribute inside your AssemblyInfo.cs, even if your ComVisible atrribute as you might have specific classes in your assembly that have ComVisible set to true.

To get a new GUID in your code editor, perform the steps from this video:

  1. Go to the TOOLS menu
  2. Click on the Create Guid submenu
  3. In the dialog, select the format you want, then
  4. Click on the Copy button, then
  5. Click on the Exit button, then
  6. In the code editor, paste the GUID

Someone should write a CodeRush extension to make this easier (:

Delphi

Usually you need a GUID as part of an interface declaration:

type
  IMyInterface = interface['{E432418F-433A-42A7-AA1B-9BA2560AF299}']
    // ...
  end;

It is always wise to have a GUID on your Delphi interfaces, as without the GUID, the is and as operators will not work on interfaces.

The Delphi IDE has a shortcut to add a GUID in your source code, so only one step is needed:

–jeroen


Filed under: .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Development, Software Development, Visual Studio and tools

Viewing all articles
Browse latest Browse all 239

Trending Articles