Skip to content

Commit

Permalink
WIP #768
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Nov 28, 2022
1 parent 7cea674 commit bee5848
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/CSharpier.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="13.2.29" />
<PackageReference Include="System.IO.Hashing" Version="7.0.0-preview.7.22375.6" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
<PackageReference Include="UTF.Unknown" Version="2.3.0" />
<PackageReference Include="UTF.Unknown" Version="2.5.1" />
<PackageReference Include="YamlDotNet" Version="11.1.1" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions Src/CSharpier.Cli/CommandLineFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ CancellationToken cancellationToken
if (codeFormattingResult.Errors.Any())
{
fileIssueLogger.WriteError("Failed to compile so was not formatted.");
foreach (var message in codeFormattingResult.Errors)
{
fileIssueLogger.WriteError(message.GetMessage());
}
Interlocked.Increment(ref commandLineFormatterResult.FailedCompilation);
return;
}
Expand Down
14 changes: 14 additions & 0 deletions Src/CSharpier.Cli/FileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,21 @@ CancellationToken cancellationToken
{
await using var fileStream = fileSystem.File.OpenRead(filePath);
var detectionResult = CharsetDetector.DetectFromStream(fileStream);
// with net6 System.Text.SBCSCodePageEncoding
var encoding = detectionResult?.Detected?.Encoding;
DebugLogger.Log(filePath);
var message = "";
foreach (var detection in detectionResult.Details)
{
message +=
detection.EncodingName
+ " "
+ detection.Encoding
+ " "
+ detection.Confidence
+ Environment.NewLine;
}
DebugLogger.Log(message);
if (encoding == null)
{
unableToDetectEncoding = true;
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Tests/CSharpier.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="UTF.Unknown" Version="2.3.0" />
<PackageReference Include="UTF.Unknown" Version="2.5.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ public class ClassName
{
public void MethodName() { }
}

public enum MeetingLocation
{
Café,
Restaurant
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
{
public void MethodName() { }
}

public enum MeetingLocation
{
Café,
Restaurant
}

0 comments on commit bee5848

Please sign in to comment.