---
title: "Serilog: int.MinValue alignment overflow in C# | VulCode"
description: "In Serilog, the .NET logging library, the C# template parser no longer throws OverflowException for an int.MinValue alignment and returns the text as it is."
url: "https://vulcode.com/en/opensource/contributions/serilog"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

serilog/serilog

# Serilog

A structured logging library for .NET. It records events from message templates, with named properties rather than plain text.

[See the repository](https://github.com/serilog/serilog) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: C#
- **GitHub stars**: 8,064
- **Merged changes**: 1
- **Project site**: [serilog.net](https://serilog.net)

## What we changed

MessageTemplateParser no longer throws OverflowException when the alignment width in a template is int.MinValue. Such a template comes back as plain text, like other invalid alignments.

### What this work shows

- Message template parsing

- Integer overflow edge cases

- xUnit unit tests

What was broken

### One log template ended in an exception

A template with the alignment -2147483648, such as "{Value,-2147483648}", passed int.TryParse, and Math.Abs(int.MinValue) threw OverflowException. Parse is meant to return text for invalid templates, but log.Information ended in an unhandled exception instead.

How we fixed it

### Such an alignment is plain text

After reading the width we reject int.MinValue and return the raw text as a TextToken, as with "+10" or "10-1". The new AlignmentOfIntMinValueIsParsedAsText test failed before the fix and passes after it.

[#2247](https://github.com/serilog/serilog/pull/2247)

## Merged change 1

- [#2247 fix: avoid OverflowException when alignment width is int.MinValue Merged 13 September 2026](https://github.com/serilog/serilog/pull/2247)

## What it taught us

We look for edge values that break a documented contract: Math.Abs(int.MinValue) does not fit in an int, so a parser meant to return text for invalid templates threw instead. The fix follows the behaviour the library already had for other invalid input.

[More about this technology: C# and .NET](https://vulcode.com/en/technologies/csharp-and-dotnet)

## Other projects we write code for

- [**ILSpy** C# · 27,138 stars An open source .NET decompiler that turns compiled assemblies back into readable C# code. It is used to inspect libraries whose source code is not at hand.](https://vulcode.com/en/opensource/contributions/ilspy)

- [**OpenRA** C# · 17,827 stars An open source real-time strategy engine for classic Westwood games such as Command & Conquer: Red Alert, written in C# with SDL and OpenGL.](https://vulcode.com/en/opensource/contributions/openra)

- [**Polly** C# · 14,255 stars A .NET library for handling transient faults: retries, circuit breakers, timeouts and fallback. Its Simmy module injects faults on purpose to test how an application copes with them.](https://vulcode.com/en/opensource/contributions/polly)

- [**FluentValidation** C# · 9,780 stars A popular .NET library for writing strongly typed validation rules in a fluent style, such as RuleFor(...).InclusiveBetween(...).](https://vulcode.com/en/opensource/contributions/fluentvalidation)

- [**NLog** C# · 6,547 stars A flexible structured logging library for many .NET platforms, configured through layouts, filters and targets.](https://vulcode.com/en/opensource/contributions/nlog)

- [**Markdig** C# · 5,359 stars A fast CommonMark-compliant Markdown processor for .NET, with extensions such as tables, definition lists and automatic heading identifiers.](https://vulcode.com/en/opensource/contributions/markdig)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
