question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet format breaks indentation in .cs files with records

See original GitHub issue

This is the result of dotnet format (freshly installed,

using EnoCore.Models.Database;
using EnoCore.Utils;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace EnoCore.Models.Json
{
    public class JsonConfigurationValidationException : Exception
    {
        public JsonConfigurationValidationException(string message) : base(message) { }
    }

    public sealed record JsonConfiguration
    {
        public string? Title { get; set; }
    public long FlagValidityInRounds { get; set; }
    public int CheckedRoundsPerRound { get; set; }
    public int RoundLengthInSeconds { get; set; }
    public string? DnsSuffix { get; set; }
    public int TeamSubnetBytesLength { get; set; }
    public string? FlagSigningKey { get; set; }
    public string? NoiseSigningKey { get; set; }
[...]
    public static JsonConfiguration? Deserialize(string json)
    {
        return JsonSerializer.Deserialize<JsonConfiguration>(json, JsonSerializerOptions);
    }
}
}

As you can see, it shifted everything in the file after the first property to the left.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kzucommented, Jan 6, 2021

Installing latest v5 with:

dotnet tool update -g dotnet-format --version 5.0.* --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json

fixes the issue for me

0reactions
JoeRobichcommented, Feb 5, 2021

Closing this issue as it has been resolved by taking an updated Roslyn dependency.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier-style line breaking · Issue #246 · dotnet/format
It's my understanding the the project doesn't do line breaking the way Prettier does: Inserting and removing line breaks depending on the ...
Read more >
c# - What is the simplest way to get indented XML with line ...
Based on the other answers, I looked into XmlTextWriter and came up with the following helper method: static public string Beautify(this ...
Read more >
C# formatting options - .NET
Learn about the code style options for formatting C# code files. ... New-line options; Indentation options; Spacing options; Wrap options ...
Read more >
Weird auto-formatting indentation : r/VisualStudio
I have this problem in razor files only. It seems like a bug to me.
Read more >
EditorConfig properties for C#: Tabs, Indents, Alignment
This page lists custom ReSharper EditorConfig properties that you can use to configure formatting preferences in C#, specifically, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found