Pull to refresh
87.16

.NET *

A hub about .NET

Show first
Rating limit
Level of difficulty

Disposable pattern (Disposable Design Principle) pt.1

Reading time9 min
Views3.4K


Disposable pattern (Disposable Design Principle)


I guess almost any programmer who uses .NET will now say this pattern is a piece of cake. That it is the best-known pattern used on the platform. However, even the simplest and well-known problem domain will have secret areas which you have never looked at. So, let’s describe the whole thing from the beginning for the first-timers and all the rest (so that each of you could remember the basics). Don’t skip these paragraphs — I am watching you!


If I ask what is IDisposable, you will surely say that it is


public interface IDisposable
{
    void Dispose();
}

What is the purpose of the interface? I mean, why do we need to clear up memory at all if we have a smart Garbage Collector that clears the memory instead of us, so we even don’t have to think about it. However, there are some small details.


This chapter was translated from Russian jointly by author and by professional translators. You can help us with translation from Russian or English into any other language, primarily into Chinese or German.

Also, if you want thank us, the best way you can do that is to give us a star on github or to fork repository github/sidristij/dotnetbook.
Read more →

Building Games with MonoGame

Reading time1 min
Views2.7K
MonoGame is an Open Source implementation of the Microsoft XNA 4 Framework. It allows developers to create games for iOS, Android, MacOS, Linux, Windows, Xbox and PlayStation.

In this episode, Brian Peek comes on to talk to us about how to get started with MonoGame, and also show some interesting games that have been built with the framework.

Read more →

Memory and Span pt.1

Reading time7 min
Views3.6K

Starting from .NET Core 2.0 and .NET Framework 4.5 we can use new data types: Span and Memory. To use them, you just need to install the System.Memory nuget package:


PM> Install-Package System.Memory

These data types are notable because the CLR team has done a great job to implement their special support inside the code of .NET Core 2.1+ JIT compiler by embedding these data types right into the core. What kind of data types are these and why are they worth a whole chapter?


If we talk about problems that made these types appear, I should name three of them. The first one is unmanaged code.


Both the language and the platform have existed for many years along with means to work with unmanaged code. So, why release another API to work with unmanaged code if the former basically existed for many years? To answer this question, we should understand what we lacked before.


This chapter was translated from Russian jointly by author and by professional translators. You can help us with translation from Russian or English into any other language, primarily into Chinese or German.

Also, if you want thank us, the best way you can do that is to give us a star on github or to fork repository github/sidristij/dotnetbook.
Read more →

Universal C# Code for NET and JavaScript

Reading time18 min
Views6.5K

In 2013, while working at GFRANQ photo service, I participated in the development of an eponymous web service for publishing and processing photos. Filters and transformations were defined in the file with parameters, and all processing was carried out on the server. During service development, there was a need to support these transformations on the client side for the preview. According to Larry Wall, one of the virtues of a programmer is laziness. Therefore, as truly lazy programmers, we thought about the possibility of using the same code on both the server and client sides. The entire development was conducted in C#. After researching the libraries and a couple of attempts, we proudly concluded that this was possible and began to write the universal code.



Why is this article needed? Indeed, 6 years have passed since 2013, and many technologies have lost their relevance, for example, Script#. On the other hand, new ones have appeared. For example, Bridge.NET or Blazor based on the fancy WebAssembly.


Nevertheless, some ideas can still be used. In this article I tried to describe them as detailed as possible. I hope that the mention of Silverlight and Flash will cause a smile with a hint of nostalgia, and not a desire to criticize the old solutions. Anyway, they have contributed to the development of the web industry.

Read more →

An update to C# versions and C# tooling

Reading time3 min
Views3.4K

Starting with Visual Studio 2019 Preview 4 and RC, we’ll be adjusting how C# versions are treated in .NET tooling. Read more below <cut>.


Summary of changes


Firstly, we’re adding two new Language Version (LangVersion) values: LatestMajor and Preview. Here’s how they stack up with the currently supported list of values:

Read more →

Generating multi-brand multi-platform icons with Sketch and a Node.js script — Part #2

Reading time16 min
Views1.6K


This is the second part of a post about the creation of a pipeline that can take a Sketch file and export all the icons included in the file, in different formats, for different platforms, with the possibility of AB testing each icon.

You can read the first part of the post here.



The Sketch files, with all the icons collected, styled and properly named, were ready. Now it was time to start writing the code.

Suffice to say, the process was very much a trial and error: after the important initial code core, developed by my team lead Nikhil Verma (who set the script foundations), I went through an incremental process that required at least three phases of refactoring and quite a few revisions. For this reason, I won’t go into too much detail on how the script was developed, but rather focus on how the script works today, in its final shape.
Read more →

.NET Reference Types vs Value Types. Part 2

Reading time10 min
Views3.2K


The Object base type and implementation of interfaces. Boxing


It seems we came through hell and high water and can nail any interview, even the one for .NET CLR team. However, let's not rush to microsoft.com and search for vacancies. Now, we need to understand how value types inherit an object if they contain neither a reference to SyncBlockIndex, not a pointer to a virtual methods table. This will completely explain our system of types and all pieces of a puzzle will find their places. However, we will need more than one sentence.


Now, let's remember again how value types are allocated in memory. They get the place in memory right where they are. Reference types get allocation on the heap of small and large objects. They always give a reference to the place on the heap where the object is. Each value type has such methods as ToString, Equals and GetHashCode. They are virtual and overridable, but don’t allow to inherit a value type by overriding methods. If value types used overridable methods, they would need a virtual methods table to route calls. This would lead to the problems of passing structures to unmanaged world: extra fields would go there. As a result, there are descriptions of value type methods somewhere, but you cannot access them directly via a virtual methods table.


This may bring the idea that the lack of inheritance is artificial


This chapter was translated from Russian jointly by author and by professional translators. You can help us with translation from Russian or English into any other language, primarily into Chinese or German.

Also, if you want thank us, the best way you can do that is to give us a star on github or to fork repository github/sidristij/dotnetbook.
Read more →

Blazor 0.8.0 experimental release now available

Reading time6 min
Views1.9K

Blazor 0.8.0 is now available! This release updates Blazor to use Razor Components in .NET Core 3.0 and adds some critical bug fixes.


Get Blazor 0.8.0


To get started with Blazor 0.8.0 install the following:


  1. .NET Core 3.0 Preview 2 SDK (3.0.100-preview-010184)
  2. Visual Studio 2019 (Preview 2 or later) with the ASP.NET and web development workload selected.
  3. The latest Blazor extension from the Visual Studio Marketplace.
  4. The Blazor templates on the command-line:


    dotnet new -i Microsoft.AspNetCore.Blazor.Templates::0.8.0-preview-19104-04

You can find getting started instructions, docs, and tutorials for Blazor at https://blazor.net.

Read more →

I lost faith in the industry, burned out, but the cult of the tool saved me

Reading time6 min
Views35K


I often rail at technologies I find inadequate, and in response I receive (along with arguments) sheer anger and pain. Sometimes physical.

Developers take critique of their favorite technologies very personally for some reason. This “cult of the tool” is such a strange phenomenon I can’t explain it logically. Some say everyone’s prone to it, because a coder’s thinking processes intertwine very deeply with his programming language. Some say it’s a junior’s fallacy — you write something for the first time, it works, and you start treating your language like something divine.

Whatever it is, I never understood it.

I always considered cultists as imbeciles. But I always try to understand why imbeciles became them, why I’ve avoided that fate. I start thinking and bam! — it turned out I’m also an imbecile. I’m a cultist who worships F#. And, of course, there’s a story behind it.
Read more →

.NET Reference Types vs Value Types. Part 1

Reading time16 min
Views7.4K

First, let’s talk about Reference Types and Value Types. I think people don’t really understand the differences and benefits of both. They usually say reference types store content on the heap and value types store content on the stack, which is wrong.


Let’s discuss the real differences:


  • A value type: its value is an entire structure. The value of a reference type is a reference to an object. – A structure in memory: value types contain only the data you indicated. Reference types also contain two system fields. The first one stores 'SyncBlockIndex', the second one stores the information about a type, including the information about a Virtual Methods Table (VMT).
  • Reference types can have methods that are overridden when inherited. Value types cannot be inherited.
  • You should allocate space on the heap for an instance of a reference type. A value type can be allocated on the stack, or it becomes the part of a reference type. This sufficiently increases the performance of some algorithms.

However, there are common features:


  • Both subclasses can inherit the object type and become its representatives.

Let’s look closer at each feature.


This chapter was translated from Russian jointly by author and by professional translators. You can help us with translation from Russian or English into any other language, primarily into Chinese or German.

Also, if you want thank us, the best way you can do that is to give us a star on github or to fork repository github/sidristij/dotnetbook.

Read more →

Microsoft Q# Coding Contest – Winter 2019

Reading time3 min
Views1.8K

Microsoft’s Quantum team is excited to announce the Q# Coding Contest – Winter 2019! In this contest you can put your quantum programming skills to the test, solving quantum computing tasks in Q#. Winners will receive a Microsoft Quantum T-shirt!


Quantum computing is a radically different computing paradigm compared to classical computing. Indeed, it is so different that some tasks that are believed to be classically intractable (such as factoring integers or simulating physical systems) can be performed efficiently on a quantum computer. In 2017 Microsoft introduced the Quantum Development Kit which includes the Q# programming language. Q# can be used with Visual Studio, Visual Studio Code or the command line, on Windows, macOS, and Linux.


Read more →

Announcing TypeScript 3.3

Reading time5 min
Views1.1K

If you’re unfamiliar with TypeScript, it’s a language that brings static type-checking to JavaScript so that you can catch issues before you even run your code – or before you even save your file. It also includes the latest JavaScript features from the ECMAScript standard on older browsers and runtimes by compiling those features into a form that they understand. But beyond type-checking and compiling your code, TypeScript also provides tooling in your favorite editor so that you can jump to the definition of any variable, find who’s using a given function, and automate refactorings and fixes to common problems.

Read more →

Announcing F# 4.6 Preview

Reading time10 min
Views1.6K

We’re excited to announce that Visual Studio 2019 will ship a new version of F# when it releases: F# 4.6!


F# 4.6 is a smaller update to the F# language, making it a “true” point-release. As with previous versions of F#, F# 4.6 was developed entirely via an open RFC (requests for comments) process. The F# community has offered very detailed feedback in discussions for this version of the language. You can view all RFCs that correspond with this release here:



This post will detail the feature set and how to get started.

Read more →

The ever-lasting strife of static vs dynamic typing – TypeScript won’t help

Reading time6 min
Views5K


When my friend and I were of school age and aspiring to become software developers, we daydreamed of designing some cool stuff together – like a game or a mega-useful app.

I chose to learn C++ and C#, he picked JavaScript. We finished school, graduated from our universities, served in the army and started our jobs. We had a pretty busy time in industrial software engineering, with lots of different jobs and positions, and after it all started to wear on us, we recalled where it all had begun.

Having finally got together as mature developers, we decided to work on our own project – a 2D video game. Since my friend’s domain was front-end and I was a full-stack developer, our immediate choice of development platform was an Internet browser. As I was only used to working with TypeScript when designing front-end, we thought, ok, no problem, after all, TS is just JavaScript at scale. Let’s use it and things will go smoothly. If I only knew how wrong I was! When we started discussing the project, we ran into an extensive chasm of misunderstanding between us.
Read more →

Introducing the .NET Community Standup Series

Reading time2 min
Views885

We love our .NET community that is filled with amazing developers writing fantastic blogs, libraries, presentations, and pull requests every week. We are always looking for ways to highlight this amazing work, and for over 4 years the ASP.NET team here at Microsoft has been hosting their ASP.NET Community Standups live on YouTube and now Twitch.

During the stream, they show off the latest and greatest community contributions along with all of the great open source work that the teams have been doing. As the .NET community expands so should the community standups, which is why we are pleased to introduce the expansion of their community standups that we officially call the “.NET Community Standup” series. These community standups span multiple teams and products in the world of .NET and show off the amazing work the community is doing.


Read more →

Searching for errors in the Amazon Web Services SDK source code for .NET

Reading time17 min
Views1.5K

Picture 1


Welcome to all fans of trashing someone else's code. :) Today in our laboratory, we have a new material for a research — the source code of the AWS SDK for .NET project. At the time, we wrote an article about checking AWS SDK for C++. Then there was not anything particularly interesting. Let's see what .NET of the AWS SDK version is worth. Once again, it is a great opportunity to demonstrate the abilities of the PVS-Studio analyzer and make the world a bit better.
Read more →

The VS Code Roadmap 2019 — DRAFT

Reading time5 min
Views2.9K

As 2018 has come to an end, now is the time to look towards the future. We typically look out 6 to 12 months and establish topics we want to work on.


As we go we learn and our assessment of some of the topics listed changes. Thus, we may add or drop topics as we go.


We describe some initiatives as «investigations» which means our goal in the next few months is to better understand the problem and potential solutions before scheduling actual feature work. Once an investigation is done, we will update our plan, either deferring the initiative or committing to it.


As always, we will listen to your feedback and adapt our plans if needed.


Read more →

Authors' contribution