NDepend Spotlight

Today I am going to be doing a tool spotlight on NDepend. NDepend has a ton of features to help you keep a handle on your applications including the following plus much more.

  • Code Rules
    • 200 default rules with ability to add custom rules using LINQ
  • Quality Gates
  • Visual Studio Integration
  • Build Process Integration
  • Dependency Graph
  • Dependency Matrix
  • Technical Debit Estimation

For full disclosure, NDepend reached out to me to give their tool a try. I am writing based on my experiences with their tool and will be including both the positive and negative aspects of my experience. None of the links in this post are referrals that would in any way provide me any sort of payment.

Installation

The download is a zip file that you then have to find out what you want to do with. This was the first negative I hit with the product. While it isn’t hard to figure out it would be much nicer if this were an installer where I could select what I wanted to install instead of having to look at the getting started docs right away. For non-build usage, the options to run the tool is either via a Visual Studio extension (NDepend.VisualStudioExtension.Installer) or as a stand alone application (VisualNDepend.exe).

I chose to go explore with the Visual Studio extension. As a hint that I didn’t notice until later, VisualNDepend provides an option to install the Visual Studio extension in addition to providing all the functionality of the Visual Studio extension.

Visual Studio Extention

After installing the NDepend extension there will be a new top level NDepend menu in Visual Studio.

With the solution you want to analyze already open select the NDepend > Attach New NDepend Project to Current VS Solution.

This will launch a dialog that allows you to select which assemblies you would like to analyze preloaded with the assemblies for the current application.

As you can see from the dialog there are a lot of options. If your project has other assemblies or solutions that you would like to be included as part of the analyses they are easy to add. When finished adding items to analyze click the Analyze button at the bottom. I am using a small project for this entry and the process took less than 10 seconds. I also tried it on a large project (500k+ lines of code) and it took less than 30 seconds.

After the analyses are complete the extension shows a dialog asking what to do next as well as launching a web page with the results of the analyses if you kept the Build Report check box checked. Following are the options in the dialog.

From here I chose to View NDepend Dashboard, but also make sure and check out the report that the analyses generated as it provides a great summary at the end of all the issues found. The following is a part of the dashboard.

There is a ton of data provided. If you notice at the top there is a Choose Baseline option which would allow comparisons of solutions over time. I can see this view of a project over time is very helpful, but not a feature I will get to explore here.

Exploration

Exploration of the data NDepend provides is something I could spend hours looking at even on a small project. For example, the following is an output to HTML (their output is much prettier than the version that is shown here) of the issues that make up the critical group in the Rules box in the dashboard above.

4 rules Issues Debt Annual Interest Breaking Point Category Full Name
Avoid methods with too many parameters 1 issue 1h 9min 5min 4 522d Project Rules \ Code Smells Rule
Avoid non-readonly static fields 12 issues 32min 4h 0min 48d Project Rules \ Immutability Rule
Avoid namespaces mutually dependent 2 issues 30min 1h 1min 179d Project Rules \ Architecture Rule
Avoid having different types with same name 3 issues 30min 1h 0min 182d Project Rules \ Naming Conventions Rule
Sum: 18 2h 41min 6h 6min 4 933d
Average: 4.5 40min 1h 31min 1 233d
Minimum: 1 30min 5min 48d
Maximum: 12 1h 9min 4h 0min 4 522d
Standard deviation: 4.39 16min 1h 28min 1 899d
Variance: 19.25 34d 979d overflow

Here is the same view inside the Queries and Rules Edit window.

Double click any line will take you to a detail view showing a listing of the rule broken down by project, namespace, and class.

The same window also shows the query that was used to find the rule violations. For example, the above is powered by the following query.

The above is CQLinq or Code Query LINQ which is used to query the code model that the NDepend analysis creates. The detail of CQLinq are outside the scope of this post, but based on the above you can see how powerfully this could be.

Other considerations

Based on my usage to get the best value from NDepend your whole team would need to be licensed and making sure new code satisfies with all the rules your team wishes to follow. NDepend has a component that can be used as part of server based build processes which is needed, but I would want to use that component as a fail safe, not as a way to avoid buying licenses. If you use multiple computers it seems that you will need multiple licenses which will cause issues for some users.

Wrapping up

After trying NDepend out for awhile I am still amazed at the amount of data it provides. Not to mention the ability to add new queries and rules of your own. One blog post is never going to be enough to cover even a fraction of what this tool does. It feels like Resharper in it does so much that it takes a lot of time to learn and take advantage of the full set of features it provides.

First talk retrospective

I made it through my first lightning talk at the May meeting of the Nashville .NET user group. If you want some background you can check out this post on my preparation for the talk.

This post is going to be mostly for me to look back on in the future in case I decided to attempt another talk, but I am sure if someone is a new speaking it could be a useful as well.

Retro

Overall the talk went OK. There was no huge epic failure, but it far from a good talk. I was extremely nervous which lead to me be locked to the podium and flying through the talk way faster than I should have. I am pretty soft spoken and didn’t project as much as I really needed to. As a result of that is my points weren’t as clear as I would have liked.

David Neal was right that the audience does want you to succeed. There were a couple of questions at the end of my talk which made me feel that my point wasn’t totally lost. I got feedback for some of the audience members and other speakers which I included in the previous paragraph. All the feedback was presented to me in a kind manner which I greatly appreciated.

The future

In the future, if I try speaking again I have a lot of things I can improve on. I know that sounds negative, but I am looking at it as an opportunity to grow. I now know that I will need more time during the prepping stage to practice out loud and in front of people.

I love technology and sharing what I learn with others. That is one of the reasons I write this blog every week. Speaking may or may not be part of the future way I get to share with other, but I am happy to now know it is something I can do. It would require a ton of work, but it is no longer something I can’t ever see myself doing.

Visual Studio 2017 Error: The project doesn’t know how to run the profile IIS Express

I have a couple of computers I work between for the samples I use on this blog and when switching to between of them I got the following error last week.

The project doesn’t know how to run the profile IIS Express.

I verified the project would still run on the other computer with no issues. I also verified that on the computer with the issues the project would still work using  dotnet run from the command line still worked.

Next, I went to verify the project properties. Here I noticed a strange thing on the computer with the error the Debug tab of the project properties was missing a lot of setting. The following is a screen shot of the computer with the issues.

And here is the same tab on the same project, but from a different computer.

The cause

After more time that I would like to admit I was able to track down the issue. On the computer with the issue, I often work on projects that are very large which tend to slow down Visual Studio pretty bad. In an effort to speed things up a bit I when through and disabled all the extensions that I could including the Microsoft Azure App Service Tools. Turns out that disabling the previous extension caused the Microsft ASP.NET and Web Tools extension to be disabled as well (with no warning).

The solution

The only way I was able to get the project to work properly was to enable both the Microsft ASP.NET and Web Tools extension AND the Microsoft Azure App Service Tools extension. I am not sure why the Microsft ASP.NET and Web Tools extension need the Microsoft Azure App Service Tools extension but based on my experience they are related in some way.

Setting Up Visual Studio Code for Debugging ASP.NET Core

Visual Studio Code is a cross-platform source code editor from Microsoft. Out of the box, Code’s language support includes JavaScript, TypeScript, and Node. Using Codes extension system support is available for almost any language you want to use including C#, F#, Elixir, SQL, Swift, and Java. As of this writing, there are 734 language extensions available.

I have been using VS Code since it was first released after Build in 2015, but I have only been using it as an editor never taking advantage of the Debugging capabilities it has available. In this post, I am going to walk through everything that is needed to get a new ASP.NET Core with an Angular front end to run via VS Code’s debugger.

Test application

The first thing I did was to create a new application using JavaScriptServices specifically for this post. For instructions on how to use JavaScriptServices to generate an application check out this post.

On Windows, after the application has been generated and you are in the application directory you can use the following command to open the directory in VS Code.

I am sure there is something similar on Linux and Mac, but I don’t have the environments to try on.

VS Code Overview

When VS Code opens you will see a view close to the following.

The icons down the left side of the screen are for Explorer (shows currently open directory and files), Seach, Source Control (git support is built in), Debug, and Extensions.

Debug

The Debug tab will be our focus so click on it which will take you to the following view.

Using the gear with red circle select .NET Core as the environment for the project.

If you don’t see .NET Core listed click More… and click install for the C# option.

After selecting an environment VS Code will add a  launch.json file to the project. This file defines what happens when the start button is clicked in the debugger. At this point clicking the start button to run the application using the debugger will result in an error that  Could not find the preLaunchTask 'build'.

Next, click the Configure Task Runner option and select .NET Core.

This will add a task.json file with a build command that the launch.json is looking for. At this point, I had to restart VS Code to get it to properly pick up the new files. This seems to be an issue that will be fixed with the next release of VS Code and can be tracked using this issue.

After restart and trying to run the debugger again I ran into the error  Run 'Debug: Download .NET Core Debugger' in the Command Palette or open a .NET project directory to download the .NET Core Debugger.

I ended up having to uninstall and reinstall the C# extension and then opening a C# file to get the debugger to download. If you are having this problem make sure and open a C# file before going as far as reinstalling the C# extension.

Hitting run in the debugger now give the error  launch: launch.json must be configured. Change 'program' to the path to the executable file that you would like to debug.

To fix this issue click  Open launch.json and you will find two places with the following.

Change both places to point to the dll your application builds. In the case of my project named  DebugTest the final version ended up being the following.

Wrapping up

Debugging now works! Based on this post it would seem like debugging in VS Code is a big pain, but really after you get it set up once it just works. For new projects, you just have to let it add the

For new projects, you just have to let it add the launch.json and tasks.json and then set the path to your project’s assembly in launch.json. After that, you are ready to go.

I wait too long to figure this process out. I hope this helps you get started with debugging in VS Code.

Preparing for my first talk

I will be doing an intro lightning talk on JavaScriptServices at the May meeting of the Nashville .NET user group. The meeting will be over by the time this post comes out, but I wanted to share my outlook on it before hand.

Background

This will be the first time I have done any sort of talk since the required speeches I did in grammar and high school. In college, all the required speaking was attached to some sort of group work in which I was happy to do some extra legwork if another group member was willing to do the presentation.

Based on what I have written so far I am sure you have picked up on the fact that speaking is terrifying to me. Although I have forced myself into more social situations in the last few years it has done nothing to alleviate my fear of speaking to a group of people.

Motivation

Trying speaking is something that has been in the back of my mind for a few years. Speaking is an area I have always shied away from, but over the last few years listening to people like Scott Hanselman, Cory House, Jeremy Clark and David Neal among others and their take on speaking/giving back to the community planted a seed that speaking is something I need to try at least once.

David Neal’s talk on Public Speaking without Barfing on Your Shoes was especially encouraging to me. Here is a recording of the talk from the last Nodevember.

Preparation

I decided on JavaScriptServices because it has provided a great amount of value to personally and I want more people to be aware of it. With the topic in hand, I moved on to making an outline of what I want to cover. Since this talk should max out at 10 minutes my initial outline ended up needing to be scaled back.

The next thing I did was to create a checklist of all the thing I need to do before the talk. The following is an example of where it stands at the moment.

  • Flesh out the outline
  • Add important items for each point in the outline
  • Create and test demo
  • Test demo offline
  • Create a couple of slides
  • Practice out loud

Of the above having to practice out loud is the one I dread the most. I am not sure what it is about hearing one’s own voice, but it is always disconcerting.

 Wrapping up

I am still in the prepping stages and ever day that the talk gets closer the more nervous I get. There is also a level of excitement to see if this could be something I enjoy. It would be fun to have a new way to share my enjoyment and lessons learned outside of this blog.

I will post an update here or a full new post after the talk with how I felt it went. I will also hopefully have the feedback of a few others as well.

Communication Issues

My wife recently had an interesting experience with her cell phone company and this experience reiterated to me the importance of communication. This post is going to cover some high-level issues I encounter regularly.

For a bit of background here is a description of out experience with the cell phone company. First level support was awesome. They were responsive, kind, and mostly knew what they were talking about. Our case ended up getting passes to second level support and this is where things went bad.

Under communication

This company’s second level support was a perfect example of under communication. It was impossible for us to communicate with a second level support person we had to just sit around and wait for them to email us. In fact, even a first level support person could actually talk to a second level support.

The response took days of sitting around and hoping that our issues haven’t fallen through the cracks. The lack of communication ended with use changing cell providers based on the level of under communication. Had we been able to get a status or be told where the issue stood things would have turned out different.

It doesn’t matter if you are dealing with your family, customers or coworkers make sure to communicate what you are doing, what your expectations, what issues you are facing, etc. by providing this information everyone will be on the same page and have good expectations of each other.

Noisy communication

This issue comes up when you are communicating, but the idea being communicated is lost due to an unfocused message. Make sure that each of your points is concise and to the point.

To extend the cell phone example above a noisy version of describing the problem would be describing to the support person how angry the issues is making you, why the weather make you angry, the problem with the cell service, the cool new trick your dog did yesterday.

In the above, the really important bit is the problem with your cell service and the rest of it distracts and obscures what the actual point of the communication.

Dishonest communication

Intentionally providing wrong information for me is the worst communication offense. Missing leading someone either through omission of facts or a full blown lie is a sure way for any process to break down. I feel people try and make the best choices they can, but when making choices based on false or missing information the results aren’t good.

Another big issue with dishonest communication is when someone finds out that you have been dishonest with them if changes all future interactions in a very negative way.

Wrapping up

I have only listed three communication issues here that I seem to deal with for the most, but there are tons of more issues. Take time to evaluate your day to day communication and make sure your communication isn’t unclear for some reason. Don’t let some of this issues cost you customer, employees or friends.

Visual Studio 2017 error encountered while cloning the remote Git repository

Going through the process of getting Visual Studio 2017 installed on all my machines has been pretty smooth. The new installer works great and makes it much clearer what needs to be installed.

The issue

The one issue I have had, which was only an issue on one install, is an error when trying to clone a repo from GitHub. I say GitHub but really it would be a problem with any Git repo. The following is the error I was getting.

Error encountered while cloning the remote repository: Git failed with a fatal error.
CloneCommand.ExecuteClone

The solution

After searching I found a lot of things to try. I uninstalled and reinstalled Git for Windows multiple times using both the Visual Studio Installer and the stand alone installer. I finally stumbled onto this forum thread which had a solution that worked for me. The following is a quote of the reason for the issue and a fix posted by J Wyman who is a software engineer for Microsoft’s Developer Division.

After intensive investigation we were able to determine that Git was accidentally loading an incorrect version of libeay32.dll and ssleay32.dll due to library loading search order and precedence rules. Multiple users have confirmed that copying the binaries from the “<VS_INSTALL>\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin\” folder to the “<VS_INSTALL>\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core\” folder completely resolved the issue for him.

Any other users seeing similar problem should attempt the same solution.

I hope this gets other people up and running as it did me. My only worry about this fix is what happens with Git gets updated.

Two Years of Blogging

Wednesday will mark two years for this blog. This post is going to be a bit of a retrospective on my blogging journey so far.

Positives

A number of positive things have come out of maintaining this blog some of them I expected other were surprises.

  • Driver for learning new things
  • Opportunity to use new/different technology outside of my normal work
  • Helping people learn a new concept or get past a sticking point
  • New connections with people outside of my normal circles
  • Improvements to my written communication skills
  • Improvements in picking up new technology

Challenges

In addition to the above, the following is a list of things that challenged me. Some of them have helped me grow and others continue to give me problems.

  • Learning new things on a deadline
  • Self-applied pressure to meet my goal of a post a week
  • Not focusing on stats, shares, comment, etc.
  • Picking the right things to learn
  • Losing focus

Hosting challenges

I hit quite a few issues with my host this year. The biggest being multiple multi-day downtimes, high site load times, and difficult to implement SSL support.

In an attempt to address the second two problems I started using Cloudflare which worked well, but the lack of SSL support from my host cause some quirky issues.

All this led to me switching to NodeHost last month. That is a referral link that will give you a $5 credit when you sign up. NodeHost does all their hosting on SSDs and has built-in support for Let’s Encrypt which took care of my SSL problems. Getting a site setup initially was harder that on my old host, but it was totally worth the switch and ended up costing less.

Even with the hosting change I still recommend using Cloudflare. By using Cloudflare my host is having to handle around 50% few requests thanks to Cloudflare’s caching.

Top post of the year

It is interesting to look back and see which post have done the best over time. It is surprising to me that my first post is still in the top 5 post for the last year. One of my top posts was featured on ASP.NET community spotlight which always pushes way more traffic.

The next year

From where it stands now I see more than enough things in the ASP.NET Core/Aurelia/Angular areas to learn and they will continue to be my focus over the next year. I am especially excited that ASP.NET Core tooling to be complete and for Visual Studio 2017 to be released this year. I am also really looking forward to the .NET Standard 2 support to be released. With those two items taken care of, I will feel completely comfortable recommending ASP.NET Core it a much wider range of scenarios.

As always I am open to topic suggestions for topics and happy to answer questions. Thank you for the support of the last couple of years.

Handling the Holidays

Between the end of November and the beginning of January, it is harder than normal to keep blog posts and other such goals and tasks going.

This time of year involves more scheduled disruption then all of the rest of the year combined. For me having a fairly predictable schedule is important. Don’t take this to mean I need to do exactly the same thing every day, but knowing that I will have X number of hours at work and that I need to fit in Y number of hours to keep my blog updated is very helpful. The holidays disrupt this schedule and make it harder to fit in things like blogging, sticking to diets and exercise.

Don’t get me wrong this time of year is great! There is nothing like seeing my 5-year-old being excited for his birthday and Christmas. It is also a time when I get to see family more than normal which is great.

The following are some ideas I am kicking around to address some of the lack of progress I have during this time of year.

 Identify weak spots

A key to staying on track during the holidays is to identify weak spots ahead of time.  For example during this time of year I tend to spend way more time that I should be playing video games. It never fails that I somehow manage to open up Steam during the black Friday time frame and come across a game I have been wanting to play at a great price. The Witcher 3 is the game that got me this year.

I am using productivity as an example here, but keep in mind the same idea can apply to other areas of your life such as nutrition, exercise, etc.

Plan a counter

Once you have your main trouble spots identified come up with a plan to counteract them. This could happen a few ways. If you are struggling with something getting out of control set boundaries around that item that are measurable. For my video game example, I could use something like Rescue Time to monitor the amount of time I spend playing and use that data to keep myself in check.

Involve another person

Another great way to stay on track is to involve another person. Having to communicate progress (or lack thereof) to another person tends to cause people to better stick with our goals. We are social creatures (despite what “social” media is doing to us) that tend to not like to disappoint others.

Don’t compound failures

This one is huge. We are all going to fall short of our goals at some point and if you aren’t careful one failure can lead to a spiral of failures. An example of this from my life tends to happen with food. One day I will back off my diet and have something I shouldn’t. Next thing I know everything I have had to eat that day has gotten progressively worse. Now guess what happens the next day? You got it the day before was so bad why do better today. In fact, I end up feeling bad about myself which spirals into another bad day. This can continue to the point that two months of eating well is ruined in a handful of days.

The sooner you can stop the downward spiral the better. Don’t let one failure kick off a train of actions that you will regret. Accept that at times you are going to fail and that is OK as long as you don’t let it kick off a train of failures.

Make allowances and adjustments

Knowing that you are entering a time when disruptions are going to occur it is important to make plans for what allowances you are going to allow for yourself. Planning for a day off of a diet will hopefully allow a departure from the norm without the feeling of failure that comes with unplanned departures.

Another strategy for handling disruptive times with it comes to things like blogging is to adjust your schedule. Knowing that in two months a disruption is coming I can adjust my current writing schedule to get an extra post written every other week or so.

Final thoughts

This post is coming from a time of failure in my own life. I have failed in my goals for my diet, exercise, blogging and who knows what else. This post of a set of ideas I plan to use to improve my own life and minimize my future failures. I hope it provides value for others as well.

Comment with your thoughts and how you prevent and handle failure in your own life.

Upgrading to npm 3 or 4

As part of writing a post on getting Angular 2 working with ASP.NET Core I needed to upgrade to npm verson 3. All went well on my main machine, but when I tried it on my laptop things didn’t go so well. No matter how many times I ran  npm install -g npm the version returned via  npm -v always returned 1.4.9.

After a bit of googling I came across this post on Stack Overflow. The post also points to npm’s github wiki on the upgrade process which can be found here. I am going to go over the option that I used to get my laptop upgraded.

Open an administrator command prompt and navigate to the install directory for nodejs. This should be either  C:\Program Files (x86)\nodejs or  C:\Program Files\nodejs and then run  npm install npm@latest.

Now if you run  npm -v you should see a 3.x version of npm.

npm 4

Since writing this npm 4 has come out. The above should still apply if you find that npm is stuck as a previous version. Check out the npm release notes page for details.