How to analyze external code high CPU usage in .NET applications
1. Be kind We are all learning. It is often easy to forget that when one has been hyper-focused on a specific code base or area. The memories of struggles one had to overcome to reach such expertise faint and expectation of pull request authors may become unbalanced.
Most people will do their best before putting their work out there for others to scrutinize. Critique, but kindly. Especially to new people.
Often times I want to spin off a new terminal window on the current directory I am working on. I use gnome-terminal, and if you just type in ‘gnome-terminal’ it does spawn a new terminal process on the current directory; but more often than not I am just using my i3 shortcut to open a new terminal window (ctrl+enter); but that just opens it on $HOME.
To make i3 open a new terminal, I thought of:
I was trying to debug some file access mssql-server process was trying to do with strace. It wasn’t quite working so I decided to let strace start the process:
sudo strace /opt/mssql/bin/sqlservr Well, I was able to get the traces I needed, but as expected it ran the process as root.
When SQL Server starts, it will write some files under /var/opt/mssql, like log and other system files. Turns out that it does update some of those files on and changes the user and group file permissions to root right away.
The other day I got a code review comment saying that I should implement the full blown disposable pattern for IDisposable including the protected virtual void Dispose(bool disposing) method. For a long time I had implemented the IDisposable without caring about the additional overload - and I started worrying how many bugs I’ve introduced by not doing so.
The pattern The most recent official documentation I could find describes the pattern in details, which I’ll summarize below.
When writing a Visual Studio extension, you pretty much need to use Visual Studio services for everything. Put simply, a service in this context, is an object that implements an interface that exposes functionality to interact with different parts of the IDE. For instance, a common service used to deal with the Visual Studio editor is the EnvDTE.DTE.
If you are building a VSPackage then likely you have used the System.
Today I was reviewing a colleague’s code and I saw a pattern similar to the one below:
I’ve been using freerdp for a while - the command line specifically.
It is quite verbose, however, to keep passing all the necessary arguments when calling freerdp, so a pretty common approach is to put all that in a script file and call it instead. But now, to avoid storing passwords in clear text in that file, you have to prompt for it in the beginning of the script. The next step, as I had to connect to different machines, is to duplicate that script.
With Visual Studio 2017, MSBuild and NuGet are better integrated, which removes the need for things like package.config, as packages can be tracked in the csproj directly, and custom MSBuild targets for packaging like NuProj, as one can now do it all from the csproj with the built in functionality in MSBuild 15.
All that is great, but I found myself stuck with an old SQLPROJ. I wanted to generate a NuGet package out of it.
Lots of ways to do this out there, ranging from “too much code” to “but, why?”. Here’s how I chose to do mine: