Pull to refresh
61.27

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 time10 min
Views848
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 →
Rating0
Comments0

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

Reading time39 min
Views1.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 →
Rating0
Comments0

How to write Palindrome Polyglot Quines

Reading time10 min
Views2.6K
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
Comments0

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

Reading time4 min
Views26K

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
Comments1

Unicorns break into RTS: analyzing the OpenRA source code

Reading time16 min
Views588
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 →
Rating0
Comments0

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

Reading time7 min
Views656
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
Comments0

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

Reading time19 min
Views728

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 →
Rating0
Comments0

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

Reading time14 min
Views824

Рисунок 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
Comments0

How does strange code hide errors? TensorFlow.NET Analysis

Reading time15 min
Views857

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
Comments0

Continuous integration and deployment for desktop apps with GitHub Actions

Reading time2 min
Views2.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
Comments0

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

Reading time23 min
Views1.4K

Рисунок 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
Comments0

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

Reading time9 min
Views586

Рисунок 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
Comments0