We don't often get the chance to write something on parallel programming issues. This time we "got lucky". The TraceEvent standard method has some implementation peculiarities. They resulted in an error with multiple threads blocking. So we'd like to warn users about this nuance and cover this interesting case from our users support practice. Why was our support involved? Keep reading to find out. Enjoy the reading!
C# *
Multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines
.NET Application Optimization: Simple Edits Speeded Up PVS-Studio and Reduced Memory Consumption by 70%
We know many ways to detect performance problems, such as extremely low speed and high memory consumption. Usually tests, developers, or testers detect such applications' drawbacks. In the worst case, users find weaknesses and report back. Alas, detecting defects is only the first step. Next, we should localize the problem. Otherwise, we won't solve it. Here comes a question - how to find weak points that lead to excessive memory consumption and slow down in a large project? Are there such at all? Maybe it's not about the application? So now you're reading a story how PVS-Studio C# developers encountered a similar problem and managed to solve it.
The '?.' Operator in foreach Will Not Protect From NullReferenceException
Do you like the '?.' operator? Well, who doesn't? Many people like these concise null checks. However, today's article shows that the '?.' operator may be tricky sometimes. That is, it can create an illusion of safety when used in the foreach loop.
OWASP, Vulnerabilities, and Taint Analysis in PVS-Studio for C#. Stir, but Don't Shake
We continue to develop PVS-Studio as a SAST solution. Thus, one of our major goals is expanding OWASP coverage. You might ask, what's the use when there's no taint analysis? That's exactly what we thought — and decided to implement taint analysis in the C# analyzer. Curious about what we accomplished? Read on!
Multithreading in Photon
What this article is about
In this article, we will talk about multithreading in the backend.
• how it is implemented
• how is it used
• what can be done
• what we invented ourselves
All these questions are relevant only if you develop something for the server side - modify the Server SDK code, write your own plugin, or even start some server application from scratch.
One of the ways to dynamically deserialize a part of a JSON document with an unknown structure
In this topic, I will tell you how to dynamically parse and deserialize only part of the whole JSON document. We will create an implementation for .NET Core with C# as a language.
For example, we have the next JSON as a data source for the report. Notice that we will get this JSON in the runtime and at the compile step we don't know the structure of this document. And what if you need to select only several fields for processing?
Pitfalls in String Pool, or Another Reason to Think Twice Before Interning Instances of String Class in C#
As software developers, we always want our software to work properly. We'll do everything to improve the software quality. To find the best solution, we are ready to use parallelizing or applying any various optimization techniques. One of these optimization techniques is the so-called string interning. It allows users to reduce memory usage. It also makes string comparison faster. However, everything is good in moderation. Interning at every turn is not worth it. Further, I'll show you how not to slip up with creating a hidden bottleneck in the form of the String.Intern method for your application.
Shrinking .NET Console Application
Building console application can produce an unexpectedly much larger file than you would think due to implicit references.
What is the problem and how it can be solved?
SmartTraits or lets add «multiple inheritance» to C#
One of our clients, a developer who used to work with php technologies for quite some time, frequently complained that with the transition to C# and .Net stack, he misses one of his favorite features from the php world — traits and he would like it very much to be able to use such functionality in .Net.
At one point, we decided to make him a present and implemented a proof of concept of similar functionality for C#.
To our surprise, it was quite easy to implement the PoC and the process of development was a lot of fun.
Compilation of math functions into Linq.Expression
Here I am going to cover my own approach to compilation of mathematical functions into Linq.Expression. What we are going to have implemented at the end:
1. Arithmetical operations, trigonometry, and other numerical functions
2. Boolean algebra (logic), less/greater and other operators
3. Arbitrary types as the function's input, output, and those intermediate
Hope it's going to be interesting!
[Opinion] Lazy Properties Are Good. That Is How You Are to Use Them
Let me also say a word about properties. I'm going to consider a good use of them for immutable records in C#.
I am a big fan of code design, so in this article I want to cover existing approaches and show what, I think, is a better solution.
What Is yield and How Does It Work in C#?
C# capabilities keep expanding from year to year. New features enrich software development. However, their advantages may not always be so obvious. For example, the good old yield. To some developers, especially beginners, it's like magic - inexplicable, but intriguing. This article shows how yield works and what this peculiar word hides. Have fun reading!
What's new in AngouriMath 1.2?
After 210 days, 600 commits, tens of debugging nights, and thousands of messages in the project chat, I finally released AngouriMath 1.2.
This is an open-source symbolic algebra library for C# and F#, maybe it is interesting for someone?
Should We Initialize an Out Parameter Before a Method Returns?
Surely every C# developer has used out-parameters. It seems that everything is extremely simple and clear with them. But is it really so? For a kickoff, let's start with a self-test task.
How to Get Nice Error Reports Using SARIF in GitHub
Let's say you use GitHub, write code, and do other fun stuff. You also use a static analyzer to enhance your work quality and optimize the timing. Once you come up with an idea - why not view the errors that the analyzer gave right in GitHub? Yeah, and also it would be great if it looked nice. So, what should you do? The answer is very simple. SARIF is right for you. This article will cover what SARIF is and how to set it up. Enjoy the reading!
A Spy Undercover: PVS-Studio to Check ILSpy Source Code
In PVS-Studio, we often check various compilers' code and post the results in our blog. Decompiler programs, however, seem to be a bit neglected. To restore justice in this world, we analyzed the ILSpy decompiler's source code. Let's take a look at the peculiar things PVS-Studio found.
C# Programmer, It's Time to Test Yourself and Find Error
The PVS-Studio analyzer is regularly updated with new diagnostic rules. Curiously enough, diagnostics often detect suspicious code fragments before the end of the work. For example, such a situation may happen while testing on open-source projects. So, let's take a look at one of these interesting finding.
Top-10 Bugs Found in C# Projects in 2020
This tough year, 2020, will soon be over at last, which means it's time to look back at our accomplishments! Over the year, the PVS-Studio team has written quite a number of articles covering a large variety of bugs found in open-source projects with the help of PVS-Studio. This 2020 Top-10 list of bugs in C# projects presents the most interesting specimens. Enjoy the reading!
ONLYOFFICE Community Server: how bugs contribute to the emergence of security problems
Server-side network applications rarely get the chance to join the ranks of our reviews of errors found in open source software. This is probably due to their popularity. After all, we try to pay attention to the projects that readers themselves offer us. At the same time, servers often perform very important functions, but their performance and benefits remain invisible to most users. So, by chance, the code of ONLYOFFICE Community Server was checked. It turned out to be a very fun review.
Talking About Errors in the QuantConnect Lean Code
This article discusses errors found using a static analyzer in an open source project. There are some simple things that can help you avoid them. For example, the usage of language syntactic constructs starting from C# 8.0. We hope it will be exciting. Have fun reading!
Authors' contribution
sidristij 1681.2SergVasiliev 1163.0olegchir 1001.8n0mo 667.0sahsAGU 656.0marshinov 654.6tguev 652.6kekekeks 623.4DreamWalker 566.0Stefanio 557.2