Make Apps Small Again. Trimming in .NET 5

0
Comments
Make Apps Small Again. Trimming in .NET 5

Because .NET Core supports self-contained deployment - runtime and framework libraries are deployed alongside the app, so the end use doesn't have to install .NET runtime. Even though this is a great feature if you want to distribute your app to the end users, it has the downside - the size. This is why .NET team developed mechanism called assembly trimming. During the publish process ILLink (the tool that does the trimming) "walk" though the code and identify the assemblies that are used by the code and remove the rest from the result bundle.

Read further...

NDepend - Keep Technical Debt And Code Quality Under Control

0
Comments
NDepend - Keep Technical Debt And Code Quality Under Control

First of all, NDepend is a static analysis tool for .NET that can be integrated into Visual Studio (as an extension) or used as part of your continuous delivery pipeline. It allows you to keep track of code quality, technical dept, and visualize the dependencies to get a better overview of the codebase.

Read further...

Blazor - It's Time to Forget JavaScript

0
Comments
Blazor - It's Time to Forget JavaScript

Blazor - build interactive, modular, and fast front-end applications in C#. Now you can finally forget about JavaScript and start using .net infrastructure to run your C# code in the browser. You can share classes, logic, and components between the backend and frontend. Try it now and you will never want to go back to JS.

Read further...

Install .NET Core 3.0 on Raspberry Pi

1
Comments
Install .NET Core 3.0 on Raspberry Pi

As you might now, .NET Core 3.0 SDK and Runtime are available on Raspberry Pi (actually, any Linux ARM32 or ARM64 architectures, as well as x64). With the new 3.0 version of .NET Core you can run your console or ASP.NET Core web site\api projects on a cheap 35$ device without any problems (do not expect high performance). We are using Raspberry Pi 3 to control our LinkedIn and Instagram automation (I will tell you about these projects when they are ready for public) via .NET Core console applications.

Read further...

Deploy and run .NET Core application without installed runtime. Self-contained applications.

3
Comments
Deploy and run .NET Core application without installed runtime. Self-contained applications.

.NET Core framework provides one very useful feature - Self-contained application. You don't need to install any .net runtime on your computer, you can just copy your application to the target host and run it. Furthermore, you can run it on any platform (Windows, Linux, OSX)! When you create a self-contained application, after publishing, you will see the whole .net runtime next to your application. There are some advantages: You do not need to have installed .NET Core on a target machine You ca...

Read further...

ZohoPeopleTimeLogger v1.4 - Smart filtering

0
Comments
ZohoPeopleTimeLogger v1.4 - Smart filtering

Changes: Show vacations only for currently logged in user (Previously, if you have access to other user's leave tracker you will see his days off as your vacation) Show only days off with Holiday and Sick type (Exclude 2hours short leave and others) Display leave type in calendar (Before was always Vacation, now Holiday or Sick) Download (GitHub) ZohoPeopleClient This C# library was also updated to v1.0.2. There are two new methods available in Fetch Record API: public enum SearchColumn { EMPLOY...

Read further...

C# 7.0 Pattern Matching. Part1

1
Comments
C# 7.0 Pattern Matching. Part1

Great news! You can already try new C# 7.0 features. All you need is Visual Studio 15 Preview. Let's start! Today we are going to talk about Pattern Matching and will look under the hood of this nice feature. Unfortunately, it is only partly available in VS 15. So we need to wait until next release. Or you can try to get latest Roslyn from GitHub. is operator The is operator is extended to test an expression against a pattern. With that you can replace this: object obj = "Hello, World!...

Read further...

C# 7.0 Local Functions

10
Comments
C# 7.0 Local Functions

C# 7.0 is coming! Even 6.0 is not released yet, you can already try new C# 7.0 features. To do that you need: Visual Studio 15 preview Set __DEMO__ and __DEMO_EXPERIMENTAL__ as Conditional compilation symbol in project settings. Not all of the new features available in current preview, but you can already play with some of them. But today we gonna look closer at Local Functions private static void Main(string[] args) { int LocalFunction(int arg) { return 42 * arg; } Console.WriteLine(LocalFuncti...

Read further...

ZohoPeopleTimeLogger v1.3 - Show me the error

0
Comments
ZohoPeopleTimeLogger v1.3 - Show me the error

At Novility, we have  found that we cannot log working time anymore. You just press "Make me happy" button and nothing :( When ZohoPeopleTimeLogger tries to make you happy it needs information about current jobs from ZOHO. For example, if I try to log time for January 16 and there is no job for this date I will get an error. But user was not able to see that error. That is fixed in release v1.3. Download GitHub User will see message box with detailed description and nice instructions:

Read further...

Build and test ASP.NET 5 application using AppVeyor

1
Comments
Build and test ASP.NET 5 application using AppVeyor

For those who do not know, AppVeyor is Continuous Integration and Deployment service for .NET projects. It is free for open-source projects. Currently, AppVeyor supports latest DNX version (1.0.0-rc1-final) and I've recently migrated my pet project to this version. I will show you how easy it is to build and run all unit tests on CI server every time you commit to GitHub. Visual Studio project (MSBuild) In LearnWordsFast project we are using Visual Studio 2015 as a development environment, so in...

Read further...

ZohoPeopleTimeLogger v1.2 - Special for Andre

0
Comments
ZohoPeopleTimeLogger v1.2 - Special for Andre

Because Andre is so special, the previous version of ZohoPeopleTimeLogger was not working with his account. I've fixed couple issues in the program to make him happy. Now, my friend, you can enjoy this lovely program! This release (v1.2) is dedicated to you! Download Now seriously! There was a small issue in a way I got information from zoho. I used user email to get user specific data (time log) but as I found out it is case sensitive, so Andre@something.com and andre@something.com are differen...

Read further...

ZohoPeopleTimeLogger v1.1 Even Smarter Than Before

0
Comments
ZohoPeopleTimeLogger v1.1 Even Smarter Than Before

Yes! It finally happened. New version of ZohoPeopleTimeLogger released :) Download In ZohoPeopleTimeLoger v1.1 you don't need to think about your time tracking at all! This smart program will do everything for you. Do you have any booked vacation in this month? Not a problem. Press "Make me happy!" button and ZohoPeopleTimeLogger will fill all days in this month except vacations   The same with public holidays! It will leave them empty... But, wait for this..... You can now fill in a single...

Read further...

ZohoPeopleTimeLogger v1.0.0 Keep Your Time Tracker Up-To-Date

0
Comments
ZohoPeopleTimeLogger v1.0.0 Keep Your Time Tracker Up-To-Date

Are you tired of filling in monthly time reports in Zoho People because of it's stupid UI? Then ZohoPeopleTimeLogger is just a right solution for you. Only one button which will make you happy! One click and you are done!   How does it work? ZohoPeopleTimeLogger will automatically find Job that is relevant for the selected month and will fill each empty day with 8 non-billable hours. That's all! If you don't need any of those days, just press a delete button... Easy, right? So why do you st...

Read further...

[ASP.NET 5] Production Ready Web Server on Linux. Run Kestrel In The Background

3
Comments
[ASP.NET 5] Production Ready Web Server on Linux. Run Kestrel In The Background

In the previous article we have installed nginx as a "gate" for our ASP.NET 5 application. Today we will see how to start kestrel server in the background. We will do even more, we will create init.d script to control our APS.NET 5 application and start it on  the system's startup. The simplest way to start kestrel in the background from console: nohup k kestrel & But if you want to start your application at the system's startup you need init.d script. Eventually, we will have following comm...

Read further...

C# 6.0 await in catch/finally

2
Comments
C# 6.0 await in catch/finally

C# 6.0 become more asynchronous-friendly than before. Finally, you can use await keyword in catch and finally blocks! Here is example: class Program { static void Main(string[] args) { do { Console.WriteLine("Before caller " + Thread.CurrentThread.ManagedThreadId); CallerMethod(); Console.WriteLine("After caller " + Thread.CurrentThread.ManagedThreadId); } while (Console.ReadKey().Key != ConsoleKey.Q); } public static async void CallerMethod() { try { throw new Exception(); }...

Read further...

[Raspberry Pi 2] Create C# Background Application for Windows 10 IoT Core

18
Comments
[Raspberry Pi 2] Create C# Background Application for Windows 10 IoT Core

In this article,  we will see how to create simple Web Server for Raspberry Pi 2 running Windows 10 IoT Core. Because it is a Web Server we don't need UI for this application, we can run it in headless mode. Open Visual Studio 2015 RC and create Windows IoT Core Background Application solution. Now we need a web server. This will be simple one. It will always response with "Hello, World!" string. internal class WebServer { private const uint BufferSize = 8192; public void Start() { StreamSocketL...

Read further...

[vNext] ASP.NET 5 Automatic Migrations with Fluent NHibernate

0
Comments
[vNext] ASP.NET 5 Automatic Migrations with Fluent NHibernate

As I said in the previous article, I am gonna tell you about Automatic migrations with NHibernate and Fluent NHibernate in ASP.NET 5 applications. Automatic migrations is a really powerful feature, but you should be also really careful with it. Sometimes it might corrupt your schema or even data. Now back to ASP.NET 5 and migrations. I have already explained how to install and configure Postgresql with NHibernate. To enable automatic migrations you need to modify configuration a bit: private sta...

Read further...

C# 6.0 Detailed Overview Of The New Features

0
Comments
C# 6.0 Detailed Overview Of The New Features

C# 6.0 has a lot of great new features, which save developer's time and make code more clean and short. At the conclusion of the C# 6.0 series let's go through the whole list of the new C# 6.0 features again (all titles are active). Each article contains detailed explanation of the particular feature with resulted IL code and "old-school" way of doing the same things. String Interpolation var a = 1.2345; Console.WriteLine($"test {a}"); Console.WriteLine($"test {a} {a} {a}");...

Read further...

C# 6.0 Expression-Bodied Methods

2
Comments
C# 6.0 Expression-Bodied Methods

The last but not the least feature of the C# 6.0 that I am going to cover is expression-bodied methods. We all have experience writing single line methods: private string name; public override string ToString() { return "Name :" + name; } Now, we have shorter way of defining the same method: public override string ToString() => "Name: " + name; As you can see, now we can use lambda style to define method's body. But there is one difference from lambda expressions, we canno...

Read further...

C# 6.0 Index Initializers

0
Comments
C# 6.0 Index Initializers

Hi, folks! Today we are gonna talk about new indexer initialization syntax introduced in C# 6.0. As we know, we already have good way to initialize dictionary: var dic = new Dictionary<string, int> { {"Apple", 2}, {"Pear", 10} }; but in C# 6.0 we have a better way to do the same: var dic2 = new Dictionary<string, int> { ["Apple"] = 2, ["Pear"] = 10 }; As for me, it is a bit nicer because we already have curly brackets in the beginning and endin...

Read further...

C# 6.0 Exception Filters. try catch when

0
Comments
C# 6.0 Exception Filters. try catch when

Exception filters is a new C# 6.0 feature. Visual Basic.NET and F# have this functionality for a long time. That is because exception filtering was implemented in CIL but not in C#. Now, this technique available for us. That's how you can use it: try { Method(); } catch (Win32Exception ex) when (ex.NativeErrorCode == 0x07) { // do exception handling logic } catch (Win32Exception ex) when (ex.NativeErrorCode == 0x148) { // do exception handling logic } catch (Exception) { // log unhandled excepti...

Read further...

C# 6.0 Auto-Property Initializers

0
Comments
C# 6.0 Auto-Property Initializers

The next new feature of the C# 6.0 is auto-property initializers and get-only auto property. The main problem that they suppose to solve is immutable type declaration. Before C# 6.0, if you want to create immutable type with properties, you have no possibility to use auto property: public string Property { get; set; } So, you were forced to use regular get-only (read-only) property with read-only backing field: private readonly string prop; public string Prop { get { return prop; } } public Ctor...

Read further...

C# 6.0 nameof Operator

1
Comments
C# 6.0 nameof Operator

C# 6.0 has a lot of new features, one of them is nameof operator. Let's see how it's implemented internally and what we can do with it. This operator will help us get rid of "magic strings" in our code. We all know following use case: public void Method(int arg) { if (arg < 0) { throw new ArgumentOutOfRangeException("arg"); } } With nameof operator we can rewrite code in a nicer way: public void Method(int arg) { if (arg < 0) { throw new ArgumentOutOfRangeException(nameof(arg));...

Read further...

C# 6.0 Null Propagation Operators ?. and ?[]

1
Comments
C# 6.0 Null Propagation Operators ?. and ?[]

C# 6.0 introduced two new null-propagation operators: ?. and ?[]. They will make null reference check much easier. In this article, we will see how they work and how they implemented internally. We all know about NullReferenceException and how to avoid it in our code. We just need to check everything for null before accessing some fields\properties\methods. Null Propagation Operator ?. var str = GetString(); if (str != null) { return str.Length; } else { return 0; } Now we can use Null Propagati...

Read further...

C# 6.0 String Interpolation

0
Comments
C# 6.0 String Interpolation

One of the top ten requests on uservoice is String Interpolation. Today we are going to see how to use this feature and how it is implemented in C# 6.0. We all use similar expressions: var str = string.Format("Date: {0}", DateTime.Now); This is string interpolation in C# before 6.0. Now, in C# 6.0, we have new string interpolation technique: var str = $"Date: {DateTime.Now}"; There was nothing new added in to runtime, this is just a syntaxis sugar for "old shcool" interpolati...

Read further...

Raspberry Pi 2 Benchmark. Linux vs Windows

4
Comments
Raspberry Pi 2 Benchmark. Linux vs Windows

I have installed Windows 10 on Raspberry Pi 2, then I have created a simple C# application for it. Now, I am curious what is the difference in performance between Windows 10 IoT Core and Raspbian. To test that I will run a simple C# code on both OS. Code I will do a simple calculation in a loop and will run this code in multiple threads. The amount of threads - 4, because Raspberry Pi 2 has 4 cores. This will load CPU up to 100%. I know that I am using different CLRs and different compilators, b...

Read further...

[vNext] ASP.NET 5 Dependency Injection with Autofac

1
Comments
[vNext] ASP.NET 5 Dependency Injection with Autofac

In this part of the vNext tale, I am gonna tell you about dependency injection in ASP.NET 5 (vNext) stack. Default Dependency Injection container First, let's see what is shipped with ASP.NET 5 by default. There is already simple DI container. It gives you a possibility to register service with three different lifetimes: scope, singleton and transient. For now it supports only constructor injection. Let's see how to use it and what is the difference between these lifetimes. Create empty ASP.NET...

Read further...

[vNext] Use PostgreSQL + Fluent NHibernate from ASP.NET 5 (DNX) on Ubuntu

7
Comments
[vNext] Use PostgreSQL + Fluent NHibernate from ASP.NET 5 (DNX) on Ubuntu

In the previous part we have installed APS.NET 5 application on Ubuntu, now we are gonna install and configure PostgreSQL on Ubuntu and access database from our application through NHibernate. Install and configure PostgreSQL First, install PostgreSQL: sudo apt-get install postgresql postgresql-contrib Next, set root password: sudo -u postgres psql postgres \password postgres And then create test database: sudo -u postgres createdb mydb Add Fluent NHibernate to the application Open project.json...

Read further...

[vNext] Install ASP.NET 5 (DNX) on Ubuntu

10
Comments
[vNext] Install ASP.NET 5 (DNX) on Ubuntu

ASP.NET MVC application on Linux? Easy! As you may know, Microsoft recently released a lot of their products under MIT license. .NET Core runtime, .NET CoreFX, ASP.NET 5, MVC 6, Entity Framework 7, MSBuild, everything is now available on GitHub. Our goal is: run Asp.Net MVC application with postgresql database on ubuntu server Today we are gonna start with setting up .NET environment. In the new asp.net stack you can choose between full .NET runtime and .NET Core. For now .NET Core has a lot of...

Read further...

[How-to] Record sound in .NET application

0
Comments

First import mciSendStringA from winmm.dll: [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)] private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); To start recording: mciSendString("open new Type waveaudio Alias recsound", null, 0, 0); mciSendString("set recsound time format ms bitspersample 16 channels 2 samplespersec...

Read further...