tools

Visual Studio Extensions that will make your life easier in 2020

Visual Studio Extensions that will make your life easier in 2020

Xaml Styler

Download Link: https://marketplace.visualstudio.com/items?itemName=TeamXavalon.XAMLStyler

Project Site: https://github.com/Xavalon/XamlStyler

In Visual Studio 2019, writing XAML normally ends up in very long lines because it does not automatically break into new lines. In May 2019, I discovered the Xaml Styler extension by watching a video on Channel9.

Xaml Styler, even in its default configuration (which I did never change, tbh), breaks your XAML code into new lines once the count of properties of an element exceeds a certain amount. The extension as tons of options to configure, but for me, the default config always worked well.

Here is a sample:

As you can see, the XAML file is a by far more readable now. The different colors on the namespace declarations and closing tags are coming from the next extension on my list.

Viasfora

Download Link: https://marketplace.visualstudio.com/items?itemName=TomasRestrepo.Viasfora

Project Site: https://viasfora.com/

Viasfora aims to make your code more readable. To achieve that goal, it is coloring the code inside Visual Studio. The coloring makes it easy to see the scopes of each line, method, and even classes. As I discovered the extensions only a few weeks ago, I decided to not change any of the default settings, but it is already making my code a whole lot more readable.

Here is a sample from one of my recent projects:

VSColorOutput

Download Link: https://marketplace.visualstudio.com/items?itemName=MikeWard-AnnArbor.VSColorOutput

Project Site: https://mike-ward.net/vscoloroutput/

Ever tried to search the Visual Studio output for warnings, build errors or exceptions? Of course, you did. VSColorOutput makes this search a whole lot easier, as it colors errors/exceptions in red, warning in yellow, and build success messages in green. You see everything at a glance, which can save you a lot of time. See yourself:

CodeMaid

Download Link: https://marketplace.visualstudio.com/items?itemName=SteveCadwallader.CodeMaid

Project Site: http://www.codemaid.net/

CodeMaid is a very powerful extension. I am pretty sure I am not even using half of its functions, to be honest. I mainly use it to let it automatically sort my code files to my gusto and let it generate regions around it. This way, my code stays always organized in the same way and I don’t even have to think about it. I will explore more of the other functions moving onwards.

Here is a sample of a code file after CodeMaid cleaned it up (collapsed regions):

Material icons generator

Download Link: https://marketplace.visualstudio.com/items?itemName=nikainteristi.Materialiconsgenerator

Project Site: https://github.com/interisti/vs-material-icons-generator

If you are developing mobile applications, chances are high you will need one or another icon within an app. Material icons generator tries to replicate the popular function of Android Studio, with the added bonus of making it also available for iOS and UWP apps. The extension sadly does not create Image Asset folders and .json files for iOS correctly, but it creates the images so one can create an Image Asset from it in just a minute. The project does seem to be actively developed according to Github – I put this extension on the list because I did not find a better alternative until now.

Markdown Editor

Download Link: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor

Project Site: https://github.com/madskristensen/MarkdownEditor

If you have to deal with Markdown files, there are floating quite a few helper apps around the web. I prefer to work on them in Visual Studio, as I use Markdown most of the time on Github when writing readme or similar files. Markdown Editor makes it easy to do so, and I almost immediately see the result in the preview window, which is quite helpful from time to time.

The extension is written by the creator of Markdig, which is by far your best option if you have to deal with Markdown in your C# app. Here is a sample:

Regex Editor

Download Link: https://marketplace.visualstudio.com/items?itemName=GeorgyLosenkov.RegexEditorLite

Project Site: N/A

If you ever had to deal with validations, chances are high you solved it with Regex. The extension provides a bunch of options that will help you to write Regex-patterns. You can test it in the same Window with some sample data to verify it will do what it is supposed to do. As a bonus, it is able to create a sample method of how to use it if you want to. Here is what it looks like with an email verification pattern:

Conclusion

To kick off my blogging year 2020, I showed you some of the most helpful Visual Studio extensions I installed on my machine. I hope some of you will find the one or another extension as helpful as I do. If you have an extension that is not on my list and you consider it useful, feel free to sound off in the comments or via social media.

Until the next post, happy coding!

Posted by msicc in Dev Stories, 4 comments
How to host a code file on Github as Gist to use in your application

How to host a code file on Github as Gist to use in your application

What the h*** is a Gist?

In case you never heard of Gist, it is an easy to use way to share code files hosted by Github. Everyone with a user account can use this feature, and now that also the premium features are free (thanks to the acquisition by Microsoft), you can even share them secretly.

Where do I find my Gists?

This one is for the beginners. If you know this already, move on. Once you have logged into your Github account, click on your user name. This will open a menu where you can see an option called ‘Your gists’. Once you clicked that one, you will see a page similar to mine (maybe with no gists in it):

gist_overview_gists

How to create a new Gist?

Well, that’s pretty easy. You just click on the ‘+’-button besides your user avatar in the top right corner:

gist_menu_add_new

This will bring up a new gist window. Enter your description, file name and fill in the content of your file or even add more files and hit the ‘Create public gist’ button to create your new gist. If you intend to host multiple files in your gist, please note that you will need the following steps on every single file you add (as each one has its own url).

gist_add_new

How to use this Gist in my app?

Luckily, both files in Github repos as well as in gists can be viewed in the so called ‘Raw’ view. You will find a corresponding button on every code file in the top right corner. Click on it, and you will see a plain-text representation (here is a sample from the one that led to this block post. It is styled by a browser extension that makes json more readable (every developer should already have one of this type installed, btw)):

gist_raw_view

Now we are close to be able to fetch this file into our applications. If you are sure that this file will never change, just use this file. If you know that this file is subject for future changes, you will need to perform a little trick.

Getting always the latest version of our Gist

If you analyze the url, you will notice that there is a unique id between the ‘raw’ part and the file name:

gist_remove_this_id

This id represents the current revision of your Gist. To make sure we always get the latest version of our gist, we need to remove this id. The url must end with ‘raw/yourfile.extensions‘, as you can see here:

gist_always_latest_revision_url

This way, you can update the file and implement an update mechanism into your app that fetches always the latest revision of that file. To fetch the file content into your app, you just need to perform a GET request against that url, without the overload of using Github’s API.

Conclusion

Instead of hosting configuration or data files on a private web server, one can utilize existing infrastructure like the one of Github. Like always, I hope this post will be helpful for some of you.

Until the next post, happy coding, everyone!
Posted by msicc in Dev Stories, Xamarin, 0 comments