Pull to refresh
107.44

C# *

Multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines

Show first
Rating limit
Level of difficulty

Check how you remember nullable value types. Let's peek under the hood

Reading time 10 min
Views 838
image1.png

Recently nullable reference types have become trendy. Meanwhile, the good old nullable value types are still here and actively used. How well do you remember the nuances of working with them? Let's jog your memory or test your knowledge by reading this article. Examples of C# and IL code, references to the CLI specification, and CoreCLR code are provided. Let's start with an interesting case.
Read more →
Rating 0
Comments 0

Aspect-Oriented Programming (AOP) by source-level weaving

Reading time 39 min
Views 1.8K
image

Aspect-oriented programming is a very appealing concept for simplifying your codebase, creating clean code, improving modularity, structure of code and minimizing copy-paste errors.

Today, in most cases, weaving aspect's advices is implemented at the bytecode level, i.e. after compilation, a certain tool «weave» an additional byte code with the support of the required logic.

Our approach (as well as the approach of some other tools) is modifying the source code to implement aspect logic. With introduction of the .NET Compiler Platform (aka Roslyn), it is quite easy to achieve this goal, and the result gives certain advantages over the modification of the byte code itself.
Read more →
Rating 0
Comments 0

How to write Palindrome Polyglot Quines

Reading time 10 min
Views 2.5K
PalidromePolyglotQuine

I offer a solution to one beautiful task — writing code that outputs its text is valid for interpreters and compilers of different languages and is correctly executed when reversing its sources.


Not so long ago I learned about code that can be both interpreted in PHP and compiled to Java: PhpJava.java. As it turned out, this idea is not new: code which is valid for several compilers or interpreters is called a polyglot. It is possible to write such code because of the peculiarities of processing strings and comments in different interpreters or compilers.

Read more →
Total votes 3: ↑3 and ↓0 +3
Comments 0

Tree Structure in EF Core: How to configure a self-referencing table and use it

Reading time 4 min
Views 26K

One of the very common questions I am getting from .NET community is how to configure and use the tree structures in EF Core. This story is one of the possible ways to do it.


The common tree structures are file tree, categories hierarchy, and so on. Let it be folders tree for example. The entity class will be a Folder:


public class Folder
{
    public Guid Id { get; set; }
    public string Name { get; set; }      
    public Folder Parent { get; set; }
    public Guid? ParentId { get; set; }
    public ICollection<Folder> SubFolders { get; } = new List<Folder>();
}
Read more →
Total votes 1: ↑1 and ↓0 +1
Comments 1

Unicorns break into RTS: analyzing the OpenRA source code

Reading time 16 min
Views 580
image1.png

This article is about the check of the OpenRA project using the static PVS-Studio analyzer. What is OpenRA? It is an open source game engine designed to create real-time strategies. The article describes the analysis process, project features, and warnings that PVS-Studio has issued. And, of course, here we will discuss some features of the analyzer that made the project checking process more comfortable.
Read more →
Rating 0
Comments 0

Analysis of merge requests in GitLab using PVS-Studio for C#

Reading time 8 min
Views 580
image1.png

Do you like GitLab and don't like bugs? Do you want to improve the quality of your source code? Then you've come to the right place. Today we will tell you how to configure the PVS-Studio C# analyzer for checking merge requests. Enjoy the reading and have a nice unicorn mood.
Read more →
Rating 0
Comments 0

How the PVS-Studio analyzer began to find even more errors in Unity projects

Reading time 7 min
Views 648
image1.png

When developing the PVS-Studio static analyzer, we try to develop it in various directions. Thus, our team is working on plugins for the IDE (Visual Studio, Rider), improving integration with CI, and so on. Increasing the efficiency of project analysis under Unity is also one of our priority goals. We believe that static analysis will allow programmers using this game engine to improve the quality of their source code and simplify work on any projects. Therefore, we would like to increase the popularity of PVS-Studio among companies that develop under Unity. One of the first steps in implementing this idea was to write annotations for the methods defined in the engine. This allows a developer to control the correctness of the code related to calls of annotated methods.
Read more →
Total votes 3: ↑3 and ↓0 +3
Comments 0

How to find errors in a C# project working under Linux and macOS

Reading time 19 min
Views 721

Picture 8

PVS-Studio is a well-known static code analyzer that allows you to find a lot of tricky errors hidden in the source code. Beta testing of the new version has recently finished. It provides the possibility to analyze C# projects under Linux and macOS. The tool can also be integrated into the cross-platform IDE from JetBrains — Rider. This article will help you to get acquainted with these features using the example of checking the open source RavenDB project.
Read more →
Rating 0
Comments 0

Single line code or check of Nethermind using PVS-Studio C# for Linux

Reading time 14 min
Views 814

Рисунок 1

This article coincides with the beta testing start of PVS-Studio C# for Linux, as well as the plugin for Rider. For such a wonderful reason, we checked the source code of the Nethermind product using these tools. This article will cover some distinguished and, in some cases, funny errors.
Read more →
Total votes 3: ↑3 and ↓0 +3
Comments 0

How does strange code hide errors? TensorFlow.NET Analysis

Reading time 15 min
Views 849

PVS-Studio and TensorFlow.NET

Static analysis is an extremely useful tool for any developer, as it helps to find in time not only errors, but also suspicious and strange code fragments that may cause bewilderment of programmers who will have to work with it in the future. This idea will be demonstrated by the analysis of the TensorFlow.NET open C# project, developed for working with the popular TensorFlow machine learning library.
Read more →
Total votes 3: ↑2 and ↓1 +1
Comments 0

Continuous integration and deployment for desktop apps with GitHub Actions

Reading time 2 min
Views 2.2K
From speaking to desktop developers, we’ve heard that you want to learn how to quickly set up continuous integration and continuous deployment (CI/CD) workflows for your WPF and Windows Forms applications in order to take advantage of the many benefits CI/CD pipelines have to offer, such as:

  • Catch bugs early in the development cycle
  • Improve software quality and reliability
  • Ensure consistent quality of builds
  • Deploy new features quickly and safely, improving release cadence
  • Fix issues quickly in production by rolling forward new deployments

That’s why we created a sample application in GitHub to showcase DevOps for your applications using the recently released GitHub Actions.

Read more →
Total votes 2: ↑2 and ↓0 +2
Comments 0

Zero, one, two, Freddy's coming for you

Reading time 23 min
Views 1.3K

Рисунок 1

This post continues the series of articles, which can well be called «horrors for developers». This time it will also touch upon a typical pattern of typos related to the usage of numbers 0, 1, 2. The language you're writing in doesn't really matter: it can be C, C++, C#, or Java. If you're using constants 0, 1, 2 or variables' names contain these numbers, most likely, Freddie will come to visit you at night. Go on, read and don't say we didn't warn you.
Read more →
Total votes 2: ↑2 and ↓0 +2
Comments 0

PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps

Reading time 9 min
Views 578

Рисунок 1

We continue making the use of PVS-Studio more convenient. Our analyzer is now available in Chocolatey, the package manager for Windows. We believe this will make it easier to deploy PVS-Studio, particularly in cloud services. So right off the bat, we also checked the source code of the same Chocolatey. Azure DevOps took on the role of the CI system.
Read more →
Total votes 1: ↑1 and ↓0 +1
Comments 0

Authors' contribution