Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net10.0</TargetFrameworks>
<LangVersion>12</LangVersion>
<LangVersion>14</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- this is the warning generators get when they fail to generate a source file this makes sure the error for it failing is obvious -->
Expand Down
5 changes: 4 additions & 1 deletion Src/CSharpier.Cli/ConsoleLogger.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Microsoft.Extensions.Logging;
#if NET8_0
using Lock = object;
#endif

namespace CSharpier.Cli;

internal class ConsoleLogger(IConsole console, LogLevel loggingLevel, LogFormat logFormat) : ILogger
{
private static readonly object ConsoleLock = new();
private static readonly Lock ConsoleLock = new();

public virtual void Log<TState>(
LogLevel logLevel,
Expand Down
26 changes: 4 additions & 22 deletions Src/CSharpier.Core/Xml/XNodePrinters/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,16 @@ internal static Doc Print(RawNode node, PrintingContext context)

foreach (var childNode in node.Nodes)
{
result.Add(Print(childNode, context), Doc.HardLine);
result.Add(
Print(childNode, context),
childNode.NodeType is XmlNodeType.Whitespace ? Doc.Null : Doc.HardLine
);
}

result.Add(Doc.HardLine);

return Doc.Concat(ref result);
}
if (node.NodeType == XmlNodeType.XmlDeclaration)
{
var version = node.Attributes.FirstOrDefault(o => o.Name == "version")?.Value;
var encoding = node.Attributes.FirstOrDefault(o => o.Name == "encoding")?.Value;
var standalone = node.Attributes.FirstOrDefault(o => o.Name == "standalone")?.Value;

var declaration = $"<?xml version=\"{version}\"";
if (!string.IsNullOrEmpty(encoding))
{
declaration += $" encoding=\"{encoding}\"";
}

if (!string.IsNullOrEmpty(standalone))
{
declaration += $" standalone=\"{standalone}\"";
}

declaration += "?>";

return declaration;
}

if (node.NodeType == XmlNodeType.DocumentType)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<Root>
<Element />
<Element />
Expand Down