How do you write a code in C# to split the list [a, b, c, d, e, f, g, h]
into sublists [a, b, c], [d, e, f], [g, h]
each with three elements and the last with less than three? The most popular answer is the following LINQ.
Blog
The dotnet format command and StyleCop.Analyzers
This article shows how to use the dotnet format command to format your source code according to a specific coding style. The article discusses its limitations and how to overcome them by introducing StyleCop.Analyzers. It also mentions the way to apply StyleCop.Analyzers to all projects in a solution.
Continue reading "The dotnet format command and StyleCop.Analyzers"How to Make Good Commits
This article explains how to make good commits in version control systems such as git. This article will show you the following topics.
- The purposes of creating commits
- How to make good commits for each purpose
- How to write good commit messages
Anything easily found by searching "git commit message."
Equality Comparison of Floating-Point Numbers in C# (and Others)
tl;dr
You should compare two floating-point numbers for equality in C# as follows:
tolerance
must be much larger than double.Epsilon
.
Implementing a System Tray App with WPF and MVVM
This article illustrates the implementation of a system tray application with WPF and the MVVM pattern. The full source code is in the GitHub repository.
The implementation has two distinctive points. First, it does not use notable WPF NotifyIcon because the license, CPOL, isn't compatible with any OSS licenses. Then, the implementation obeys the MVVM pattern and has no code behind.
Continue reading "Implementing a System Tray App with WPF and MVVM"Migrate To MahApps.Metro 2.x
This article shows the migration steps from MahApps 1.3.0 to 2.4.3 for BurageSnap, a screen capture tool. BurageSnap uses MahApps to realize its small footprint, as shown below.
Continue reading "Migrate To MahApps.Metro 2.x"Controlling Unity Application Through NamedPipe
This article shows how to control scenes on a Unity application by a Windows application with NamedPipe like the following demonstration. The full source is on the GitHub repository.
Continue reading "Controlling Unity Application Through NamedPipe"Quite Simple Memory Pool in C#
This article shows a quite simple memory pool to make a thread-unsafe library thread-safe without performance degradation in single-threaded programs. Same as the previous article, this article is about DynaJson.
Thread-safety requires overhead to allocate an instance by each invocation to isolate data being altered. Unless thread-safety is required, we can use a static class or a singleton to eliminate any additional allocation.
Continue reading "Quite Simple Memory Pool in C#"NaN Boxing in C#
This article shows how to use NaN Boxing to improve the performance of a JSON parser for C# named DynaJson.
About DynaJson
DynaJson is a fast JSON parser for C# compatible with DynamicJson. I feel DynamicJson is very useful but lack sufficient performance, so I developed a faster replacement.
Continue reading "NaN Boxing in C#"[Unity] How to Use Physics.OverlapCapsule
Updated on 2021-09-06: This article was largely revised to take into account the rotation of the attached game object and the direction of the CapsuleCollider.
You can use Physics.OverlapCapsule
to get the two Colliders overlapped with the CapsulCollider as above. This method takes the position and the size of a capsule and returns all Colliders overlapped by the capsule.