Skip to content

Commit

Permalink
Sort aliases (#1173)
Browse files Browse the repository at this point in the history
* making sure alias's sort properly

closes #1168

* assume csharpier-repos is next to csharpier

* self code review
  • Loading branch information
belav committed Feb 17, 2024
1 parent c81a5ea commit 0b239f6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Shell/ReviewBranch.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function CSH-ReviewBranch {
Set-Location $repositoryRoot

if (!$pathToTestingRepo) {
$pathToTestingRepo = "C:\Projects\csharpier-repos"
$pathToTestingRepo = Join-Path $PSScriptRoot "../../csharpier-repos"
}
if ($folder -ne $null) {
$pathToTestingRepo = Join-Path $pathToTestingRepo $folder
Expand Down Expand Up @@ -108,7 +108,7 @@ function CSH-ReviewBranch {
if ($firstRun) {
# uses https://github.com/github/hub/releases
# if this hangs run a command against this repo outside of here, it will store
# a token. Or I can just have a way to pass a GITHUB_TOKEN or store it in a .envc
# a token. Or I can just have a way to pass a GITHUB_TOKEN or store it in a .env
$newPr = & hub pull-request -b belav:$preBranch -m "Testing $branch $folder"
Write-Output $newPr
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using A = string;
using B = string;
using C = string;
using D = string;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using A = string;
using B = string;
using C = string;
using D = string;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using D = string;
using C = string;
using B = string;
using A = string;
14 changes: 7 additions & 7 deletions Src/CSharpier/SyntaxPrinter/UsingDirectives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,28 +277,28 @@ private class DefaultOrder : IComparer<UsingDirectiveSyntax?>
{
public int Compare(UsingDirectiveSyntax? x, UsingDirectiveSyntax? y)
{
if (x?.Name is null)
if (x?.Name is null && y?.Name is not null)
{
return -1;
}

if (y?.Name is null)
if (y?.Name is null && x?.Name is not null)
{
return 1;
}

if (x.Alias is not null && y.Alias is not null)
if (x?.Alias is not null && y?.Alias is not null)
{
return String.Compare(
return string.Compare(
x.Alias.ToFullString(),
y.Alias.ToFullString(),
StringComparison.OrdinalIgnoreCase
);
}

return String.Compare(
x.Name.ToFullString(),
y.Name.ToFullString(),
return string.Compare(
x?.Name?.ToFullString(),
y?.Name?.ToFullString(),
StringComparison.OrdinalIgnoreCase
);
}
Expand Down

0 comments on commit 0b239f6

Please sign in to comment.