For tech-savvy people, knowing about upcoming features of their favorite software can come as thrilling. Wanting to make use of the changes ASAP, they often grasp for beta versions. Whereas it may often bring joy, by definition these builds are not properly tested and come with many bugs on-board.

Just as many other companies, Microsoft also offers beta builds of Windows 10 within the Windows Insider Program. Those who joined the program and signed up to receive Fast Ring updates, often experience huge bugs and look for a way to roll back. Doing so is not easy, but I’ll present 3 ways to do so anyway.

OPTION 0 – FOR THE NOVICES

If you joined the Program less than 10 days ago, can opt out easily. Simply go to Settings, then select Update & Security and click on the Windows Insider Program button on the left. On the right, under Go back to an earlier build, click the Get Started button if it is not greyed out.

Option 1 – Beta BUILD BECOMES STABLE

This option is very safe and doesn’t require any reinstalling of the OS. If you want to stop getting Insider builds and don’t mind waiting, simply go to Settings, click the Update & Security tile and then scroll down and click on Windows Insider Program. In the right pane, click Stop Insider Preview Builds. In the newly opened window, click the Stop Insider builds completely button and that’s it. You’ll only keep getting Insider builds until a stable version comes out at which point you will no longer be a member of the Windows Insider Program.

Option 2 – REINSTALL

If you have been using Insider builds for more than 10 days and don’t want to wait before going back to stable builds, this option should help you. Unfortunately, it requires reinstalling the OS. So be sure to back up any files, which you deem important prior to moving forward with this option!

After backing up your files, simply download Media Creation Tool, run it and select Upgrade now in the newly opened window. This will download a stable version of Windows and install it in place of the Insider build you are currently runnin.

While reading up on Xamarin.Forms, I came across some interesting properties within the
Color structure – the
Color.Transparent ,
Color.Accent and
Color.Default.

Color.Transparent

In the Xamarin.Forms documentation this color has the RGBA values of (255, 255, 255, 0). To a user this color seems transparent, meaning they don’t see it at all. In it’s essence though, it is just a red color with the alpha channel set to 0.

Color.Accent

The accent color is a very interesting one, since on all platforms this one means something different.

First it is worth noting, that Android as well as Windows Phone and Window, allow for accent color change. This is not true with iOS, though.

For the purpose of this article, I used the Android Emulator and iOS Simulator in Visual Studio to find out the exact RGBA color represenations. With Android I got
R: 1, G:0.250980406999588, B: 0.505882382392883, A: 1 and with iOS
R: 0.196078434586525, G:0.309803932905197, B: 0.521568655967712, A: 1. As you can see, the colors, in this case, are platform-dependent.

Also, if a user were to change his phone’s UI to a dark theme, we would get different results.

Color.Default

Xamarin.Forms APIs use this color as a default for most views. It’s RGBA values are all set to -1, which in normal cases wouldn’t form any real color.

With views, like a Label, their
BackgroundColor property is also set to
Color.Default. In this case, it is a transparent color. But while their
TextColor property is also set to
Color.Default, that one is actually dependent on the OS and the accent color.

Overall, this topic carries more that I could describe in a short article, but I hope you got the gist of it.

I have been thinking about this particular question a lot recently and I believe it is a great starter to this article series. This article is aimed at beginner developers and I’ll only discuss the key differences of both options.

So which one?

My major concern was simplicity – I am an impatient person and like to see some results ASAP – and also the UI-dependent aspects of native development, that I forgo with Forms. So how did I settle on one or another?

Beforehand, I should let you in on more context. I know the Swift programming language and the iOS environment, so my go to choice was native Xamarin.iOS. After consulting this with fellow developers and learning that Forms are all the more used in big companies, I decided to give them a go.

Furthemore, here you can check out a table to help you with the decision.

Xamarin.Forms pros

Xamarin.Native pros

One UI codebase for all platforms

Maximum customization of UI

Custom UI renderers enabling custom controls

Reuse of existing UI code (Interface Builder or AXML)

No need to know all the ins and outs of each platform

Works with all platform-specific APIs

In the next article we’ll look at the first bump on the road of taking up Xamarin.Forms.

In this article, we’ll talk about some of the extensions I use in Visual Studio. I do not consider this piece very technical, however I assume it might be interesting for some of you.

But…why the title?

Figure 1

I get it, you don’t understand the title. But let me explain. The very reason I used the negative, was to say one thing which applies to all extensions. They are going to be performance hogs. Regardless of whether we are talking about an extension as huge as ReSharper or one as small as WakaTime, the drawbacks will always exist.

Now let’s get to the extensions.

WakaTime

The companion extension to the famous web app. With a simple installation, prompting only for your account API key, this small service running it the background of Visual Studio allows me track how much time I code. It also gathers information about the time spent working on a specific project and how long I have been coding in a given language. Later I can compare my results with fellow developers from all over the world. According to their website, this extension supports 43 IDEs and editors, so you can continue tracking your progress even when working in other editors.

Markdown Editor

This is one extension I like to use mainly for aesthetic reasons. It doesn’t really bring much to the table in terms of development, but it is nice to see my Markdown file in a more graphical manner. It is also a good way to make sure I am writing valid Markdown.

ReSharper

I saved the most famous extension for last. Almost everybody in the C# industry has either used or heard about ReSharper – a tool developed by JetBrains, the guys and gals behind IntelliJ. It offers a completely revamped key scheme with a handful of shortcuts designed to speed up one’s workflow. Something I really love is refactoring automation. It constantly checks my project for redundant code or convention irregularities. Apart from that, it allows for easier navigation in my project.

Figure 4: Unreachable code of an if-else statement

However, it is one of the biggest extensions out there and often crashes when working on large projects. This extension also supports C++ development in Visual Studio.

Over the years, I got used to having all new projects created in the “Documents/Visual Studio 2017/Projects” folder. But for some reason, this setting was different when I recently opened Visual Studio. I spent a bit looking for a way to change it back and I believe I have found one!

Why would you want to do this?

After installing Visual Studio and hitting the New Project button, you are presented with a dialog window. Among many other settings, there is also a project directory at the bottom. This is generally “C:/Users/<your_account>/Documents/Visual Studio 2017/Projects”. While most people keep it this way, you might want all new projects be saved somewhere else, i.e. a Git directory.

HOW TO DO IT THEN?

It is very simple and very fast. All you need to do is fire up a new instance of Visual Studio 2017 (the same applies for earlier versions as well) and hit the Tools menu item at the top. Then select Options from the dropdown menu.

Open Visual Studio options

With the new window open, double-click Projects and Solutions in the left column and find the Locations row. On the right, you will find various text entries to tweak different settings in VS. The one you are interested in is dubbed Projects locations. Enter your new default project location here.

When editing HTML files in Visual Studio Code I have always been driven away by the weird auto-indentation when typing out closing tags. Since I am used to writing opening and closing tags before adding any further child elements, I have refrained from using VS Code for this purpose.

In the latest versions there seems to be certain improvement, though it still isn’t perfect. Therefore I decided to dig into the topic a little more and believe I found a solution to satisfy one’s needs. We shall achieve this by adding a simple line of JSON into user settings within Visual Studio.

How…?

We’ll start off by launching a new instance of Visual Studio and opening an HTML file. When adding some content as described above, we end up with something like this.

How I don’t like it!

You can clearly see that the body tag is indented to the right when it shouldn’t be. Though this might be a thing of personal preference I wanted to help those, who are feeling the same as me.

The workaround here is rather simple. Just bring up Command Palette using the Control + P (on Windows) or Command + P (on macOS) key combo and search for “user settings”. Another approach is to hit Control + , (on Windows) or Command + , (on macOS). This will open two JSON files. The one on the right will be empty. Here we will set the editor.formatOnSave setting to true. So make your file look like this.

Format on save

Now you can go back to your HTML file and hit save. VS Code will automatically format the file as to your desire.

Just recently I had to deal with WinForms for the first time in a long while and I stumbled upon an interesting thought. How would I go about making a custom WinForms TextBox with some kind of ‘uncommon behaviour’? I dug deeper into this subject, did some research on it and I think I have come up with something that is worth sharing.

Little intro

As far as simple WinForms projects are concerned, customising behaviour of their controls can be done easily. However, if your project requires some TextBoxes to work traditionally and others to have been inbuilt with some validation logic, I suggest you follow the steps described in this piece.

I am going to demonstrate this on a project, where every ‘a’ entered into a text box will become a ‘b’.

Let’s roll

To kick things off, create a WinForms project and name it whatever you want (I named mine
CustomWinFormsTextBox).

Create new project

Then right-click your project in the Solution Explorer and add a new class. I have chosen
CustomTextBox as it’s name.

Set the class name

After the class is successfully created, make it a child of TextBox. Then in order to add the described behaviour, override the
OnKeyPress method of the TextBox class. This method is called everytime we press a key on the keyboard while the TextBox is focused.

Edit OnKeyPress method

We are essentially checking if an ‘a’ has been pressed, in which case we would replace it with a ‘b’, that would then get displayed in the text box.

Now all that’s left to do is to add our
CustomTextBox to the Toolbox window so that we can drag-and-drop it onto our form. The Toolbox won’t offer you custom control just yet. First you have to build your solution. Then if you search for CustomTextBox you should see it appear in the search results.

Search Results

Now just simply drag and drop it onto the form, save your project and hit Start. If you try to enter ‘maniac’, the text box will show ‘mbnibc’.

Place CustomTextBox and Start the app

Although I know this won’t come to good use to everyone, I still think it is worth knowing about it.

In connection with the last article regarding the basic concepts of working with ASP.NET Core MVC, I came up with a little tweak to speed up your development by at least a small margin. To make things clear enough I won’t go into much technical detail.

Consider the situation in which we were last time. We successfully created a new project and went ahead to open it in Visual Studio Code. What we did and always can do is to launch a new instance of Code and open the project folder by navigating to it in the Finder dialog window. While this approach works, I will show you a quicker way to do it.

Setup

Essentially, all that is needed to be done is to invoke a command that will do all the work for us.

Launch Visual Studio

Press Command + Shift + P, which will bring up the Command Palette.

Enter “shell”.

Command Palette within Visual Studio Code

You should be presented with two results, one of them being “Shell Command: Install “code” command in PATH”. Click on this option and wait until the operation has completed. This usually takes no more that a second.

All is now setup. Let’s head to the usage!

Usage

So far, all seems a little easy, doesn’t it? Well…this part will be of no exception. Simply navigate to your project folder in a Terminal window and enter
code. . This will instantly open a new Visual Studio Code instance with the project loaded. No further hassle.

This tweak helped me and I hope it will make your workflow a bit snappier, as well.

For this article I decided that it would be appropriate to show off the process of installing and creating an ASP.NET Core MVC project on macOS. Also I will explain what you have to do differently when creating a web project instead of a console application.

Installation process

Microsoft’s ASP.NET Core website explains the installation part thoroughly. Nevertheless, here I prepared a short summary of what you have to perform prior to running the project.

Now since this article is about ASP.NET Core MVC you shall not follow the whole third step, because it advises to use
dotnet new. This would, by default, create a .NET Core Hello World console application and it’s respective project structure. Instead, enter
dotnet new-tweb into the Terminal window.

Terminal window with command to create new ASP.NET Core MVC project

After the command is executed you may proceed to step 4 (
dotnet restore — which will restore NuGet packages for the project and ensure that installed packages and it’s versions comply to those of the project.json file int the root folder — and
dotnet run which will start serving the project under http://localhost:5000).

Testing YOUR Project

If you now navigate to the above-mentioned localhost URL in your browser, you are presented with a default ASP.NET page known for many years as part of ASP.NET MVC.

Working with the project

At this point you can edit each file of your project as you like. When the page gets refreshed, all changes will be applied instantly — without the need to run
dotnet run in your Terminal window — and seen in your browser window.

I myself have struggled to create web application instead of a console application when it came to .NET Core CLI. Now I hope the process has been properly explained. However, if you ever get lost, feel free to use the
dotnet--help command. From there you will sure get to the bottom of your problem.

I know that many C# developers scratch their heads all the time, wondering how casting in really works and where lies the difference between the is and as keywords in C#.

Let’s dive in

To make this article easy to understand I won’t go into much detail.

For illustration purposes, imagine we have two classes – Car and Student. Obviously, these two classes do not belong to the same inheritance tree. All they have in common is that they both derive from System.Object. This piece of will be common for all upcoming examples.

Example time!

C#

1

2

Car car=newCar();

Student student=newStudent();

Explicit casting

Now that we have declared the two objects, we can perform a casting operation. We will assign the student object to the car object. Unfortunately, this will fail. Using explicit casting, we will be informed about such problem by an InvalidCastException, which means the remaining Console.WriteLine statement won’t be executed.

1

2

car=(Car)student;

Console.WriteLine("All went well");

As

If casting is valid, the car object will be assigned the value of the student object. Otherwise, it will have the value of null.

When using the as keyword, checks against the null value have to be carried out. This is done within the if statement. If all goes well, we should see “All went good” printed to the console.

1

2

3

4

5

car=student asCar;

if(studentPerson!=null)

{

Console.WriteLine("All went well");

}

Is

As far as the is keyword is concerned, we have a pretty straightforward and type-safe approach to deal with casting.

Within an if statement we simply check if the cast would be valid. Following this check, we can proceed to explicit conversion, a.k.a. explicit cast.

1

2

3

4

5

if(car isStudent)

{

car=(Car)student;

Console.WriteLine("All went well");

}

This method, however, is quite inefficient, because at first we check the types and then carry out the cast. It’s true in situations when we know the cast will go through.