Navigation

Search

Categories

On this page

Utterly Destroy #regions
LoaderLock Was Detected
What Was That Format String Again You Know The One For The GUID Where You Only Output The Guid But With No Formatting

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Friday, September 05, 2008
Friday, September 05, 2008 10:22:12 AM (Mountain Daylight Time, UTC-06:00) ( All things Microsoft )

I use C# on a daily basis to do most of my coding.

I really don't like #region directives. It's not just a love-hate thing. I really hate it. I have a compulsive need to eliminate them. It's extra fluff that really doesn't need to be in the in the code to make the code any more meaningful. It doesn't add any value to the executable bits.

Using Find/Replace always gets tedius. Why not just remove all instances of it throughout the solution in one action?

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module CodeHelper

    Public Sub RemoveRegions()
        RemoveThisRegexFromSolution("\#region.+")
        RemoveThisRegexFromSolution("\#endregion")
    End Sub

    Public Sub RemoveThisRegexFromSolution(ByVal findRegex As String)

        DTE.Windows.Item(Constants.vsWindowKindFindReplace).Activate() 'Find and Replace
        DTE.Find.FindWhat = findRegex
        DTE.Find.ReplaceWith = ""
        DTE.Find.Target = vsFindTarget.vsFindTargetFiles
        DTE.Find.MatchCase = False
        DTE.Find.MatchWholeWord = False
        DTE.Find.MatchInHiddenText = True
        DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
        DTE.Find.SearchPath = "Entire Solution"
        DTE.Find.SearchSubfolders = True
        DTE.Find.KeepModifiedDocumentsOpen = False
        DTE.Find.FilesOfType = "*.*"
        DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1
        DTE.Find.Action = vsFindAction.vsFindActionReplaceAll

        DTE.Find.Execute() ' Do it

        DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close() ' Close the box

    End Sub

End Module

Comments [0] | | # 
# Friday, August 22, 2008
Friday, August 22, 2008 10:01:07 AM (Mountain Daylight Time, UTC-06:00) ( )

I encountered this while debugging some Managed DirectX code.

1) Open Debug Menu and select Exceptions.
2) Selected Managed Debugging Assistants and find LoaderLock
3) Remove the selected value from the Thrown column

Comments [0] | | # 
# Tuesday, April 22, 2008
Tuesday, April 22, 2008 10:03:45 AM (Mountain Daylight Time, UTC-06:00) ( All things Microsoft | Code )

What was that format string again? You know, the one for the GUID where you only output the guid, but with no formatting?

using System;
public class GuidTest
{
    public static void Main()
    {
        string[] guidFormats = {"N", "D", "B", "P"};
        Guid g = new Guid();
        Array.ForEach(guidFormats, delegate(string t)
        {
            Console.WriteLine("{0}:{1}", t, g.ToString(t));
        });
        Console.ReadLine();
    }
}

N:00000000000000000000000000000000
D:00000000-0000-0000-0000-000000000000
B:{00000000-0000-0000-0000-000000000000}
P:(00000000-0000-0000-0000-000000000000)

That's right. Now I remember.

Edit: 1/8/2010 - I've forgotten again... Darn.

I should create a mnemonic device to remember this

N = Nothing

D = Dashes

B = Brackets

P = Parenthesis

http://msdn.microsoft.com/en-us/system.guid.tostring.aspx


Comments [0] | | #