Week 5, 2022 - Tips I learned this week
Tags: dotnet, azuredevops, vscode, tooling
Published: 2022-02-04 13:14:38

---
title: Week 5, 2022 - Tips I learned this week
published: true
date: 2022-02-04 00:00:00 UTC
tags: dotnet, azuredevops, vscode, tooling
canonical_url: https://techwatching.dev/posts/w05-2022-tips-learned-this-week
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsqkjf4tpjjxmvqv9gtm.jpg
series: Tips I learned this week
---

This week we talk about code analysis in .NET, cron expressions with crontab guru, diagrams in Azure DevOps wikis, and sending HTTP requests in VS Code.

## .NET tip of the week: configuring code analysis on your project

Static code analysis is great because it helps you to have a better code quality, and it allows you to detect potential issues or bad practices in your code directly from your IDE. I knew about Roslyn Analyzers and the possibility to configure which rules are enabled or not (with their level of severity) through an `.editorconfig` file. However, until I read this [article](https://endjin.com/blog/2022/01/raising-coding-standard-dotnet-analyzers.html) a few days ago, I did not know that you could set a [predefined code analysis configuration](https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#analysismode) just by setting an `AnalysisMode` property in your project file. This is great, especially if you don't want to lose time configuring all the rules individually in an `editorconfig` file. You can just choose the analysis mode you feel more appropriate and eventually disable a few rules that you don't want.

For instance, in this ASP.NET Core 6 project I created from the built-in template, I added an empty interface in the `Program.cs` file. By default I see a message indicating that I should declare my interface in a namespace.

 ![](https://techwatching.dev/posts/images/w052022tips_analysismode_1.png)

If I set the analysis mode to `Recommended`, the code analysis indicates to me the same thing but this time as a warning.

 ![](https://techwatching.dev/posts/images/w052022tips_analysismode_2.png)

If I set the analysis mode to `All`, then not only do I have the previous warning but I also have a warning to tell me I should not have an empty interface.

 ![](https://techwatching.dev/posts/images/w052022tips_analysismode_3.png)

There are also properties to only apply rules specific to a category (security for instance). You can check the [documentation](https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#analysismodecategory) to learn more about these.

## Tool of the week: crontab guru

You are probably using cron expressions in a lot of different contexts whether it be to schedule an Azure Function or to trigger periodically a CI/CD pipeline (GitHub Actions or Azure DevOps for instance). Cron expressions are useful but you might not use them often, which makes it hard to remember the syntax. `crontab guru` is a tool that helps you create cron schedule expressions or understand what existing cron expressions mean.

 ![](https://techwatching.dev/posts/images/w052022tips_crontab_guru.png)

It's really helpful, so add it to your [bookmarks](https://crontab.guru/).

## The Azure DevOps tip you did not know about: creating diagrams in markdown with Mermaid.js

If you are using Azure DevOps, you are probably writing your technical documentation in markdown in a wiki. I like the idea of having "documentation as code" with markdown stored in a git repository that keeps the history of changes. Yet, sometimes documentation is not just about text, you want to have diagrams to properly illustrate what your text is explaining. And you don't want to have these diagrams just stored as images in your repository but you want them within the markdown to be modified as easily as the text.

And guess what, that's possible thanks to `Mermaid.js`. As you can read on its website, [Mermaid.js](https://mermaid-js.github.io/) is a "JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically". It means that you can write in your markdown file some text that describes a diagram and it will be rendered by `Mermaid.js`. There are a lot of types of diagrams that you can create using `Mermaid.js` but Azure DevOps only [supports Sequence diagrams, Gantt Charts, and Flowcharts](https://docs.microsoft.com/en-us/azure/devops/project/wiki/wiki-markdown-guidance?view=azure-devops#add-mermaid-diagrams-to-a-wiki-page).

Here is an example of a diagram I created in an Azure DevOps wiki:

 ![](https://techwatching.dev/posts/images/w052022tips_mermaid_1.png)
## The VS Code extension you should try: Rest Client

[REST Client](https://github.com/Huachao/vscode-restclient) is an open source VS Code extension that allows you to send HTTP requests and view the responses as you would do with Postman. But I prefer using REST Client over Postman because with REST Client you write the HTTP requests in text files (using the RFC 2616 standard) that you can version in your git repository along with your code. REST Client is not something I discovered this week, I have been using it for quite a long time but it's still very useful to me so I thought this post was a good opportunity to tell you to try it if you have not yet.

 ![](https://techwatching.dev/posts/images/w052022tips_restclient.png)

In fact, it's quite funny because the [first article](https://www.techwatching.dev/posts/testing-your-api-with-rest-client) I wrote here on my blog was an article about REST Client, how to use it and why you should use it instead of Postman.

And that's it for this week, happy learning!