MacBook, defective by design banner

title:
Put the knife down and take a green herb, dude.


descrip:

One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com

Using 89% of the same design the blog had in 2001.

FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white.

As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green.

x

MarkUpDown is the best Markdown editor for professionals on Windows 10.

It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support.

Features you won't find anywhere else include...

You've wasted more than $15 of your time looking for a great Markdown editor.

Stop looking. MarkUpDown is the app you're looking for.

Learn more or head over to the 'Store now!

Wednesday, March 17, 2021

How do you Prettier on save in Visual Studio 2019? You use Mads Kristensen's extension, JavaScript Prettier. It lets you set it to run on save, which you absolutely must do. It's an 100% godsend.

"But Mads' extension only runs Prettier 1.12.1 if another Prettier isn't installed locally in my project!" I hear you say. "That doesn't put in the extra space between function and () in anonymous declarations! I can't use it!" you complain.

Well, thanks to your resident hacker (maybe not my best separation of concerns, but it works), that's not a problem any more. Open Tools >>> settings, choose Prettier, type in the version you want to use. Poof. The embedded version is the version you entered and you're Prettier-ing.

Why did I bother updating a Prettier extension for Visual Studio? With my current team, I'm the only dev using, um, modern client-side tooling (mostly VS Code). Most folks are using Visual Studio 2019. That's fine. I love VS2019 for C# work. I can see how familiarity sometimes breeds not contempt but content. -Edness. Or something. But we need to use Prettier as a team. The tool's that good. So update it is!

You're welcome. ;^) 

Btw, I really owe Rackis a whiskey of his choice for this one. Being OCD about whitespace myself, I complained at first (okay, I complained like a cat getting a bath) when he told me years ago that I had to use a tool that automatically "corrected" whitespace for me, reformatting the entire file without apology, before I could check in my code. What the heck?! I know how to format code to make it easiest to read and understand. How dare a tool mess with my art?!!?

Then, very quickly, I dropped the pretense and became addicted. 

In a team using Prettier, I never got a file with craptastic whitespace from another coder. 

And, more important selfishly, I found I never wasted another moment making sure the whitespace for my code was perfect.

Get lazy, type some code, hit save, WHAM, competent whitespace is inserted for you. It's instant. It's mindless. It's magical.

Anything that makes coding easier and standardizes something subjective in a way that's Not Wrong is a very good thing. You should use it. Now. You can thank me later for the recommendation... and the extension, if you're still a Visual Studio 2019 addict.

Labels: , , ,


posted by ruffin at 3/17/2021 10:43:00 PM
Tuesday, February 09, 2021

In one place so I don't have to look it all up (and invariably get the wrong app's shortcuts first) when I forget again

Code folding for Visual Studio 2019 (the old lady):

The following commands can be found on theย Editย >ย Outliningย submenu.

TABLE 1
NameDescription
Hide Selection(Ctrl+M,ย Ctrl+H) - Collapses a selected block of code that would not normally be available for outlining, for example anย ifย block. To remove the custom region, useย Stop Hiding Currentย (orย Ctrl+M,ย Ctrl+U). Not available in Visual Basic.
Toggle Outlining Expansion(Ctrl+M,ย Ctrl+M) - Reverses the current hidden or expanded state of the innermost outlining section when the cursor lies in a nested collapsed section.
Toggle All Outlining(Ctrl+M,ย Ctrl+L) - Sets all regions to the same collapsed or expanded state. If some regions are expanded and some collapsed, then the collapsed regions are expanded.
Stop Outlining(Ctrl+M,ย Ctrl+P) - Removes all outlining information for the entire document.
Stop Hiding Current(Ctrl+M,ย Ctrl+U) - Removes the outlining information for the currently selected user-defined region. Not available in Visual Basic.
Collapse to Definitions(Ctrl+M,ย Ctrl+O) - Collapses the members of all types.
Collapse Block:<logical boundary>(C++) Collapses a region in the function containing the insertion point. For example, if the insertion point lies inside a loop, the loop is hidden.
Collapse All in: <logical structures>(C++) Collapses all the structures inside the function.

Code folding for Visual Studio Code (the upstart) from stackoverflow.com:

As of Visual Studio Code version 1.12.0, April 2017, seeย Basic Editing > Foldingย section in the docs.

The default keys are:

Fold All:ย CTRL+K,ย CTRL+0ย (zero)

Fold Level [n]:ย CTRL+K,ย CTRL+[n]*

Unfold All:ย CTRL+K,ย CTRL+J

Fold Region:ย CTRL+K,ย CTRL+[

Unfold Region:ย CTRL+K,ย CTRL+]

*Fold Level: to fold all but the most outer classes, tryย CTRL+K,ย CTRL+1

Macs: useย โŒ˜ย instead ofย CTRLย (thanks Prajeet)

Labels: , ,


posted by ruffin at 2/09/2021 11:42:00 AM
Saturday, June 22, 2019

TL;DR

dotnet add reference /Users/login/Projects/path-to-other-ref-folder/FolderName/newProjectToAdd.csproj

… from the directory of the csproj you want to add the reference to.


Today’s issue: Visual Studio is giving me some the type initializer for monodevelop threw an exception whenever I open or try to create a new project.

Solution: Use VS Code for now (which I usually only use for TypeScript).


Issue #2: I need to add a reference to a local project.

Solution #2: dotnet add reference -- hat tip to step 4 from here


It’s really that easy. I’m on macOS, so I cd to the directory where the other csproj file lives.

Then I pwd to get the full path.

mydrive:FolderName login$ pwd
/Users/login/Projects/path-to-other-ref-folder/FolderName

Go back to the location of the csproj you’re adding the reference to.

Now hit up add ref:

dotnet add reference /Users/login/Projects/path-to-other-ref-folder/FolderName/newProjectToAdd.csproj

And it’ll put it in that csproj, with a path relative to your current csproj.

  <ItemGroup>
    <ProjectReference Include="..\..\..\path-to-other-ref-folder\FolderName\newProjectToAdd.csproj" />
  </ItemGroup>

That’s good enough for now. When I’m back in full VS mode with good net access, I’ll replace with a nuget, but this was a good temporary solution.

Keep on codin’…

Labels: , ,


posted by ruffin at 6/22/2019 09:52:00 AM
Wednesday, March 15, 2017

Remember how I took the time to show how to map Gvim to F1 in Visual Studio? I think there's probably a much better way: VsVim.

I installed it, forgot, had Win10 "helpfully" reboot, and suddenly saw a phat cursor in Visual Studio. Took me a second, but then it hit me -- I'm VImming in VS.

Only gotcha -- I needed to create a new environment variable, VIM, to put the path to my normal _vimrc file so that VsVim could find it.

But after that, so far, beautiful. Embarrassed I didn't hear about this one sooner. Would've saved me some time. That's one of the big reasons I use Sublime Text. I mean, it's a great text editor in lots of other ways, particularly fast searches, multiple cursors, and nice plugins, but it's vintage mode that hooked me quickly.

In any event, a nice upgrade for VS so far. And 281 reviews averaging essentially five stars ain't bad. My only complaint so far? No gqgq. For that, I'm back to F1.

EDIT (20170901): Let's add a picture of what I mean. You literally make an environment variable pointing to the folder that holds your vimrc.


In other news, got word of my second MarkUpDown Microsoft Store payout today. That's always fun to get, even if it won't cover my already exceptionally trivial marketing budget. But it is growing. That's cool.

Labels: , , ,


posted by ruffin at 3/15/2017 09:44:00 PM
Sunday, January 29, 2017

From Visual Studio - Command to collapse all sections of code? - Stack Overflow:

CTRL + M + O will collapse all.

CTRL + M + L will expand all. (in VS 2013 - Toggle All outlining)

CTRL + M + P will expand all and disable outlining.

CTRL + M + M will collapse/expand the current section.

These options are also in the context menu under Outlining.

I keep forgetting these.

Labels: ,


posted by ruffin at 1/29/2017 10:24:00 PM
Monday, January 02, 2017

Argh. Fun day of setting up LocalDB.

First, you have to have it installed. Unfortunately, our friend http://downloadsqlserverexpress.com/ is busted, and one of the more promising links from MSDN is busted too.

If I'm remembering correctly, the new location seems to be here:
https://www.microsoft.com/en-us/download/details.aspx?id=54284

But the real sticking point for me is that the default connection string for LocalDB from the Web App Template in Visual Studio 2015U3 -- at least if you've installed LocalDB from SQL Server Express 2016 -- doesn't work. The real pain was that I trusted the template, but SQL Server Management Studio was working with LocalDB just fine.

Here are the steps I used to create the solution...

From microsoft.com:

  • From theย Fileย menu, selectย New > Project.

  • From the left pane, selectย Templates > Visual C# > Web.

  • Select theย ASP.NET Core Web Application (.NET Core)ย project template.

  • Enter ContosoUniversity as the name and clickย OK.

    New Project dialog

Now if I did everything correctly (yes, I took the default name instead of changing it to ContosoUniversity, for instance), here's the appsettings.json file's connection string that came out of that template...

"DefaultConnection": "Server=(localdb)\\\\mssqllocaldb;Database=aspnet-WebApplication2-ac2d2954-804a-4157-821e-f0e494fdb334;Trusted_Connection=True;MultipleActiveResultSets=true",

... and here's what actually works...

"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=BoodaPow;Trusted_Connection=True;MultipleActiveResultSets=true"

It's just an extra backslash, as far as I can tell. Not sure how I could've introduced that, but perhaps I did?

I ended up getting the correct format from here, which is the github repo for the completed Contoso U example I referenced earlier.

Enjoy. Your C:\Users\YourUserName\ folder is now full of mdf & tdf files, just like you wanted.

Labels: , ,


posted by ruffin at 1/02/2017 03:34:00 PM

Where is the "ASP.NET Core Web Application" template in Visual Studio? It'll show up once you've installed the ".NET Core tools preview for Visual Studio".

Makes sense. ;^)

It's never fun when a hard drive dies.

Labels: , ,


posted by ruffin at 1/02/2017 09:09:00 AM
Wednesday, November 16, 2016

I went to build an app package for my newest app -- Podcasters' RSS Feed Generator, which does, not surprisingly, exactly what it says it does -- I got the following error in Visual Studio.

App manifest references the image 'Assets\StoreLogo.png' which does not have a candidate in main app package.

Turns out this is a pretty cryptic error. We get a partial answer from hololens.com:

Best Answer

... but it's not quite that easy. You can't simply rename the file; the images also have to be exactly the right size. Painfully, all the .scale-xxx extensions to the names that I had weren't from Unity; they were from Visual Studio. Et tu, VS? That stinks. Microsoft is helping me create a situation they don't support.

Anyhow, the three I had complaints about with their "correct" sizes are:

  • StoreLogo.png: 50x50 pixels
  • BadgeLogo.png: 48x48 pixels
  • Square71x71Logo.png: 142x142 pixels (of course, right?)

Blasting all the old ones with StoreLogo, etc, in the name and then dropping the new, "correctly-sized" replacements into the Assets folder, then including them in the project from VS, does the trick.

Or so I thought. Now I get...

Severity

Description Project

Line

Error

App manifest references the badge
logo image 'Assets\BadgeLogo.png'
which does not have valid dimensions. It must be 24x24 pixels.

19

Error

App manifest references the square
71x71 logo image
'Assets\Square71x71Logo.png' which
does not have valid dimensions. It
must be 71x71 pixels.

20

Which is it, dang it?

Visual Studio complaining about BadgeLogo sizing, though we have the size the error window asked for earlier

Answer: Apparently we wanted the sizes the error window wanted. Ignore errors like the ones pictured, above.

Labels: , , ,


posted by ruffin at 11/16/2016 01:56:00 PM
Monday, November 14, 2016

In other news, from stackoverflow.com:

You can append ",ac" to the watch expression to have it automatically refresh the value

x.ToString(),ac

Seeย http://msdn.microsoft.com/en-us/library/e514eeby.aspxย for more information and other format specifiers.

Well, of course. /sigh

I was trying to evaluate src.Substring(i,20) in my Watch window, and it had the "This expression causes side effects and will not be evaluated" deal beside it with the annoying little "refresh" button. Finally decided there's got to be a better option than hitting "refresh" every loop iteration.

I like Visual Studio a lot -- and, somewhat unrelatedly, though I guess it speaks to the general quality of MS IDE tools, have started using Visual Studio Code to debug Node apps -- but there are some edge cases that really surprise me.

Labels: ,


posted by ruffin at 11/14/2016 12:32:00 PM
Friday, November 11, 2016

When I'm on a laptop without an external monitor, I often want my external tool windows in Visual Studio where I usually have my Output, Error, and Find windows situated, to stop floating over the main VS edit windows.

I keep thinking I've forgotten how to do it, though it's not difficult. You just open your preferences, search for "window", and up it comes.

Turning off tool window floating

This really is a better way to get around on a small-screened setup. I have a super-cheap Lenovo 100S that I keep around for when I don't have a computer with me (har har), as it has great battery life and a screen that'll go to 180 degrees on its hinge. It's small, fits nicely on my lap, and there's plenty of space to fit this little thing in front of the steering wheel when I'm sitting around for a while and want to hack a bit. The keyboard and trackpad are pretty crappy, but for the price, I'll manage. (Occasionally, yes, I couple it with my ThinkPad Compact USB keyboard. That thing is wonderful, even if it isn't backlit.)

I consider the 100S my off-brand MacBook Air.

But the 1366x768 screen is pretty small. When I'm using Visual Studio [sic], it's nice to keep those three tool windows somewhere else so that I can still see the code. Much easier than all the window rearranging I used to do.

Labels: ,


posted by ruffin at 11/11/2016 07:39:00 PM
Wednesday, August 24, 2016

Perhaps the most important Visual Studio trick to know about the Immediate Window: To print something with all the newlines and carriage returns "invoked", so to speak, you suffix the string in question with ,nq.

Say you're debugging some SQL. This isn't horribly useful...

String with linebreaks rendered in immediate window

It's all on one line with \r\ns all over the place.

Let's try it again with ,nq afterwards...

SQL formatted without carriage returns and newlines

For some reason, I've got the SQL indented like mad (okay, okay, it's so it lines up in Visual Studio. This is a quick and dirty utility service that has embedded SQL), but you get the point. It's actually legible with the ,nq suffix.

I could've sworn I'd posted this before, but couldn't google it up in my own blog in a minute or less, so here we go again, proper keywords attached.

Labels: ,


posted by ruffin at 8/24/2016 10:46:00 AM
Tuesday, August 18, 2015

Customize how Find in Files results are displayed in the Find Results Window - The Ultimate Visual Studio Tips and Tricks Blog - Site Home - MSDN Blogs

You can customize your Find in Files results to show what you want to see and how you want to see it.

Example: You don’t want to view the entire file path shown in the Find Results tool window.

Surely he jests. Right? No, fellow mere mortals, he does not.
  1. Open up RegEdit
  2. Go to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Find
  3. Add a new string called Find result format with a value of $f$e($l,$c):$t\r\n
 Gamechanger. ;^) It’s the little things, man, the little things.


UPDATE 6 July 2018: This got a lot more complicated. From that answer (and, now, personal experience): You now have to load what’s essentially a compressed version of a registry key set that lives in %localappdata%\Microsoft\VisualStudio\15.0_[instanceid]{RootSuffix}\privateregistry.bin, mount privateregistry.bin in RegEdit, do the same string value hack as above, then dismount privateregistry.bin from RegEdit. Bizarre.

But it’s even more bizarre that this isn’t a “real”, supported setting in Visual Studio yet.

Labels: ,


posted by ruffin at 8/18/2015 04:32:00 PM
Saturday, September 27, 2014


Look, I appreciate that you're trying to save me keystrokes when I type try[tab][tab]. That you put the selection onto Exception so that I can immediately overwrite it is exceptionally thoughtful as well.

But come on, you can just check the prefs to see that I don't want you polluting my source with tab characters. Might be nice if you smart-tabbed[-as-spaces] the try-catch block to the context of the code around it too, you know?

Sometimes I feel you only pretend to care. It's a complicated relationship we have, isn't it? ;^)

Labels: ,


posted by ruffin at 9/27/2014 01:11:00 PM
Tuesday, April 29, 2014

People. Paper. Electrons | Visual Studio: Show active file in solution explorer:


There is actually a setting in Visual Studio that does this automatically.

Tools โ€“ Options โ€“ Projects and Solutions โ€“ Track Active Item in Solution Explorer


That works, but it's awfully Solution Explorer spammy.  I've installed the "Collapse Selection in Solution Explorer" add-on already just to combat my own spam...  we'll see, I guess.

Update 20150730: This function is in VS 2012+ by default, as advertised.

Labels: ,


posted by ruffin at 4/29/2014 09:59:00 AM
Saturday, November 02, 2013

suo file, what is this ?:

NO, do not add it to your CM system.

The .suo files contain user dependant information, like the state of the solution explorer (collaps all nodes, close the solution, delete the file and you'll notice that the nodes in the solution explorer are expanded again).

 More than that, if you keep your files in your Document's folder on Windows, it's got your login name in it as well.  /sigh

Labels: ,


posted by ruffin at 11/02/2013 08:41:00 PM
Tuesday, September 24, 2013

Can I save the window layout in Visual Studio 2010/2012? - Stack Overflow:

There's a nice Visual Studio plugin that lets you save and load custom window layouts: http://perspectives.codeplex.com (you can also find it in the VS gallery).

I use it because I often have to switch between a three screens layout(when my laptop is docket) and a single screen layout (laptop display only).

Wish I'd googled that a little earlier on.  I've driven myself crazy rearranging windows when I go from three screens docked in the office to one with the laptop on its own to two at home (where I don't have my usb video out...  at some point, I should consider getting another usb to video, but my personal Lenovo can output to two more displays and its built-in display doesn't stink like my work computer's does.  (Overshare alert.))

Labels: ,


posted by ruffin at 9/24/2013 10:08:00 AM
Friday, June 14, 2013

Collapse Selection In Solution Explorer extension

Many Visual Studio users have a solution tree structure with multiple projects and solution folders that are organized as a deep hierarchy. To avoid visual pollution, users want only those projects expanded that are being actively developed (often with many of the projectโ€™s child nodes recursively collapsed). To accomplish this task, they have to manually collapse each node recursively โ€“ an onerous chore if one has a deeply nested solution tree. The Collapse Selection in Solution Explorer extension addresses this particular issue by enabling the user to recursively collapse multiple nodes with a single click.

Thank heavens (and SO).  Wonder why it took me that long to Google it up.

Labels: ,


posted by ruffin at 6/14/2013 11:40:00 AM
Tuesday, May 14, 2013

customization - How to exclude private members from StyleCop rule SA1600 - Stack Overflow:

Right click on your project node in Visual Studio, select StyleCop Settings. On the Rules tab, select the Documentation Rules node. In the right-hand pane, select the Ignore privates checkbox, and\or unselect the Include fields box. Either of these will achieve the desired effect.

Thab bu berry buch.

Labels: ,


posted by ruffin at 5/14/2013 09:18:00 AM
Monday, May 13, 2013

Hide the Status Bar - The Ultimate Visual Studio Tips and Tricks Blog - Site Home - MSDN Blogs:

This one falls into the โ€œHuh?โ€ category. If you go to Tools >>> Options >>> Environment >>> General and uncheck the โ€œShow status barโ€ option. It will remove the status bar from view.

Awesomepants, especially on under-pixeled laptop displays.

Labels: ,


posted by ruffin at 5/13/2013 02:59:00 PM
Thursday, January 03, 2013

Javascript .NET - Documentation:

This section provides documentation to get quickly started to embed and run Javascript .NET in your application.

The project you were looking for is  Javascript.NET, which is/uses (?) Noesis.Javascript, which embeds the "Google V8" javascript engine.  Enjoy, profit, whatever.

Found that by chasing down how the JSLint plugin for Visual Studio worked.

Labels: , , ,


posted by ruffin at 1/03/2013 09:51:00 AM

<< Older | Newer >>


Support freedom
All posts can be accessed here:


Just the last year o' posts:

URLs I want to remember:
* Atari 2600 programming on your Mac
* joel on software (tip pt)
* Professional links: resume, github, paltry StackOverflow * Regular Expression Introduction (copy)
* The hex editor whose name I forget
* JSONLint to pretty-ify JSON
* Using CommonDialog in VB 6 * Free zip utils
* git repo mapped drive setup * Regex Tester
* Read the bits about the zone * Find column in sql server db by name
* Giant ASCII Textifier in Stick Figures (in Ivrit) * Quick intro to Javascript
* Don't [over-]sweat "micro-optimization" * Parsing str's in VB6
* .ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture); (src) * Break on a Lenovo T430: Fn+Alt+B
email if ya gotta, RSS if ya wanna RSS, (?_?), ยข, & ? if you're keypadless


Powered by Blogger etree.org Curmudgeon Gamer badge
The postings on this site are [usually] my own and do not necessarily reflect the views of any employer, past or present, or other entity.