Skip to content

Commit

Permalink
update formatting check
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezor committed Jun 6, 2024
1 parent 9c204f0 commit 83fc222
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/CheckFormat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ $ErrorActionPreference = "Stop"

Import-Module (Join-Path $PSScriptRoot Common.psm1) -Function `
AssertDotnet, `
AssertDotnetFormatVersion, `
GetArtefactsDir
AssertDotnetFormatVersion, `
GetArtefactsDir

function Main {
function Main
{
AssertDotnetFormatVersion

$scriptDir = $PSScriptRoot
Expand All @@ -31,17 +32,28 @@ function Main {

Write-Host "Running dotnet format..."
dotnet format --verify-no-changes --report $reportPath --exclude "**/DocTest*.cs"
$formatReport = Get-Content $reportPath |ConvertFrom-Json
$formatReport = Get-Content $reportPath | ConvertFrom-Json
if ($formatReport.Count -ge 1)
{
throw "There are $( $formatReport.Count ) dotnet-format issue(s). " + `
"The report is stored in: $reportPath"
Write-Host "There are $( $formatReport.Count ) dotnet-format issue(s):"
foreach ($issue in $formatReport)
{
Write-Host " - $( $issue.FileName ): Line $( $issue.LineSpan.StartLinePosition.Line ), Column $( $issue.LineSpan.StartLinePosition.Character ): $( $issue.Failure.Message )"
}
throw "Formatting issues found. The report is stored in: $reportPath"
}
else
{
Write-Host "No formatting issues found."
}
}

$previousLocation = Get-Location
try {
try
{
Main
} finally {
}
finally
{
Set-Location $previousLocation
}

0 comments on commit 83fc222

Please sign in to comment.